ParseHelper: assign global XfbBuffer to a block missing it

If a block has assigned a XfbOffset it is assumed that it would
inherit the current global XfbBuffer. This commit fixes two use cases:

1) Getting the members of a Block with a XfbOffset to be assigned an
   offset, as explained on GLSL 4.60 spec, section "4.4.2 Output
   Layout Qualifiers", subsection "Transform Feedback Layout
   Qualifiers".

2) Compute properly an error on overlapping ranges if a block is
   assigned a XfbOffset and one of it members is assigned a explicit
   one. This gets working because when the members of a block get
   assigned a Offset/Buffer at fixBlockXfbOffsets, then the block is
   deassigned the Offsets, so ranges are computed only with the block
   members.

BTW, this is already done when redeclaring block builtins.

Fixes #1535
This commit is contained in:
Alejandro Piñeiro 2018-10-23 14:54:26 +02:00
parent 918caa7ee4
commit adba7dfc68
6 changed files with 208 additions and 0 deletions

View file

@ -6843,6 +6843,16 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
layoutMemberLocationArrayCheck(loc, memberWithLocation, arraySizes);
// Ensure that the block has an XfbBuffer assigned. This is needed
// because if the block has a XfbOffset assigned, then it is
// assumed that it has implicitly assigned the current global
// XfbBuffer, and because it's members need to be assigned a
// XfbOffset if they lack it.
if (currentBlockQualifier.storage == EvqVaryingOut && globalOutputDefaults.hasXfbBuffer()) {
if (!currentBlockQualifier.hasXfbBuffer() && currentBlockQualifier.hasXfbOffset())
currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer;
}
// Process the members
fixBlockLocations(loc, currentBlockQualifier, typeList, memberWithLocation, memberWithoutLocation);
fixXfbOffsets(currentBlockQualifier, typeList);