From be202ef9ba53ea7fc24143d718544c04e5f237f2 Mon Sep 17 00:00:00 2001 From: Malcolm Bechard Date: Wed, 9 Feb 2022 18:44:22 -0500 Subject: [PATCH] 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 --- glslang/MachineIndependent/iomapper.cpp | 28 ++++++++++++++-------------- glslang/MachineIndependent/iomapper.h | 9 +++++++++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/glslang/MachineIndependent/iomapper.cpp b/glslang/MachineIndependent/iomapper.cpp index a3c53f5..4250e92 100644 --- a/glslang/MachineIndependent/iomapper.cpp +++ b/glslang/MachineIndependent/iomapper.cpp @@ -203,11 +203,7 @@ struct TResolverUniformAdaptor { inline void operator()(std::pair& entKey) { TVarEntryInfo& ent = entKey.second; - ent.newLocation = -1; - ent.newComponent = -1; - ent.newBinding = -1; - ent.newSet = -1; - ent.newIndex = -1; + ent.clearNewAssignments(); const bool isValid = resolver.validateBinding(stage, ent); if (isValid) { resolver.resolveSet(ent.stage, ent); @@ -281,11 +277,7 @@ struct TResolverInOutAdaptor { inline void operator()(std::pair& entKey) { TVarEntryInfo& ent = entKey.second; - ent.newLocation = -1; - ent.newComponent = -1; - ent.newBinding = -1; - ent.newSet = -1; - ent.newIndex = -1; + ent.clearNewAssignments(); const bool isValid = resolver.validateInOut(ent.stage, ent); if (isValid) { resolver.resolveInOutLocation(stage, ent); @@ -1670,6 +1662,10 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) { if (size <= int(autoPushConstantMaxSize)) { qualifier.setBlockStorage(EbsPushConstant); qualifier.layoutPacking = autoPushConstantBlockPacking; + // Push constants don't have set/binding etc. decorations, remove those. + qualifier.layoutSet = TQualifier::layoutSetEnd; + at->second.clearNewAssignments(); + 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 // so it doesn't get a set/binding assigned to it. if (upgraded) { - auto at = std::find_if(uniformVector.begin(), uniformVector.end(), - [this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; }); - if (at != uniformVector.end()) - uniformVector.erase(at); + while (1) { + auto at = std::find_if(uniformVector.begin(), uniformVector.end(), + [this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; }); + if (at != uniformVector.end()) + uniformVector.erase(at); + else + break; + } } } for (size_t stage = 0; stage < EShLangCount; stage++) { diff --git a/glslang/MachineIndependent/iomapper.h b/glslang/MachineIndependent/iomapper.h index c43864e..ba7bc3b 100644 --- a/glslang/MachineIndependent/iomapper.h +++ b/glslang/MachineIndependent/iomapper.h @@ -61,6 +61,15 @@ struct TVarEntryInfo { int newComponent; int newIndex; EShLanguage stage; + + void clearNewAssignments() { + newBinding = -1; + newSet = -1; + newLocation = -1; + newComponent = -1; + newIndex = -1; + } + struct TOrderById { inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; } }; -- 2.7.4