diff options
author | Sebastián Aedo <saedo@codeweavers.com> | 2021-11-13 20:13:30 +0300 |
---|---|---|
committer | Sebastián Aedo <saedo@codeweavers.com> | 2021-11-13 20:13:30 +0300 |
commit | 5345051a8551b3fe6bc89bced15ec1a31fc4e60d (patch) | |
tree | 342ae39e97379f3c3bf9d2b6fb031e1b9c81b0fd /spirv_cross.cpp | |
parent | 75e3752273f4e032defa451880f80c2313454d09 (diff) |
Removed tracking of OpConstant and OpPhi.
We don't need to keep track of them because when the block.condition is
either a SPIRConstant or a SPIRVariable, we can get the type directly in
the get_case_list.
Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
Diffstat (limited to 'spirv_cross.cpp')
-rw-r--r-- | spirv_cross.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 85e2a755..2b047722 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -1628,13 +1628,31 @@ SPIRBlock::ContinueBlockType Compiler::continue_block_type(const SPIRBlock &bloc const SmallVector<SPIRBlock::Case> &Compiler::get_case_list(const SPIRBlock &block) const { - auto search = ir.load_type_width.find(block.condition); - if (search == ir.load_type_width.end()) + uint32_t width = 0; + + // First we check if we can get the type directly from the block.condition + // since it can be a SPIRConstant or a SPIRVariable. + if (const auto *constant = maybe_get<SPIRConstant>(block.condition)) + { + const auto &type = get<SPIRType>(constant->constant_type); + width = type.width; + } + else if (const auto *var = maybe_get<SPIRVariable>(block.condition)) { - SPIRV_CROSS_THROW("Use of undeclared variable on a switch statement."); + const auto &type = get<SPIRType>(var->basetype); + width = type.width; + } + else + { + auto search = ir.load_type_width.find(block.condition); + if (search == ir.load_type_width.end()) + { + SPIRV_CROSS_THROW("Use of undeclared variable on a switch statement."); + } + + width = search->second; } - const uint32_t width = search->second; if (width > 32) return block.cases_64bit; |