Commit 174ccb8f by LoopDawg

HLSL: Add imat, umat, and bmat constructors

Fixes #894
parent 1d585ac8
...@@ -1528,6 +1528,33 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt ...@@ -1528,6 +1528,33 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpConstructDMat4x2: case glslang::EOpConstructDMat4x2:
case glslang::EOpConstructDMat4x3: case glslang::EOpConstructDMat4x3:
case glslang::EOpConstructDMat4x4: case glslang::EOpConstructDMat4x4:
case glslang::EOpConstructIMat2x2:
case glslang::EOpConstructIMat2x3:
case glslang::EOpConstructIMat2x4:
case glslang::EOpConstructIMat3x2:
case glslang::EOpConstructIMat3x3:
case glslang::EOpConstructIMat3x4:
case glslang::EOpConstructIMat4x2:
case glslang::EOpConstructIMat4x3:
case glslang::EOpConstructIMat4x4:
case glslang::EOpConstructUMat2x2:
case glslang::EOpConstructUMat2x3:
case glslang::EOpConstructUMat2x4:
case glslang::EOpConstructUMat3x2:
case glslang::EOpConstructUMat3x3:
case glslang::EOpConstructUMat3x4:
case glslang::EOpConstructUMat4x2:
case glslang::EOpConstructUMat4x3:
case glslang::EOpConstructUMat4x4:
case glslang::EOpConstructBMat2x2:
case glslang::EOpConstructBMat2x3:
case glslang::EOpConstructBMat2x4:
case glslang::EOpConstructBMat3x2:
case glslang::EOpConstructBMat3x3:
case glslang::EOpConstructBMat3x4:
case glslang::EOpConstructBMat4x2:
case glslang::EOpConstructBMat4x3:
case glslang::EOpConstructBMat4x4:
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
case glslang::EOpConstructF16Mat2x2: case glslang::EOpConstructF16Mat2x2:
case glslang::EOpConstructF16Mat2x3: case glslang::EOpConstructF16Mat2x3:
......
int main() : SV_TARGET
{
// integer mat constructors
const int4x4 var441 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
const int4x4 var442 = int4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
int4x4 var443 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
int4x4 var444 = int4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
const int4x2 var421 = { 0,1, 1,1, 1,0, 0,0 };
const int4x2 var422 = int4x2( 0,1, 1,1, 1,0, 0,0 );
int4x2 var423 = { 0,1, 1,1, 1,0, 0,0 };
int4x2 var424 = int4x2( 0,1, 1,1, 1,0, 0,0 );
const int3x2 var321 = { 0,1, 1,1, 1,0 };
const int3x2 var322 = int3x2( 0,1, 1,1, 1,0 );
int3x2 var323 = { 0,1, 1,1, 1,0 };
int3x2 var234 = int3x2( 0,1, 1,1, 1,0);
// unsigned integer mat constructors
const uint4x4 uvar441 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
const uint4x4 uvar442 = uint4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
uint4x4 uvar443 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
uint4x4 uvar444 = uint4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
const uint4x2 uvar421 = { 0,1, 1,1, 1,0, 0,0 };
const uint4x2 uvar422 = uint4x2( 0,1, 1,1, 1,0, 0,0 );
uint4x2 uvar423 = { 0,1, 1,1, 1,0, 0,0 };
uint4x2 uvar424 = uint4x2( 0,1, 1,1, 1,0, 0,0 );
const uint3x2 uvar321 = { 0,1, 1,1, 1,0 };
const uint3x2 uvar322 = uint3x2( 0,1, 1,1, 1,0 );
uint3x2 uvar323 = { 0,1, 1,1, 1,0 };
uint3x2 uvar234 = uint3x2( 0,1, 1,1, 1,0);
// boolean mat constructors
const bool4x4 bvar441 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
const bool4x4 bvar442 = bool4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
bool4x4 bvar443 = { 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 };
bool4x4 bvar444 = bool4x4( 0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0 );
const bool4x2 bvar421 = { 0,1, 1,1, 1,0, 0,0 };
const bool4x2 bvar422 = bool4x2( 0,1, 1,1, 1,0, 0,0 );
bool4x2 bvar423 = { 0,1, 1,1, 1,0, 0,0 };
bool4x2 bvar424 = bool4x2( 0,1, 1,1, 1,0, 0,0 );
const bool3x2 bvar321 = { 0,1, 1,1, 1,0 };
const bool3x2 bvar322 = bool3x2( 0,1, 1,1, 1,0 );
bool3x2 bvar323 = { 0,1, 1,1, 1,0 };
bool3x2 bvar234 = bool3x2( 0,1, 1,1, 1,0);
return 0;
}
...@@ -436,6 +436,33 @@ enum TOperator { ...@@ -436,6 +436,33 @@ enum TOperator {
EOpConstructDMat4x2, EOpConstructDMat4x2,
EOpConstructDMat4x3, EOpConstructDMat4x3,
EOpConstructDMat4x4, EOpConstructDMat4x4,
EOpConstructIMat2x2,
EOpConstructIMat2x3,
EOpConstructIMat2x4,
EOpConstructIMat3x2,
EOpConstructIMat3x3,
EOpConstructIMat3x4,
EOpConstructIMat4x2,
EOpConstructIMat4x3,
EOpConstructIMat4x4,
EOpConstructUMat2x2,
EOpConstructUMat2x3,
EOpConstructUMat2x4,
EOpConstructUMat3x2,
EOpConstructUMat3x3,
EOpConstructUMat3x4,
EOpConstructUMat4x2,
EOpConstructUMat4x3,
EOpConstructUMat4x4,
EOpConstructBMat2x2,
EOpConstructBMat2x3,
EOpConstructBMat2x4,
EOpConstructBMat3x2,
EOpConstructBMat3x3,
EOpConstructBMat3x4,
EOpConstructBMat4x2,
EOpConstructBMat4x3,
EOpConstructBMat4x4,
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
EOpConstructFloat16, EOpConstructFloat16,
EOpConstructF16Vec2, EOpConstructF16Vec2,
......
...@@ -1220,21 +1220,79 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const ...@@ -1220,21 +1220,79 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
break; break;
#endif #endif
case EbtInt: case EbtInt:
switch(type.getVectorSize()) { if (type.getMatrixCols()) {
case 1: op = EOpConstructInt; break; switch (type.getMatrixCols()) {
case 2: op = EOpConstructIVec2; break; case 2:
case 3: op = EOpConstructIVec3; break; switch (type.getMatrixRows()) {
case 4: op = EOpConstructIVec4; break; case 2: op = EOpConstructIMat2x2; break;
default: break; // some compilers want this case 3: op = EOpConstructIMat2x3; break;
case 4: op = EOpConstructIMat2x4; break;
default: break; // some compilers want this
}
break;
case 3:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructIMat3x2; break;
case 3: op = EOpConstructIMat3x3; break;
case 4: op = EOpConstructIMat3x4; break;
default: break; // some compilers want this
}
break;
case 4:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructIMat4x2; break;
case 3: op = EOpConstructIMat4x3; break;
case 4: op = EOpConstructIMat4x4; break;
default: break; // some compilers want this
}
break;
}
} else {
switch(type.getVectorSize()) {
case 1: op = EOpConstructInt; break;
case 2: op = EOpConstructIVec2; break;
case 3: op = EOpConstructIVec3; break;
case 4: op = EOpConstructIVec4; break;
default: break; // some compilers want this
}
} }
break; break;
case EbtUint: case EbtUint:
switch(type.getVectorSize()) { if (type.getMatrixCols()) {
case 1: op = EOpConstructUint; break; switch (type.getMatrixCols()) {
case 2: op = EOpConstructUVec2; break; case 2:
case 3: op = EOpConstructUVec3; break; switch (type.getMatrixRows()) {
case 4: op = EOpConstructUVec4; break; case 2: op = EOpConstructUMat2x2; break;
default: break; // some compilers want this case 3: op = EOpConstructUMat2x3; break;
case 4: op = EOpConstructUMat2x4; break;
default: break; // some compilers want this
}
break;
case 3:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructUMat3x2; break;
case 3: op = EOpConstructUMat3x3; break;
case 4: op = EOpConstructUMat3x4; break;
default: break; // some compilers want this
}
break;
case 4:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructUMat4x2; break;
case 3: op = EOpConstructUMat4x3; break;
case 4: op = EOpConstructUMat4x4; break;
default: break; // some compilers want this
}
break;
}
} else {
switch(type.getVectorSize()) {
case 1: op = EOpConstructUint; break;
case 2: op = EOpConstructUVec2; break;
case 3: op = EOpConstructUVec3; break;
case 4: op = EOpConstructUVec4; break;
default: break; // some compilers want this
}
} }
break; break;
case EbtInt64: case EbtInt64:
...@@ -1256,12 +1314,41 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const ...@@ -1256,12 +1314,41 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
} }
break; break;
case EbtBool: case EbtBool:
switch(type.getVectorSize()) { if (type.getMatrixCols()) {
case 1: op = EOpConstructBool; break; switch (type.getMatrixCols()) {
case 2: op = EOpConstructBVec2; break; case 2:
case 3: op = EOpConstructBVec3; break; switch (type.getMatrixRows()) {
case 4: op = EOpConstructBVec4; break; case 2: op = EOpConstructBMat2x2; break;
default: break; // some compilers want this case 3: op = EOpConstructBMat2x3; break;
case 4: op = EOpConstructBMat2x4; break;
default: break; // some compilers want this
}
break;
case 3:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructBMat3x2; break;
case 3: op = EOpConstructBMat3x3; break;
case 4: op = EOpConstructBMat3x4; break;
default: break; // some compilers want this
}
break;
case 4:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructBMat4x2; break;
case 3: op = EOpConstructBMat4x3; break;
case 4: op = EOpConstructBMat4x4; break;
default: break; // some compilers want this
}
break;
}
} else {
switch(type.getVectorSize()) {
case 1: op = EOpConstructBool; break;
case 2: op = EOpConstructBVec2; break;
case 3: op = EOpConstructBVec3; break;
case 4: op = EOpConstructBVec4; break;
default: break; // some compilers want this
}
} }
break; break;
default: default:
......
...@@ -505,6 +505,33 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node ...@@ -505,6 +505,33 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpConstructDMat4x2: out.debug << "Construct dmat4x2"; break; case EOpConstructDMat4x2: out.debug << "Construct dmat4x2"; break;
case EOpConstructDMat4x3: out.debug << "Construct dmat4x3"; break; case EOpConstructDMat4x3: out.debug << "Construct dmat4x3"; break;
case EOpConstructDMat4x4: out.debug << "Construct dmat4"; break; case EOpConstructDMat4x4: out.debug << "Construct dmat4"; break;
case EOpConstructIMat2x2: out.debug << "Construct imat2"; break;
case EOpConstructIMat2x3: out.debug << "Construct imat2x3"; break;
case EOpConstructIMat2x4: out.debug << "Construct imat2x4"; break;
case EOpConstructIMat3x2: out.debug << "Construct imat3x2"; break;
case EOpConstructIMat3x3: out.debug << "Construct imat3"; break;
case EOpConstructIMat3x4: out.debug << "Construct imat3x4"; break;
case EOpConstructIMat4x2: out.debug << "Construct imat4x2"; break;
case EOpConstructIMat4x3: out.debug << "Construct imat4x3"; break;
case EOpConstructIMat4x4: out.debug << "Construct imat4"; break;
case EOpConstructUMat2x2: out.debug << "Construct umat2"; break;
case EOpConstructUMat2x3: out.debug << "Construct umat2x3"; break;
case EOpConstructUMat2x4: out.debug << "Construct umat2x4"; break;
case EOpConstructUMat3x2: out.debug << "Construct umat3x2"; break;
case EOpConstructUMat3x3: out.debug << "Construct umat3"; break;
case EOpConstructUMat3x4: out.debug << "Construct umat3x4"; break;
case EOpConstructUMat4x2: out.debug << "Construct umat4x2"; break;
case EOpConstructUMat4x3: out.debug << "Construct umat4x3"; break;
case EOpConstructUMat4x4: out.debug << "Construct umat4"; break;
case EOpConstructBMat2x2: out.debug << "Construct bmat2"; break;
case EOpConstructBMat2x3: out.debug << "Construct bmat2x3"; break;
case EOpConstructBMat2x4: out.debug << "Construct bmat2x4"; break;
case EOpConstructBMat3x2: out.debug << "Construct bmat3x2"; break;
case EOpConstructBMat3x3: out.debug << "Construct bmat3"; break;
case EOpConstructBMat3x4: out.debug << "Construct bmat3x4"; break;
case EOpConstructBMat4x2: out.debug << "Construct bmat4x2"; break;
case EOpConstructBMat4x3: out.debug << "Construct bmat4x3"; break;
case EOpConstructBMat4x4: out.debug << "Construct bmat4"; break;
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
case EOpConstructFloat16: out.debug << "Construct float16_t"; break; case EOpConstructFloat16: out.debug << "Construct float16_t"; break;
case EOpConstructF16Vec2: out.debug << "Construct f16vec2"; break; case EOpConstructF16Vec2: out.debug << "Construct f16vec2"; break;
......
...@@ -100,6 +100,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -100,6 +100,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.conditional.frag", "PixelShaderFunction"}, {"hlsl.conditional.frag", "PixelShaderFunction"},
{"hlsl.constantbuffer.frag", "main"}, {"hlsl.constantbuffer.frag", "main"},
{"hlsl.constructexpr.frag", "main"}, {"hlsl.constructexpr.frag", "main"},
{"hlsl.constructimat.frag", "main"},
{"hlsl.depthGreater.frag", "PixelShaderFunction"}, {"hlsl.depthGreater.frag", "PixelShaderFunction"},
{"hlsl.depthLess.frag", "PixelShaderFunction"}, {"hlsl.depthLess.frag", "PixelShaderFunction"},
{"hlsl.discard.frag", "PixelShaderFunction"}, {"hlsl.discard.frag", "PixelShaderFunction"},
......
...@@ -5150,6 +5150,33 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node ...@@ -5150,6 +5150,33 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node
case EOpConstructDMat4x2: case EOpConstructDMat4x2:
case EOpConstructDMat4x3: case EOpConstructDMat4x3:
case EOpConstructDMat4x4: case EOpConstructDMat4x4:
case EOpConstructIMat2x2:
case EOpConstructIMat2x3:
case EOpConstructIMat2x4:
case EOpConstructIMat3x2:
case EOpConstructIMat3x3:
case EOpConstructIMat3x4:
case EOpConstructIMat4x2:
case EOpConstructIMat4x3:
case EOpConstructIMat4x4:
case EOpConstructUMat2x2:
case EOpConstructUMat2x3:
case EOpConstructUMat2x4:
case EOpConstructUMat3x2:
case EOpConstructUMat3x3:
case EOpConstructUMat3x4:
case EOpConstructUMat4x2:
case EOpConstructUMat4x3:
case EOpConstructUMat4x4:
case EOpConstructBMat2x2:
case EOpConstructBMat2x3:
case EOpConstructBMat2x4:
case EOpConstructBMat3x2:
case EOpConstructBMat3x3:
case EOpConstructBMat3x4:
case EOpConstructBMat4x2:
case EOpConstructBMat4x3:
case EOpConstructBMat4x4:
constructingMatrix = true; constructingMatrix = true;
break; break;
default: default:
...@@ -7274,6 +7301,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op ...@@ -7274,6 +7301,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
case EOpConstructIVec2: case EOpConstructIVec2:
case EOpConstructIVec3: case EOpConstructIVec3:
case EOpConstructIVec4: case EOpConstructIVec4:
case EOpConstructIMat2x2:
case EOpConstructIMat2x3:
case EOpConstructIMat2x4:
case EOpConstructIMat3x2:
case EOpConstructIMat3x3:
case EOpConstructIMat3x4:
case EOpConstructIMat4x2:
case EOpConstructIMat4x3:
case EOpConstructIMat4x4:
case EOpConstructInt: case EOpConstructInt:
basicOp = EOpConstructInt; basicOp = EOpConstructInt;
break; break;
...@@ -7281,6 +7317,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op ...@@ -7281,6 +7317,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
case EOpConstructUVec2: case EOpConstructUVec2:
case EOpConstructUVec3: case EOpConstructUVec3:
case EOpConstructUVec4: case EOpConstructUVec4:
case EOpConstructUMat2x2:
case EOpConstructUMat2x3:
case EOpConstructUMat2x4:
case EOpConstructUMat3x2:
case EOpConstructUMat3x3:
case EOpConstructUMat3x4:
case EOpConstructUMat4x2:
case EOpConstructUMat4x3:
case EOpConstructUMat4x4:
case EOpConstructUint: case EOpConstructUint:
basicOp = EOpConstructUint; basicOp = EOpConstructUint;
break; break;
...@@ -7288,6 +7333,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op ...@@ -7288,6 +7333,15 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
case EOpConstructBVec2: case EOpConstructBVec2:
case EOpConstructBVec3: case EOpConstructBVec3:
case EOpConstructBVec4: case EOpConstructBVec4:
case EOpConstructBMat2x2:
case EOpConstructBMat2x3:
case EOpConstructBMat2x4:
case EOpConstructBMat3x2:
case EOpConstructBMat3x3:
case EOpConstructBMat3x4:
case EOpConstructBMat4x2:
case EOpConstructBMat4x3:
case EOpConstructBMat4x4:
case EOpConstructBool: case EOpConstructBool:
basicOp = EOpConstructBool; basicOp = EOpConstructBool;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment