From 3d803893da5b9ce06f8963ac8103d220b85f7e87 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 12 Jan 2021 13:04:59 +0100 Subject: [PATCH] nir/lower_bool: Rewrite dest_type for boolean destinations This happens with nir_texop_samples_identical, and we need to keep things consistent and (soon) keep the validator happy when expanding booleans once we switch that to having a dest_type of bool1. Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir_lower_bool_to_bitsize.c | 17 ++++++++++++++++- src/compiler/nir/nir_lower_bool_to_float.c | 17 ++++++++++++++++- src/compiler/nir/nir_lower_bool_to_int32.c | 17 ++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_lower_bool_to_bitsize.c b/src/compiler/nir/nir_lower_bool_to_bitsize.c index 7b71aceccc5..86b1a5ab1af 100644 --- a/src/compiler/nir/nir_lower_bool_to_bitsize.c +++ b/src/compiler/nir/nir_lower_bool_to_bitsize.c @@ -389,6 +389,18 @@ lower_phi_instr(nir_builder *b, nir_phi_instr *phi) return true; } +static bool +lower_tex_instr(nir_tex_instr *tex) +{ + bool progress = false; + rewrite_1bit_ssa_def_to_32bit(&tex->dest.ssa, &progress); + if (tex->dest_type == nir_type_bool1) { + tex->dest_type = nir_type_bool32; + progress = true; + } + return progress; +} + static bool nir_lower_bool_to_bitsize_impl(nir_builder *b, nir_function_impl *impl) { @@ -411,11 +423,14 @@ nir_lower_bool_to_bitsize_impl(nir_builder *b, nir_function_impl *impl) case nir_instr_type_ssa_undef: case nir_instr_type_intrinsic: - case nir_instr_type_tex: nir_foreach_ssa_def(instr, rewrite_1bit_ssa_def_to_32bit, &progress); break; + case nir_instr_type_tex: + progress |= lower_tex_instr(nir_instr_as_tex(instr)); + break; + default: nir_foreach_ssa_def(instr, assert_ssa_def_is_not_1bit, NULL); } diff --git a/src/compiler/nir/nir_lower_bool_to_float.c b/src/compiler/nir/nir_lower_bool_to_float.c index ac6f581bbf1..edd8b04dc80 100644 --- a/src/compiler/nir/nir_lower_bool_to_float.c +++ b/src/compiler/nir/nir_lower_bool_to_float.c @@ -127,6 +127,18 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *alu) return true; } +static bool +lower_tex_instr(nir_tex_instr *tex) +{ + bool progress = false; + rewrite_1bit_ssa_def_to_32bit(&tex->dest.ssa, &progress); + if (tex->dest_type == nir_type_bool1) { + tex->dest_type = nir_type_bool32; + progress = true; + } + return progress; +} + static bool nir_lower_bool_to_float_impl(nir_function_impl *impl) { @@ -157,11 +169,14 @@ nir_lower_bool_to_float_impl(nir_function_impl *impl) case nir_instr_type_intrinsic: case nir_instr_type_ssa_undef: case nir_instr_type_phi: - case nir_instr_type_tex: nir_foreach_ssa_def(instr, rewrite_1bit_ssa_def_to_32bit, &progress); break; + case nir_instr_type_tex: + progress |= lower_tex_instr(nir_instr_as_tex(instr)); + break; + default: nir_foreach_ssa_def(instr, assert_ssa_def_is_not_1bit, NULL); } diff --git a/src/compiler/nir/nir_lower_bool_to_int32.c b/src/compiler/nir/nir_lower_bool_to_int32.c index 77e90fab6bc..7be54fb7185 100644 --- a/src/compiler/nir/nir_lower_bool_to_int32.c +++ b/src/compiler/nir/nir_lower_bool_to_int32.c @@ -116,6 +116,18 @@ lower_alu_instr(nir_alu_instr *alu) return true; } +static bool +lower_tex_instr(nir_tex_instr *tex) +{ + bool progress = false; + rewrite_1bit_ssa_def_to_32bit(&tex->dest.ssa, &progress); + if (tex->dest_type == nir_type_bool1) { + tex->dest_type = nir_type_bool32; + progress = true; + } + return progress; +} + static bool nir_lower_bool_to_int32_impl(nir_function_impl *impl) { @@ -143,11 +155,14 @@ nir_lower_bool_to_int32_impl(nir_function_impl *impl) case nir_instr_type_intrinsic: case nir_instr_type_ssa_undef: case nir_instr_type_phi: - case nir_instr_type_tex: nir_foreach_ssa_def(instr, rewrite_1bit_ssa_def_to_32bit, &progress); break; + case nir_instr_type_tex: + progress |= lower_tex_instr(nir_instr_as_tex(instr)); + break; + default: nir_foreach_ssa_def(instr, assert_ssa_def_is_not_1bit, NULL); }