mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
ntt: Add option to not optimized register allocation
On virglrenderer it is of interest to not re-use temporaries when we
want to handle precise, invariant, and highp/mediump with better
possibility for optimization.
v2: Force optimized RA if the number of registers is too large
(Emma: only 16 bit signed int are reserved for register indices)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16051>
This commit is contained in:
parent
b043d4c4c6
commit
535f0b9391
2 changed files with 17 additions and 1 deletions
|
|
@ -523,6 +523,14 @@ ntt_allocate_regs(struct ntt_compile *c, nir_function_impl *impl)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ntt_allocate_regs_unoptimized(struct ntt_compile *c, nir_function_impl *impl)
|
||||
{
|
||||
for (int i = c->first_non_array_temp; i < c->num_temps; i++)
|
||||
ureg_DECL_temporary(c->ureg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to find an iadd of a constant value with a non-constant value in the
|
||||
* nir_src's first component, returning the constant offset and replacing *src
|
||||
|
|
@ -3048,6 +3056,7 @@ ntt_emit_impl(struct ntt_compile *c, nir_function_impl *impl)
|
|||
_mesa_hash_table_insert(c->blocks, block, ntt_block);
|
||||
}
|
||||
|
||||
|
||||
ntt_setup_registers(c, &impl->registers);
|
||||
|
||||
c->cur_block = ntt_block_from_nir(c, nir_start_block(impl));
|
||||
|
|
@ -3058,7 +3067,13 @@ ntt_emit_impl(struct ntt_compile *c, nir_function_impl *impl)
|
|||
/* Emit the ntt insns */
|
||||
ntt_emit_cf_list(c, &impl->body);
|
||||
|
||||
ntt_allocate_regs(c, impl);
|
||||
/* Don't do optimized RA if the driver requests it, unless the number of
|
||||
* temps is too large to be covered by the 16 bit signed int that TGSI
|
||||
* allocates for the register index */
|
||||
if (!c->options->unoptimized_ra || c->num_temps > 0x7fff)
|
||||
ntt_allocate_regs(c, impl);
|
||||
else
|
||||
ntt_allocate_regs_unoptimized(c, impl);
|
||||
|
||||
/* Turn the ntt insns into actual TGSI tokens */
|
||||
ntt_emit_cf_list_ureg(c, &impl->body);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct nir_to_tgsi_options {
|
|||
bool lower_cmp;
|
||||
/* Emit MAX(a,-a) instead of abs src modifier) */
|
||||
bool lower_fabs;
|
||||
bool unoptimized_ra;
|
||||
};
|
||||
|
||||
const void *nir_to_tgsi(struct nir_shader *s,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue