mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 09:10:12 +01:00
nir/opt_shrink_vectors: hoist alu helpers
to be used earlier in the file in the next commit Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28004>
This commit is contained in:
parent
d1916432ab
commit
aa99753a28
1 changed files with 25 additions and 25 deletions
|
|
@ -58,6 +58,31 @@ round_up_components(unsigned n)
|
|||
return (n > 5) ? util_next_power_of_two(n) : n;
|
||||
}
|
||||
|
||||
static void
|
||||
reswizzle_alu_uses(nir_def *def, uint8_t *reswizzle)
|
||||
{
|
||||
nir_foreach_use(use_src, def) {
|
||||
/* all uses must be ALU instructions */
|
||||
assert(nir_src_parent_instr(use_src)->type == nir_instr_type_alu);
|
||||
nir_alu_src *alu_src = (nir_alu_src *)use_src;
|
||||
|
||||
/* reswizzle ALU sources */
|
||||
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
|
||||
alu_src->swizzle[i] = reswizzle[alu_src->swizzle[i]];
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
is_only_used_by_alu(nir_def *def)
|
||||
{
|
||||
nir_foreach_use(use_src, def) {
|
||||
if (nir_src_parent_instr(use_src)->type != nir_instr_type_alu)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
shrink_dest_to_read_mask(nir_def *def)
|
||||
{
|
||||
|
|
@ -121,31 +146,6 @@ shrink_intrinsic_to_non_sparse(nir_intrinsic_instr *instr)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
reswizzle_alu_uses(nir_def *def, uint8_t *reswizzle)
|
||||
{
|
||||
nir_foreach_use(use_src, def) {
|
||||
/* all uses must be ALU instructions */
|
||||
assert(nir_src_parent_instr(use_src)->type == nir_instr_type_alu);
|
||||
nir_alu_src *alu_src = (nir_alu_src *)use_src;
|
||||
|
||||
/* reswizzle ALU sources */
|
||||
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
|
||||
alu_src->swizzle[i] = reswizzle[alu_src->swizzle[i]];
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
is_only_used_by_alu(nir_def *def)
|
||||
{
|
||||
nir_foreach_use(use_src, def) {
|
||||
if (nir_src_parent_instr(use_src)->type != nir_instr_type_alu)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
opt_shrink_vector(nir_builder *b, nir_alu_instr *instr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue