From 38a9c59377c129b9be653efcd98c7a4fb07880cd Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 27 May 2021 22:44:55 -0400 Subject: [PATCH] asahi: Dirty track viewport descriptor Mitigates the extra CPU cost from packing in the previous commit, and avoids the redundant memcpy. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 1 + src/gallium/drivers/asahi/agx_state.c | 8 +++++++- src/gallium/drivers/asahi/agx_state.h | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index e24579946b8..cae9cbdc787 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -463,6 +463,7 @@ agx_flush(struct pipe_context *pctx, ctx->batch->clear = 0; ctx->batch->draw = 0; ctx->batch->encoder_current = ctx->batch->encoder->ptr.cpu; + ctx->dirty = ~0; } static void diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 4ac45410171..e2577bdbb36 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -431,6 +431,7 @@ agx_set_viewport_states(struct pipe_context *pctx, assert(start_slot == 0 && "no geometry shaders"); assert(num_viewports == 1 && "no geometry shaders"); + ctx->dirty |= AGX_DIRTY_VIEWPORT; ctx->viewport = *vp; } @@ -483,6 +484,7 @@ agx_set_framebuffer_state(struct pipe_context *pctx, ctx->batch->height = state->height; ctx->batch->nr_cbufs = state->nr_cbufs; ctx->batch->cbufs[0] = state->cbufs[0]; + ctx->dirty = ~0; for (unsigned i = 0; i < state->nr_cbufs; ++i) { struct pipe_surface *surf = state->cbufs[i]; @@ -1123,7 +1125,10 @@ agx_encode_state(struct agx_context *ctx, uint8_t *out, agx_push_record(&out, 4, demo_linkage(ctx->vs, pool)); agx_push_record(&out, 7, demo_rasterizer(ctx, pool)); agx_push_record(&out, 5, demo_unk11(pool, is_lines, reads_tib)); - agx_push_record(&out, 10, agx_upload_viewport(pool, &ctx->viewport)); + + if (ctx->dirty & AGX_DIRTY_VIEWPORT) + agx_push_record(&out, 10, agx_upload_viewport(pool, &ctx->viewport)); + agx_push_record(&out, 3, demo_unk12(pool)); agx_push_record(&out, 2, agx_pool_upload(pool, ctx->rast->cull, sizeof(ctx->rast->cull))); agx_push_record(&out, 2, demo_unk14(pool)); @@ -1245,6 +1250,7 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, } batch->encoder_current = out; + ctx->dirty = 0; } void agx_init_state_functions(struct pipe_context *ctx); diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index b93759b6682..8a853ece396 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -114,7 +114,10 @@ struct asahi_shader_key { enum pipe_format rt_formats[PIPE_MAX_COLOR_BUFS]; }; -#define AGX_DIRTY_VERTEX (1 << 0) +enum agx_dirty { + AGX_DIRTY_VERTEX = BITFIELD_BIT(0), + AGX_DIRTY_VIEWPORT = BITFIELD_BIT(1), +}; struct agx_context { struct pipe_context base;