From 9fa5dec767eabc0e3c745fe2efe19a5e0509aa6c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 11 Aug 2023 16:41:00 -0400 Subject: [PATCH] asahi: Add real per-stage dirty flags Instead of just using ~0 as a stub todo. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 14 +++++++------- src/gallium/drivers/asahi/agx_state.h | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 2ab1f5c21cc..85e5dff1a3f 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -86,7 +86,7 @@ agx_set_shader_images(struct pipe_context *pctx, enum pipe_shader_type shader, const struct pipe_image_view *iviews) { struct agx_context *ctx = agx_context(pctx); - ctx->stage[shader].dirty = ~0; + ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_IMAGE; /* Unbind start_slot...start_slot+count */ if (!iviews) { @@ -155,7 +155,7 @@ agx_set_shader_buffers(struct pipe_context *pctx, enum pipe_shader_type shader, &ctx->stage[shader].ssbo_mask, buffers, start, count); - ctx->stage[shader].dirty = ~0; + ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_SSBO; } static void @@ -529,7 +529,7 @@ agx_bind_sampler_states(struct pipe_context *pctx, enum pipe_shader_type shader, { struct agx_context *ctx = agx_context(pctx); - ctx->stage[shader].dirty = ~0; + ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_SAMPLER; for (unsigned i = 0; i < count; i++) { unsigned p = start + i; @@ -812,7 +812,7 @@ agx_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader, (struct pipe_sampler_view **)&ctx->stage[shader].textures[i], NULL); } ctx->stage[shader].texture_count = new_nr; - ctx->stage[shader].dirty = ~0; + ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_IMAGE; } static void @@ -1286,7 +1286,7 @@ agx_set_constant_buffer(struct pipe_context *pctx, enum pipe_shader_type shader, else s->cb_mask &= ~mask; - ctx->stage[shader].dirty = ~0; + ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_CONST; } static void @@ -2181,10 +2181,10 @@ agx_update_descriptors(struct agx_batch *batch, struct agx_compiled_shader *cs, { struct agx_context *ctx = batch->ctx; - /* TODO: Dirty track more finely */ - if (ctx->stage[stage].dirty) { + if (ctx->stage[stage].dirty & AGX_STAGE_DIRTY_IMAGE) agx_upload_textures(batch, cs, stage); + if (ctx->stage[stage].dirty) { batch->tables[AGX_SYSVAL_STAGE(stage)] = agx_upload_stage_uniforms(batch, batch->textures[stage], stage); } diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index 91fde22abec..490535e521d 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -208,6 +208,13 @@ struct agx_uncompiled_shader { unsigned base_varying; }; +enum agx_stage_dirty { + AGX_STAGE_DIRTY_CONST = BITFIELD_BIT(0), + AGX_STAGE_DIRTY_SSBO = BITFIELD_BIT(1), + AGX_STAGE_DIRTY_IMAGE = BITFIELD_BIT(2), + AGX_STAGE_DIRTY_SAMPLER = BITFIELD_BIT(3), +}; + struct agx_stage { struct agx_uncompiled_shader *shader; uint32_t dirty;