avoid leaving decorations on auto-push-constants

uniform blocks that are upgraded to push_constants shouldn't have
set/binding etc. decorations applied to them
This commit is contained in:
Malcolm Bechard 2022-02-09 18:44:22 -05:00
parent b7ba87bcfe
commit be202ef9ba
2 changed files with 23 additions and 14 deletions

View File

@ -203,11 +203,7 @@ struct TResolverUniformAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) { inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) {
TVarEntryInfo& ent = entKey.second; TVarEntryInfo& ent = entKey.second;
ent.newLocation = -1; ent.clearNewAssignments();
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
const bool isValid = resolver.validateBinding(stage, ent); const bool isValid = resolver.validateBinding(stage, ent);
if (isValid) { if (isValid) {
resolver.resolveSet(ent.stage, ent); resolver.resolveSet(ent.stage, ent);
@ -281,11 +277,7 @@ struct TResolverInOutAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey)
{ {
TVarEntryInfo& ent = entKey.second; TVarEntryInfo& ent = entKey.second;
ent.newLocation = -1; ent.clearNewAssignments();
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
const bool isValid = resolver.validateInOut(ent.stage, ent); const bool isValid = resolver.validateInOut(ent.stage, ent);
if (isValid) { if (isValid) {
resolver.resolveInOutLocation(stage, ent); resolver.resolveInOutLocation(stage, ent);
@ -1670,6 +1662,10 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
if (size <= int(autoPushConstantMaxSize)) { if (size <= int(autoPushConstantMaxSize)) {
qualifier.setBlockStorage(EbsPushConstant); qualifier.setBlockStorage(EbsPushConstant);
qualifier.layoutPacking = autoPushConstantBlockPacking; qualifier.layoutPacking = autoPushConstantBlockPacking;
// Push constants don't have set/binding etc. decorations, remove those.
qualifier.layoutSet = TQualifier::layoutSetEnd;
at->second.clearNewAssignments();
upgraded = true; upgraded = true;
} }
} }
@ -1677,10 +1673,14 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
// If it's been upgraded to push_constant, then remove it from the uniformVector // If it's been upgraded to push_constant, then remove it from the uniformVector
// so it doesn't get a set/binding assigned to it. // so it doesn't get a set/binding assigned to it.
if (upgraded) { if (upgraded) {
while (1) {
auto at = std::find_if(uniformVector.begin(), uniformVector.end(), auto at = std::find_if(uniformVector.begin(), uniformVector.end(),
[this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; }); [this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; });
if (at != uniformVector.end()) if (at != uniformVector.end())
uniformVector.erase(at); uniformVector.erase(at);
else
break;
}
} }
} }
for (size_t stage = 0; stage < EShLangCount; stage++) { for (size_t stage = 0; stage < EShLangCount; stage++) {

View File

@ -61,6 +61,15 @@ struct TVarEntryInfo {
int newComponent; int newComponent;
int newIndex; int newIndex;
EShLanguage stage; EShLanguage stage;
void clearNewAssignments() {
newBinding = -1;
newSet = -1;
newLocation = -1;
newComponent = -1;
newIndex = -1;
}
struct TOrderById { struct TOrderById {
inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; } inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; }
}; };