diff options
Diffstat (limited to 'source/opt/module.cpp')
-rw-r--r-- | source/opt/module.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/source/opt/module.cpp b/source/opt/module.cpp index 6585012f..f97defbd 100644 --- a/source/opt/module.cpp +++ b/source/opt/module.cpp @@ -151,16 +151,15 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const { this](const Instruction* i) { // Skip emitting line instructions between merge and branch instructions. auto opcode = i->opcode(); - if (between_merge_and_branch && - (opcode == SpvOpLine || opcode == SpvOpNoLine)) { + if (between_merge_and_branch && i->IsLineInst()) { return; } between_merge_and_branch = false; if (last_line_inst != nullptr) { - // If the current instruction is OpLine and it is the same with - // the last line instruction that is still effective (can be applied + // If the current instruction is OpLine or DebugLine and it is the same + // as the last line instruction that is still effective (can be applied // to the next instruction), we skip writing the current instruction. - if (opcode == SpvOpLine) { + if (i->IsLine()) { uint32_t operand_index = 0; if (last_line_inst->WhileEachInOperand( [&operand_index, i](const uint32_t* word) { @@ -169,11 +168,22 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const { })) { return; } - } else if (opcode != SpvOpNoLine && i->dbg_line_insts().empty()) { + } else if (!i->IsNoLine() && i->dbg_line_insts().empty()) { // If the current instruction does not have the line information, // the last line information is not effective any more. Emit OpNoLine - // to specify it. - binary->push_back((1 << 16) | static_cast<uint16_t>(SpvOpNoLine)); + // or DebugNoLine to specify it. + uint32_t shader_set_id = context() + ->get_feature_mgr() + ->GetExtInstImportId_Shader100DebugInfo(); + if (shader_set_id != 0) { + binary->push_back((5 << 16) | static_cast<uint16_t>(SpvOpExtInst)); + binary->push_back(context()->get_type_mgr()->GetVoidTypeId()); + binary->push_back(context()->TakeNextId()); + binary->push_back(shader_set_id); + binary->push_back(NonSemanticShaderDebugInfo100DebugNoLine); + } else { + binary->push_back((1 << 16) | static_cast<uint16_t>(SpvOpNoLine)); + } last_line_inst = nullptr; } } @@ -181,7 +191,7 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const { if (opcode == SpvOpLabel) { between_label_and_phi_var = true; } else if (opcode != SpvOpVariable && opcode != SpvOpPhi && - opcode != SpvOpLine && opcode != SpvOpNoLine) { + !spvtools::opt::IsOpLineInst(opcode)) { between_label_and_phi_var = false; } @@ -190,7 +200,7 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const { if (scope != last_scope) { // Can only emit nonsemantic instructions after all phi instructions // in a block so don't emit scope instructions before phi instructions - // for Vulkan.NonSemantic.DebugInfo.100. + // for NonSemantic.Shader.DebugInfo.100. if (!between_label_and_phi_var || context() ->get_feature_mgr() @@ -206,18 +216,19 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const { i->ToBinaryWithoutAttachedDebugInsts(binary); } // Update the last line instruction. - if (spvOpcodeIsBlockTerminator(opcode) || opcode == SpvOpNoLine) { + if (spvOpcodeIsBlockTerminator(opcode) || i->IsNoLine()) { last_line_inst = nullptr; } else if (opcode == SpvOpLoopMerge || opcode == SpvOpSelectionMerge) { between_merge_and_branch = true; last_line_inst = nullptr; - } else if (opcode == SpvOpLine) { + } else if (i->IsLine()) { last_line_inst = i; } }; ForEachInst(write_inst, true); - // We create new instructions for DebugScope. The bound must be updated. + // We create new instructions for DebugScope and DebugNoLine. The bound must + // be updated. binary->data()[bound_idx] = header_.bound; } |