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

Author: Gert Wollny <[email protected]>
Date:   Wed Dec 23 16:19:31 2020 +0100

nir: Add r600 specific CUBE opcode to evaluate cube texture coords and
face

The opcode evaluates tha unnormalized coordinates, the length of the
major axis, and the cube face.

Signed-off-by: Gert Wollny <[email protected]>
Acked-by: Eric Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9200>

---

 src/compiler/nir/nir_opcodes.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index f261ddff8f1..854f7562635 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -1167,6 +1167,40 @@ dst = ((((src0 & 0xffff0000) >> 16) * (src1 & 
0x0000ffff)) << 16) + src2;
 triop("imad24_ir3", tint32, _2src_commutative,
       "(((int32_t)src0 << 8) >> 8) * (((int32_t)src1 << 8) >> 8) + src2")
 
+# r600-specific instruction that evaluates unnormalized cube texture 
coordinates
+# and face index
+# The actual texture coordinates are evaluated from this according to
+#    dst.yx / abs(dst.z) + 1.5
+unop_horiz("cube_r600", 4, tfloat32, 3, tfloat32, """
+   dst.x = dst.y = dst.z = 0.0;
+   float absX = fabsf(src0.x);
+   float absY = fabsf(src0.y);
+   float absZ = fabsf(src0.z);
+
+   if (absX >= absY && absX >= absZ) { dst.z = 2 * src0.x; }
+   if (absY >= absX && absY >= absZ) { dst.z = 2 * src0.y; }
+   if (absZ >= absX && absZ >= absY) { dst.z = 2 * src0.z; }
+
+   if (src0.x >= 0 && absX >= absY && absX >= absZ) {
+      dst.y = -src0.z; dst.x = -src0.y; dst.w = 0;
+   }
+   if (src0.x < 0 && absX >= absY && absX >= absZ) {
+      dst.y = src0.z; dst.x = -src0.y; dst.w = 1;
+   }
+   if (src0.y >= 0 && absY >= absX && absY >= absZ) {
+      dst.y = src0.x; dst.x = src0.z; dst.w = 2;
+   }
+   if (src0.y < 0 && absY >= absX && absY >= absZ) {
+      dst.y = src0.x; dst.x = -src0.z; dst.w = 3;
+   }
+   if (src0.z >= 0 && absZ >= absX && absZ >= absY) {
+      dst.y = src0.x; dst.x = -src0.y; dst.w = 4;
+   }
+   if (src0.z < 0 && absZ >= absX && absZ >= absY) {
+      dst.y = -src0.x; dst.x = -src0.y; dst.w = 5;
+   }
+""")
+
 # 24b multiply into 32b result (with sign extension)
 binop("imul24", tint32, _2src_commutative + associative,
       "(((int32_t)src0 << 8) >> 8) * (((int32_t)src1 << 8) >> 8)")

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to