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 <robdclark@gmail.com>
This commit is contained in:
Eric Anholt
2017-02-22 16:53:18 -08:00
parent e37b32f80c
commit c34295b1a3
9 changed files with 168 additions and 55 deletions

View File

@@ -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 */