asahi: Hook up scratch

Instantiate our 3 scratch managers for each shader type, and pass them
to the hardware if a batch uses scratch.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27616>
This commit is contained in:
Asahi Lina 2023-11-08 22:27:10 +09:00 committed by Marge Bot
parent fa475c1b56
commit bb5277aa3d
3 changed files with 29 additions and 0 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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