GLSL: Fix #741: rationalize per-block vs. per-member offset checking.

This commit is contained in:
John Kessenich 2017-02-28 14:10:00 -07:00
parent 69a2c69649
commit 5a042c0686
4 changed files with 20 additions and 15 deletions

View file

@ -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;