asahi: allocate preamble scratch

needed for preamble spilling

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27616>
This commit is contained in:
Alyssa Rosenzweig 2024-01-26 14:27:13 -04:00 committed by Marge Bot
parent f97b041e87
commit 485e17e01e
3 changed files with 27 additions and 10 deletions

View file

@ -139,6 +139,9 @@ agx_batch_init(struct agx_context *ctx,
batch->vs_scratch = false;
batch->fs_scratch = false;
batch->cs_scratch = false;
batch->vs_preamble_scratch = 0;
batch->fs_preamble_scratch = 0;
batch->cs_preamble_scratch = 0;
/* We need to emit prim state at the start. Max collides with all. */
batch->reduced_prim = MESA_PRIM_COUNT;

View file

@ -3183,26 +3183,30 @@ agx_build_pipeline(struct agx_batch *batch, struct agx_compiled_shader *cs,
cfg.unk_2 = (stage == PIPE_SHADER_FRAGMENT) ? 2 : 3;
}
uint32_t spill_bucket = 0;
uint32_t max_scratch_size =
MAX2(cs->info.scratch_size, cs->info.preamble_scratch_size);
if (cs->info.scratch_size > 0) {
spill_bucket = agx_scratch_get_bucket(cs->info.scratch_size);
if (max_scratch_size > 0) {
unsigned preamble_size = (cs->info.preamble_scratch_size > 0) ? 1 : 0;
switch (stage) {
case PIPE_SHADER_FRAGMENT:
agx_scratch_alloc(&ctx->scratch_fs, cs->info.scratch_size,
max_subgroups);
agx_scratch_alloc(&ctx->scratch_fs, max_scratch_size, max_subgroups);
batch->fs_scratch = true;
batch->fs_preamble_scratch =
MAX2(batch->fs_preamble_scratch, preamble_size);
break;
case PIPE_SHADER_VERTEX:
agx_scratch_alloc(&ctx->scratch_vs, cs->info.scratch_size,
max_subgroups);
agx_scratch_alloc(&ctx->scratch_vs, max_scratch_size, max_subgroups);
batch->vs_scratch = true;
batch->vs_preamble_scratch =
MAX2(batch->vs_preamble_scratch, preamble_size);
break;
default:
agx_scratch_alloc(&ctx->scratch_cs, cs->info.scratch_size,
max_subgroups);
agx_scratch_alloc(&ctx->scratch_cs, max_scratch_size, max_subgroups);
batch->cs_scratch = true;
batch->cs_preamble_scratch =
MAX2(batch->cs_preamble_scratch, preamble_size);
break;
}
}
@ -3210,7 +3214,9 @@ agx_build_pipeline(struct agx_batch *batch, struct agx_compiled_shader *cs,
agx_usc_pack(&b, REGISTERS, cfg) {
cfg.register_count = cs->info.nr_gprs;
cfg.unk_1 = (stage == PIPE_SHADER_FRAGMENT);
cfg.spill_size = spill_bucket;
cfg.spill_size = cs->info.scratch_size
? agx_scratch_get_bucket(cs->info.scratch_size)
: 0;
}
if (stage == PIPE_SHADER_FRAGMENT) {

View file

@ -390,6 +390,14 @@ struct agx_batch {
bool vs_scratch;
bool fs_scratch;
bool cs_scratch;
/* Whether each stage has preambles using scratch, and if so which bucket.
* This just needs to be zero/nonzero for correctness, the magnitude in
* buckets is for statistics.
*/
unsigned vs_preamble_scratch;
unsigned fs_preamble_scratch;
unsigned cs_preamble_scratch;
};
struct agx_zsa {