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>
This commit is contained in:
@@ -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)")
|
||||
|
Reference in New Issue
Block a user