summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_builder.h
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2017-02-22 16:53:18 -0800
committerEric Anholt <[email protected]>2017-10-10 11:42:04 -0700
commitc34295b1a3e2bd6ddf8a79bbe391aae1e98cd976 (patch)
tree1f66b4d477702e7c913c18352833138c2e73cb61 /src/compiler/nir/nir_builder.h
parente37b32f80c8ed95a3c3f49ba20d6155820c8bba8 (diff)
nir: Move vc4's alpha test lowering to core NIR.
I've been doing this inside of vc4, but vc5 wants it as well and it may be useful for other drivers (Intel has a related path for pre-gen6 with MRT, and freedreno had a TGSI path for it at one point). This required defining a common enum for the standard comparison functions, but other lowering passes are likely to also want that enum. v2: Add to meson.build as well. Acked-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_builder.h')
-rw-r--r--src/compiler/nir/nir_builder.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 7c65886356d..4bd5628ff7d 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -643,4 +643,29 @@ nir_jump(nir_builder *build, nir_jump_type jump_type)
nir_builder_instr_insert(build, &jump->instr);
}
+static inline nir_ssa_def *
+nir_compare_func(nir_builder *b, enum compare_func func,
+ nir_ssa_def *src0, nir_ssa_def *src1)
+{
+ switch (func) {
+ case COMPARE_FUNC_NEVER:
+ return nir_imm_int(b, 0);
+ case COMPARE_FUNC_ALWAYS:
+ return nir_imm_int(b, ~0);
+ case COMPARE_FUNC_EQUAL:
+ return nir_feq(b, src0, src1);
+ case COMPARE_FUNC_NOTEQUAL:
+ return nir_fne(b, src0, src1);
+ case COMPARE_FUNC_GREATER:
+ return nir_flt(b, src1, src0);
+ case COMPARE_FUNC_GEQUAL:
+ return nir_fge(b, src0, src1);
+ case COMPARE_FUNC_LESS:
+ return nir_flt(b, src0, src1);
+ case COMPARE_FUNC_LEQUAL:
+ return nir_fge(b, src1, src0);
+ }
+ unreachable("bad compare func");
+}
+
#endif /* NIR_BUILDER_H */