From d3bff63caedced00e022ca046b547598f5d1c25d Mon Sep 17 00:00:00 2001 From: Malcolm Bechard Date: Wed, 15 Sep 2021 23:39:02 -0400 Subject: [PATCH] avoid growing the global uniform block with duplicates When using GL_EXT_vulkan_glsl_relaxed, check to see if a uniform already exists in the block uniform block, and if so, ensure they are the same type. Otherwise, avoid growing the block with a duplicate. --- glslang/MachineIndependent/ParseContextBase.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/glslang/MachineIndependent/ParseContextBase.cpp b/glslang/MachineIndependent/ParseContextBase.cpp index 02cca40..1da50d6 100644 --- a/glslang/MachineIndependent/ParseContextBase.cpp +++ b/glslang/MachineIndependent/ParseContextBase.cpp @@ -622,6 +622,19 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem globalUniformBlock->getWritableType().getQualifier().layoutBinding = globalUniformBinding; globalUniformBlock->getWritableType().getQualifier().layoutSet = globalUniformSet; + // Check for declarations of this default uniform that already exist due to other compilation units. + TSymbol* symbol = symbolTable.find(memberName); + if (symbol) { + if (memberType != symbol->getType()) { + TString err; + err += "\"" + memberType.getCompleteString() + "\""; + err += " versus "; + err += "\"" + symbol->getType().getCompleteString() + "\""; + error(loc, "Types must match:", memberType.getFieldName().c_str(), err.c_str()); + } + return; + } + // Add the requested member as a member to the global block. TType* type = new TType; type->shallowCopy(memberType); -- 2.7.4