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

Function ReadOpSource

layers/error_message/spirv_logging.cpp:81–110  ·  view source on GitHub ↗

Read the contents of the SPIR-V OpSource instruction and any following continuation instructions. Split the single string into a vector of strings, one for each line, for easier processing.

Source from the content-addressed store, hash-verified

79// Read the contents of the SPIR-V OpSource instruction and any following continuation instructions.
80// Split the single string into a vector of strings, one for each line, for easier processing.
81static void ReadOpSource(const std::vector<uint32_t>& instructions, const uint32_t reported_file_id,
82 std::vector<std::string>& out_source_lines) {
83 uint32_t offset = kModuleStartingOffset;
84 while (offset < instructions.size()) {
85 const uint32_t instruction = instructions[offset];
86 const uint32_t length = Length(instruction);
87 const uint32_t opcode = Opcode(instruction);
88 if (opcode == spv::OpSource && length >= 5 && instructions[offset + 3] == reported_file_id) {
89 const char* source_text = reinterpret_cast<const char*>(&instructions[offset + 4]);
90 AppendSourceText(source_text, out_source_lines);
91 offset += length; // point to next instruction after OpSource
92 break;
93 }
94 offset += length;
95 }
96
97 // Look for OpSourceContinued, it must be right after
98 while (offset < instructions.size()) {
99 const uint32_t continue_insn = instructions[offset];
100 const uint32_t length = Length(continue_insn);
101 const uint32_t opcode = Opcode(continue_insn);
102 if (opcode != spv::OpSourceContinued) {
103 break;
104 }
105
106 const char* continue_text = reinterpret_cast<const char*>(&instructions[offset + 1]);
107 AppendSourceText(continue_text, out_source_lines);
108 offset += length;
109 }
110}
111
112static void ReadDebugSource(const std::vector<uint32_t>& instructions, const uint32_t debug_source_id, uint32_t& out_file_string_id,
113 std::vector<std::string>& out_source_lines) {

Callers 1

GetShaderSourceInfoFunction · 0.85

Calls 4

LengthFunction · 0.85
OpcodeFunction · 0.85
AppendSourceTextFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected