diff options
Diffstat (limited to 'thirdparty/glslang/SPIRV/SPVRemapper.cpp')
-rw-r--r-- | thirdparty/glslang/SPIRV/SPVRemapper.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/thirdparty/glslang/SPIRV/SPVRemapper.cpp b/thirdparty/glslang/SPIRV/SPVRemapper.cpp index fd0bb8950c..56d6d5d4a5 100644 --- a/thirdparty/glslang/SPIRV/SPVRemapper.cpp +++ b/thirdparty/glslang/SPIRV/SPVRemapper.cpp @@ -544,6 +544,9 @@ namespace spv { // Extended instructions: currently, assume everything is an ID. // TODO: add whatever data we need for exceptions to that if (opCode == spv::OpExtInst) { + + idFn(asId(word)); // Instruction set is an ID that also needs to be mapped + word += 2; // instruction set, and instruction from set numOperands -= 2; @@ -625,6 +628,9 @@ namespace spv { break; } + case spv::OperandVariableLiteralStrings: + return nextInst; + // Execution mode might have extra literal operands. Skip them. case spv::OperandExecutionMode: return nextInst; @@ -827,7 +833,15 @@ namespace spv { [&](spv::Id& id) { if (thisOpCode != spv::OpNop) { ++idCounter; - const std::uint32_t hashval = opCounter[thisOpCode] * thisOpCode * 50047 + idCounter + fnId * 117; + const std::uint32_t hashval = + // Explicitly cast operands to unsigned int to avoid integer + // promotion to signed int followed by integer overflow, + // which would result in undefined behavior. + static_cast<unsigned int>(opCounter[thisOpCode]) + * thisOpCode + * 50047 + + idCounter + + static_cast<unsigned int>(fnId) * 117; if (isOldIdUnmapped(id)) localId(id, nextUnusedId(hashval % softTypeIdLimit + firstMappedID)); |