summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/shader_bytecode.h30
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp31
2 files changed, 47 insertions, 14 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index 8d4ea3401..ef749937e 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -230,22 +230,19 @@ union Instruction {
230 std::memcpy(&result, &imm, sizeof(imm)); 230 std::memcpy(&result, &imm, sizeof(imm));
231 return result; 231 return result;
232 } 232 }
233 } alu;
234
235 union {
236 BitField<39, 5, u64> shift_amount;
237 BitField<20, 19, u64> immediate_low;
238 BitField<56, 1, u64> immediate_high;
239 BitField<48, 1, u64> negate_b;
240 BitField<49, 1, u64> negate_a;
241 233
242 s32 GetImmediate() const { 234 s32 GetSignedImm20_20() const {
243 u32 immediate = static_cast<u32>(immediate_low | (immediate_high << 19)); 235 u32 immediate = static_cast<u32>(imm20_19 | (negate_imm << 19));
244 // Sign extend the 20-bit value. 236 // Sign extend the 20-bit value.
245 u32 mask = 1U << (20 - 1); 237 u32 mask = 1U << (20 - 1);
246 return static_cast<s32>((immediate ^ mask) - mask); 238 return static_cast<s32>((immediate ^ mask) - mask);
247 } 239 }
240 } alu;
248 241
242 union {
243 BitField<39, 5, u64> shift_amount;
244 BitField<48, 1, u64> negate_b;
245 BitField<49, 1, u64> negate_a;
249 } iscadd; 246 } iscadd;
250 247
251 union { 248 union {
@@ -402,6 +399,9 @@ public:
402 MOV_R, 399 MOV_R,
403 MOV_IMM, 400 MOV_IMM,
404 MOV32_IMM, 401 MOV32_IMM,
402 SHL_C,
403 SHL_R,
404 SHL_IMM,
405 SHR_C, 405 SHR_C,
406 SHR_R, 406 SHR_R,
407 SHR_IMM, 407 SHR_IMM,
@@ -424,6 +424,7 @@ public:
424 Trivial, 424 Trivial,
425 Arithmetic, 425 Arithmetic,
426 Logic, 426 Logic,
427 Shift,
427 ScaledAdd, 428 ScaledAdd,
428 Ffma, 429 Ffma,
429 Flow, 430 Flow,
@@ -565,13 +566,16 @@ private:
565 INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"), 566 INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"),
566 INST("0011100-10011---", Id::MOV_IMM, Type::Arithmetic, "MOV_IMM"), 567 INST("0011100-10011---", Id::MOV_IMM, Type::Arithmetic, "MOV_IMM"),
567 INST("000000010000----", Id::MOV32_IMM, Type::Arithmetic, "MOV32_IMM"), 568 INST("000000010000----", Id::MOV32_IMM, Type::Arithmetic, "MOV32_IMM"),
568 INST("0100110000101---", Id::SHR_C, Type::Arithmetic, "SHR_C"),
569 INST("0101110000101---", Id::SHR_R, Type::Arithmetic, "SHR_R"),
570 INST("0011100-00101---", Id::SHR_IMM, Type::Arithmetic, "SHR_IMM"),
571 INST("0100110001100---", Id::FMNMX_C, Type::Arithmetic, "FMNMX_C"), 569 INST("0100110001100---", Id::FMNMX_C, Type::Arithmetic, "FMNMX_C"),
572 INST("0101110001100---", Id::FMNMX_R, Type::Arithmetic, "FMNMX_R"), 570 INST("0101110001100---", Id::FMNMX_R, Type::Arithmetic, "FMNMX_R"),
573 INST("0011100-01100---", Id::FMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"), 571 INST("0011100-01100---", Id::FMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"),
574 INST("000001----------", Id::LOP32I, Type::Logic, "LOP32I"), 572 INST("000001----------", Id::LOP32I, Type::Logic, "LOP32I"),
573 INST("0100110001001---", Id::SHL_C, Type::Shift, "SHL_C"),
574 INST("0101110001001---", Id::SHL_R, Type::Shift, "SHL_R"),
575 INST("0011100-01001---", Id::SHL_IMM, Type::Shift, "SHL_IMM"),
576 INST("0100110000101---", Id::SHR_C, Type::Shift, "SHR_C"),
577 INST("0101110000101---", Id::SHR_R, Type::Shift, "SHR_R"),
578 INST("0011100-00101---", Id::SHR_IMM, Type::Shift, "SHR_IMM"),
575 INST("0100110011100---", Id::I2I_C, Type::Conversion, "I2I_C"), 579 INST("0100110011100---", Id::I2I_C, Type::Conversion, "I2I_C"),
576 INST("0101110011100---", Id::I2I_R, Type::Conversion, "I2I_R"), 580 INST("0101110011100---", Id::I2I_R, Type::Conversion, "I2I_R"),
577 INST("01110001-1000---", Id::I2I_IMM, Type::Conversion, "I2I_IMM"), 581 INST("01110001-1000---", Id::I2I_IMM, Type::Conversion, "I2I_IMM"),
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 6f66dfbcd..2c9ffcafc 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -884,6 +884,35 @@ private:
884 } 884 }
885 break; 885 break;
886 } 886 }
887
888 case OpCode::Type::Shift: {
889 std::string op_a = regs.GetRegisterAsInteger(instr.gpr8, 0, false);
890 std::string op_b;
891
892 if (instr.is_b_imm) {
893 op_b += '(' + std::to_string(instr.alu.GetSignedImm20_20()) + ')';
894 } else {
895 if (instr.is_b_gpr) {
896 op_b += regs.GetRegisterAsInteger(instr.gpr20);
897 } else {
898 op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Integer);
899 }
900 }
901
902 switch (opcode->GetId()) {
903 case OpCode::Id::SHL_C:
904 case OpCode::Id::SHL_R:
905 case OpCode::Id::SHL_IMM:
906 regs.SetRegisterToInteger(instr.gpr0, true, 0, op_a + " << " + op_b, 1, 1);
907 break;
908 default: {
909 NGLOG_CRITICAL(HW_GPU, "Unhandled shift instruction: {}", opcode->GetName());
910 UNREACHABLE();
911 }
912 }
913 break;
914 }
915
887 case OpCode::Type::ScaledAdd: { 916 case OpCode::Type::ScaledAdd: {
888 std::string op_a = regs.GetRegisterAsInteger(instr.gpr8); 917 std::string op_a = regs.GetRegisterAsInteger(instr.gpr8);
889 918
@@ -893,7 +922,7 @@ private:
893 std::string op_b = instr.iscadd.negate_b ? "-" : ""; 922 std::string op_b = instr.iscadd.negate_b ? "-" : "";
894 923
895 if (instr.is_b_imm) { 924 if (instr.is_b_imm) {
896 op_b += '(' + std::to_string(instr.iscadd.GetImmediate()) + ')'; 925 op_b += '(' + std::to_string(instr.alu.GetSignedImm20_20()) + ')';
897 } else { 926 } else {
898 if (instr.is_b_gpr) { 927 if (instr.is_b_gpr) {
899 op_b += regs.GetRegisterAsInteger(instr.gpr20); 928 op_b += regs.GetRegisterAsInteger(instr.gpr20);