From b70ea03302f27bf7eed963e0f9ce0ff9472ec241 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 7 Feb 2023 09:07:28 -0800 Subject: [PATCH] freedreno: Add FD_DIRTY_QUERY 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 Part-of: --- src/gallium/drivers/freedreno/a5xx/fd5_blitter.c | 2 +- src/gallium/drivers/freedreno/a6xx/fd6_blitter.c | 4 ++-- src/gallium/drivers/freedreno/freedreno_batch.h | 2 +- src/gallium/drivers/freedreno/freedreno_context.h | 10 +++------- src/gallium/drivers/freedreno/freedreno_draw.c | 9 ++++++--- src/gallium/drivers/freedreno/freedreno_query.c | 2 +- src/gallium/drivers/freedreno/freedreno_query_acc.c | 6 ++---- src/gallium/drivers/freedreno/freedreno_query_hw.c | 2 +- src/gallium/drivers/freedreno/freedreno_state.c | 1 - 9 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c index a66d288..d7379a2 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c @@ -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; } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 72c1108..1e115c7 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -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; } diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index da6e8bd..81e02b4 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index d1892ba..223f834 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -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: */ diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 63464c2..cf40c19 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -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); } diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c index 5866f52..12c8dfe 100644 --- a/src/gallium/drivers/freedreno/freedreno_query.c +++ b/src/gallium/drivers/freedreno/freedreno_query.c @@ -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 diff --git a/src/gallium/drivers/freedreno/freedreno_query_acc.c b/src/gallium/drivers/freedreno/freedreno_query_acc.c index 4e37cb5..181ff25 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_acc.c +++ b/src/gallium/drivers/freedreno/freedreno_query_acc.c @@ -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 diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 3a42d9a..982d803 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index f204d52..268b521 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -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) { -- 2.7.4