nir/builder: Eliminate nir_f2b helper (and use of nir_f2b32 helper)
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 22 Feb 2022 20:07:04 +0000 (12:07 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 22:39:57 +0000 (22:39 +0000)
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>

src/compiler/nir/nir_builder.h
src/compiler/nir/nir_lower_bitmap.c
src/gallium/auxiliary/nir/nir_draw_helpers.c

index ecb3838..1972f12 100644 (file)
@@ -414,13 +414,6 @@ nir_f2fN(nir_builder *b, nir_ssa_def *src, unsigned 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)
 {
    return nir_ine(b, src, nir_imm_intN_t(b, 0, src->bit_size));
index ffb3b49..7130487 100644 (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);
 
index 60fcf7d..ad0d6d1 100644 (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.");