From: Dave Airlie Date: Mon, 19 Jul 2021 01:57:12 +0000 (+1000) Subject: llvmpipe: add support for time elapsed queries. X-Git-Tag: upstream/22.3.5~20001 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f5cd08ede0b9d445535d54beffcad0e5c4a62bb;p=platform%2Fupstream%2Fmesa.git 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: 506e51b8560f ("llvmpipe: initial query buffer object support. (v2)") Reviewed-by: Michel Dänzer Part-of: --- diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt index 9c54c6a..84d1f4a 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt @@ -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 diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 703512d..38c1319 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -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]; diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 87dc68b..f054f4c 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -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: diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f57e3f9..5e8c823 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -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; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index dbf59e3..9109114 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -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 */