nir/tests: use ffma_weak

Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41165>
This commit is contained in:
Karol Herbst 2026-04-23 17:26:59 +02:00 committed by Marge Bot
parent b7094546f4
commit 688e5cda94
3 changed files with 18 additions and 8 deletions

View file

@ -186,6 +186,11 @@ DEFINE_TEST(fmul, 2)
DEFINE_TEST(fmulz, 2)
DEFINE_TEST(fpow, 2)
DEFINE_TEST(fdot2, 2)
DEFINE_TEST(ffma, 3)
DEFINE_TEST(ffma_weak, 3)
DEFINE_TEST(ffmaz, 3)
DEFINE_TEST(fmad, 3)
DEFINE_TEST(fmadz, 3)
DEFINE_TEST(ffma_old, 3)
DEFINE_TEST(ffmaz_old, 3)
DEFINE_TEST(fabs, 1)

View file

@ -158,9 +158,9 @@ protected:
nir_def *build_uniform_expr(nir_builder *b, unsigned bit_size, unsigned index)
{
return nir_fsqrt(b, nir_ffma_old(b, load_uniform(b, bit_size, index),
nir_imm_floatN_t(b, 3.14, bit_size),
load_ubo(b, bit_size, index)));
return nir_fsqrt(b, nir_ffma_weak(b, load_uniform(b, bit_size, index),
nir_imm_floatN_t(b, 3.14, bit_size),
load_ubo(b, bit_size, index)));
}
bool shader_contains_uniform(nir_builder *target_b, unsigned bit_size,
@ -254,13 +254,13 @@ protected:
if (contains) {
return shader_contains_uniform(b, bit_size, index) &&
shader_contains_ubo(b, bit_size, index) &&
shader_contains_alu_op(b, nir_op_ffma_old, bit_size) &&
shader_contains_alu_op(b, nir_op_ffma_weak, bit_size) &&
shader_contains_alu_op(b, nir_op_fsqrt, bit_size) &&
shader_contains_const_float(b, 3.14, bit_size);
} else {
return !shader_contains_uniform(b, bit_size, index) &&
!shader_contains_ubo(b, bit_size, index) &&
!shader_contains_alu_op(b, nir_op_ffma_old, bit_size) &&
!shader_contains_alu_op(b, nir_op_ffma_weak, bit_size) &&
!shader_contains_alu_op(b, nir_op_fsqrt, bit_size) &&
!shader_contains_const_float(b, 3.14, bit_size);
}
@ -553,8 +553,8 @@ load_interpolated_input_tes(nir_builder *b, gl_varying_slot slot,
if (i == 0)
def[i] = nir_fmul(b, def[i], nir_channel(b, tesscoord, remap[i]));
else
def[i] = nir_ffma_old(b, def[i], nir_channel(b, tesscoord, remap[i]),
def[i - 1]);
def[i] = nir_ffma_weak(b, def[i], nir_channel(b, tesscoord, remap[i]),
def[i - 1]);
} else {
def[i] = nir_fmul(b, def[i], nir_channel(b, tesscoord, remap[i]));
}
@ -650,6 +650,11 @@ movable_across_interp(nir_builder *b, nir_op op, unsigned interp[3],
case nir_op_fmul:
case nir_op_fmulz:
case nir_op_ffma:
case nir_op_ffma_weak:
case nir_op_ffmaz:
case nir_op_fmad:
case nir_op_fmadz:
case nir_op_ffma_old:
case nir_op_ffmaz_old:
return !divergent[0] || !divergent[1];

View file

@ -165,7 +165,7 @@ TEST_P(nir_serialize_all_test, alu_vec)
TEST_P(nir_serialize_all_test, alu_two_components_full_swizzle)
{
nir_def *undef = nir_undef(b, 2, 32);
nir_def *fma = nir_ffma_old(b, undef, undef, undef);
nir_def *fma = nir_ffma_weak(b, undef, undef, undef);
nir_alu_instr *fma_alu = nir_def_as_alu(fma);
fma->num_components = GetParam();