From 5a042c068626f1ffcc5612a4f6058a59d9bf69ca Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 28 Feb 2017 14:10:00 -0700 Subject: [PATCH] GLSL: Fix #741: rationalize per-block vs. per-member offset checking. --- Test/baseResults/420.vert.out | 3 ++- Test/baseResults/430.vert.out | 7 ++++--- Test/baseResults/440.frag.out | 13 +++++++------ glslang/MachineIndependent/ParseHelper.cpp | 12 +++++++----- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Test/baseResults/420.vert.out b/Test/baseResults/420.vert.out index cc6b13fe..9de843fa 100644 --- a/Test/baseResults/420.vert.out +++ b/Test/baseResults/420.vert.out @@ -47,12 +47,13 @@ ERROR: 0:142: 'r8_snorm' : does not apply to signed integer images ERROR: 0:143: 'rgba32ui' : does not apply to signed integer images ERROR: 0:144: 'r8ui' : does not apply to signed integer images ERROR: 0:147: 'offset on block member' : not supported for this version or the enabled extensions +ERROR: 0:147: 'offset/align' : can only be used with std140 or std430 layout packing ERROR: 0:157: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:157: 'assign' : cannot convert from 'const float' to 'temp int' ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:158: 'assign' : cannot convert from 'const float' to 'temp int' WARNING: 0:161: '[]' : assuming array size of one for compile-time checking of binding numbers for implicitly-sized array -ERROR: 50 compilation errors. No code generated. +ERROR: 51 compilation errors. No code generated. Shader version: 420 diff --git a/Test/baseResults/430.vert.out b/Test/baseResults/430.vert.out index 8cd1156b..358d6c80 100644 --- a/Test/baseResults/430.vert.out +++ b/Test/baseResults/430.vert.out @@ -28,8 +28,9 @@ ERROR: 0:64: 'uniform buffer-member align' : not supported for this version or t ERROR: 0:65: 'uniform buffer-member align' : not supported for this version or the enabled extensions ERROR: 0:65: 'offset on block member' : not supported for this version or the enabled extensions ERROR: 0:66: 'offset on block member' : not supported for this version or the enabled extensions -ERROR: 0:64: 'offset/align' : can only be used with std140 or std430 layout packing -ERROR: 0:65: 'align' : can only be used with std140 or std430 layout packing +ERROR: 0:64: 'align' : can only be used with std140 or std430 layout packing +ERROR: 0:65: 'offset/align' : can only be used with std140 or std430 layout packing +ERROR: 0:66: 'offset/align' : can only be used with std140 or std430 layout packing ERROR: 0:71: 'offset on block member' : not supported for this version or the enabled extensions ERROR: 0:74: 'gl_MaxTransformFeedbackBuffers' : required extension not requested: GL_ARB_enhanced_layouts ERROR: 0:75: 'gl_MaxTransformFeedbackInterleavedComponents' : required extension not requested: GL_ARB_enhanced_layouts @@ -63,7 +64,7 @@ ERROR: 0:221: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:221: 'assign' : cannot convert from 'const float' to 'temp int' ERROR: 0:222: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:222: 'assign' : cannot convert from 'const float' to 'temp int' -ERROR: 63 compilation errors. No code generated. +ERROR: 64 compilation errors. No code generated. Shader version: 430 diff --git a/Test/baseResults/440.frag.out b/Test/baseResults/440.frag.out index bdc1b095..56001724 100644 --- a/Test/baseResults/440.frag.out +++ b/Test/baseResults/440.frag.out @@ -22,11 +22,11 @@ ERROR: 0:38: 'offset' : only applies to block members, not blocks ERROR: 0:39: 'output block' : not supported in this stage: fragment ERROR: 0:39: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:39: 'offset' : only applies to block members, not blocks -ERROR: 0:42: 'offset/align' : can only be used with std140 or std430 layout packing -ERROR: 0:43: 'offset/align' : can only be used with std140 or std430 layout packing +ERROR: 0:42: 'align' : can only be used with std140 or std430 layout packing +ERROR: 0:43: 'align' : can only be used with std140 or std430 layout packing ERROR: 0:43: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:44: 'output block' : not supported in this stage: fragment -ERROR: 0:44: 'offset/align' : can only be used with std140 or std430 layout packing +ERROR: 0:44: 'align' : can only be used with std140 or std430 layout packing ERROR: 0:44: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:46: 'offset' : cannot specify on a variable declaration ERROR: 0:47: 'layout' : offset/align can only be used on a uniform or buffer @@ -37,8 +37,9 @@ ERROR: 0:52: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:54: 'layout' : matrix or packing qualifiers can only be used on a uniform or buffer ERROR: 0:55: 'layout' : cannot specify packing on a variable declaration ERROR: 0:57: 'align' : must be a power of 2 -ERROR: 0:58: 'align' : can only be used with std140 or std430 layout packing -ERROR: 0:63: 'align' : can only be used with std140 or std430 layout packing +ERROR: 0:58: 'offset/align' : can only be used with std140 or std430 layout packing +ERROR: 0:62: 'offset/align' : can only be used with std140 or std430 layout packing +ERROR: 0:63: 'offset/align' : can only be used with std140 or std430 layout packing ERROR: 0:62: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:63: 'layout' : offset/align can only be used on a uniform or buffer ERROR: 0:84: 'align' : must be a power of 2 @@ -48,7 +49,7 @@ ERROR: 0:103: 'align' : must be a power of 2 ERROR: 0:105: 'align' : must be a power of 2 ERROR: 0:102: 'offset' : cannot lie in previous members ERROR: 0:104: 'offset' : must be a multiple of the member's alignment -ERROR: 48 compilation errors. No code generated. +ERROR: 49 compilation errors. No code generated. Shader version: 440 diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index db77b41d..acb4d738 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -5597,11 +5597,10 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con mergeObjectLayoutQualifiers(defaultQualification, currentBlockQualifier, true); - // "The offset qualifier can only be used on block members of blocks declared with std140 or std430 layouts." // "The align qualifier can only be used on blocks or block members, and only for blocks declared with std140 or std430 layouts." - if (currentBlockQualifier.hasAlign() || currentBlockQualifier.hasAlign()) { + if (currentBlockQualifier.hasAlign()) { if (defaultQualification.layoutPacking != ElpStd140 && defaultQualification.layoutPacking != ElpStd430) { - error(loc, "can only be used with std140 or std430 layout packing", "offset/align", ""); + error(loc, "can only be used with std140 or std430 layout packing", "align", ""); defaultQualification.layoutAlign = -1; } } @@ -5643,9 +5642,12 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con } } else memberWithoutLocation = true; - if (memberQualifier.hasAlign()) { + + // "The offset qualifier can only be used on block members of blocks declared with std140 or std430 layouts." + // "The align qualifier can only be used on blocks or block members, and only for blocks declared with std140 or std430 layouts." + if (memberQualifier.hasAlign() || memberQualifier.hasOffset()) { if (defaultQualification.layoutPacking != ElpStd140 && defaultQualification.layoutPacking != ElpStd430) - error(memberLoc, "can only be used with std140 or std430 layout packing", "align", ""); + error(memberLoc, "can only be used with std140 or std430 layout packing", "offset/align", ""); } TQualifier newMemberQualification = defaultQualification;