llvmpipe: add support for time elapsed queries.
authorDave Airlie <airlied@redhat.com>
Mon, 19 Jul 2021 01:57:12 +0000 (11:57 +1000)
committerMarge Bot <eric+marge@anholt.net>
Thu, 22 Jul 2021 09:17:05 +0000 (09:17 +0000)
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@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11946>

src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt
src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_setup.c

index 9c54c6a..84d1f4a 100644 (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
index 703512d..38c1319 100644 (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];
index 87dc68b..f054f4c 100644 (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:
index f57e3f9..5e8c823 100644 (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;
index dbf59e3..9109114 100644 (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 */