This patch is Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>
I think we should also add a flag for lowering this instruction as is done in GLSL IR. You should then add some patterns to nir_opt_algebraic.py that recognize open-code versions. It would also be interesting to detect clamp() patterns and convert them to med3. I don't have any expectation that you would implement the actual lowering. On 03/08/2018 02:14 PM, Daniel Schürmann wrote: > From: Dave Airlie <airl...@redhat.com> > > These are needed for SPV_AMD_shader_trinary_minmax, > the AMD HW supports these. > > Co-authored-by: Daniel Schürmann <daniel.schuerm...@campus.tu-berlin.de> > Signed-off-by: Dave Airlie <airl...@redhat.com> > --- > src/compiler/nir/nir_opcodes.py | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py > index 65d1320062..fdf90ef3f5 100644 > --- a/src/compiler/nir/nir_opcodes.py > +++ b/src/compiler/nir/nir_opcodes.py > @@ -658,6 +658,20 @@ triop("flrp", tfloat, "src0 * (1 - src2) + src1 * src2") > > > triop("fcsel", tfloat32, "(src0 != 0.0f) ? src1 : src2") > + > +# 3 way min/max/med > +triop("fmin3", tfloat, "fminf(src0, fminf(src1, src2))") > +triop("imin3", tint, "MIN2(src0, MIN2(src1, src2))") > +triop("umin3", tuint, "MIN2(src0, MIN2(src1, src2))") > + > +triop("fmax3", tfloat, "fmaxf(src0, fmaxf(src1, src2))") > +triop("imax3", tint, "MAX2(src0, MAX2(src1, src2))") > +triop("umax3", tuint, "MAX2(src0, MAX2(src1, src2))") > + > +triop("fmed3", tfloat, "fmaxf(fminf(fmaxf(src0, src1), src2), fminf(src0, > src1))") > +triop("imed3", tint, "MAX2(MIN2(MAX2(src0, src1), src2), MIN2(src0, src1))") > +triop("umed3", tuint, "MAX2(MIN2(MAX2(src0, src1), src2), MIN2(src0, src1))") > + > opcode("bcsel", 0, tuint, [0, 0, 0], > [tbool, tuint, tuint], "", "src0 ? src1 : src2") > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev