llvmpipe: add support for time elapsed queries.

It turns out for QBO you really need to explicitly support time
elapsed queries to avoid wierd interactions with the non-qbo
query paths.

Fixes: 506e51b856 ("llvmpipe: initial query buffer object support. (v2)")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11946>
This commit is contained in:
Dave Airlie 2021-07-19 11:57:12 +10:00 committed by Marge Bot
parent d8bfad70dc
commit 2f5cd08ede
5 changed files with 33 additions and 9 deletions

View file

@ -472,12 +472,6 @@ spec/arb_internalformat_query/misc. api error checks: skip
spec/arb_pipeline_statistics_query/arb_pipeline_statistics_query-frag: fail
spec/arb_post_depth_coverage/arb_post_depth_coverage-multisampling: fail
spec/arb_program_interface_query/arb_program_interface_query-getprogramresourceindex/'vs_input2[1][0]' on gl_program_input: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-async_cpu_read_before-gl_int: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-async_cpu_read_before-gl_unsigned_int: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-async_cpu_read_before-gl_unsigned_int64_arb: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-sync_cpu_read_after_cache_test-gl_int: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-sync_cpu_read_after_cache_test-gl_unsigned_int: fail
spec/arb_query_buffer_object/qbo/query-gl_time_elapsed-sync_cpu_read_after_cache_test-gl_unsigned_int64_arb: fail
spec/arb_sample_locations/test: skip
spec/arb_sample_shading/builtin-gl-num-samples 16: skip
spec/arb_sample_shading/builtin-gl-num-samples 32: skip

View file

@ -139,6 +139,17 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
}
}
break;
case PIPE_QUERY_TIME_ELAPSED: {
uint64_t start = (uint64_t)-1, end = 0;
for (i = 0; i < num_threads; i++) {
if (pq->start[i] && pq->start[i] < start)
start = pq->start[i];
if (pq->end[i] && pq->end[i] > end)
end = pq->end[i];
}
*result = end - start;
break;
}
case PIPE_QUERY_TIMESTAMP_DISJOINT: {
struct pipe_query_data_timestamp_disjoint *td =
(struct pipe_query_data_timestamp_disjoint *)vresult;
@ -260,6 +271,17 @@ llvmpipe_get_query_result_resource(struct pipe_context *pipe,
}
}
break;
case PIPE_QUERY_TIME_ELAPSED: {
uint64_t start = (uint64_t)-1, end = 0;
for (i = 0; i < num_threads; i++) {
if (pq->start[i] && pq->start[i] < start)
start = pq->start[i];
if (pq->end[i] && pq->end[i] > end)
end = pq->end[i];
}
value = end - start;
break;
}
case PIPE_QUERY_SO_STATISTICS:
value = pq->num_primitives_written[0];
value2 = pq->num_primitives_generated[0];

View file

@ -648,6 +648,9 @@ lp_rast_begin_query(struct lp_rasterizer_task *task,
case PIPE_QUERY_PIPELINE_STATISTICS:
pq->start[task->thread_index] = task->thread_data.ps_invocations;
break;
case PIPE_QUERY_TIME_ELAPSED:
pq->start[task->thread_index] = os_time_get_nano();
break;
default:
assert(0);
break;
@ -675,6 +678,7 @@ lp_rast_end_query(struct lp_rasterizer_task *task,
pq->start[task->thread_index] = 0;
break;
case PIPE_QUERY_TIMESTAMP:
case PIPE_QUERY_TIME_ELAPSED:
pq->end[task->thread_index] = os_time_get_nano();
break;
case PIPE_QUERY_PIPELINE_STATISTICS:

View file

@ -139,6 +139,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return PIPE_MAX_COLOR_BUFS;
case PIPE_CAP_OCCLUSION_QUERY:
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_QUERY_TIME_ELAPSED:
return 1;
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
return 1;

View file

@ -1627,7 +1627,8 @@ lp_setup_begin_query(struct lp_setup_context *setup,
if (!(pq->type == PIPE_QUERY_OCCLUSION_COUNTER ||
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE ||
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE ||
pq->type == PIPE_QUERY_PIPELINE_STATISTICS))
pq->type == PIPE_QUERY_PIPELINE_STATISTICS ||
pq->type == PIPE_QUERY_TIME_ELAPSED))
return;
/* init the query to its beginning state */
@ -1679,7 +1680,8 @@ lp_setup_end_query(struct lp_setup_context *setup, struct llvmpipe_query *pq)
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE ||
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE ||
pq->type == PIPE_QUERY_PIPELINE_STATISTICS ||
pq->type == PIPE_QUERY_TIMESTAMP) {
pq->type == PIPE_QUERY_TIMESTAMP ||
pq->type == PIPE_QUERY_TIME_ELAPSED) {
if (pq->type == PIPE_QUERY_TIMESTAMP &&
!(setup->scene->tiles_x | setup->scene->tiles_y)) {
/*
@ -1715,7 +1717,8 @@ fail:
if (pq->type == PIPE_QUERY_OCCLUSION_COUNTER ||
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE ||
pq->type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE ||
pq->type == PIPE_QUERY_PIPELINE_STATISTICS) {
pq->type == PIPE_QUERY_PIPELINE_STATISTICS ||
pq->type == PIPE_QUERY_TIME_ELAPSED) {
unsigned i;
/* remove from active binned query list */