summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics_vertex_shader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/debugger/graphics_vertex_shader.cpp')
-rw-r--r--src/citra_qt/debugger/graphics_vertex_shader.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp
index 06eaf0bf0..3b072d015 100644
--- a/src/citra_qt/debugger/graphics_vertex_shader.cpp
+++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp
@@ -12,6 +12,7 @@
12 12
13#include "graphics_vertex_shader.h" 13#include "graphics_vertex_shader.h"
14 14
15using nihstro::OpCode;
15using nihstro::Instruction; 16using nihstro::Instruction;
16using nihstro::SourceRegister; 17using nihstro::SourceRegister;
17using nihstro::SwizzlePattern; 18using nihstro::SwizzlePattern;
@@ -78,7 +79,7 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
78 const SwizzlePattern& swizzle = info.swizzle_info[instr.common.operand_desc_id].pattern; 79 const SwizzlePattern& swizzle = info.swizzle_info[instr.common.operand_desc_id].pattern;
79 80
80 // longest known instruction name: "setemit " 81 // longest known instruction name: "setemit "
81 output << std::setw(8) << std::left << instr.opcode.GetInfo().name; 82 output << std::setw(8) << std::left << instr.opcode.Value().GetInfo().name;
82 83
83 // e.g. "-c92.xyzw" 84 // e.g. "-c92.xyzw"
84 static auto print_input = [](std::stringstream& output, const SourceRegister& input, 85 static auto print_input = [](std::stringstream& output, const SourceRegister& input,
@@ -109,16 +110,16 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
109 print_input_indexed(output, input, negate, swizzle_mask, address_register_name); 110 print_input_indexed(output, input, negate, swizzle_mask, address_register_name);
110 }; 111 };
111 112
112 switch (instr.opcode.GetInfo().type) { 113 switch (instr.opcode.Value().GetInfo().type) {
113 case Instruction::OpCodeType::Trivial: 114 case OpCode::Type::Trivial:
114 // Nothing to do here 115 // Nothing to do here
115 break; 116 break;
116 117
117 case Instruction::OpCodeType::Arithmetic: 118 case OpCode::Type::Arithmetic:
118 { 119 {
119 // Use custom code for special instructions 120 // Use custom code for special instructions
120 switch (instr.opcode.EffectiveOpCode()) { 121 switch (instr.opcode.Value().EffectiveOpCode()) {
121 case Instruction::OpCode::CMP: 122 case OpCode::Id::CMP:
122 { 123 {
123 // NOTE: CMP always writes both cc components, so we do not consider the dest mask here. 124 // NOTE: CMP always writes both cc components, so we do not consider the dest mask here.
124 output << std::setw(4) << std::right << "cc."; 125 output << std::setw(4) << std::right << "cc.";
@@ -142,13 +143,13 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
142 143
143 default: 144 default:
144 { 145 {
145 bool src_is_inverted = 0 != (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::SrcInversed); 146 bool src_is_inverted = 0 != (instr.opcode.Value().GetInfo().subtype & OpCode::Info::SrcInversed);
146 147
147 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::Dest) { 148 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Dest) {
148 // e.g. "r12.xy__" 149 // e.g. "r12.xy__"
149 output << std::setw(4) << std::right << instr.common.dest.GetName() + "."; 150 output << std::setw(4) << std::right << instr.common.dest.Value().GetName() + ".";
150 output << swizzle.DestMaskToString(); 151 output << swizzle.DestMaskToString();
151 } else if (instr.opcode.GetInfo().subtype == Instruction::OpCodeInfo::MOVA) { 152 } else if (instr.opcode.Value().GetInfo().subtype == OpCode::Info::MOVA) {
152 output << std::setw(4) << std::right << "a0."; 153 output << std::setw(4) << std::right << "a0.";
153 output << swizzle.DestMaskToString(); 154 output << swizzle.DestMaskToString();
154 } else { 155 } else {
@@ -156,7 +157,7 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
156 } 157 }
157 output << " "; 158 output << " ";
158 159
159 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::Src1) { 160 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Src1) {
160 SourceRegister src1 = instr.common.GetSrc1(src_is_inverted); 161 SourceRegister src1 = instr.common.GetSrc1(src_is_inverted);
161 print_input_indexed(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false), instr.common.AddressRegisterName()); 162 print_input_indexed(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false), instr.common.AddressRegisterName());
162 } else { 163 } else {
@@ -164,7 +165,7 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
164 } 165 }
165 166
166 // TODO: In some cases, the Address Register is used as an index for SRC2 instead of SRC1 167 // TODO: In some cases, the Address Register is used as an index for SRC2 instead of SRC1
167 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::Src2) { 168 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Src2) {
168 SourceRegister src2 = instr.common.GetSrc2(src_is_inverted); 169 SourceRegister src2 = instr.common.GetSrc2(src_is_inverted);
169 print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(false)); 170 print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(false));
170 } 171 }
@@ -175,17 +176,17 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
175 break; 176 break;
176 } 177 }
177 178
178 case Instruction::OpCodeType::Conditional: 179 case OpCode::Type::Conditional:
179 { 180 {
180 switch (instr.opcode.EffectiveOpCode()) { 181 switch (instr.opcode.Value().EffectiveOpCode()) {
181 case Instruction::OpCode::LOOP: 182 case OpCode::Id::LOOP:
182 output << "(unknown instruction format)"; 183 output << "(unknown instruction format)";
183 break; 184 break;
184 185
185 default: 186 default:
186 output << "if "; 187 output << "if ";
187 188
188 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::HasCondition) { 189 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasCondition) {
189 const char* ops[] = { 190 const char* ops[] = {
190 " || ", " && ", "", "" 191 " || ", " && ", "", ""
191 }; 192 };
@@ -198,22 +199,22 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
198 output << ((!instr.flow_control.refy) ? "!" : " ") << "cc.y"; 199 output << ((!instr.flow_control.refy) ? "!" : " ") << "cc.y";
199 200
200 output << " "; 201 output << " ";
201 } else if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::HasUniformIndex) { 202 } else if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasUniformIndex) {
202 output << "b" << instr.flow_control.bool_uniform_id << " "; 203 output << "b" << instr.flow_control.bool_uniform_id << " ";
203 } 204 }
204 205
205 u32 target_addr = instr.flow_control.dest_offset; 206 u32 target_addr = instr.flow_control.dest_offset;
206 u32 target_addr_else = instr.flow_control.dest_offset; 207 u32 target_addr_else = instr.flow_control.dest_offset;
207 208
208 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::HasAlternative) { 209 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasAlternative) {
209 output << "else jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " "; 210 output << "else jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " ";
210 } else if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::HasExplicitDest) { 211 } else if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasExplicitDest) {
211 output << "jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " "; 212 output << "jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " ";
212 } else { 213 } else {
213 // TODO: Handle other cases 214 // TODO: Handle other cases
214 } 215 }
215 216
216 if (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::HasFinishPoint) { 217 if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasFinishPoint) {
217 output << "(return on " << std::setw(4) << std::right << std::setfill('0') 218 output << "(return on " << std::setw(4) << std::right << std::setfill('0')
218 << 4 * instr.flow_control.dest_offset + 4 * instr.flow_control.num_instructions << ")"; 219 << 4 * instr.flow_control.dest_offset + 4 * instr.flow_control.num_instructions << ")";
219 } 220 }