Fix #2005. Allow multiple compilation units to declare identical push_constant blocks (#2123)

* Fixes #2005

Allow multiple units in a stage to have push_constants as long
as the blocks match.
Requires #2006 to be fixed to be functional.

* tweaks to #2005 fix after some testing

* add unit tests for push constants across multiple compilation units

For #2005

* update reference output for tests that fail validation

* fix uninitialized result.validationResult
This commit is contained in:
Malcolm Bechard 2020-03-16 10:51:15 -04:00 committed by GitHub
parent 9b620aa0c1
commit 4b2483ee88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 503 additions and 1 deletions

View file

@ -138,7 +138,11 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
MERGE_MAX(spvVersion.openGl);
numErrors += unit.getNumErrors();
numPushConstants += unit.numPushConstants;
// Only one push_constant is allowed, mergeLinkerObjects() will ensure the push_constant
// is the same for all units.
if (numPushConstants > 1 || unit.numPushConstants > 1)
error(infoSink, "Only one push_constant block is allowed per stage");
numPushConstants = std::min(numPushConstants + unit.numPushConstants, 1);
if (unit.invocations != TQualifier::layoutNotSet) {
if (invocations == TQualifier::layoutNotSet)
@ -462,6 +466,9 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
// Check for consistent types/qualification/initializers etc.
mergeErrorCheck(infoSink, *symbol, *unitSymbol, false);
}
// If different symbols, verify they arn't push_constant since there can only be one per stage
else if (symbol->getQualifier().isPushConstant() && unitSymbol->getQualifier().isPushConstant())
error(infoSink, "Only one push_constant block is allowed per stage");
}
if (merge)
linkerObjects.push_back(unitLinkerObjects[unitLinkObj]);