mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
nir: mark progress when removing trailing unused alu channels
When the unused channels were at the end and so no reswizzling was
needed, we wouldn't correctly mark the progress.
Fixes: cb7f2012
Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21014>
This commit is contained in:
parent
ef800da3f7
commit
fe56dd9c42
2 changed files with 44 additions and 4 deletions
|
|
@ -234,17 +234,19 @@ opt_shrink_vectors_alu(nir_builder *b, nir_alu_instr *instr)
|
|||
}
|
||||
}
|
||||
|
||||
/* update uses */
|
||||
if (progress)
|
||||
reswizzle_alu_uses(def, reswizzle);
|
||||
|
||||
unsigned rounded = round_up_components(num_components);
|
||||
assert(rounded <= def->num_components);
|
||||
if (rounded < def->num_components)
|
||||
progress = true;
|
||||
|
||||
/* update dest */
|
||||
def->num_components = rounded;
|
||||
instr->dest.write_mask = BITFIELD_MASK(rounded);
|
||||
|
||||
/* update uses */
|
||||
if (progress)
|
||||
reswizzle_alu_uses(def, reswizzle);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,44 @@ static void check_swizzle(nir_alu_src * src, const char * swizzle)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(nir_opt_shrink_vectors_test, opt_shrink_vectors_alu_trailing_component_only)
|
||||
{
|
||||
/* Test that opt_shrink_vectors correctly removes unused trailing channels
|
||||
* of alus.
|
||||
*
|
||||
* vec4 32 ssa_1 = fmov ssa_0.xyzx
|
||||
* vec1 32 ssa_2 = fmov ssa_1.x
|
||||
*
|
||||
* to
|
||||
*
|
||||
* vec1 32 ssa_1 = fmov ssa_0.x
|
||||
* vec1 32 ssa_2 = fmov ssa_1.x
|
||||
*/
|
||||
|
||||
nir_ssa_def *alu_result = nir_build_alu1(&bld, nir_op_mov, in_def);
|
||||
nir_alu_instr *alu_instr = nir_instr_as_alu(alu_result->parent_instr);
|
||||
alu_result->num_components = 4;
|
||||
alu_instr->dest.write_mask = BITFIELD_MASK(4);
|
||||
set_swizzle(&alu_instr->src[0], "xyxx");
|
||||
|
||||
nir_ssa_def *alu2_result = nir_build_alu1(&bld, nir_op_mov, alu_result);
|
||||
nir_alu_instr *alu2_instr = nir_instr_as_alu(alu2_result->parent_instr);
|
||||
set_swizzle(&alu2_instr->src[0], "x");
|
||||
alu2_result->num_components = 1;
|
||||
alu2_instr->dest.write_mask = BITFIELD_MASK(1);
|
||||
|
||||
nir_store_var(&bld, out_var, alu2_result, 1);
|
||||
|
||||
ASSERT_TRUE(nir_opt_shrink_vectors(bld.shader));
|
||||
|
||||
nir_validate_shader(bld.shader, NULL);
|
||||
|
||||
check_swizzle(&alu_instr->src[0], "x");
|
||||
ASSERT_TRUE(alu_result->num_components == 1);
|
||||
|
||||
ASSERT_FALSE(nir_opt_shrink_vectors(bld.shader));
|
||||
}
|
||||
|
||||
TEST_F(nir_opt_shrink_vectors_test, opt_shrink_vectors_simple)
|
||||
{
|
||||
/* Tests that opt_shrink_vectors correctly shrinks a simple case.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue