Mesa (main): llvmpipe: add support for time elapsed queries.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 22 09:32:50 UTC 2021
Module: Mesa
Branch: main
Commit: 2f5cd08ede0b9d445535d54beffcad0e5c4a62bb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f5cd08ede0b9d445535d54beffcad0e5c4a62bb
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Jul 19 11:57:12 2021 +1000
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 <mdaenzer at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11946>
---
.../drivers/llvmpipe/ci/llvmpipe-quick_gl.txt | 6 ------
src/gallium/drivers/llvmpipe/lp_query.c | 22 ++++++++++++++++++++++
src/gallium/drivers/llvmpipe/lp_rast.c | 4 ++++
src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
src/gallium/drivers/llvmpipe/lp_setup.c | 9 ++++++---
5 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt
index 9c54c6a0eb4..84d1f4a622e 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 703512d011d..38c1319a466 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 87dc68b992e..f054f4cc952 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 f57e3f95461..5e8c8239725 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 dbf59e39ed1..9109114487c 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 */
More information about the mesa-commit
mailing list