From 7225a1cb1ecdd8dc736156f45cf3bba38cc3136c Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 13 Feb 2017 09:09:04 -0700 Subject: [PATCH] Support align/offset for all versions GLSL/ESSL targeting SPIR-V. --- Test/baseResults/spv.140.frag.out | 2 +- Test/baseResults/spv.300layout.vert.out | 2 +- Test/spv.140.frag | 2 +- Test/spv.300layout.vert | 2 +- glslang/Include/revision.h | 4 ++-- glslang/MachineIndependent/ParseHelper.cpp | 22 ++++++++++++++-------- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Test/baseResults/spv.140.frag.out b/Test/baseResults/spv.140.frag.out index d8ec8cfbf..324cc0c5c 100755 --- a/Test/baseResults/spv.140.frag.out +++ b/Test/baseResults/spv.140.frag.out @@ -54,7 +54,7 @@ spv.140.frag MemberDecorate 87(bn) 3 Offset 576 MemberDecorate 87(bn) 3 MatrixStride 16 MemberDecorate 87(bn) 4 RowMajor - MemberDecorate 87(bn) 4 Offset 640 + MemberDecorate 87(bn) 4 Offset 1024 MemberDecorate 87(bn) 4 MatrixStride 16 Decorate 87(bn) Block Decorate 89 DescriptorSet 0 diff --git a/Test/baseResults/spv.300layout.vert.out b/Test/baseResults/spv.300layout.vert.out index 20eb8e7d5..69f66b6a3 100644 --- a/Test/baseResults/spv.300layout.vert.out +++ b/Test/baseResults/spv.300layout.vert.out @@ -61,7 +61,7 @@ Warning, version 310 is not yet complete; most version-specific features are pre MemberDecorate 45(T3) 2 ColMajor MemberDecorate 45(T3) 2 Offset 128 MemberDecorate 45(T3) 2 MatrixStride 16 - MemberDecorate 45(T3) 3 Offset 160 + MemberDecorate 45(T3) 3 Offset 2048 Decorate 45(T3) Block Decorate 47 DescriptorSet 0 MemberDecorate 78(T2) 0 Offset 0 diff --git a/Test/spv.140.frag b/Test/spv.140.frag index 61ad1a6fb..ceeac47bf 100644 --- a/Test/spv.140.frag +++ b/Test/spv.140.frag @@ -14,7 +14,7 @@ layout(std140) uniform bn { layout(column_major) mat4 matca[4]; layout(row_major) mat4 matr; layout(column_major) mat4 matc; - mat4 matrdef; + layout(align=512, offset=1024) mat4 matrdef; }; uniform sampler2DRect sampR; diff --git a/Test/spv.300layout.vert b/Test/spv.300layout.vert index 81218b5d3..a32a95de7 100644 --- a/Test/spv.300layout.vert +++ b/Test/spv.300layout.vert @@ -25,7 +25,7 @@ layout(column_major) uniform T3 { // shared and column_major mat4 M3; // column_major layout(row_major) mat4 M4; // row major mat2x3 N2; // column_major - uvec3 uv3a[4]; + layout(align=16, offset=2048) uvec3 uv3a[4]; }; in uint uiuin; diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 18a062550..dd060abc1 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // 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 "Overload400-PrecQual.1825" -#define GLSLANG_DATE "10-Feb-2017" +#define GLSLANG_REVISION "Overload400-PrecQual.1828" +#define GLSLANG_DATE "13-Feb-2017" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index c659604c7..daa8acc14 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4008,16 +4008,20 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi // - uniform offsets // - atomic_uint offsets const char* feature = "offset"; - requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature); - const char* exts[2] = { E_GL_ARB_enhanced_layouts, E_GL_ARB_shader_atomic_counters }; - profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 2, exts, feature); - profileRequires(loc, EEsProfile, 310, nullptr, feature); + if (spvVersion.spv == 0) { + requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature); + const char* exts[2] = { E_GL_ARB_enhanced_layouts, E_GL_ARB_shader_atomic_counters }; + profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 2, exts, feature); + profileRequires(loc, EEsProfile, 310, nullptr, feature); + } publicType.qualifier.layoutOffset = value; return; } else if (id == "align") { const char* feature = "uniform buffer-member align"; - requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature); - profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, E_GL_ARB_enhanced_layouts, feature); + if (spvVersion.spv == 0) { + requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature); + profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, E_GL_ARB_enhanced_layouts, feature); + } // "The specified alignment must be a power of 2, or a compile-time error results." if (! IsPow2(value)) error(loc, "must be a power of 2", "align", ""); @@ -5546,8 +5550,10 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con if (memberType.isArray()) arrayUnsizedCheck(memberLoc, currentBlockQualifier, &memberType.getArraySizes(), false, member == typeList.size() - 1); if (memberQualifier.hasOffset()) { - requireProfile(memberLoc, ~EEsProfile, "offset on block member"); - profileRequires(memberLoc, ~EEsProfile, 440, E_GL_ARB_enhanced_layouts, "offset on block member"); + if (spvVersion.spv == 0) { + requireProfile(memberLoc, ~EEsProfile, "offset on block member"); + profileRequires(memberLoc, ~EEsProfile, 440, E_GL_ARB_enhanced_layouts, "offset on block member"); + } } if (memberType.containsOpaque())