From 74d448cc1575f74260b6d198f3a858c7e7c16a69 Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Thu, 18 Jul 2024 18:16:20 -0400 Subject: [PATCH] Add some comments and rename a helper function This adds some documentation of the checkTypes() function to make clearer what exactly it is checking. --- glslang/MachineIndependent/linkValidate.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index d56c833c..81857b24 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -1736,7 +1736,10 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ return collision; } -static bool checkType(TBasicType t1, TBasicType t2) { + +// Check that two types can be stored in different components in the same location. +// They must be the same type, except signed/unsigned integers are considered compatible. +static bool checkCompatibleTypes(TBasicType t1, TBasicType t2) { if (t1 != t2) { if ((t1 == EbtInt8 && t2 == EbtUint8) || (t2 == EbtInt8 && t1 == EbtUint8) || @@ -1751,6 +1754,7 @@ static bool checkType(TBasicType t1, TBasicType t2) { } return t1 == t2; } + // Compare a new (the passed in) 'range' against the existing set, and see // if there are any collisions. // @@ -1763,7 +1767,7 @@ int TIntermediate::checkLocationRange(int set, const TIoRange& range, const TTyp // there is a collision; pick one return std::max(range.location.start, usedIo[set][r].location.start); } else if (range.location.overlap(usedIo[set][r].location) && - (!checkType(type.getBasicType(), usedIo[set][r].basicType) || + (!checkCompatibleTypes(type.getBasicType(), usedIo[set][r].basicType) || type.getQualifier().centroid != usedIo[set][r].centroid || type.getQualifier().smooth != usedIo[set][r].smooth || type.getQualifier().flat != usedIo[set][r].flat ||