easier to use recursion to traverse the OpTypeStruct
| 40 | |
| 41 | // easier to use recursion to traverse the OpTypeStruct |
| 42 | static void GetVariableInfo(const spirv::Module& module_state, const spirv::Instruction* insn, VariableInstInfo& info) { |
| 43 | if (!insn) { |
| 44 | return; |
| 45 | } else if (insn->Opcode() == spv::OpTypePointer || insn->Opcode() == spv::OpTypeUntypedPointerKHR) { |
| 46 | return; |
| 47 | } else if (insn->Opcode() == spv::OpTypeFloat || insn->Opcode() == spv::OpTypeInt) { |
| 48 | const uint32_t bit_width = insn->Word(2); |
| 49 | info.has_8bit |= (bit_width == 8); |
| 50 | info.has_16bit |= (bit_width == 16); |
| 51 | } else if (insn->Opcode() == spv::OpTypeStruct) { |
| 52 | for (uint32_t i = 2; i < insn->Length(); i++) { |
| 53 | const spirv::Instruction* member_insn = module_state.FindDef(insn->Word(i)); |
| 54 | if (member_insn->StorageClass() == spv::StorageClassPhysicalStorageBuffer) { |
| 55 | continue; // a uint8 pointer is not a 8-bit element |
| 56 | } |
| 57 | const uint32_t base_insn_id = module_state.GetBaseType(member_insn); |
| 58 | const spirv::Instruction* base_insn = module_state.FindDef(base_insn_id); |
| 59 | GetVariableInfo(module_state, base_insn, info); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static bool IsTileAttachmentImagePointer(const spirv::Module& module_state, uint32_t image_id) { |
| 65 | const auto* insn = module_state.FindDef(image_id); |
no test coverage detected