spv::Id createSpvVariable(const glslang::TIntermSymbol*);
spv::Id getSampledType(const glslang::TSampler&);
spv::Id convertGlslangToSpvType(const glslang::TType& type);
+ spv::Id convertGlslangToSpvType(const glslang::TType& type, bool explicitLayout);
+ bool requiresExplicitLayout(const glslang::TType& type) const;
int getArrayStride(const glslang::TType& arrayType);
int getMatrixStride(const glslang::TType& matrixType);
void updateMemberOffset(const glslang::TType& structType, const glslang::TType& memberType, int& currentOffset, int& nextOffset);
}
}
-// Do full recursive conversion of an arbitrary glslang type to a SPIR-V Id.
+// Convert from a glslang type to an SPV type, by calling into
+// recursive version of this function.
spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type)
{
+ return convertGlslangToSpvType(type, requiresExplicitLayout(type));
+}
+
+// Do full recursive conversion of an arbitrary glslang type to a SPIR-V Id.
+// explicitLayout can be kept the same throughout the heirarchical recursive walk.
+spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type, bool explicitLayout)
+{
spv::Id spvType = 0;
switch (type.getBasicType()) {
} else {
if (type.getBasicType() == glslang::EbtBlock)
memberRemapper[glslangStruct][i] = i - memberDelta;
- structFields.push_back(convertGlslangToSpvType(glslangType));
+ structFields.push_back(convertGlslangToSpvType(glslangType, explicitLayout));
}
}
builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent);
if (glslangType.getQualifier().hasXfbOffset())
builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset);
- else {
+ else if (explicitLayout) {
// figure out what to do with offset, which is accumulating
int nextOffset;
updateMemberOffset(type, glslangType, offset, nextOffset);
offset = nextOffset;
}
- if (glslangType.isMatrix()) {
+ if (glslangType.isMatrix() && explicitLayout) {
builder.addMemberDecoration(spvType, member, spv::DecorationMatrixStride, getMatrixStride(glslangType));
}
} else
arraySize = type.getOuterArraySize();
spvType = builder.makeArrayType(spvType, arraySize);
- builder.addDecoration(spvType, spv::DecorationArrayStride, getArrayStride(type));
+
+ if (explicitLayout)
+ builder.addDecoration(spvType, spv::DecorationArrayStride, getArrayStride(type));
}
return spvType;
}
+bool TGlslangToSpvTraverser::requiresExplicitLayout(const glslang::TType& type) const
+{
+ return type.getBasicType() == glslang::EbtBlock &&
+ type.getQualifier().layoutPacking != glslang::ElpShared &&
+ type.getQualifier().layoutPacking != glslang::ElpPacked &&
+ (type.getQualifier().storage == glslang::EvqUniform ||
+ type.getQualifier().storage == glslang::EvqBuffer);
+}
+
// Given an array type, returns the integer stride required for that array
int TGlslangToSpvTraverser::getArrayStride(const glslang::TType& arrayType)
{
MemberName 90(bn) 4 "matrdef"\r
Name 92 ""\r
Decorate 17(gl_FrontFacing) BuiltIn FrontFacing\r
- Decorate 32 ArrayStride 4\r
Decorate 34(gl_ClipDistance) Smooth\r
Decorate 34(gl_ClipDistance) BuiltIn ClipDistance\r
Decorate 43(k) Smooth\r
- Decorate 84 ArrayStride 4\r
Decorate 86(samp2Da) NoStaticUse\r
Decorate 89 ArrayStride 64\r
Decorate 89 ArrayStride 64\r
Decorate 9(fromVertex) Stream 3\r
Decorate 11 Stream 3\r
Decorate 14(fromVertex) Block\r
- Decorate 17 ArrayStride 16\r
- Decorate 27 ArrayStride 4\r
MemberDecorate 28(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 28(gl_PerVertex) 1 BuiltIn PointSize\r
MemberDecorate 28(gl_PerVertex) 2 BuiltIn ClipDistance\r
Decorate 28(gl_PerVertex) Block\r
Decorate 28(gl_PerVertex) Stream 0\r
Decorate 30 Stream 0\r
- Decorate 27 ArrayStride 4\r
MemberDecorate 31(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 31(gl_PerVertex) 1 BuiltIn PointSize\r
MemberDecorate 31(gl_PerVertex) 2 BuiltIn ClipDistance\r
Decorate 31(gl_PerVertex) Block\r
- Decorate 32 ArrayStride 16\r
Decorate 48(gl_PrimitiveID) Stream 0\r
Decorate 48(gl_PrimitiveID) BuiltIn PrimitiveId\r
Decorate 50(gl_PrimitiveIDIn) BuiltIn PrimitiveId\r
Name 49 "ui"\r
Name 51 "gl_VertexID"\r
Name 52 "gl_InstanceID"\r
- Decorate 11 ArrayStride 4\r
- Decorate 13 ArrayStride 16\r
MemberDecorate 14(gl_PerVertex) 0 Invariant\r
MemberDecorate 14(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 14(gl_PerVertex) 1 BuiltIn PointSize\r
MemberDecorate 14(gl_PerVertex) 2 BuiltIn ClipDistance\r
Decorate 14(gl_PerVertex) Block\r
- Decorate 11 ArrayStride 4\r
- Decorate 35 ArrayStride 16\r
- Decorate 37 ArrayStride 64\r
- Decorate 37 ArrayStride 64\r
- Decorate 35 ArrayStride 16\r
Decorate 49(ui) NoStaticUse\r
Decorate 51(gl_VertexID) BuiltIn VertexId\r
Decorate 51(gl_VertexID) NoStaticUse\r
Decorate 12(color) Smooth\r
MemberDecorate 14(S) 0 RelaxedPrecision\r
MemberDecorate 14(S) 1 RelaxedPrecision\r
- Decorate 25 ArrayStride 16\r
Decorate 27(p) RelaxedPrecision\r
Decorate 27(p) Location 3\r
Decorate 30(pos) RelaxedPrecision\r
MemberDecorate 18(Transform) 2 MatrixStride 16\r
MemberDecorate 18(Transform) 3 Offset 176\r
Decorate 18(Transform) Block\r
- Decorate 33 ArrayStride 12\r
MemberDecorate 34(T3) 0 ColMajor\r
- MemberDecorate 34(T3) 0 MatrixStride 16\r
MemberDecorate 34(T3) 1 RowMajor\r
- MemberDecorate 34(T3) 1 MatrixStride 16\r
MemberDecorate 34(T3) 2 ColMajor\r
- MemberDecorate 34(T3) 2 MatrixStride 16\r
Decorate 34(T3) GLSLShared\r
Decorate 34(T3) Block\r
MemberDecorate 44(T2) 1 RowMajor\r
- MemberDecorate 44(T2) 1 MatrixStride 16\r
Decorate 44(T2) GLSLShared\r
Decorate 44(T2) Block\r
Decorate 52(color) Smooth\r
Decorate 54(c) Location 7\r
Decorate 62(iout) Flat\r
Decorate 74(aiv2) Location 9\r
- Decorate 33 ArrayStride 12\r
Decorate 110(gl_VertexID) BuiltIn VertexId\r
Decorate 110(gl_VertexID) NoStaticUse\r
Decorate 111(gl_InstanceID) BuiltIn InstanceId\r
MemberName 17(gl_PerVertex) 0 "gl_Position"\r
MemberName 17(gl_PerVertex) 1 "gl_ClipDistance"\r
Name 21 "gl_in"\r
- Decorate 11 ArrayStride 4\r
MemberDecorate 12(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 12(gl_PerVertex) 1 BuiltIn ClipDistance\r
Decorate 12(gl_PerVertex) Block\r
Decorate 12(gl_PerVertex) Stream 0\r
Decorate 14 Stream 0\r
- Decorate 11 ArrayStride 4\r
MemberDecorate 17(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 17(gl_PerVertex) 1 BuiltIn ClipDistance\r
Decorate 17(gl_PerVertex) Block\r
- Decorate 19 ArrayStride 16\r
- Decorate 11 ArrayStride 4\r
- Decorate 11 ArrayStride 4\r
2: TypeVoid\r
3: TypeFunction 2\r
7: TypeFloat 32\r
Name 86 "ivlb"\r
Name 89 "ovla"\r
Name 90 "ovlb"\r
- Decorate 19 ArrayStride 4\r
Decorate 20(gl_PerVertex) Block\r
- Decorate 22 ArrayStride 16\r
- Decorate 19 ArrayStride 4\r
Decorate 41(gl_PatchVerticesIn) BuiltIn PatchVertices\r
Decorate 44(gl_PrimitiveID) BuiltIn PrimitiveId\r
Decorate 47(gl_InvocationID) BuiltIn InvocationId\r
- Decorate 19 ArrayStride 4\r
MemberDecorate 49(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 49(gl_PerVertex) 1 BuiltIn PointSize\r
MemberDecorate 49(gl_PerVertex) 2 BuiltIn ClipDistance\r
Decorate 49(gl_PerVertex) Block\r
- Decorate 51 ArrayStride 16\r
- Decorate 19 ArrayStride 4\r
- Decorate 62 ArrayStride 4\r
Decorate 64(gl_TessLevelOuter) Patch\r
Decorate 64(gl_TessLevelOuter) BuiltIn TessLevelOuter\r
- Decorate 69 ArrayStride 4\r
Decorate 71(gl_TessLevelInner) Patch\r
Decorate 71(gl_TessLevelInner) BuiltIn TessLevelInner\r
- Decorate 74 ArrayStride 4\r
Decorate 76(outa) NoStaticUse\r
Decorate 77(patchOut) Patch\r
Decorate 77(patchOut) NoStaticUse\r
- Decorate 79 ArrayStride 8\r
Decorate 81(inb) NoStaticUse\r
- Decorate 79 ArrayStride 8\r
Decorate 82(ind) NoStaticUse\r
- Decorate 83 ArrayStride 16\r
Decorate 85(ivla) Location 3\r
Decorate 85(ivla) NoStaticUse\r
- Decorate 83 ArrayStride 16\r
Decorate 86(ivlb) Location 4\r
Decorate 86(ivlb) NoStaticUse\r
- Decorate 87 ArrayStride 16\r
Decorate 89(ovla) Location 3\r
Decorate 89(ovla) NoStaticUse\r
- Decorate 87 ArrayStride 16\r
Decorate 90(ovlb) Location 4\r
Decorate 90(ovlb) NoStaticUse\r
2: TypeVoid\r
Name 94 "ivla"\r
Name 95 "ivlb"\r
Name 98 "ovla"\r
- Decorate 17 ArrayStride 4\r
Decorate 18(gl_PerVertex) Block\r
- Decorate 20 ArrayStride 16\r
- Decorate 17 ArrayStride 4\r
Decorate 39(gl_PatchVerticesIn) BuiltIn PatchVertices\r
Decorate 42(gl_PrimitiveID) BuiltIn PrimitiveId\r
Decorate 48(gl_TessCoord) BuiltIn TessCoord\r
- Decorate 52 ArrayStride 4\r
Decorate 54(gl_TessLevelOuter) Patch\r
Decorate 54(gl_TessLevelOuter) BuiltIn TessLevelOuter\r
- Decorate 60 ArrayStride 4\r
Decorate 62(gl_TessLevelInner) Patch\r
Decorate 62(gl_TessLevelInner) BuiltIn TessLevelInner\r
- Decorate 66 ArrayStride 4\r
MemberDecorate 67(gl_PerVertex) 0 BuiltIn Position\r
MemberDecorate 67(gl_PerVertex) 1 BuiltIn PointSize\r
MemberDecorate 67(gl_PerVertex) 2 BuiltIn ClipDistance\r
Decorate 67(gl_PerVertex) Block\r
- Decorate 66 ArrayStride 4\r
Decorate 78(patchIn) Patch\r
Decorate 78(patchIn) NoStaticUse\r
- Decorate 80 ArrayStride 8\r
Decorate 82(inb) NoStaticUse\r
- Decorate 80 ArrayStride 8\r
Decorate 83(ind) NoStaticUse\r
Decorate 84(testblb) Block\r
- Decorate 85 ArrayStride 16\r
Decorate 87(blb) NoStaticUse\r
Decorate 88(testbld) Block\r
- Decorate 89 ArrayStride 16\r
Decorate 91(bld) NoStaticUse\r
- Decorate 92 ArrayStride 16\r
Decorate 94(ivla) Location 23\r
Decorate 94(ivla) NoStaticUse\r
- Decorate 92 ArrayStride 16\r
Decorate 95(ivlb) Location 24\r
Decorate 95(ivlb) NoStaticUse\r
- Decorate 96 ArrayStride 16\r
Decorate 98(ovla) Location 23\r
Decorate 98(ovla) NoStaticUse\r
2: TypeVoid\r
Name 59 "sampb4"\r
Name 61 "gl_VertexID"\r
Name 62 "gl_InstanceID"\r
- Decorate 10 ArrayStride 4\r
MemberDecorate 11(gl_PerVertex) 0 BuiltIn ClipDistance\r
Decorate 11(gl_PerVertex) Block\r
- Decorate 10 ArrayStride 4\r
- Decorate 22 ArrayStride 16\r
Decorate 35(badorder3) Flat\r
- Decorate 10 ArrayStride 4\r
Decorate 43(uv4) Location 4\r
Decorate 43(uv4) NoStaticUse\r
Decorate 29 NoStaticUse\r
Decorate 51 NoStaticUse\r
Decorate 55(sampb1) Binding 4\r
Decorate 55(sampb1) NoStaticUse\r
- Decorate 56 ArrayStride 4\r
Decorate 58(sampb2) Binding 5\r
Decorate 58(sampb2) NoStaticUse\r
Decorate 59(sampb4) Binding 31\r
Name 73 "arrY"\r
Name 74 "arrZ"\r
Decorate 22(counter) Binding 0\r
- Decorate 28 ArrayStride 4\r
Decorate 30(countArr) Binding 0\r
- Decorate 70 ArrayStride 4\r
Decorate 72(arrX) NoStaticUse\r
- Decorate 70 ArrayStride 4\r
Decorate 73(arrY) NoStaticUse\r
- Decorate 70 ArrayStride 4\r
Decorate 74(arrZ) NoStaticUse\r
2: TypeVoid\r
3: TypeFunction 2\r
Name 4 "main"\r
Name 13 "gl_FragData"\r
Name 17 "Color"\r
- Decorate 11 ArrayStride 16\r
Decorate 13(gl_FragData) BuiltIn FragColor\r
Decorate 17(Color) Smooth\r
2: TypeVoid\r
Name 13 "gl_FragData"\r
Name 16 "i"\r
Name 19 "Color"\r
- Decorate 11 ArrayStride 16\r
Decorate 13(gl_FragData) BuiltIn FragColor\r
Decorate 19(Color) Smooth\r
2: TypeVoid\r
Name 27 "color"\r
Name 33 "gl_Position"\r
Name 38 "gl_VertexID"\r
- Decorate 22 ArrayStride 16\r
Decorate 24(colorOut) Smooth\r
Decorate 33(gl_Position) BuiltIn Position\r
Decorate 38(gl_VertexID) BuiltIn VertexId\r
Name 15 "v"\r
Name 27 "gl_FragColor"\r
Name 33 "u"\r
- Decorate 13 ArrayStride 8\r
Decorate 15(v) Smooth\r
Decorate 27(gl_FragColor) BuiltIn FragColor\r
- Decorate 31 ArrayStride 16\r
Decorate 33(u) NoStaticUse\r
2: TypeVoid\r
3: TypeFunction 2\r
Name 131 "foo"\r
Name 132 "foo2"\r
Name 134 "uFloatArray"\r
- Decorate 35 ArrayStride 4\r
Decorate 41(coord) Smooth\r
- Decorate 46 ArrayStride 4\r
- Decorate 35 ArrayStride 4\r
- Decorate 35 ArrayStride 4\r
Decorate 95(color) Smooth\r
Decorate 105(gl_FragColor) BuiltIn FragColor\r
Decorate 131(foo) NoStaticUse\r
Decorate 132(foo2) NoStaticUse\r
- Decorate 35 ArrayStride 4\r
Decorate 134(uFloatArray) NoStaticUse\r
2: TypeVoid\r
3: TypeFunction 2\r
Name 67 "z"\r
Name 74 "v"\r
Name 93 "gl_FragColor"\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
- Decorate 14 ArrayStride 4\r
Decorate 93(gl_FragColor) BuiltIn FragColor\r
2: TypeVoid\r
3: TypeFunction 2\r
Name 43 "gl_InstanceID"\r
Decorate 10(glPos) Smooth\r
Decorate 20(f) Smooth\r
- Decorate 33 ArrayStride 64\r
Decorate 42(gl_VertexID) BuiltIn VertexId\r
Decorate 42(gl_VertexID) NoStaticUse\r
Decorate 43(gl_InstanceID) BuiltIn InstanceId\r
Name 97 "gl_FragColor"\r
Name 114 "sampler"\r
Name 120 "foo2"\r
- Decorate 14 ArrayStride 36\r
- Decorate 14 ArrayStride 36\r
- Decorate 39 ArrayStride 4\r
- Decorate 39 ArrayStride 4\r
- Decorate 45 ArrayStride 20\r
Decorate 62(coord) Smooth\r
- Decorate 39 ArrayStride 4\r
Decorate 97(gl_FragColor) BuiltIn FragColor\r
Decorate 120(foo2) NoStaticUse\r
2: TypeVoid\r
Name 52 "sampler"\r
Name 56 "coord"\r
Name 61 "foo"\r
- Decorate 14 ArrayStride 4\r
- Decorate 16 ArrayStride 4\r
- Decorate 18 ArrayStride 16\r
- Decorate 21 ArrayStride 160\r
- Decorate 23 ArrayStride 1216\r
- Decorate 14 ArrayStride 4\r
- Decorate 21 ArrayStride 160\r
- Decorate 18 ArrayStride 16\r
- Decorate 21 ArrayStride 160\r
- Decorate 16 ArrayStride 4\r
Decorate 47(gl_FragColor) BuiltIn FragColor\r
Decorate 56(coord) Smooth\r
Decorate 61(foo) NoStaticUse\r
Name 36 "alpha"\r
Name 47 "gl_FragColor"\r
Name 52 "texSampler2D"\r
- Decorate 13 ArrayStride 16\r
- Decorate 34 ArrayStride 4\r
Decorate 47(gl_FragColor) BuiltIn FragColor\r
Decorate 52(texSampler2D) NoStaticUse\r
2: TypeVoid\r
Name 60 "sampler"\r
Name 64 "coord"\r
Name 70 "constructed"\r
- Decorate 18 ArrayStride 24\r
- Decorate 18 ArrayStride 24\r
- Decorate 33 ArrayStride 24\r
- Decorate 18 ArrayStride 24\r
- Decorate 18 ArrayStride 24\r
Decorate 55(gl_FragColor) BuiltIn FragColor\r
Decorate 64(coord) Smooth\r
- Decorate 68 ArrayStride 8\r
- Decorate 68 ArrayStride 8\r
2: TypeVoid\r
3: TypeFunction 2\r
7: TypeInt 32 1\r
Name 40 "alpha"\r
Name 45 "gl_FragColor"\r
Name 49 "foo"\r
- Decorate 18 ArrayStride 16\r
Decorate 20(gl_TexCoord) Smooth\r
Decorate 35(color) Smooth\r
Decorate 40(alpha) Smooth\r
Decorate 45(gl_FragColor) BuiltIn FragColor\r
- Decorate 47 ArrayStride 16\r
Decorate 49(foo) Smooth\r
2: TypeVoid\r
3: TypeFunction 2\r
Name 46 "color"\r
Name 51 "alpha"\r
Name 56 "gl_FragColor"\r
- Decorate 18 ArrayStride 16\r
Decorate 20(userIn) Smooth\r
- Decorate 29 ArrayStride 16\r
Decorate 31(gl_TexCoord) Smooth\r
Decorate 46(color) Smooth\r
Decorate 51(alpha) Smooth\r
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
-#define GLSLANG_REVISION "3.0.745"
+#define GLSLANG_REVISION "3.0.746"
#define GLSLANG_DATE "09-Sep-2015"