freedreno: Add FD_DIRTY_QUERY
authorRob Clark <robdclark@chromium.org>
Tue, 7 Feb 2023 17:07:28 +0000 (09:07 -0800)
committerMarge Bot <emma+marge@anholt.net>
Sat, 11 Feb 2023 16:36:37 +0000 (16:36 +0000)
Replace update_active_queries, which was really just a dirty-bit in
disguise.  This also lets us associate it with FD_DIRTY_RESOURCE so
we can skip the associated resource tracking when it isn't dirty.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21202>

src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
src/gallium/drivers/freedreno/freedreno_batch.h
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_query.c
src/gallium/drivers/freedreno/freedreno_query_acc.c
src/gallium/drivers/freedreno/freedreno_query_hw.c
src/gallium/drivers/freedreno/freedreno_state.c

index a66d288..d7379a2 100644 (file)
@@ -468,7 +468,7 @@ fd5_blitter_blit(struct fd_context *ctx,
    /* Acc query state will have been dirtied by our fd_batch_update_queries, so
     * the ctx->batch may need to turn its queries back on.
     */
-   ctx->update_active_queries = true;
+   fd_context_dirty(ctx, FD_DIRTY_QUERY);
 
    return true;
 }
index 72c1108..1e115c7 100644 (file)
@@ -928,7 +928,7 @@ fd6_clear_texture(struct pipe_context *pctx, struct pipe_resource *prsc,
    /* Acc query state will have been dirtied by our fd_batch_update_queries, so
     * the ctx->batch may need to turn its queries back on.
     */
-   ctx->update_active_queries = true;
+   fd_context_dirty(ctx, FD_DIRTY_QUERY);
 
    return;
 
@@ -1080,7 +1080,7 @@ handle_rgba_blit(struct fd_context *ctx,
    /* Acc query state will have been dirtied by our fd_batch_update_queries, so
     * the ctx->batch may need to turn its queries back on.
     */
-   ctx->update_active_queries = true;
+   fd_context_dirty(ctx, FD_DIRTY_QUERY);
 
    return true;
 }
index da6e8bd..81e02b4 100644 (file)
@@ -374,7 +374,7 @@ fd_batch_update_queries(struct fd_batch *batch) assert_dt
 {
    struct fd_context *ctx = batch->ctx;
 
-   if (!ctx->update_active_queries)
+   if (!(ctx->dirty & FD_DIRTY_QUERY))
       return;
 
    ctx->query_update_batch(batch, false);
index d1892ba..223f834 100644 (file)
@@ -164,9 +164,10 @@ enum fd_dirty_3d_state {
    FD_DIRTY_TEX = BIT(17),
    FD_DIRTY_IMAGE = BIT(18),
    FD_DIRTY_SSBO = BIT(19),
+   FD_DIRTY_QUERY = BIT(20),
 
    /* only used by a2xx.. possibly can be removed.. */
-   FD_DIRTY_TEXSTATE = BIT(20),
+   FD_DIRTY_TEXSTATE = BIT(21),
 
    /* fine grained state changes, for cases where state is not orthogonal
     * from hw perspective:
@@ -256,11 +257,6 @@ struct fd_context {
    float default_inner_level[2] dt;
    uint8_t patch_vertices dt;
 
-   /* Whether we need to recheck the active_queries list next
-    * fd_batch_update_queries().
-    */
-   bool update_active_queries dt;
-
    /* Current state of pctx->set_active_query_state() (i.e. "should drawing
     * be counted against non-perfcounter queries")
     */
@@ -606,7 +602,7 @@ fd_context_dirty_resource(enum fd_dirty_3d_state dirty)
 {
    return dirty & (FD_DIRTY_FRAMEBUFFER | FD_DIRTY_ZSA | FD_DIRTY_BLEND |
                    FD_DIRTY_SSBO | FD_DIRTY_IMAGE | FD_DIRTY_VTXBUF |
-                   FD_DIRTY_TEX | FD_DIRTY_STREAMOUT);
+                   FD_DIRTY_TEX | FD_DIRTY_STREAMOUT | FD_DIRTY_QUERY);
 }
 
 /* Mark specified non-shader-stage related state as dirty: */
index 63464c2..cf40c19 100644 (file)
@@ -185,6 +185,12 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt
             resource_written(batch, ctx->streamout.targets[i]->buffer);
    }
 
+   if (ctx->dirty & FD_DIRTY_QUERY) {
+      list_for_each_entry (struct fd_acc_query, aq, &ctx->acc_active_queries, node) {
+         resource_written(batch, aq->prsc);
+      }
+   }
+
    /* any buffers that haven't been cleared yet, we need to restore: */
    batch->restore |= restore_buffers & (FD_BUFFER_ALL & ~batch->invalidated);
    /* and any buffers used, need to be resolved: */
@@ -227,9 +233,6 @@ batch_draw_tracking(struct fd_batch *batch, const struct pipe_draw_info *info,
 
    resource_written(batch, batch->query_buf);
 
-   list_for_each_entry (struct fd_acc_query, aq, &ctx->acc_active_queries, node)
-      resource_written(batch, aq->prsc);
-
    fd_screen_unlock(ctx->screen);
 }
 
index 5866f52..12c8dfe 100644 (file)
@@ -194,7 +194,7 @@ fd_set_active_query_state(struct pipe_context *pctx, bool enable) assert_dt
 {
    struct fd_context *ctx = fd_context(pctx);
    ctx->active_queries = enable;
-   ctx->update_active_queries = true;
+   fd_context_dirty(ctx, FD_DIRTY_QUERY);
 }
 
 static enum pipe_driver_query_type
index 4e37cb5..181ff25 100644 (file)
@@ -104,7 +104,7 @@ fd_acc_begin_query(struct fd_context *ctx, struct fd_query *q) assert_dt
    realloc_query_bo(ctx, aq);
 
    /* Signal that we need to update the active queries on the next draw */
-   ctx->update_active_queries = true;
+   fd_context_dirty(ctx, FD_DIRTY_QUERY);
 
    /* add to active list: */
    assert(list_is_empty(&aq->node));
@@ -312,7 +312,7 @@ fd_acc_query_update_batch(struct fd_batch *batch, bool disable_all)
 {
    struct fd_context *ctx = batch->ctx;
 
-   if (disable_all || ctx->update_active_queries) {
+   if (disable_all || (ctx->dirty & FD_DIRTY_QUERY)) {
       struct fd_acc_query *aq;
       LIST_FOR_EACH_ENTRY (aq, &ctx->acc_active_queries, node) {
          bool batch_change = aq->batch != batch;
@@ -326,8 +326,6 @@ fd_acc_query_update_batch(struct fd_batch *batch, bool disable_all)
             fd_acc_query_resume(aq, batch);
       }
    }
-
-   ctx->update_active_queries = false;
 }
 
 void
index 3a42d9a..982d803 100644 (file)
@@ -375,7 +375,7 @@ fd_hw_query_update_batch(struct fd_batch *batch, bool disable_all)
 {
    struct fd_context *ctx = batch->ctx;
 
-   if (disable_all || ctx->update_active_queries) {
+   if (disable_all || (ctx->dirty & FD_DIRTY_QUERY)) {
       struct fd_hw_query *hq;
       LIST_FOR_EACH_ENTRY (hq, &batch->ctx->hw_active_queries, list) {
          bool was_active = query_active_in_batch(batch, hq);
index f204d52..268b521 100644 (file)
@@ -321,7 +321,6 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
 
       fd_batch_reference(&ctx->batch, NULL);
       fd_context_all_dirty(ctx);
-      ctx->update_active_queries = true;
 
       fd_batch_reference(&old_batch, NULL);
    } else if (ctx->batch) {