glslang -> SPV: add decorations for built-ins that are inside blocks.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31266 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-05-22 01:53:15 +00:00
parent ea543986f9
commit 6b3fd19d89
8 changed files with 33 additions and 6 deletions

View File

@ -303,9 +303,9 @@ 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)
spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable builtIn)
{
switch (node.getQualifier().builtIn) {
switch (builtIn) {
case glslang::EbvPosition: return spv::BuiltInPosition;
case glslang::EbvPointSize: return spv::BuiltInPointSize;
case glslang::EbvClipVertex: return spv::BuiltInClipVertex;
@ -1344,6 +1344,11 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent);
if (glslangType.getQualifier().hasXfbOffset())
builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset);
// built-in variable decorations
int builtIn = TranslateBuiltInDecoration(glslangType.getQualifier().builtIn);
if (builtIn != spv::BadValue)
builder.addMemberDecoration(spvType, member, spv::DecorationBuiltIn, builtIn);
}
}
@ -2412,9 +2417,9 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
}
// built-in variable decorations
int num = TranslateBuiltInDecoration(*symbol);
if (num != spv::BadValue)
builder.addDecoration(id, spv::DecorationBuiltIn, num);
int builtIn = TranslateBuiltInDecoration(symbol->getQualifier().builtIn);
if (builtIn != spv::BadValue)
builder.addDecoration(id, spv::DecorationBuiltIn, builtIn);
if (linkageOnly)
builder.addDecoration(id, spv::DecorationNoStaticUse);

View File

@ -368,7 +368,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
disassembleIds(numOperands);
return;
case OperandVariableLiterals:
if (opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn) {
if (opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn ||
opCode == OpMemberDecorate && stream[word - 1] == DecorationBuiltIn) {
out << BuiltInString(stream[word++]);
--numOperands;
++op;

View File

@ -45,9 +45,15 @@ Linked geometry stage:
Decorate 9(fromVertex) Stream 3
Decorate 11 Stream 3
Decorate 14(fromVertex) Block
MemberDecorate 28(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 28(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 28(gl_PerVertex) 2 BuiltIn ClipDistance
Decorate 28(gl_PerVertex) Block
Decorate 28(gl_PerVertex) Stream 0
Decorate 30 Stream 0
MemberDecorate 31(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 31(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 31(gl_PerVertex) 2 BuiltIn ClipDistance
Decorate 31(gl_PerVertex) Block
Decorate 48(gl_PrimitiveID) Stream 0
Decorate 48(gl_PrimitiveID) BuiltIn PrimitiveId

View File

@ -42,6 +42,10 @@ Linked vertex stage:
Name 51 "gl_VertexID"
Name 52 "gl_InstanceID"
MemberDecorate 14(gl_PerVertex) 0 Invariant
MemberDecorate 14(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 14(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 14(gl_PerVertex) 2 BuiltIn ClipDistance
MemberDecorate 14(gl_PerVertex) 3 BuiltIn ClipVertex
Decorate 14(gl_PerVertex) Block
Decorate 49(ui) NoStaticUse
Decorate 51(gl_VertexID) BuiltIn VertexId

View File

@ -28,9 +28,13 @@ Linked geometry stage:
MemberName 17(gl_PerVertex) 0 "gl_Position"
MemberName 17(gl_PerVertex) 1 "gl_ClipDistance"
Name 21 "gl_in"
MemberDecorate 12(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 12(gl_PerVertex) 1 BuiltIn ClipDistance
Decorate 12(gl_PerVertex) Block
Decorate 12(gl_PerVertex) Stream 0
Decorate 14 Stream 0
MemberDecorate 17(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 17(gl_PerVertex) 1 BuiltIn ClipDistance
Decorate 17(gl_PerVertex) Block
2: TypeVoid
3: TypeFunction 2

View File

@ -52,6 +52,9 @@ Linked tessellation control stage:
Decorate 39(gl_PatchVerticesIn) BuiltIn PatchVertices
Decorate 42(gl_PrimitiveID) BuiltIn PrimitiveId
Decorate 45(gl_InvocationID) BuiltIn InvocationId
MemberDecorate 47(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 47(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 47(gl_PerVertex) 2 BuiltIn ClipDistance
Decorate 47(gl_PerVertex) Block
Decorate 62(gl_TessLevelOuter) Patch
Decorate 62(gl_TessLevelOuter) BuiltIn TessLevelOuter

View File

@ -62,6 +62,9 @@ Linked tessellation evaluation stage:
Decorate 54(gl_TessLevelOuter) BuiltIn TessLevelOuter
Decorate 62(gl_TessLevelInner) Patch
Decorate 62(gl_TessLevelInner) BuiltIn TessLevelInner
MemberDecorate 67(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 67(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 67(gl_PerVertex) 2 BuiltIn ClipDistance
Decorate 67(gl_PerVertex) Block
Decorate 78(patchIn) Patch
Decorate 78(patchIn) NoStaticUse

View File

@ -36,6 +36,7 @@ Linked vertex stage:
Name 58 "sampb4"
Name 60 "gl_VertexID"
Name 61 "gl_InstanceID"
MemberDecorate 11(gl_PerVertex) 0 BuiltIn ClipDistance
Decorate 11(gl_PerVertex) Block
Decorate 35(badorder3) Flat
Decorate 43(uv4) Location 4