Mesa (master): nir: add support for min/max/median of 3 srcs

Bas Nieuwenhuizen bnieuwenhuizen at kemper.freedesktop.org
Wed Mar 28 23:32:23 UTC 2018


Module: Mesa
Branch: master
Commit: 3e830a1af2dcd0a8e6c76ea04c50e814e550b244
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e830a1af2dcd0a8e6c76ea04c50e814e550b244

Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Dec 28 00:31:02 2016 +0000

nir: add support for min/max/median of 3 srcs

These are needed for SPV_AMD_shader_trinary_minmax,
the AMD HW supports these.

Co-authored-by: Daniel Schürmann <daniel.schuermann at campus.tu-berlin.de>
Signed-off-by: Dave Airlie <airlied at redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.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 04edffc6c0..a762fdd220 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -661,6 +661,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")
 




More information about the mesa-commit mailing list