glslang -> SPV: Use the new TBuiltInVariable instead of string compares to get the type of SPV built in. Also fixed gl_FragData and gl_PrimitiveIDIn.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31226 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-05-18 23:25:32 +00:00
parent dff18a2be0
commit 40e391184c
10 changed files with 81 additions and 105 deletions

View File

@ -290,64 +290,40 @@ spv::Decoration TranslateInvariantDecoration(const glslang::TType& type)
// Translate glslang built-in variable to SPIR-V built in decoration.
spv::BuiltIn TranslateBuiltInDecoration(const glslang::TIntermSymbol& node)
{
const glslang::TString& name = node.getName();
if (name.compare(0, 3, "gl_") != 0)
return (spv::BuiltIn)spv::BadValue;
switch (node.getQualifier().storage) {
case glslang::EvqPosition: return spv::BuiltInPosition;
case glslang::EvqPointSize: return spv::BuiltInPointSize;
case glslang::EvqClipVertex: return spv::BuiltInClipVertex;
case glslang::EvqVertexId: return spv::BuiltInVertexId;
case glslang::EvqInstanceId: return spv::BuiltInInstanceId;
case glslang::EvqFragCoord: return spv::BuiltInFragCoord;
case glslang::EvqPointCoord: return spv::BuiltInPointCoord;
case glslang::EvqFace: return spv::BuiltInFrontFacing;
case glslang::EvqFragColor: return spv::BuiltInFragColor;
case glslang::EvqFragDepth: return spv::BuiltInFragDepth;
default:
if (name == "gl_ClipDistance")
return spv::BuiltInClipDistance;
else if (name == "gl_PrimitiveID" || name == "gl_PrimitiveIDIn")
return spv::BuiltInPrimitiveId;
else if (name == "gl_InvocationID")
return spv::BuiltInInvocationId;
else if (name == "gl_Layer")
return spv::BuiltInLayer;
else if (name == "gl_ViewportIndex")
return spv::BuiltInViewportIndex;
else if (name == "gl_TessLevelOuter")
return spv::BuiltInTessLevelOuter;
else if (name == "gl_TessLevelInner")
return spv::BuiltInTessLevelInner;
else if (name == "gl_TessCoord")
return spv::BuiltInTessCoord;
else if (name == "gl_PatchVerticesIn")
return spv::BuiltInPatchVertices;
else if (name == "gl_SampleID")
return spv::BuiltInSampleId;
else if (name == "gl_SamplePosition")
return spv::BuiltInSamplePosition;
else if (name == "gl_SampleMask" || name == "gl_SampleMaskIn")
return spv::BuiltInSampleMask;
// Compute shader:
else if (name == "gl_NumWorkGroups")
return spv::BuiltInNumWorkgroups;
else if (name == "gl_WorkGroupSize")
return spv::BuiltInWorkgroupSize;
else if (name == "gl_WorkGroupID")
return spv::BuiltInWorkgroupId;
else if (name == "gl_LocalInvocationID")
return spv::BuiltInLocalInvocationId;
else if (name == "gl_GlobalInvocationID")
return spv::BuiltInGlobalInvocationId;
else if (name == "gl_LocalInvocationIndexID")
return spv::BuiltInLocalInvocationIndex;
break;
switch (node.getQualifier().builtIn) {
case glslang::EbvPosition: return spv::BuiltInPosition;
case glslang::EbvPointSize: return spv::BuiltInPointSize;
case glslang::EbvClipVertex: return spv::BuiltInClipVertex;
case glslang::EbvClipDistance: return spv::BuiltInClipDistance;
case glslang::EbvCullDistance: return spv::BuiltInCullDistance;
case glslang::EbvVertexId: return spv::BuiltInVertexId;
case glslang::EbvInstanceId: return spv::BuiltInInstanceId;
case glslang::EbvPrimitiveId: return spv::BuiltInPrimitiveId;
case glslang::EbvInvocationId: return spv::BuiltInInvocationId;
case glslang::EbvLayer: return spv::BuiltInLayer;
case glslang::EbvViewportIndex: return spv::BuiltInViewportIndex;
case glslang::EbvTessLevelInner: return spv::BuiltInTessLevelInner;
case glslang::EbvTessLevelOuter: return spv::BuiltInTessLevelOuter;
case glslang::EbvTessCoord: return spv::BuiltInTessCoord;
case glslang::EbvPatchVertices: return spv::BuiltInPatchVertices;
case glslang::EbvFragCoord: return spv::BuiltInFragCoord;
case glslang::EbvPointCoord: return spv::BuiltInPointCoord;
case glslang::EbvFace: return spv::BuiltInFrontFacing;
case glslang::EbvSampleId: return spv::BuiltInSampleId;
case glslang::EbvSamplePosition: return spv::BuiltInSamplePosition;
case glslang::EbvSampleMask: return spv::BuiltInSampleMask;
case glslang::EbvFragColor: return spv::BuiltInFragColor;
case glslang::EbvFragData: return spv::BuiltInFragColor;
case glslang::EbvFragDepth: return spv::BuiltInFragDepth;
case glslang::EbvHelperInvocation: return spv::BuiltInHelperInvocation;
case glslang::EbvNumWorkGroups: return spv::BuiltInNumWorkgroups;
case glslang::EbvWorkGroupSize: return spv::BuiltInWorkgroupSize;
case glslang::EbvWorkGroupId: return spv::BuiltInWorkgroupId;
case glslang::EbvLocalInvocationId: return spv::BuiltInLocalInvocationId;
case glslang::EbvLocalInvocationIndex: return spv::BuiltInLocalInvocationIndex;
case glslang::EbvGlobalInvocationId: return spv::BuiltInGlobalInvocationId;
default: return (spv::BuiltIn)spv::BadValue;
}
return (spv::BuiltIn)spv::BadValue;
}
//
@ -2193,7 +2169,7 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
case glslang::EOpConvUintToDouble:
convOp = spv::OpConvertUToF;
break;
case glslang::EOpConvDoubleToFloat:
case glslang::EOpConvFloatToDouble:
convOp = spv::OpFConvert;
@ -2224,7 +2200,7 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
if (convOp == spv::OpSelect) {
zero = makeSmearedConstant(zero, vectorSize);
one = makeSmearedConstant(one, vectorSize);
result = builder.createTriOp(convOp, destType, operand, one, zero);
result = builder.createTriOp(convOp, destType, operand, one, zero);
} else
result = builder.createUnaryOp(convOp, destType, operand);

View File

@ -109,7 +109,7 @@ ERROR: node is still EOpNull!
0:35 1 (const int)
0:36 move second child to first child (temp int)
0:36 'gl_PrimitiveID' (layout(stream=0 ) out int PrimitiveID)
0:36 'gl_PrimitiveIDIn' (in int)
0:36 'gl_PrimitiveIDIn' (in int PrimitiveID)
0:37 move second child to first child (temp int)
0:37 'gl_Layer' (layout(stream=0 ) out int Layer)
0:37 Constant:
@ -250,7 +250,7 @@ ERROR: node is still EOpNull!
0:35 1 (const int)
0:36 move second child to first child (temp int)
0:36 'gl_PrimitiveID' (layout(stream=0 ) out int PrimitiveID)
0:36 'gl_PrimitiveIDIn' (in int)
0:36 'gl_PrimitiveIDIn' (in int PrimitiveID)
0:37 move second child to first child (temp int)
0:37 'gl_Layer' (layout(stream=0 ) out int Layer)
0:37 Constant:

View File

@ -47,8 +47,8 @@ ERROR: node is still EOpNull!
0:10 'gl_FragColor' (fragColor 4-component vector of float FragColor)
0:10 'varyingVar' (smooth in 4-component vector of float)
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 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:11 direct index (temp 4-component vector of float FragData)
0:11 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:11 Constant:
0:11 1 (const int)
0:11 'inVar' (smooth in 4-component vector of float)
@ -120,8 +120,8 @@ ERROR: node is still EOpNull!
0:10 'gl_FragColor' (fragColor 4-component vector of float FragColor)
0:10 'varyingVar' (smooth in 4-component vector of float)
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 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:11 direct index (temp 4-component vector of float FragData)
0:11 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:11 Constant:
0:11 1 (const int)
0:11 'inVar' (smooth in 4-component vector of float)

View File

@ -9,8 +9,8 @@ Shader version: 330
0:10 'gl_FragColor' (fragColor 4-component vector of float FragColor)
0:10 'varyingVar' (smooth in 4-component vector of float)
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 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:11 direct index (temp 4-component vector of float FragData)
0:11 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:11 Constant:
0:11 1 (const int)
0:11 vector-times-matrix (temp 4-component vector of float)
@ -35,8 +35,8 @@ Shader version: 330
0:10 'gl_FragColor' (fragColor 4-component vector of float FragColor)
0:10 'varyingVar' (smooth in 4-component vector of float)
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 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:11 direct index (temp 4-component vector of float FragData)
0:11 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:11 Constant:
0:11 1 (const int)
0:11 vector-times-matrix (temp 4-component vector of float)

View File

@ -127,8 +127,8 @@ ERROR: node is still EOpNull!
0:43 Function Call: foo(f1[5]; (global 4-element array of float)
0:43 'u' (temp 5-element array of float)
0:45 move second child to first child (temp 4-component vector of float)
0:45 direct index (temp 4-component vector of float)
0:45 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:45 direct index (temp 4-component vector of float FragData)
0:45 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:45 Constant:
0:45 1000 (const int)
0:45 Constant:
@ -137,8 +137,8 @@ ERROR: node is still EOpNull!
0:45 1.000000
0:45 1.000000
0:46 move second child to first child (temp 4-component vector of float)
0:46 direct index (temp 4-component vector of float)
0:46 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:46 direct index (temp 4-component vector of float FragData)
0:46 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:46 Constant:
0:46 -1 (const int)
0:46 Constant:
@ -147,8 +147,8 @@ ERROR: node is still EOpNull!
0:46 1.000000
0:46 1.000000
0:47 move second child to first child (temp 4-component vector of float)
0:47 direct index (temp 4-component vector of float)
0:47 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:47 direct index (temp 4-component vector of float FragData)
0:47 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:47 Constant:
0:47 3 (const int)
0:47 Constant:
@ -371,8 +371,8 @@ ERROR: node is still EOpNull!
0:43 Function Call: foo(f1[5]; (global 4-element array of float)
0:43 'u' (temp 5-element array of float)
0:45 move second child to first child (temp 4-component vector of float)
0:45 direct index (temp 4-component vector of float)
0:45 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:45 direct index (temp 4-component vector of float FragData)
0:45 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:45 Constant:
0:45 1000 (const int)
0:45 Constant:
@ -381,8 +381,8 @@ ERROR: node is still EOpNull!
0:45 1.000000
0:45 1.000000
0:46 move second child to first child (temp 4-component vector of float)
0:46 direct index (temp 4-component vector of float)
0:46 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:46 direct index (temp 4-component vector of float FragData)
0:46 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:46 Constant:
0:46 -1 (const int)
0:46 Constant:
@ -391,8 +391,8 @@ ERROR: node is still EOpNull!
0:46 1.000000
0:46 1.000000
0:47 move second child to first child (temp 4-component vector of float)
0:47 direct index (temp 4-component vector of float)
0:47 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:47 direct index (temp 4-component vector of float FragData)
0:47 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:47 Constant:
0:47 3 (const int)
0:47 Constant:

View File

@ -99,8 +99,8 @@ ERROR: node is still EOpNull!
0:36 Function Call: foo(f1[5]; (global 4-element array of mediump float)
0:36 'u' (temp 5-element array of mediump float)
0:38 move second child to first child (temp mediump 4-component vector of float)
0:38 direct index (temp mediump 4-component vector of float)
0:38 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:38 direct index (temp mediump 4-component vector of float FragData)
0:38 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:38 Constant:
0:38 1000 (const int)
0:38 Constant:
@ -109,8 +109,8 @@ ERROR: node is still EOpNull!
0:38 1.000000
0:38 1.000000
0:39 move second child to first child (temp mediump 4-component vector of float)
0:39 direct index (temp mediump 4-component vector of float)
0:39 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:39 direct index (temp mediump 4-component vector of float FragData)
0:39 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:39 Constant:
0:39 -1 (const int)
0:39 Constant:
@ -119,8 +119,8 @@ ERROR: node is still EOpNull!
0:39 1.000000
0:39 1.000000
0:40 move second child to first child (temp mediump 4-component vector of float)
0:40 direct index (temp mediump 4-component vector of float)
0:40 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:40 direct index (temp mediump 4-component vector of float FragData)
0:40 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:40 Constant:
0:40 3 (const int)
0:40 Constant:
@ -236,8 +236,8 @@ ERROR: node is still EOpNull!
0:36 Function Call: foo(f1[5]; (global 4-element array of mediump float)
0:36 'u' (temp 5-element array of mediump float)
0:38 move second child to first child (temp mediump 4-component vector of float)
0:38 direct index (temp mediump 4-component vector of float)
0:38 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:38 direct index (temp mediump 4-component vector of float FragData)
0:38 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:38 Constant:
0:38 1000 (const int)
0:38 Constant:
@ -246,8 +246,8 @@ ERROR: node is still EOpNull!
0:38 1.000000
0:38 1.000000
0:39 move second child to first child (temp mediump 4-component vector of float)
0:39 direct index (temp mediump 4-component vector of float)
0:39 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:39 direct index (temp mediump 4-component vector of float FragData)
0:39 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:39 Constant:
0:39 -1 (const int)
0:39 Constant:
@ -256,8 +256,8 @@ ERROR: node is still EOpNull!
0:39 1.000000
0:39 1.000000
0:40 move second child to first child (temp mediump 4-component vector of float)
0:40 direct index (temp mediump 4-component vector of float)
0:40 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float)
0:40 direct index (temp mediump 4-component vector of float FragData)
0:40 'gl_FragData' (fragColor 32-element array of mediump 4-component vector of float FragData)
0:40 Constant:
0:40 3 (const int)
0:40 Constant:

View File

@ -7,8 +7,8 @@ Shader version: 130
0:5 Function Parameters:
0:7 Sequence
0:7 move second child to first child (temp 4-component vector of float)
0:7 direct index (temp 4-component vector of float)
0:7 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:7 direct index (temp 4-component vector of float FragData)
0:7 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:7 Constant:
0:7 1 (const int)
0:7 'Color' (smooth in 4-component vector of float)
@ -25,8 +25,8 @@ Shader version: 130
0:5 Function Parameters:
0:7 Sequence
0:7 move second child to first child (temp 4-component vector of float)
0:7 direct index (temp 4-component vector of float)
0:7 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:7 direct index (temp 4-component vector of float FragData)
0:7 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:7 Constant:
0:7 1 (const int)
0:7 'Color' (smooth in 4-component vector of float)

View File

@ -7,8 +7,8 @@ Shader version: 130
0:7 Function Parameters:
0:9 Sequence
0:9 move second child to first child (temp 4-component vector of float)
0:9 indirect index (temp 4-component vector of float)
0:9 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:9 indirect index (temp 4-component vector of float FragData)
0:9 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:9 'i' (uniform int)
0:9 'Color' (smooth in 4-component vector of float)
0:? Linker Objects
@ -25,8 +25,8 @@ Shader version: 130
0:7 Function Parameters:
0:9 Sequence
0:9 move second child to first child (temp 4-component vector of float)
0:9 indirect index (temp 4-component vector of float)
0:9 'gl_FragData' (fragColor 32-element array of 4-component vector of float)
0:9 indirect index (temp 4-component vector of float FragData)
0:9 'gl_FragData' (fragColor 32-element array of 4-component vector of float FragData)
0:9 'i' (uniform int)
0:9 'Color' (smooth in 4-component vector of float)
0:? Linker Objects

View File

@ -66,8 +66,8 @@ enum TStorageQualifier {
EvqTemporary, // For temporaries (within a function), read/write
EvqGlobal, // For globals read/write
EvqConst, // User-defined constant values, will be semantically constant and constant folded
EvqVaryingIn, // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltIn)
EvqVaryingOut, // pipeline ouput, read/write, also supercategory for all built-ins not included in this enum (see TBuiltIn)
EvqVaryingIn, // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
EvqVaryingOut, // pipeline ouput, read/write, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
EvqUniform, // read only, shared with app
EvqBuffer, // read/write, shared with app
EvqShared, // compute shader's read/write 'shared' qualifier

View File

@ -2706,6 +2706,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable);
BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
BuiltInVariable("gl_PrimitiveIDIn", EbvPrimitiveId, symbolTable);
BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable);
BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
@ -2767,8 +2768,6 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
// Compatibility variables
SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
BuiltInVariable("gl_in", "gl_Color", EbvColor, symbolTable);
@ -3037,6 +3036,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
arraySizes->setSize(resources.maxDrawBuffers);
fragData.setArraySizes(arraySizes);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
}
break;