Browse Source

glslang: add support for validating overlapping vertex input locations in OpenGL GLSL.

Sasha Szpakowski 11 months ago
parent
commit
e6e5ec0ab5

+ 1 - 1
src/libraries/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -6583,7 +6583,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
         }
         }
 
 
         bool typeCollision;
         bool typeCollision;
-        int repeated = intermediate.addUsedLocation(qualifier, type, typeCollision);
+        int repeated = intermediate.addUsedLocation(messages, qualifier, type, typeCollision);
         if (repeated >= 0 && ! typeCollision)
         if (repeated >= 0 && ! typeCollision)
             error(loc, "overlapping use of location", "location", "%d", repeated);
             error(loc, "overlapping use of location", "location", "%d", repeated);
         // When location aliasing, the aliases sharing the location must have the same underlying numerical type and bit width(
         // When location aliasing, the aliases sharing the location must have the same underlying numerical type and bit width(

+ 2 - 2
src/libraries/glslang/glslang/MachineIndependent/linkValidate.cpp

@@ -1644,7 +1644,7 @@ bool TIntermediate::userOutputUsed() const
 // typeCollision is set to true if there is no direct collision, but the types in the same location
 // typeCollision is set to true if there is no direct collision, but the types in the same location
 // are different.
 // are different.
 //
 //
-int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& type, bool& typeCollision)
+int TIntermediate::addUsedLocation(EShMessages messages, const TQualifier& qualifier, const TType& type, bool& typeCollision)
 {
 {
     typeCollision = false;
     typeCollision = false;
 
 
@@ -1758,7 +1758,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
     TIoRange range(locationRange, componentRange, basicTy, qualifier.hasIndex() ? qualifier.getIndex() : 0, qualifier.centroid, qualifier.smooth, qualifier.flat, qualifier.sample, qualifier.patch);
     TIoRange range(locationRange, componentRange, basicTy, qualifier.hasIndex() ? qualifier.getIndex() : 0, qualifier.centroid, qualifier.smooth, qualifier.flat, qualifier.sample, qualifier.patch);
 
 
     // check for collisions, except for vertex inputs on desktop targeting OpenGL
     // check for collisions, except for vertex inputs on desktop targeting OpenGL
-    if (! (!isEsProfile() && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0)
+    if (! (!isEsProfile() && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0 || (messages & EshMsgOverlappingLocations) != 0)
         collision = checkLocationRange(set, range, type, typeCollision);
         collision = checkLocationRange(set, range, type, typeCollision);
 
 
     if (collision < 0)
     if (collision < 0)

+ 1 - 1
src/libraries/glslang/glslang/MachineIndependent/localintermediate.h

@@ -1058,7 +1058,7 @@ public:
     void addIoAccessed(const TString& name) { ioAccessed.insert(name); }
     void addIoAccessed(const TString& name) { ioAccessed.insert(name); }
     bool inIoAccessed(const TString& name) const { return ioAccessed.find(name) != ioAccessed.end(); }
     bool inIoAccessed(const TString& name) const { return ioAccessed.find(name) != ioAccessed.end(); }
 
 
-    int addUsedLocation(const TQualifier&, const TType&, bool& typeCollision);
+    int addUsedLocation(EShMessages, const TQualifier&, const TType&, bool& typeCollision);
     int checkLocationRange(int set, const TIoRange& range, const TType&, bool& typeCollision);
     int checkLocationRange(int set, const TIoRange& range, const TType&, bool& typeCollision);
     int checkLocationRT(int set, int location);
     int checkLocationRT(int set, int location);
     int addUsedOffsets(int binding, int offset, int numOffsets);
     int addUsedOffsets(int binding, int offset, int numOffsets);

+ 2 - 1
src/libraries/glslang/glslang/Public/ShaderLang.h

@@ -272,7 +272,8 @@ enum EShMessages : unsigned {
     EShMsgEnhanced             = (1 << 15), // enhanced message readability
     EShMsgEnhanced             = (1 << 15), // enhanced message readability
     EShMsgAbsolutePath         = (1 << 16), // Output Absolute path for messages
     EShMsgAbsolutePath         = (1 << 16), // Output Absolute path for messages
     EShMsgDisplayErrorColumn   = (1 << 17), // Display error message column aswell as line
     EShMsgDisplayErrorColumn   = (1 << 17), // Display error message column aswell as line
-    EshMsgCrossStageIO         = (1 << 30), // Always validate cross-stage IO
+    EshMsgCrossStageIO         = (1 << 28), // Always validate cross-stage IO
+    EshMsgOverlappingLocations = (1 << 29), // Always validate overlapping layout locations
     LAST_ELEMENT_MARKER(EShMsgCount),
     LAST_ELEMENT_MARKER(EShMsgCount),
 };
 };