Skip to content

Commit

Permalink
glslang: add support for validating overlapping vertex input location…
Browse files Browse the repository at this point in the history
…s in OpenGL GLSL.
  • Loading branch information
slime73 committed Sep 7, 2024
1 parent d1e58ab commit e6e5ec0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6583,7 +6583,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
}

bool typeCollision;
int repeated = intermediate.addUsedLocation(qualifier, type, typeCollision);
int repeated = intermediate.addUsedLocation(messages, qualifier, type, typeCollision);
if (repeated >= 0 && ! typeCollision)
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
// 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;

Expand Down Expand Up @@ -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);

// 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);

if (collision < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ class TIntermediate {
void addIoAccessed(const TString& name) { ioAccessed.insert(name); }
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 checkLocationRT(int set, int location);
int addUsedOffsets(int binding, int offset, int numOffsets);
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/glslang/glslang/Public/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ enum EShMessages : unsigned {
EShMsgEnhanced = (1 << 15), // enhanced message readability
EShMsgAbsolutePath = (1 << 16), // Output Absolute path for messages
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),
};

Expand Down

0 comments on commit e6e5ec0

Please sign in to comment.