summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-04-28 20:01:36 -0400
committerGravatar bunnei2018-04-28 20:03:19 -0400
commit0c01c34eff9456e1341fcc0f7a048325e6929cd3 (patch)
tree6917d5dfb5f4556d76b81129a9d16b00b441d9eb
parentgl_shader_decompiler: More cleanups, etc. with how we handle register types. (diff)
downloadyuzu-0c01c34eff9456e1341fcc0f7a048325e6929cd3.tar.gz
yuzu-0c01c34eff9456e1341fcc0f7a048325e6929cd3.tar.xz
yuzu-0c01c34eff9456e1341fcc0f7a048325e6929cd3.zip
gl_shader_decompiler: Partially implement I2I_R, and I2F_R.
-rw-r--r--src/video_core/engines/shader_bytecode.h16
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp26
2 files changed, 34 insertions, 8 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index 0cbe5e94d..f20c2cd41 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -250,7 +250,7 @@ union Instruction {
250 BitField<45, 1, u64> negate_a; 250 BitField<45, 1, u64> negate_a;
251 BitField<49, 1, u64> abs_a; 251 BitField<49, 1, u64> abs_a;
252 BitField<50, 1, u64> saturate_a; 252 BitField<50, 1, u64> saturate_a;
253 } i2i; 253 } conversion;
254 254
255 BitField<61, 1, u64> is_b_imm; 255 BitField<61, 1, u64> is_b_imm;
256 BitField<60, 1, u64> is_b_gpr; 256 BitField<60, 1, u64> is_b_gpr;
@@ -330,7 +330,7 @@ public:
330 FloatSet, 330 FloatSet,
331 FloatSetPredicate, 331 FloatSetPredicate,
332 IntegerSetPredicate, 332 IntegerSetPredicate,
333 I2I, 333 Conversion,
334 Unknown, 334 Unknown,
335 }; 335 };
336 336
@@ -452,9 +452,6 @@ private:
452 INST("0100110010110---", Id::F2I_C, Type::Arithmetic, "F2I_C"), 452 INST("0100110010110---", Id::F2I_C, Type::Arithmetic, "F2I_C"),
453 INST("0101110010110---", Id::F2I_R, Type::Arithmetic, "F2I_R"), 453 INST("0101110010110---", Id::F2I_R, Type::Arithmetic, "F2I_R"),
454 INST("0011100-10110---", Id::F2I_IMM, Type::Arithmetic, "F2I_IMM"), 454 INST("0011100-10110---", Id::F2I_IMM, Type::Arithmetic, "F2I_IMM"),
455 INST("0100110010111---", Id::I2F_C, Type::Arithmetic, "I2F_C"),
456 INST("0101110010111---", Id::I2F_R, Type::Arithmetic, "I2F_R"),
457 INST("0011100-10111---", Id::I2F_IMM, Type::Arithmetic, "I2F_IMM"),
458 INST("000001----------", Id::LOP32I, Type::Arithmetic, "LOP32I"), 455 INST("000001----------", Id::LOP32I, Type::Arithmetic, "LOP32I"),
459 INST("0100110010011---", Id::MOV_C, Type::Arithmetic, "MOV_C"), 456 INST("0100110010011---", Id::MOV_C, Type::Arithmetic, "MOV_C"),
460 INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"), 457 INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"),
@@ -463,9 +460,12 @@ private:
463 INST("0100110000101---", Id::SHR_C, Type::Arithmetic, "SHR_C"), 460 INST("0100110000101---", Id::SHR_C, Type::Arithmetic, "SHR_C"),
464 INST("0101110000101---", Id::SHR_R, Type::Arithmetic, "SHR_R"), 461 INST("0101110000101---", Id::SHR_R, Type::Arithmetic, "SHR_R"),
465 INST("0011100-00101---", Id::SHR_IMM, Type::Arithmetic, "SHR_IMM"), 462 INST("0011100-00101---", Id::SHR_IMM, Type::Arithmetic, "SHR_IMM"),
466 INST("0100110011100---", Id::I2I_C, Type::I2I, "I2I_C"), 463 INST("0100110011100---", Id::I2I_C, Type::Conversion, "I2I_C"),
467 INST("0101110011100---", Id::I2I_R, Type::I2I, "I2I_R"), 464 INST("0101110011100---", Id::I2I_R, Type::Conversion, "I2I_R"),
468 INST("01110001-1000---", Id::I2I_IMM, Type::I2I, "I2I_IMM"), 465 INST("01110001-1000---", Id::I2I_IMM, Type::Conversion, "I2I_IMM"),
466 INST("0100110010111---", Id::I2F_C, Type::Conversion, "I2F_C"),
467 INST("0101110010111---", Id::I2F_R, Type::Conversion, "I2F_R"),
468 INST("0011100-10111---", Id::I2F_IMM, Type::Conversion, "I2F_IMM"),
469 INST("01011000--------", Id::FSET_R, Type::FloatSet, "FSET_R"), 469 INST("01011000--------", Id::FSET_R, Type::FloatSet, "FSET_R"),
470 INST("0100100---------", Id::FSET_C, Type::FloatSet, "FSET_C"), 470 INST("0100100---------", Id::FSET_C, Type::FloatSet, "FSET_C"),
471 INST("0011000---------", Id::FSET_IMM, Type::FloatSet, "FSET_IMM"), 471 INST("0011000---------", Id::FSET_IMM, Type::FloatSet, "FSET_IMM"),
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index f90f74a48..27190cc45 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -770,6 +770,32 @@ private:
770 regs.SetRegisterToFloat(instr.gpr0, 0, op_a + " * " + op_b + " + " + op_c, 1, 1); 770 regs.SetRegisterToFloat(instr.gpr0, 0, op_a + " * " + op_b + " + " + op_c, 1, 1);
771 break; 771 break;
772 } 772 }
773 case OpCode::Type::Conversion: {
774 ASSERT_MSG(instr.conversion.size == Register::Size::Word, "Unimplemented");
775 ASSERT_MSG(!instr.conversion.selector, "Unimplemented");
776 ASSERT_MSG(!instr.conversion.negate_a, "Unimplemented");
777 ASSERT_MSG(!instr.conversion.saturate_a, "Unimplemented");
778
779 switch (opcode->GetId()) {
780 case OpCode::Id::I2I_R:
781 case OpCode::Id::I2F_R: {
782 std::string op_a =
783 regs.GetRegisterAsInteger(instr.gpr20, 0, instr.conversion.is_signed);
784
785 if (instr.conversion.abs_a) {
786 op_a = "abs(" + op_a + ')';
787 }
788
789 regs.SetRegisterToInteger(instr.gpr0, instr.conversion.is_signed, 0, op_a, 1, 1);
790 break;
791 }
792 default: {
793 NGLOG_CRITICAL(HW_GPU, "Unhandled conversion instruction: {}", opcode->GetName());
794 UNREACHABLE();
795 }
796 }
797 break;
798 }
773 case OpCode::Type::Memory: { 799 case OpCode::Type::Memory: {
774 const Attribute::Index attribute = instr.attribute.fmt20.index; 800 const Attribute::Index attribute = instr.attribute.fmt20.index;
775 801