v3d: cache pipe query results
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Wed, 6 Jul 2022 09:18:14 +0000 (11:18 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 21 Mar 2023 12:31:24 +0000 (12:31 +0000)
As the BO storing the results is destroyed after getting the query
results, store the results in case requesting the results again.

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Signed-off-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17373>

src/gallium/drivers/v3d/v3d_query_pipe.c

index 00fcc0f..7618daa 100644 (file)
@@ -43,6 +43,7 @@ struct v3d_query_pipe
         struct v3d_bo *bo;
 
         uint32_t start, end;
+        uint32_t result;
 };
 
 static void
@@ -140,7 +141,6 @@ v3d_get_query_result_pipe(struct v3d_context *v3d, struct v3d_query *query,
                           bool wait, union pipe_query_result *vresult)
 {
         struct v3d_query_pipe *pquery = (struct v3d_query_pipe *)query;
-        uint32_t result = 0;
 
         if (pquery->bo) {
                 v3d_flush_jobs_using_bo(v3d, pquery->bo);
@@ -155,18 +155,18 @@ v3d_get_query_result_pipe(struct v3d_context *v3d, struct v3d_query *query,
 
                 /* XXX: Sum up per-core values. */
                 uint32_t *map = v3d_bo_map(pquery->bo);
-                result = *map;
+                pquery->result = *map;
 
                 v3d_bo_unreference(&pquery->bo);
         }
 
         switch (pquery->type) {
         case PIPE_QUERY_OCCLUSION_COUNTER:
-                vresult->u64 = result;
+                vresult->u64 = pquery->result;
                 break;
         case PIPE_QUERY_OCCLUSION_PREDICATE:
         case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
-                vresult->b = result != 0;
+                vresult->b = pquery->result != 0;
                 break;
         case PIPE_QUERY_PRIMITIVES_GENERATED:
         case PIPE_QUERY_PRIMITIVES_EMITTED: