panfrost: Do fine-grained flushing for occlusion query results
authorIcecream95 <ixn@keemail.me>
Sun, 28 Jun 2020 08:48:36 +0000 (20:48 +1200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 30 Jun 2020 15:14:05 +0000 (15:14 +0000)
This allows doing occlusion queries in one frame and getting the
results in the next frame without having to flush.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5676>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c

index 841e89d75a08ccba4a4303bc0c55f05f65653db9..c1267b43f026e8ee06f7bbb1675872b822f378af 100644 (file)
@@ -134,10 +134,15 @@ panfrost_vt_update_occlusion_query(struct panfrost_context *ctx,
                                    struct mali_vertex_tiler_postfix *postfix)
 {
         SET_BIT(postfix->gl_enables, MALI_OCCLUSION_QUERY, ctx->occlusion_query);
-        if (ctx->occlusion_query)
+        if (ctx->occlusion_query) {
                 postfix->occlusion_counter = ctx->occlusion_query->bo->gpu;
-        else
+                panfrost_batch_add_bo(ctx->batch, ctx->occlusion_query->bo,
+                                      PAN_BO_ACCESS_SHARED |
+                                      PAN_BO_ACCESS_RW |
+                                      PAN_BO_ACCESS_FRAGMENT);
+        } else {
                 postfix->occlusion_counter = 0;
+        }
 }
 
 void
index 2ec636e1579c47d0474ee48ac5081efc03fb7f8b..69f05e5beab7e1ee99f152566f06a8704bd0582f 100644 (file)
@@ -1327,7 +1327,8 @@ panfrost_get_query_result(struct pipe_context *pipe,
         case PIPE_QUERY_OCCLUSION_PREDICATE:
         case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
                 DBG("Flushing for occlusion query\n");
-                panfrost_flush_all_batches(ctx, true);
+                panfrost_flush_batches_accessing_bo(ctx, query->bo, PAN_BO_ACCESS_WRITE);
+                panfrost_bo_wait(query->bo, INT64_MAX, PAN_BO_ACCESS_WRITE);
 
                 /* Read back the query results */
                 unsigned *result = (unsigned *) query->bo->cpu;