From: Christian Gmeiner Date: Fri, 3 Jul 2020 10:42:56 +0000 (+0200) Subject: etnaviv: do register setup only once X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=60915f87c73cd8f0361b2f465670313a1e121b41;p=mesa.git etnaviv: do register setup only once Register set setup should be done once at backend initializaion, as ra_set_finalize is O(r^2*c^2). Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index aa6b2c6d29b..0cb07c03cd7 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -25,6 +25,8 @@ */ #include "etnaviv_compiler.h" +#include "etnaviv_compiler_nir.h" +#include "etnaviv_debug.h" #include "util/ralloc.h" struct etna_compiler * @@ -32,6 +34,15 @@ etna_compiler_create(void) { struct etna_compiler *compiler = rzalloc(NULL, struct etna_compiler); + if (!DBG_ENABLED(ETNA_DBG_NIR)) + return compiler; + + compiler->regs = etna_ra_setup(compiler); + if (!compiler->regs) { + ralloc_free((void *)compiler); + compiler = NULL; + } + return compiler; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.h b/src/gallium/drivers/etnaviv/etnaviv_compiler.h index af979766ef3..e03b748b48b 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.h +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.h @@ -50,6 +50,7 @@ */ struct etna_compiler { uint32_t shader_count; + struct ra_regs *regs; }; /* compiler output per input/output */ diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.h b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.h index 7a2bbdf70a1..2ad004d85e0 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.h +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.h @@ -51,7 +51,6 @@ struct etna_compile { /* ra state */ struct ra_graph *g; - struct ra_regs *regs; unsigned *live_map; unsigned num_nodes; @@ -319,6 +318,9 @@ static inline int reg_get_base(struct etna_compile *c, int virt_reg) return virt_reg / NUM_REG_TYPES; } +struct ra_regs * +etna_ra_setup(void *mem_ctx); + void etna_ra_assign(struct etna_compile *c, nir_shader *shader); diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_ra.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_ra.c index b322f035279..fef982c9bf0 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_ra.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_ra.c @@ -81,10 +81,10 @@ static inline int reg_get_class(int virt_reg) return 0; } -void -etna_ra_assign(struct etna_compile *c, nir_shader *shader) +struct ra_regs * +etna_ra_setup(void *mem_ctx) { - struct ra_regs *regs = ra_alloc_reg_set(NULL, ETNA_MAX_TEMPS * + struct ra_regs *regs = ra_alloc_reg_set(mem_ctx, ETNA_MAX_TEMPS * NUM_REG_TYPES, false); /* classes always be created from index 0, so equal to the class enum @@ -108,6 +108,15 @@ etna_ra_assign(struct etna_compile *c, nir_shader *shader) } ra_set_finalize(regs, q_values); + return regs; +} + +void +etna_ra_assign(struct etna_compile *c, nir_shader *shader) +{ + struct etna_compiler *compiler = c->variant->shader->compiler; + struct ra_regs *regs = compiler->regs; + nir_function_impl *impl = nir_shader_get_entrypoint(shader); /* liveness and interference */ @@ -226,7 +235,6 @@ etna_ra_assign(struct etna_compile *c, nir_shader *shader) assert(ok); c->g = g; - c->regs = regs; c->live_map = live_map; c->num_nodes = num_nodes; } @@ -241,7 +249,6 @@ etna_ra_finish(struct etna_compile *c) } ralloc_free(c->g); - ralloc_free(c->regs); ralloc_free(c->live_map); return j; diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 44ab8eda363..b44354483ae 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -404,6 +404,7 @@ etna_create_shader_state(struct pipe_context *pctx, shader->id = p_atomic_inc_return(&compiler->shader_count); shader->specs = &screen->specs; + shader->compiler = screen->compiler; if (DBG_ENABLED(ETNA_DBG_NIR)) shader->nir = (pss->type == PIPE_SHADER_IR_NIR) ? pss->ir.nir : diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.h b/src/gallium/drivers/etnaviv/etnaviv_shader.h index 528603a55a9..c1ea785a135 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.h +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.h @@ -66,6 +66,7 @@ struct etna_shader { struct tgsi_token *tokens; struct nir_shader *nir; const struct etna_specs *specs; + struct etna_compiler *compiler; struct etna_shader_variant *variants; };