diff options
author | Gert Wollny <gert.wollny@collabora.com> | 2020-12-23 16:19:31 +0100 |
---|---|---|
committer | Gert Wollny <gert.wollny@collabora.com> | 2021-02-26 09:51:37 +0100 |
commit | e5db9c3dd4ebbd02a9c89ac4e177f6bc638a28fb (patch) | |
tree | bd6fc8037cc4ab34a5333b207ecdd360977b4f25 | |
parent | 4f4e1e5ed9a20a457181be78646c68944535d83a (diff) |
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 <gert.wollny@collabora.com>
Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9200>
-rw-r--r-- | src/compiler/nir/nir_opcodes.py | 34 |
1 files changed, 34 insertions, 0 deletions
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)") |