HLSL: Add EOpMatrixSwizzle, selectively decomposed to other ops, for issue #670.

Since EOpMatrixSwizzle is a new op, existing back-ends only work when the
front end first decomposes it to other operations. So far, this is only
being done for simple assignment into matrix swizzles.
This commit is contained in:
John Kessenich 2017-01-13 12:27:52 -07:00
parent 001dfa1c5c
commit fdf6347f0a
12 changed files with 907 additions and 116 deletions

View File

@ -1115,6 +1115,9 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
builder.accessChainPushSwizzle(swizzle, convertGlslangToSpvType(node->getLeft()->getType()));
}
return false;
case glslang::EOpMatrixSwizzle:
logger->missingFunctionality("matrix swizzle");
return true;
case glslang::EOpLogicalOr:
case glslang::EOpLogicalAnd:
{

View File

@ -5,46 +5,325 @@ Shader version: 450
0:2 Function Parameters:
0:2 'inf' (layout(location=0 ) in float)
0:? Sequence
0:5 move second child to first child (temp float)
0:5 direct index (temp float)
0:5 direct index (temp 4-component vector of float)
0:5 'm' (temp 3X4 matrix of float)
0:5 Constant:
0:5 2 (const int)
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 1.000000
0:6 move second child to first child (temp float)
0:6 direct index (temp float)
0:6 direct index (temp 4-component vector of float)
0:6 'm' (temp 3X4 matrix of float)
0:6 Constant:
0:6 2 (const int)
0:6 Constant:
0:6 3 (const int)
0:6 Constant:
0:6 2.000000
0:8 move second child to first child (temp 4-component vector of float)
0:7 move second child to first child (temp float)
0:7 direct index (temp float)
0:7 direct index (temp 4-component vector of float)
0:7 'm' (temp 3X4 matrix of float)
0:7 Constant:
0:7 2 (const int)
0:7 Constant:
0:7 3 (const int)
0:7 Constant:
0:7 1.000000
0:8 move second child to first child (temp float)
0:8 direct index (temp float)
0:8 direct index (temp 4-component vector of float)
0:8 'm' (temp 3X4 matrix of float)
0:8 Constant:
0:8 0 (const int)
0:8 2 (const int)
0:8 Constant:
0:8 3.000000
0:8 3.000000
0:8 3.000000
0:8 3.000000
0:9 move second child to first child (temp 4-component vector of float)
0:8 3 (const int)
0:8 Constant:
0:8 2.000000
0:9 move second child to first child (temp float)
0:9 direct index (temp float)
0:9 direct index (temp 4-component vector of float)
0:9 'm' (temp 3X4 matrix of float)
0:9 Constant:
0:9 1 (const int)
0:9 2 (const int)
0:9 Constant:
0:9 3.000000
0:9 3.000000
0:9 3.000000
0:9 3.000000
0:9 3 (const int)
0:9 Constant:
0:9 2.000000
0:11 move second child to first child (temp 4-component vector of float)
0:11 direct index (temp 4-component vector of float)
0:11 'm' (temp 3X4 matrix of float)
0:11 Constant:
0:11 0 (const int)
0:11 Constant:
0:11 3.000000
0:11 3.000000
0:11 3.000000
0:11 3.000000
0:12 move second child to first child (temp 4-component vector of float)
0:12 direct index (temp 4-component vector of float)
0:12 'm' (temp 3X4 matrix of float)
0:12 Constant:
0:12 1 (const int)
0:12 Constant:
0:12 3.000000
0:12 3.000000
0:12 3.000000
0:12 3.000000
0:13 move second child to first child (temp 4-component vector of float)
0:13 direct index (temp 4-component vector of float)
0:13 'm' (temp 3X4 matrix of float)
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 3.000000
0:13 3.000000
0:13 3.000000
0:13 3.000000
0:? Sequence
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 0 (const int)
0:18 Constant:
0:18 0 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 0 (const int)
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 1 (const int)
0:18 Constant:
0:18 1 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 1 (const int)
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 1 (const int)
0:18 Constant:
0:18 2 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 2 (const int)
0:19 Sequence
0:19 move second child to first child (temp 3-component vector of float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 5.000000
0:19 5.000000
0:19 5.000000
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 1 (const int)
0:19 Constant:
0:19 0 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 0 (const int)
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 0 (const int)
0:19 Constant:
0:19 1 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 1 (const int)
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 2 (const int)
0:19 Constant:
0:19 0 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 2 (const int)
0:20 Sequence
0:20 move second child to first child (temp 3-component vector of float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 vector-scale (temp 3-component vector of float)
0:20 Constant:
0:20 2.000000
0:20 'f3' (temp 3-component vector of float)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 0 (const int)
0:20 Constant:
0:20 0 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 0 (const int)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 0 (const int)
0:20 Constant:
0:20 1 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 1 (const int)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 1 (const int)
0:20 Constant:
0:20 0 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 2 (const int)
0:23 move second child to first child (temp 3-component vector of float)
0:23 'f3' (temp 3-component vector of float)
0:23 matrix swizzle (temp 3-component vector of float)
0:23 'm' (temp 3X4 matrix of float)
0:23 Sequence
0:23 Constant:
0:23 1 (const int)
0:23 Constant:
0:23 0 (const int)
0:23 Constant:
0:23 0 (const int)
0:23 Constant:
0:23 1 (const int)
0:23 Constant:
0:23 2 (const int)
0:23 Constant:
0:23 0 (const int)
0:27 Function Definition: createMat3x3(vf3;vf3;vf3; (temp 3X3 matrix of float)
0:27 Function Parameters:
0:27 'a' (in 3-component vector of float)
0:27 'b' (in 3-component vector of float)
0:27 'c' (in 3-component vector of float)
0:? Sequence
0:? Sequence
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 0 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 0 (const int)
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 1 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 1 (const int)
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 2 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 2 (const int)
0:? Sequence
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 0 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 0 (const int)
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 1 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 1 (const int)
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 2 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:? Sequence
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 0 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 0 (const int)
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 1 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 1 (const int)
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 2 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 2 (const int)
0:32 Branch: Return with expression
0:32 'm' (temp 3X3 matrix of float)
0:? Linker Objects
0:? 'inf' (layout(location=0 ) in float)
@ -58,91 +337,482 @@ Shader version: 450
0:2 Function Parameters:
0:2 'inf' (layout(location=0 ) in float)
0:? Sequence
0:5 move second child to first child (temp float)
0:5 direct index (temp float)
0:5 direct index (temp 4-component vector of float)
0:5 'm' (temp 3X4 matrix of float)
0:5 Constant:
0:5 2 (const int)
0:5 Constant:
0:5 3 (const int)
0:5 Constant:
0:5 1.000000
0:6 move second child to first child (temp float)
0:6 direct index (temp float)
0:6 direct index (temp 4-component vector of float)
0:6 'm' (temp 3X4 matrix of float)
0:6 Constant:
0:6 2 (const int)
0:6 Constant:
0:6 3 (const int)
0:6 Constant:
0:6 2.000000
0:8 move second child to first child (temp 4-component vector of float)
0:7 move second child to first child (temp float)
0:7 direct index (temp float)
0:7 direct index (temp 4-component vector of float)
0:7 'm' (temp 3X4 matrix of float)
0:7 Constant:
0:7 2 (const int)
0:7 Constant:
0:7 3 (const int)
0:7 Constant:
0:7 1.000000
0:8 move second child to first child (temp float)
0:8 direct index (temp float)
0:8 direct index (temp 4-component vector of float)
0:8 'm' (temp 3X4 matrix of float)
0:8 Constant:
0:8 0 (const int)
0:8 2 (const int)
0:8 Constant:
0:8 3.000000
0:8 3.000000
0:8 3.000000
0:8 3.000000
0:9 move second child to first child (temp 4-component vector of float)
0:8 3 (const int)
0:8 Constant:
0:8 2.000000
0:9 move second child to first child (temp float)
0:9 direct index (temp float)
0:9 direct index (temp 4-component vector of float)
0:9 'm' (temp 3X4 matrix of float)
0:9 Constant:
0:9 1 (const int)
0:9 2 (const int)
0:9 Constant:
0:9 3.000000
0:9 3.000000
0:9 3.000000
0:9 3.000000
0:9 3 (const int)
0:9 Constant:
0:9 2.000000
0:11 move second child to first child (temp 4-component vector of float)
0:11 direct index (temp 4-component vector of float)
0:11 'm' (temp 3X4 matrix of float)
0:11 Constant:
0:11 0 (const int)
0:11 Constant:
0:11 3.000000
0:11 3.000000
0:11 3.000000
0:11 3.000000
0:12 move second child to first child (temp 4-component vector of float)
0:12 direct index (temp 4-component vector of float)
0:12 'm' (temp 3X4 matrix of float)
0:12 Constant:
0:12 1 (const int)
0:12 Constant:
0:12 3.000000
0:12 3.000000
0:12 3.000000
0:12 3.000000
0:13 move second child to first child (temp 4-component vector of float)
0:13 direct index (temp 4-component vector of float)
0:13 'm' (temp 3X4 matrix of float)
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 3.000000
0:13 3.000000
0:13 3.000000
0:13 3.000000
0:? Sequence
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 0 (const int)
0:18 Constant:
0:18 0 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 0 (const int)
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 1 (const int)
0:18 Constant:
0:18 1 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 1 (const int)
0:18 move second child to first child (temp float)
0:18 direct index (temp float)
0:18 direct index (temp 4-component vector of float)
0:18 'm' (temp 3X4 matrix of float)
0:18 Constant:
0:18 1 (const int)
0:18 Constant:
0:18 2 (const int)
0:18 direct index (temp float)
0:18 'f3' (temp 3-component vector of float)
0:18 Constant:
0:18 2 (const int)
0:19 Sequence
0:19 move second child to first child (temp 3-component vector of float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 5.000000
0:19 5.000000
0:19 5.000000
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 1 (const int)
0:19 Constant:
0:19 0 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 0 (const int)
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 0 (const int)
0:19 Constant:
0:19 1 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 1 (const int)
0:19 move second child to first child (temp float)
0:19 direct index (temp float)
0:19 direct index (temp 4-component vector of float)
0:19 'm' (temp 3X4 matrix of float)
0:19 Constant:
0:19 2 (const int)
0:19 Constant:
0:19 0 (const int)
0:19 direct index (temp float)
0:19 'intermVec' (temp 3-component vector of float)
0:19 Constant:
0:19 2 (const int)
0:20 Sequence
0:20 move second child to first child (temp 3-component vector of float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 vector-scale (temp 3-component vector of float)
0:20 Constant:
0:20 2.000000
0:20 'f3' (temp 3-component vector of float)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 0 (const int)
0:20 Constant:
0:20 0 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 0 (const int)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 0 (const int)
0:20 Constant:
0:20 1 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 1 (const int)
0:20 move second child to first child (temp float)
0:20 direct index (temp float)
0:20 direct index (temp 4-component vector of float)
0:20 'm' (temp 3X4 matrix of float)
0:20 Constant:
0:20 1 (const int)
0:20 Constant:
0:20 0 (const int)
0:20 direct index (temp float)
0:20 'intermVec' (temp 3-component vector of float)
0:20 Constant:
0:20 2 (const int)
0:23 move second child to first child (temp 3-component vector of float)
0:23 'f3' (temp 3-component vector of float)
0:23 matrix swizzle (temp 3-component vector of float)
0:23 'm' (temp 3X4 matrix of float)
0:23 Sequence
0:23 Constant:
0:23 1 (const int)
0:23 Constant:
0:23 0 (const int)
0:23 Constant:
0:23 0 (const int)
0:23 Constant:
0:23 1 (const int)
0:23 Constant:
0:23 2 (const int)
0:23 Constant:
0:23 0 (const int)
0:27 Function Definition: createMat3x3(vf3;vf3;vf3; (temp 3X3 matrix of float)
0:27 Function Parameters:
0:27 'a' (in 3-component vector of float)
0:27 'b' (in 3-component vector of float)
0:27 'c' (in 3-component vector of float)
0:? Sequence
0:? Sequence
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 0 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 0 (const int)
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 1 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 1 (const int)
0:29 move second child to first child (temp float)
0:29 direct index (temp float)
0:29 direct index (temp 3-component vector of float)
0:29 'm' (temp 3X3 matrix of float)
0:29 Constant:
0:29 2 (const int)
0:29 Constant:
0:29 0 (const int)
0:29 direct index (temp float)
0:29 'a' (in 3-component vector of float)
0:29 Constant:
0:29 2 (const int)
0:? Sequence
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 0 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 0 (const int)
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 1 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 1 (const int)
0:30 move second child to first child (temp float)
0:30 direct index (temp float)
0:30 direct index (temp 3-component vector of float)
0:30 'm' (temp 3X3 matrix of float)
0:30 Constant:
0:30 2 (const int)
0:30 Constant:
0:30 1 (const int)
0:30 direct index (temp float)
0:30 'b' (in 3-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:? Sequence
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 0 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 0 (const int)
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 1 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 1 (const int)
0:31 move second child to first child (temp float)
0:31 direct index (temp float)
0:31 direct index (temp 3-component vector of float)
0:31 'm' (temp 3X3 matrix of float)
0:31 Constant:
0:31 2 (const int)
0:31 Constant:
0:31 2 (const int)
0:31 direct index (temp float)
0:31 'c' (in 3-component vector of float)
0:31 Constant:
0:31 2 (const int)
0:32 Branch: Return with expression
0:32 'm' (temp 3X3 matrix of float)
0:? Linker Objects
0:? 'inf' (layout(location=0 ) in float)
Missing functionality: matrix swizzle
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 29
// Id's are bound by 109
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "ShaderFunction" 28
EntryPoint Vertex 4 "ShaderFunction" 108
Name 4 "ShaderFunction"
Name 10 "m"
Name 28 "inf"
Decorate 28(inf) Location 0
Name 14 "createMat3x3(vf3;vf3;vf3;"
Name 11 "a"
Name 12 "b"
Name 13 "c"
Name 19 "m"
Name 38 "f3"
Name 51 "intermVec"
Name 63 "intermVec"
Name 76 "m"
Name 108 "inf"
Decorate 108(inf) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeMatrix 7(fvec4) 3
9: TypePointer Function 8
11: TypeInt 32 1
12: 11(int) Constant 2
13: 6(float) Constant 1065353216
14: TypeInt 32 0
15: 14(int) Constant 3
16: TypePointer Function 6(float)
18: 6(float) Constant 1073741824
20: 11(int) Constant 0
21: 6(float) Constant 1077936128
22: 7(fvec4) ConstantComposite 21 21 21 21
23: TypePointer Function 7(fvec4)
25: 11(int) Constant 1
27: TypePointer Input 6(float)
28(inf): 27(ptr) Variable Input
7: TypeVector 6(float) 3
8: TypePointer Function 7(fvec3)
9: TypeMatrix 7(fvec3) 3
10: TypeFunction 9 8(ptr) 8(ptr) 8(ptr)
16: TypeVector 6(float) 4
17: TypeMatrix 16(fvec4) 3
18: TypePointer Function 17
20: TypeInt 32 1
21: 20(int) Constant 2
22: 6(float) Constant 1065353216
23: TypeInt 32 0
24: 23(int) Constant 3
25: TypePointer Function 6(float)
27: 6(float) Constant 1073741824
30: 20(int) Constant 0
31: 6(float) Constant 1077936128
32: 16(fvec4) ConstantComposite 31 31 31 31
33: TypePointer Function 16(fvec4)
35: 20(int) Constant 1
39: 23(int) Constant 0
43: 23(int) Constant 1
47: 23(int) Constant 2
52: 6(float) Constant 1084227584
53: 7(fvec3) ConstantComposite 52 52 52
75: TypePointer Function 9
107: TypePointer Input 6(float)
108(inf): 107(ptr) Variable Input
4(ShaderFunction): 2 Function None 3
5: Label
10(m): 9(ptr) Variable Function
17: 16(ptr) AccessChain 10(m) 12 15
Store 17 13
19: 16(ptr) AccessChain 10(m) 12 15
Store 19 18
24: 23(ptr) AccessChain 10(m) 20
Store 24 22
26: 23(ptr) AccessChain 10(m) 25
19(m): 18(ptr) Variable Function
38(f3): 8(ptr) Variable Function
51(intermVec): 8(ptr) Variable Function
63(intermVec): 8(ptr) Variable Function
26: 25(ptr) AccessChain 19(m) 21 24
Store 26 22
28: 25(ptr) AccessChain 19(m) 21 24
Store 28 27
29: 25(ptr) AccessChain 19(m) 21 24
Store 29 27
34: 33(ptr) AccessChain 19(m) 30
Store 34 32
36: 33(ptr) AccessChain 19(m) 35
Store 36 32
37: 33(ptr) AccessChain 19(m) 35
Store 37 32
40: 25(ptr) AccessChain 38(f3) 39
41: 6(float) Load 40
42: 25(ptr) AccessChain 19(m) 30 39
Store 42 41
44: 25(ptr) AccessChain 38(f3) 43
45: 6(float) Load 44
46: 25(ptr) AccessChain 19(m) 35 43
Store 46 45
48: 25(ptr) AccessChain 38(f3) 47
49: 6(float) Load 48
50: 25(ptr) AccessChain 19(m) 35 47
Store 50 49
Store 51(intermVec) 53
54: 25(ptr) AccessChain 51(intermVec) 39
55: 6(float) Load 54
56: 25(ptr) AccessChain 19(m) 35 39
Store 56 55
57: 25(ptr) AccessChain 51(intermVec) 43
58: 6(float) Load 57
59: 25(ptr) AccessChain 19(m) 30 43
Store 59 58
60: 25(ptr) AccessChain 51(intermVec) 47
61: 6(float) Load 60
62: 25(ptr) AccessChain 19(m) 21 39
Store 62 61
64: 7(fvec3) Load 38(f3)
65: 7(fvec3) VectorTimesScalar 64 27
Store 63(intermVec) 65
66: 25(ptr) AccessChain 63(intermVec) 39
67: 6(float) Load 66
68: 25(ptr) AccessChain 19(m) 30 39
Store 68 67
69: 25(ptr) AccessChain 63(intermVec) 43
70: 6(float) Load 69
71: 25(ptr) AccessChain 19(m) 30 43
Store 71 70
72: 25(ptr) AccessChain 63(intermVec) 47
73: 6(float) Load 72
74: 25(ptr) AccessChain 19(m) 35 39
Store 74 73
Store 38(f3) 30
Return
FunctionEnd
14(createMat3x3(vf3;vf3;vf3;): 9 Function None 10
11(a): 8(ptr) FunctionParameter
12(b): 8(ptr) FunctionParameter
13(c): 8(ptr) FunctionParameter
15: Label
76(m): 75(ptr) Variable Function
77: 25(ptr) AccessChain 11(a) 39
78: 6(float) Load 77
79: 25(ptr) AccessChain 76(m) 30 39
Store 79 78
80: 25(ptr) AccessChain 11(a) 43
81: 6(float) Load 80
82: 25(ptr) AccessChain 76(m) 35 39
Store 82 81
83: 25(ptr) AccessChain 11(a) 47
84: 6(float) Load 83
85: 25(ptr) AccessChain 76(m) 21 39
Store 85 84
86: 25(ptr) AccessChain 12(b) 39
87: 6(float) Load 86
88: 25(ptr) AccessChain 76(m) 30 43
Store 88 87
89: 25(ptr) AccessChain 12(b) 43
90: 6(float) Load 89
91: 25(ptr) AccessChain 76(m) 35 43
Store 91 90
92: 25(ptr) AccessChain 12(b) 47
93: 6(float) Load 92
94: 25(ptr) AccessChain 76(m) 21 43
Store 94 93
95: 25(ptr) AccessChain 13(c) 39
96: 6(float) Load 95
97: 25(ptr) AccessChain 76(m) 30 47
Store 97 96
98: 25(ptr) AccessChain 13(c) 43
99: 6(float) Load 98
100: 25(ptr) AccessChain 76(m) 35 47
Store 100 99
101: 25(ptr) AccessChain 13(c) 47
102: 6(float) Load 101
103: 25(ptr) AccessChain 76(m) 21 47
Store 103 102
104: 9 Load 76(m)
ReturnValue 104
FunctionEnd

View File

@ -2,9 +2,32 @@ void ShaderFunction(float inf) : COLOR0
{
float3x4 m;
// tests that convert to non-matrix swizzles
m._34 = 1.0; // AST should have a normal component select
m._m23 = 2.0; // same code
m[2][3] = 2.0; // same code
m._11_12_13_14 = float4(3.0); // AST should have normal column selection (first row)
m._m10_m11_m12_m13 = float4(3.0); // AST should have normal column selection (second row)
m[1] = float4(3.0); // same code
// tests that stay as matrix swizzles
float3 f3;
m._11_22_23 = f3;
m._21_12_31 = float3(5.0);
m._11_12_21 = 2 * f3;
// r-value
f3 = m._21_12_31;
}
float3x3 createMat3x3(float3 a, float3 b, float3 c)
{
float3x3 m;
m._11_21_31 = a;
m._12_22_32 = b;
m._13_23_33 = c;
return m;
}

View File

@ -626,6 +626,9 @@ enum TOperator {
// geometry methods
EOpMethodAppend, // Geometry shader methods
EOpMethodRestartStrip, // ...
// matrix
EOpMatrixSwizzle, // select multiple matrix components (non-column)
};
class TIntermTraverser;

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1764"
#define GLSLANG_DATE "12-Jan-2017"
#define GLSLANG_REVISION "Overload400-PrecQual.1766"
#define GLSLANG_DATE "13-Jan-2017"

View File

@ -1408,6 +1408,26 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, const TSourceLoc&
return node;
}
// A matrix swizzle is a sequence of nodes, 2N long, where N is the
// number of components in the swizzle, alternating col,row, col,row, ...
TIntermTyped* TIntermediate::addSwizzle(TMatrixComponents& comps, const TSourceLoc& loc)
{
TIntermAggregate* node = new TIntermAggregate(EOpSequence);
node->setLoc(loc);
TIntermConstantUnion* constIntNode;
TIntermSequence &sequenceVector = node->getSequence();
for (int i = 0; i < comps.size(); i++) {
constIntNode = addConstantUnion(comps.get(i).coord1, loc);
sequenceVector.push_back(constIntNode);
constIntNode = addConstantUnion(comps.get(i).coord2, loc);
sequenceVector.push_back(constIntNode);
}
return node;
}
//
// Follow the left branches down to the root of an l-value
// expression (just "." and []).
@ -1425,10 +1445,10 @@ const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool
if (binary == nullptr)
return node;
TOperator op = binary->getOp();
if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle)
if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle && op != EOpMatrixSwizzle)
return nullptr;
if (! swizzleOkay) {
if (op == EOpVectorSwizzle)
if (op == EOpVectorSwizzle || op == EOpMatrixSwizzle)
return nullptr;
if ((op == EOpIndexDirect || op == EOpIndexIndirect) &&
(binary->getLeft()->getType().isVector() || binary->getLeft()->getType().isScalar()) &&

View File

@ -129,6 +129,7 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EOpIndexIndirect: // fall through
case EOpIndexDirectStruct: // fall through
case EOpVectorSwizzle:
case EOpMatrixSwizzle:
return lValueErrorCheck(loc, op, binaryNode->getLeft());
default:
break;
@ -208,6 +209,7 @@ void TParseContextBase::rValueErrorCheck(const TSourceLoc& loc, const char* op,
case EOpIndexIndirect:
case EOpIndexDirectStruct:
case EOpVectorSwizzle:
case EOpMatrixSwizzle:
rValueErrorCheck(loc, op, binaryNode->getLeft());
default:
break;

View File

@ -146,6 +146,7 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
out.debug << (*node->getLeft()->getType().getStruct())[node->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst()].type->getFieldName();
out.debug << ": direct index for structure"; break;
case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
case EOpMatrixSwizzle: out.debug << "matrix swizzle"; break;
case EOpAdd: out.debug << "add"; break;
case EOpSub: out.debug << "subtract"; break;

View File

@ -275,6 +275,7 @@ public:
TIntermBranch* addBranch(TOperator, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&);
TIntermTyped* addSwizzle(TVectorFields&, const TSourceLoc&);
TIntermTyped* addSwizzle(TMatrixComponents&, const TSourceLoc&);
// Low level functions to add nodes (no conversions or other higher level transformations)
// If a type is provided, the node's type will be set to it.

View File

@ -90,6 +90,7 @@ bool isDereferenceOperation(glslang::TOperator op)
case glslang::EOpIndexDirectStruct:
case glslang::EOpIndexIndirect:
case glslang::EOpVectorSwizzle:
case glslang::EOpMatrixSwizzle:
return true;
default:
return false;

View File

@ -966,10 +966,9 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary));
} else {
TString vectorString = field;
TIntermTyped* index = intermediate.addSwizzle(fields, loc);
result = intermediate.addIndex(EOpVectorSwizzle, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, (int)vectorString.size()));
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, fields.num));
}
}
} else if (base->isMatrix()) {
@ -979,7 +978,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
if (comps.size() == 1) {
// Representable by m[c][r]
if (base->getType().getQualifier().storage == EvqConst) {
if (base->getType().getQualifier().isFrontEndConstant()) {
result = intermediate.foldDereference(base, comps.get(0).coord1, loc);
result = intermediate.foldDereference(result, comps.get(1).coord2, loc);
} else {
@ -994,7 +993,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
int column = getMatrixComponentsColumn(base->getMatrixRows(), comps);
if (column >= 0) {
// Representable by m[c]
if (base->getType().getQualifier().storage == EvqConst)
if (base->getType().getQualifier().isFrontEndConstant())
result = intermediate.foldDereference(base, column, loc);
else {
result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(column, loc), loc);
@ -1003,7 +1002,9 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
}
} else {
// general case, not a column, not a single component
error(loc, "arbitrary matrix component selection not supported", field.c_str(), "");
TIntermTyped* index = intermediate.addSwizzle(comps, loc);
result = intermediate.addIndex(EOpMatrixSwizzle, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, comps.size()));
}
}
} else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
@ -1890,11 +1891,17 @@ void HlslParseContext::handleFunctionArgument(TFunction* function,
// Some simple source assignments need to be flattened to a sequence
// of AST assignments. Catch these and flatten, otherwise, pass through
// to intermediate.addAssign().
TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right) const
//
// Also, assignment to matrix swizzles requires multiple component assignments,
// intercept those as well.
TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
{
if (left == nullptr || right == nullptr)
return nullptr;
if (left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle)
return handleAssignToMatrixSwizzle(loc, op, left, right);
const bool isSplitLeft = wasSplit(left);
const bool isSplitRight = wasSplit(right);
@ -1902,7 +1909,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
const bool isFlattenRight = wasFlattened(right);
// OK to do a single assign if both are split, or both are unsplit. But if one is and the other
// isn't, we fall back to a memberwise copy.
// isn't, we fall back to a member-wise copy.
if (! isFlattenLeft && ! isFlattenRight && !isSplitLeft && !isSplitRight)
return intermediate.addAssign(op, left, right, loc);
@ -2079,6 +2086,65 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
return assignList;
}
// An assignment to matrix swizzle must be decomposed into individual assignments.
// These must be selected component-wise from the RHS and stored component-wise
// into the LHS.
TIntermTyped* HlslParseContext::handleAssignToMatrixSwizzle(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
{
assert(left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle);
if (op != EOpAssign)
error(loc, "only simple assignment to non-simple matrix swizzle is supported", "assign", "");
// isolate the matrix and swizzle nodes
TIntermTyped* matrix = left->getAsBinaryNode()->getLeft()->getAsTyped();
const TIntermSequence& swizzle = left->getAsBinaryNode()->getRight()->getAsAggregate()->getSequence();
// if the RHS isn't already a simple vector, let's store into one
TIntermSymbol* vector = right->getAsSymbolNode();
TIntermTyped* vectorAssign = nullptr;
if (vector == nullptr) {
// create a new intermediate vector variable to assign to
TType vectorType(matrix->getBasicType(), EvqTemporary, matrix->getQualifier().precision, swizzle.size()/2);
vector = intermediate.addSymbol(*makeInternalVariable("intermVec", vectorType), loc);
// assign the right to the new vector
vectorAssign = handleAssign(loc, op, vector, right);
}
// Assign the vector components to the matrix components.
// Store this as a sequence, so a single aggregate node represents this
// entire operation.
TIntermAggregate* result = intermediate.makeAggregate(vectorAssign);
TType columnType(matrix->getType(), 0);
TType componentType(columnType, 0);
TType indexType(EbtInt);
for (int i = 0; i < (int)swizzle.size(); i += 2) {
// the right component, single index into the RHS vector
TIntermTyped* rightComp = intermediate.addIndex(EOpIndexDirect, vector,
intermediate.addConstantUnion(i/2, loc), loc);
// the left component, double index into the LHS matrix
TIntermTyped* leftComp = intermediate.addIndex(EOpIndexDirect, matrix,
intermediate.addConstantUnion(swizzle[i]->getAsConstantUnion()->getConstArray(),
indexType, loc),
loc);
leftComp->setType(columnType);
leftComp = intermediate.addIndex(EOpIndexDirect, leftComp,
intermediate.addConstantUnion(swizzle[i+1]->getAsConstantUnion()->getConstArray(),
indexType, loc),
loc);
leftComp->setType(componentType);
// Add the assignment to the aggregate
result = intermediate.growAggregate(result, intermediate.addAssign(op, leftComp, rightComp, loc));
}
result->setOp(EOpSequence);
return result;
}
//
// HLSL atomic operations have slightly different arguments than
// GLSL/AST/SPIRV. The semantics are converted below in decomposeIntrinsic.

View File

@ -78,7 +78,8 @@ public:
void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right) const;
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*);
void decomposeIntrinsic(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
void decomposeSampleMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);