diff --git a/src/gallium/drivers/asahi/agx_batch.c b/src/gallium/drivers/asahi/agx_batch.c index 75b464328c3..dc48830b9f9 100644 --- a/src/gallium/drivers/asahi/agx_batch.c +++ b/src/gallium/drivers/asahi/agx_batch.c @@ -144,6 +144,9 @@ agx_batch_init(struct agx_context *ctx, agx_bo_unreference(batch->sampler_heap.bo); batch->sampler_heap.bo = NULL; batch->sampler_heap.count = 0; + batch->vs_scratch = false; + batch->fs_scratch = false; + batch->cs_scratch = false; /* We need to emit prim state at the start. Max collides with all. */ batch->reduced_prim = MESA_PRIM_COUNT; diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 3c50baf47ee..10436d73ed1 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -1289,6 +1289,9 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch) return; } + if (batch->cs_scratch) + agx_batch_add_bo(batch, ctx->scratch_cs.buf); + assert(batch->initialized); /* Finalize the encoder */ @@ -1339,6 +1342,11 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch) batch->occlusion_buffer.gpu = 0; } + if (batch->vs_scratch) + agx_batch_add_bo(batch, ctx->scratch_vs.buf); + if (batch->fs_scratch) + agx_batch_add_bo(batch, ctx->scratch_fs.buf); + /* TODO: Linux UAPI submission */ (void)dev; (void)zbias; @@ -1390,6 +1398,10 @@ agx_destroy_context(struct pipe_context *pctx) pipe_resource_reference(&ctx->heap, NULL); + agx_scratch_fini(&ctx->scratch_vs); + agx_scratch_fini(&ctx->scratch_fs); + agx_scratch_fini(&ctx->scratch_cs); + ralloc_free(ctx); } @@ -1507,6 +1519,10 @@ agx_create_context(struct pipe_screen *screen, void *priv, unsigned flags) ctx->support_lod_bias = !(flags & PIPE_CONTEXT_NO_LOD_BIAS); ctx->robust = (flags & PIPE_CONTEXT_ROBUST_BUFFER_ACCESS); + agx_scratch_init(agx_device(screen), &ctx->scratch_vs); + agx_scratch_init(agx_device(screen), &ctx->scratch_fs); + agx_scratch_init(agx_device(screen), &ctx->scratch_cs); + return pctx; } diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index d686bd95cfb..9ded768d23c 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -13,6 +13,7 @@ #include "asahi/lib/agx_device.h" #include "asahi/lib/agx_nir_lower_vbo.h" #include "asahi/lib/agx_pack.h" +#include "asahi/lib/agx_scratch.h" #include "asahi/lib/agx_tilebuffer.h" #include "asahi/lib/pool.h" #include "asahi/lib/shaders/geometry.h" @@ -381,6 +382,11 @@ struct agx_batch { /* Actual pointer in a uniform */ struct agx_bo *geom_params_bo; + + /* Whether each stage uses scratch */ + bool vs_scratch; + bool fs_scratch; + bool cs_scratch; }; struct agx_zsa { @@ -633,6 +639,10 @@ struct agx_context { uint32_t dummy_syncobj; int in_sync_fd; uint32_t in_sync_obj; + + struct agx_scratch scratch_vs; + struct agx_scratch scratch_fs; + struct agx_scratch scratch_cs; }; static void