diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-11 18:41:59 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-11 18:42:51 +0100 |
commit | 26b2defe0c50032a94af6011f43936b653e0a061 (patch) | |
tree | 478cdc2a715ad8cf54db16e30f51076e2532d03f /thirdparty/glslang/SPIRV/disassemble.cpp | |
parent | 18d6b75ba82a7e5d9889224a04fb7686b275f545 (diff) |
vulkan: Update volk, headers and glslang to 1.3.204
Diffstat (limited to 'thirdparty/glslang/SPIRV/disassemble.cpp')
-rw-r--r-- | thirdparty/glslang/SPIRV/disassemble.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/thirdparty/glslang/SPIRV/disassemble.cpp b/thirdparty/glslang/SPIRV/disassemble.cpp index 73c988c5b3..74dd605409 100644 --- a/thirdparty/glslang/SPIRV/disassemble.cpp +++ b/thirdparty/glslang/SPIRV/disassemble.cpp @@ -43,6 +43,7 @@ #include <stack> #include <sstream> #include <cstring> +#include <utility> #include "disassemble.h" #include "doc.h" @@ -100,6 +101,7 @@ protected: void outputMask(OperandClass operandClass, unsigned mask); void disassembleImmediates(int numOperands); void disassembleIds(int numOperands); + std::pair<int, std::string> decodeString(); int disassembleString(); void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands); @@ -290,31 +292,44 @@ void SpirvStream::disassembleIds(int numOperands) } } -// return the number of operands consumed by the string -int SpirvStream::disassembleString() +// decode string from words at current position (non-consuming) +std::pair<int, std::string> SpirvStream::decodeString() { - int startWord = word; - - out << " \""; - - const char* wordString; + std::string res; + int wordPos = word; + char c; bool done = false; + do { - unsigned int content = stream[word]; - wordString = (const char*)&content; + unsigned int content = stream[wordPos]; for (int charCount = 0; charCount < 4; ++charCount) { - if (*wordString == 0) { + c = content & 0xff; + content >>= 8; + if (c == '\0') { done = true; break; } - out << *(wordString++); + res += c; } - ++word; - } while (! done); + ++wordPos; + } while(! done); + + return std::make_pair(wordPos - word, res); +} + +// return the number of operands consumed by the string +int SpirvStream::disassembleString() +{ + out << " \""; + std::pair<int, std::string> decoderes = decodeString(); + + out << decoderes.second; out << "\""; - return word - startWord; + word += decoderes.first; + + return decoderes.first; } void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, int numOperands) @@ -331,7 +346,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, nextNestedControl = 0; } } else if (opCode == OpExtInstImport) { - idDescriptor[resultId] = (const char*)(&stream[word]); + idDescriptor[resultId] = decodeString().second; } else { if (resultId != 0 && idDescriptor[resultId].size() == 0) { @@ -428,7 +443,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, --numOperands; // Get names for printing "(XXX)" for readability, *after* this id if (opCode == OpName) - idDescriptor[stream[word - 1]] = (const char*)(&stream[word]); + idDescriptor[stream[word - 1]] = decodeString().second; break; case OperandVariableIds: disassembleIds(numOperands); |