summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 1bb8174e4..8912d4c5e 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -241,12 +241,13 @@ private:
241 * @param value the code representing the value to assign. 241 * @param value the code representing the value to assign.
242 */ 242 */
243 void SetDest(u64 elem, const std::string& reg, const std::string& value, 243 void SetDest(u64 elem, const std::string& reg, const std::string& value,
244 u64 dest_num_components, u64 value_num_components) { 244 u64 dest_num_components, u64 value_num_components, bool is_abs = false) {
245 std::string swizzle = "."; 245 std::string swizzle = ".";
246 swizzle += "xyzw"[elem]; 246 swizzle += "xyzw"[elem];
247 247
248 std::string dest = reg + (dest_num_components != 1 ? swizzle : ""); 248 std::string dest = reg + (dest_num_components != 1 ? swizzle : "");
249 std::string src = "(" + value + ")" + (value_num_components != 1 ? swizzle : ""); 249 std::string src = "(" + value + ")" + (value_num_components != 1 ? swizzle : "");
250 src = is_abs ? "abs(" + src + ")" : src;
250 251
251 shader.AddLine(dest + " = " + src + ";"); 252 shader.AddLine(dest + " = " + src + ";");
252 } 253 }
@@ -264,8 +265,6 @@ private:
264 265
265 switch (OpCode::GetInfo(instr.opcode).type) { 266 switch (OpCode::GetInfo(instr.opcode).type) {
266 case OpCode::Type::Arithmetic: { 267 case OpCode::Type::Arithmetic: {
267 ASSERT_MSG(!instr.alu.abs_d, "unimplemented");
268
269 std::string dest = GetRegister(instr.gpr0); 268 std::string dest = GetRegister(instr.gpr0);
270 std::string op_a = instr.alu.negate_a ? "-" : ""; 269 std::string op_a = instr.alu.negate_a ? "-" : "";
271 op_a += GetRegister(instr.gpr8); 270 op_a += GetRegister(instr.gpr8);
@@ -304,8 +303,26 @@ private:
304 } 303 }
305 case OpCode::Id::MUFU: { 304 case OpCode::Id::MUFU: {
306 switch (instr.sub_op) { 305 switch (instr.sub_op) {
306 case SubOp::Cos:
307 SetDest(0, dest, "cos(" + op_a + ")", 1, 1, instr.alu.abs_d);
308 break;
309 case SubOp::Sin:
310 SetDest(0, dest, "sin(" + op_a + ")", 1, 1, instr.alu.abs_d);
311 break;
312 case SubOp::Ex2:
313 SetDest(0, dest, "exp2(" + op_a + ")", 1, 1, instr.alu.abs_d);
314 break;
315 case SubOp::Lg2:
316 SetDest(0, dest, "log2(" + op_a + ")", 1, 1, instr.alu.abs_d);
317 break;
307 case SubOp::Rcp: 318 case SubOp::Rcp:
308 SetDest(0, dest, "1.0 / " + op_a, 1, 1); 319 SetDest(0, dest, "1.0 / " + op_a, 1, 1, instr.alu.abs_d);
320 break;
321 case SubOp::Rsq:
322 SetDest(0, dest, "inversesqrt(" + op_a + ")", 1, 1, instr.alu.abs_d);
323 break;
324 case SubOp::Min:
325 SetDest(0, dest, "min(" + op_a + "," + op_b + ")", 1, 1, instr.alu.abs_d);
309 break; 326 break;
310 default: 327 default:
311 LOG_ERROR(HW_GPU, "Unhandled sub op: 0x%02x", (int)instr.sub_op.Value()); 328 LOG_ERROR(HW_GPU, "Unhandled sub op: 0x%02x", (int)instr.sub_op.Value());
@@ -324,9 +341,6 @@ private:
324 break; 341 break;
325 } 342 }
326 case OpCode::Type::Ffma: { 343 case OpCode::Type::Ffma: {
327 ASSERT_MSG(!instr.ffma.negate_b, "untested");
328 ASSERT_MSG(!instr.ffma.negate_c, "untested");
329
330 std::string dest = GetRegister(instr.gpr0); 344 std::string dest = GetRegister(instr.gpr0);
331 std::string op_a = GetRegister(instr.gpr8); 345 std::string op_a = GetRegister(instr.gpr8);
332 std::string op_b = instr.ffma.negate_b ? "-" : ""; 346 std::string op_b = instr.ffma.negate_b ? "-" : "";