HLSL: various SPIR-V compute shader IDs must be a 3-vector of integers.

This PR forces the external definition of SV_GroupID variables to 3-vectors.
The conversion process between the shader-declared type and the external type
happens in wrapped main IO variable conversion.

The same applies to SV_DispatchThreadID and SV_GroupThreadID.

Fixes: #1371
This commit is contained in:
LoopDawg
2018-05-15 14:52:14 -06:00
parent 1831087e48
commit 91a8178efb
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) {