agx: Report GPRs to the driver

This needs to be passed onto the hardware.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18813>
This commit is contained in:
Alyssa Rosenzweig
2022-10-20 22:15:54 -04:00
parent 6e32826345
commit ec9eae99b1
4 changed files with 22 additions and 13 deletions

View File

@@ -1535,21 +1535,12 @@ agx_set_st_vary_final(agx_context *ctx)
static int static int
agx_dump_stats(agx_context *ctx, unsigned size, char **out) agx_dump_stats(agx_context *ctx, unsigned size, char **out)
{ {
unsigned nr_ins = 0, max_reg = 0; unsigned nr_ins = 0;
agx_foreach_instr_global(ctx, I) {
/* Count instructions */ /* Count instructions */
agx_foreach_instr_global(ctx, I)
nr_ins++; nr_ins++;
/* Count registers */
agx_foreach_dest(I, d) {
if (I->dest[d].type == AGX_INDEX_REGISTER) {
max_reg = MAX2(max_reg,
I->dest[d].value + agx_write_registers(I, d) - 1);
}
}
}
/* TODO: Pipe through occupancy */ /* TODO: Pipe through occupancy */
unsigned nr_threads = 1; unsigned nr_threads = 1;
@@ -1557,7 +1548,7 @@ agx_dump_stats(agx_context *ctx, unsigned size, char **out)
"%s shader: %u inst, %u bytes, %u halfregs, %u threads, " "%s shader: %u inst, %u bytes, %u halfregs, %u threads, "
"%u loops, %u:%u spills:fills", "%u loops, %u:%u spills:fills",
gl_shader_stage_name(ctx->stage), gl_shader_stage_name(ctx->stage),
nr_ins, size, max_reg, nr_threads, ctx->loop_count, nr_ins, size, ctx->max_reg, nr_threads, ctx->loop_count,
ctx->spills, ctx->fills); ctx->spills, ctx->fills);
} }
@@ -1845,6 +1836,13 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
agx_pack_binary(ctx, binary); agx_pack_binary(ctx, binary);
unsigned nr_gprs = ctx->max_reg + 1;
if (impl->function->is_preamble)
out->nr_preamble_gprs = nr_gprs;
else
out->nr_gprs = nr_gprs;
/* Don't dump statistics for preambles, since they're not worth optimizing */ /* Don't dump statistics for preambles, since they're not worth optimizing */
if (!impl->function->is_preamble) { if (!impl->function->is_preamble) {
char *stats; char *stats;

View File

@@ -175,6 +175,11 @@ struct agx_shader_info {
/* Is colour output omitted? */ /* Is colour output omitted? */
bool no_colour_output; bool no_colour_output;
/* Number of 16-bit registers used by the main shader and preamble
* respectively.
*/
unsigned nr_gprs, nr_preamble_gprs;
}; };
#define AGX_MAX_RTS (8) #define AGX_MAX_RTS (8)

View File

@@ -411,6 +411,7 @@ typedef struct {
unsigned loop_count; unsigned loop_count;
unsigned spills; unsigned spills;
unsigned fills; unsigned fills;
unsigned max_reg;
} agx_context; } agx_context;
static inline void static inline void

View File

@@ -350,6 +350,11 @@ agx_ra(agx_context *ctx)
}); });
} }
for (unsigned i = 0; i < ctx->alloc; ++i) {
if (ncomps[i])
ctx->max_reg = MAX2(ctx->max_reg, ssa_to_reg[i] + ncomps[i] - 1);
}
agx_foreach_instr_global(ctx, ins) { agx_foreach_instr_global(ctx, ins) {
agx_foreach_src(ins, s) { agx_foreach_src(ins, s) {
if (ins->src[s].type == AGX_INDEX_NORMAL) { if (ins->src[s].type == AGX_INDEX_NORMAL) {