agx: Ensure we don't overallocate registers
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11751>
This commit is contained in:

committed by
Marge Bot

parent
7e65e47d19
commit
1d0008734c
@@ -1366,6 +1366,7 @@ agx_compile_shader_nir(nir_shader *nir,
|
|||||||
ctx->nir_regalloc[reg->index] = nir_regalloc;
|
ctx->nir_regalloc[reg->index] = nir_regalloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->max_register = nir_regalloc;
|
||||||
ctx->alloc += func->impl->ssa_alloc;
|
ctx->alloc += func->impl->ssa_alloc;
|
||||||
emit_cf_list(ctx, &func->impl->body);
|
emit_cf_list(ctx, &func->impl->body);
|
||||||
break; /* TODO: Multi-function shaders */
|
break; /* TODO: Multi-function shaders */
|
||||||
|
@@ -363,6 +363,9 @@ typedef struct {
|
|||||||
* driver. YOLO the mapping of nir_register to fixed hardware registers */
|
* driver. YOLO the mapping of nir_register to fixed hardware registers */
|
||||||
unsigned *nir_regalloc;
|
unsigned *nir_regalloc;
|
||||||
|
|
||||||
|
/* We reserve the top (XXX: that hurts thread count) */
|
||||||
|
unsigned max_register;
|
||||||
|
|
||||||
/* Place to start pushing new values */
|
/* Place to start pushing new values */
|
||||||
unsigned push_base;
|
unsigned push_base;
|
||||||
|
|
||||||
|
@@ -73,9 +73,9 @@ agx_write_registers(agx_instr *I, unsigned d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
agx_assign_regs(BITSET_WORD *used_regs, unsigned count, unsigned align)
|
agx_assign_regs(BITSET_WORD *used_regs, unsigned count, unsigned align, unsigned max)
|
||||||
{
|
{
|
||||||
for (unsigned reg = 0; reg < AGX_NUM_REGS; reg += align) {
|
for (unsigned reg = 0; reg < max; reg += align) {
|
||||||
bool conflict = false;
|
bool conflict = false;
|
||||||
|
|
||||||
for (unsigned j = 0; j < count; ++j)
|
for (unsigned j = 0; j < count; ++j)
|
||||||
@@ -95,7 +95,7 @@ agx_assign_regs(BITSET_WORD *used_regs, unsigned count, unsigned align)
|
|||||||
/** Assign registers to SSA values in a block. */
|
/** Assign registers to SSA values in a block. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
agx_ra_assign_local(agx_block *block, uint8_t *ssa_to_reg)
|
agx_ra_assign_local(agx_block *block, uint8_t *ssa_to_reg, unsigned max_reg)
|
||||||
{
|
{
|
||||||
BITSET_DECLARE(used_regs, AGX_NUM_REGS) = { 0 };
|
BITSET_DECLARE(used_regs, AGX_NUM_REGS) = { 0 };
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ agx_ra_assign_local(agx_block *block, uint8_t *ssa_to_reg)
|
|||||||
if (I->dest[d].type == AGX_INDEX_NORMAL) {
|
if (I->dest[d].type == AGX_INDEX_NORMAL) {
|
||||||
unsigned count = agx_write_registers(I, d);
|
unsigned count = agx_write_registers(I, d);
|
||||||
unsigned align = (I->dest[d].size == AGX_SIZE_16) ? 1 : 2;
|
unsigned align = (I->dest[d].size == AGX_SIZE_16) ? 1 : 2;
|
||||||
unsigned reg = agx_assign_regs(used_regs, count, align);
|
unsigned reg = agx_assign_regs(used_regs, count, align, max_reg);
|
||||||
|
|
||||||
ssa_to_reg[I->dest[d].value] = reg;
|
ssa_to_reg[I->dest[d].value] = reg;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ agx_ra(agx_context *ctx)
|
|||||||
agx_compute_liveness(ctx);
|
agx_compute_liveness(ctx);
|
||||||
uint8_t *ssa_to_reg = calloc(ctx->alloc, sizeof(uint8_t));
|
uint8_t *ssa_to_reg = calloc(ctx->alloc, sizeof(uint8_t));
|
||||||
agx_foreach_block(ctx, block)
|
agx_foreach_block(ctx, block)
|
||||||
agx_ra_assign_local(block, ssa_to_reg);
|
agx_ra_assign_local(block, ssa_to_reg, ctx->max_register);
|
||||||
|
|
||||||
/* TODO: Coalesce combines */
|
/* TODO: Coalesce combines */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user