diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 1933342cda7..51e5e3ba510 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -741,31 +741,31 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch) dev->internal.clear, agx_pool_upload(&batch->pool, clear_colour, sizeof(clear_colour))); - if (batch->cbufs[0]) { - enum pipe_format fmt = batch->cbufs[0]->format; + if (batch->key.cbufs[0]) { + enum pipe_format fmt = batch->key.cbufs[0]->format; enum agx_format internal = agx_pixel_format[fmt].internal; uint32_t shader = dev->reload.format[internal]; pipeline_reload = agx_build_reload_pipeline(batch, shader, - batch->cbufs[0]); + batch->key.cbufs[0]); } - if (batch->cbufs[0] && !(batch->clear & PIPE_CLEAR_COLOR0)) { + if (batch->key.cbufs[0] && !(batch->clear & PIPE_CLEAR_COLOR0)) { clear_pipeline_textures = true; pipeline_clear = pipeline_reload; } uint64_t pipeline_store = 0; - if (batch->cbufs[0]) { + if (batch->key.cbufs[0]) { pipeline_store = agx_build_store_pipeline(batch, dev->internal.store, agx_pool_upload(&batch->pool, ctx->render_target[0], sizeof(ctx->render_target))); } - for (unsigned i = 0; i < batch->nr_cbufs; ++i) { - struct pipe_surface *surf = batch->cbufs[i]; + for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) { + struct pipe_surface *surf = batch->key.cbufs[i]; if (surf && surf->texture) { struct agx_resource *rt = agx_resource(surf->texture); @@ -773,11 +773,11 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch) } } - struct agx_resource *zbuf = batch->zsbuf ? - agx_resource(batch->zsbuf->texture) : NULL; + struct agx_resource *zbuf = batch->key.zsbuf ? + agx_resource(batch->key.zsbuf->texture) : NULL; if (zbuf) { - unsigned level = ctx->batch->zsbuf->u.tex.level; + unsigned level = batch->key.zsbuf->u.tex.level; BITSET_SET(zbuf->data_valid, level); if (zbuf->separate_stencil) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 8e1547637b9..2c4b3a74cd4 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -690,10 +690,10 @@ agx_upload_viewport_scissor(struct agx_pool *pool, * the viewport is an odd number of pixels, both the translate and the scale * will have a fractional part of 0.5, so adding and subtracting them yields * an integer. Therefore we don't need to round explicitly */ - unsigned minx = CLAMP((int) (trans_x - abs_scale_x), 0, batch->width); - unsigned miny = CLAMP((int) (trans_y - abs_scale_y), 0, batch->height); - unsigned maxx = CLAMP((int) (trans_x + abs_scale_x), 0, batch->width); - unsigned maxy = CLAMP((int) (trans_y + abs_scale_y), 0, batch->height); + unsigned minx = CLAMP((int) (trans_x - abs_scale_x), 0, batch->key.width); + unsigned miny = CLAMP((int) (trans_y - abs_scale_y), 0, batch->key.height); + unsigned maxx = CLAMP((int) (trans_x + abs_scale_x), 0, batch->key.width); + unsigned maxy = CLAMP((int) (trans_y + abs_scale_y), 0, batch->key.height); if (ss) { minx = MAX2(ss->minx, minx); @@ -785,22 +785,15 @@ agx_set_framebuffer_state(struct pipe_context *pctx, agx_flush_all(ctx, "Framebuffer switch"); util_copy_framebuffer_state(&ctx->framebuffer, state); - ctx->batch->width = state->width; - ctx->batch->height = state->height; - ctx->batch->nr_cbufs = state->nr_cbufs; - ctx->batch->zsbuf = state->zsbuf; + util_copy_framebuffer_state(&ctx->batch->key, state); ctx->dirty = ~0; if (state->zsbuf) agx_batch_writes(ctx->batch, agx_resource(state->zsbuf->texture)); - /* Clear out stale pointers */ - memset(ctx->batch->cbufs, 0, sizeof(ctx->batch->cbufs)); for (unsigned i = 0; i < state->nr_cbufs; ++i) { struct pipe_surface *surf = state->cbufs[i]; - ctx->batch->cbufs[i] = surf; - struct agx_resource *tex = agx_resource(surf->texture); const struct util_format_description *desc = util_format_description(surf->format); @@ -1234,7 +1227,7 @@ static bool agx_update_fs(struct agx_context *ctx) { struct asahi_shader_key key = { - .nr_cbufs = ctx->batch->nr_cbufs, + .nr_cbufs = ctx->batch->key.nr_cbufs, .clip_plane_enable = ctx->rast->base.clip_plane_enable, }; @@ -1242,7 +1235,7 @@ agx_update_fs(struct agx_context *ctx) key.sprite_coord_enable = ctx->rast->base.sprite_coord_enable; for (unsigned i = 0; i < key.nr_cbufs; ++i) { - struct pipe_surface *surf = ctx->batch->cbufs[i]; + struct pipe_surface *surf = ctx->batch->key.cbufs[i]; if (surf) { enum pipe_format fmt = surf->format; diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index adf76fd511e..a6291264dad 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -94,10 +94,7 @@ struct agx_array { struct agx_batch { struct agx_context *ctx; - - unsigned width, height, nr_cbufs; - struct pipe_surface *cbufs[8]; - struct pipe_surface *zsbuf; + struct pipe_framebuffer_state key; /* PIPE_CLEAR_* bitmask */ uint32_t clear, draw, load;