diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-02-16 13:49:24 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-02-16 13:49:24 +0300 |
commit | 29cc18988cfecbbcfa46e9e09273fe970e15a920 (patch) | |
tree | 697d9153c54568f6b9cad93e0758b3e681eb469b | |
parent | 339e61a0e07aff8e212db431f6126dbab05192a9 (diff) |
Fix regression from adding 64-bit switch support.
Missed some cases where we did not handle the loaded type width
properly.
-rw-r--r-- | spirv_cross.cpp | 5 | ||||
-rw-r--r-- | spirv_parser.cpp | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/spirv_cross.cpp b/spirv_cross.cpp index cf60197e..fac7587d 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -1677,6 +1677,11 @@ const SmallVector<SPIRBlock::Case> &Compiler::get_case_list(const SPIRBlock &blo const auto &type = get<SPIRType>(var->basetype); width = type.width; } + else if (const auto *undef = maybe_get<SPIRUndef>(block.condition)) + { + const auto &type = get<SPIRType>(undef->basetype); + width = type.width; + } else { auto search = ir.load_type_width.find(block.condition); diff --git a/spirv_parser.cpp b/spirv_parser.cpp index 55700fdb..29782c26 100644 --- a/spirv_parser.cpp +++ b/spirv_parser.cpp @@ -291,7 +291,15 @@ void Parser::parse(const Instruction &instruction) { // The SPIR-V debug information extended instructions might come at global scope. if (current_block) + { current_block->ops.push_back(instruction); + if (length >= 2) + { + const auto *type = maybe_get<SPIRType>(ops[0]); + if (type) + ir.load_type_width.insert({ ops[1], type->width }); + } + } break; } @@ -1211,10 +1219,9 @@ void Parser::parse(const Instruction &instruction) { const auto *type = maybe_get<SPIRType>(ops[0]); if (type) - { ir.load_type_width.insert({ ops[1], type->width }); - } } + if (!current_block) SPIRV_CROSS_THROW("Currently no block to insert opcode."); |