Skip to content

Commit

Permalink
layers: Handle OpTypeBool in structs
Browse files Browse the repository at this point in the history
  • Loading branch information
sjfricke authored and ncesario-lunarg committed Aug 19, 2022
1 parent ab21f17 commit 7e916e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion layers/shader_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,8 @@ uint32_t SHADER_MODULE_STATE::GetTypeBytesSize(const spirv_inst_iter &iter) cons
// Returns the base type (float, int or unsigned int) or struct (can have multiple different base types inside)
uint32_t SHADER_MODULE_STATE::GetBaseType(const spirv_inst_iter &iter) const {
const uint32_t opcode = iter.opcode();
if (opcode == spv::OpTypeFloat || opcode == spv::OpTypeInt || opcode == spv::OpTypeStruct) {
if (opcode == spv::OpTypeFloat || opcode == spv::OpTypeInt || opcode == spv::OpTypeBool || opcode == spv::OpTypeStruct) {
// point to itself as its the base type (or a struct that needs to be traversed still)
return iter.word(1);
} else if (opcode == spv::OpTypeVector) {
const auto& component_type = get_def(iter.word(2));
Expand All @@ -1903,6 +1904,9 @@ uint32_t SHADER_MODULE_STATE::GetBaseType(const spirv_inst_iter &iter) const {
const auto& type = get_def(iter.word(3));
return GetBaseType(type);
}
// If we assert here, we are missing a valid base type that must be handled. Without this assert, a return value of 0 will
// produce a hard bug to track
assert(false);
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions layers/shader_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ static bool BaseTypesMatch(const SHADER_MODULE_STATE &a, const SHADER_MODULE_STA
} else if (a_opcode == spv::OpTypeFloat) {
// Match width
return a_base_insn.word(2) == b_base_insn.word(2);
} else if (a_opcode == spv::OpTypeBool) {
return true;
} else if (a_opcode == spv::OpTypeStruct) {
// Match on all element types
if (a_base_insn.len() != b_base_insn.len()) {
Expand Down

0 comments on commit 7e916e8

Please sign in to comment.