Merge pull request #1379 from LoopDawg/groupid-fix

HLSL: various SPIR-V compute shader IDs must be 3-vectors of integers
This commit is contained in:
John Kessenich
2018-05-16 10:36:16 -06:00
committed by GitHub
6 changed files with 237 additions and 67 deletions

View File

@@ -1475,22 +1475,17 @@ bool HlslParseContext::isClipOrCullDistance(TBuiltInVariable builtIn)
void HlslParseContext::fixBuiltInIoType(TType& type)
{
int requiredArraySize = 0;
int requiredVectorSize = 0;
switch (type.getQualifier().builtIn) {
case EbvTessLevelOuter: requiredArraySize = 4; break;
case EbvTessLevelInner: requiredArraySize = 2; break;
case EbvTessCoord:
{
// tesscoord is always a vec3 for the IO variable, no matter the shader's
// declared vector size.
TType tessCoordType(type.getBasicType(), type.getQualifier().storage, 3);
case EbvWorkGroupId: requiredVectorSize = 3; break;
case EbvGlobalInvocationId: requiredVectorSize = 3; break;
case EbvLocalInvocationId: requiredVectorSize = 3; break;
case EbvTessCoord: requiredVectorSize = 3; break;
tessCoordType.getQualifier() = type.getQualifier();
type.shallowCopy(tessCoordType);
break;
}
default:
if (isClipOrCullDistance(type)) {
const int loc = type.getQualifier().layoutLocation;
@@ -1511,6 +1506,14 @@ void HlslParseContext::fixBuiltInIoType(TType& type)
return;
}
// Alter or set vector size as needed.
if (requiredVectorSize > 0) {
TType newType(type.getBasicType(), type.getQualifier().storage, requiredVectorSize);
newType.getQualifier() = type.getQualifier();
type.shallowCopy(newType);
}
// Alter or set array size as needed.
if (requiredArraySize > 0) {
if (!type.isArray() || type.getOuterArraySize() != requiredArraySize) {