nir/builder: Eliminate nir_f2b helper (and use of nir_f2b32 helper)

There were only two users. Replace each with nir_fneu instead.

This is now a squash of what was two separate commits.
nir_lower_pstipple_block is called after nir_lower_bool_to_int32, so
nir_fneu32 has to be used here or there will be regresssions in stipple
tests on llvmpipe.

v2: Rebase on !20869.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Suggested-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20509>
This commit is contained in:
Ian Romanick 2022-02-22 12:07:04 -08:00 committed by Marge Bot
parent 7b0d000342
commit b265020b82
3 changed files with 8 additions and 12 deletions

View file

@ -413,13 +413,6 @@ nir_f2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
return nir_convert_to_bit_size(b, src, nir_type_float, bit_size);
}
static inline nir_ssa_def *
nir_f2b(nir_builder *b, nir_ssa_def *src)
{
return nir_type_convert(b, src, nir_type_float, nir_type_bool1,
nir_rounding_mode_undef);
}
static inline nir_ssa_def *
nir_i2b(nir_builder *b, nir_ssa_def *src)
{

View file

@ -109,8 +109,9 @@ lower_bitmap(nir_shader *shader, nir_builder *b,
nir_builder_instr_insert(b, &tex->instr);
/* kill if tex != 0.0.. take .x or .w channel according to format: */
cond = nir_f2b(b, nir_channel(b, &tex->dest.ssa,
options->swizzle_xxxx ? 0 : 3));
cond = nir_fneu(b, nir_channel(b, &tex->dest.ssa,
options->swizzle_xxxx ? 0 : 3),
nir_imm_floatN_t(b, 0.0, tex->dest.ssa.bit_size));
nir_discard_if(b, cond);

View file

@ -90,14 +90,16 @@ nir_lower_pstipple_block(nir_block *block,
nir_builder_instr_insert(b, &tex->instr);
nir_ssa_def *condition = nir_f2b32(b, nir_channel(b, &tex->dest.ssa, 3));
nir_ssa_def *condition;
switch (state->bool_type) {
case nir_type_bool1:
condition = nir_f2b(b, nir_channel(b, &tex->dest.ssa, 3));
condition = nir_fneu(b, nir_channel(b, &tex->dest.ssa, 3),
nir_imm_floatN_t(b, 0.0, tex->dest.ssa.bit_size));
break;
case nir_type_bool32:
condition = nir_f2b32(b, nir_channel(b, &tex->dest.ssa, 3));
condition = nir_fneu32(b, nir_channel(b, &tex->dest.ssa, 3),
nir_imm_floatN_t(b, 0.0, tex->dest.ssa.bit_size));
break;
default:
unreachable("Invalid Boolean type.");