From b265020b825d0f79be9941a0cc58e1a26ce34940 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Feb 2022 12:07:04 -0800 Subject: [PATCH] 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 Suggested-by: Konstantin Seurer Part-of: --- src/compiler/nir/nir_builder.h | 7 ------- src/compiler/nir/nir_lower_bitmap.c | 5 +++-- src/gallium/auxiliary/nir/nir_draw_helpers.c | 8 +++++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index ecb3838adbe..1972f125dae 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -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) { diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c index ffb3b4945d1..713048714cb 100644 --- a/src/compiler/nir/nir_lower_bitmap.c +++ b/src/compiler/nir/nir_lower_bitmap.c @@ -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); diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c index 60fcf7dd941..ad0d6d15ea1 100644 --- a/src/gallium/auxiliary/nir/nir_draw_helpers.c +++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c @@ -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.");