MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / GetVariableInfo

Function GetVariableInfo

layers/stateless/sl_spirv.cpp:42–62  ·  view source on GitHub ↗

easier to use recursion to traverse the OpTypeStruct

Source from the content-addressed store, hash-verified

40
41// easier to use recursion to traverse the OpTypeStruct
42static 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
64static bool IsTileAttachmentImagePointer(const spirv::Module& module_state, uint32_t image_id) {
65 const auto* insn = module_state.FindDef(image_id);

Callers 1

Calls 6

OpcodeMethod · 0.80
WordMethod · 0.80
LengthMethod · 0.80
FindDefMethod · 0.80
GetBaseTypeMethod · 0.80
StorageClassMethod · 0.45

Tested by

no test coverage detected