From d8971128accc84db04becf820b66e455d5d7534c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 17 Aug 2016 05:03:29 -0700 Subject: [PATCH] nir/builder: Add bany_inequal and bany helpers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The first simply picks the bany_inequal[234] opcodes based on the SSA def's number of components. The latter implicitly compares with zero to achieve the same semantics of GLSL's any(). Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Kenneth Graunke Reviewed-by: Alejandro Piñeiro --- src/compiler/nir/nir_builder.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 435582aca3c..affa29cb025 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -317,6 +317,25 @@ nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1) return NULL; } +static inline nir_ssa_def * +nir_bany_inequal(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1) +{ + switch (src0->num_components) { + case 1: return nir_ine(b, src0, src1); + case 2: return nir_bany_inequal2(b, src0, src1); + case 3: return nir_bany_inequal3(b, src0, src1); + case 4: return nir_bany_inequal4(b, src0, src1); + default: + unreachable("bad component size"); + } +} + +static inline nir_ssa_def * +nir_bany(nir_builder *b, nir_ssa_def *src) +{ + return nir_bany_inequal(b, src, nir_imm_int(b, 0)); +} + static inline nir_ssa_def * nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c) { -- 2.30.2