summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/shader_bytecode.h20
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp12
2 files changed, 24 insertions, 8 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index af18c2d81..ab45cfbef 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -390,6 +390,9 @@ class OpCode {
390public: 390public:
391 enum class Id { 391 enum class Id {
392 KIL, 392 KIL,
393 BFE_C,
394 BFE_R,
395 BFE_IMM,
393 BRA, 396 BRA,
394 LD_A, 397 LD_A,
395 LD_C, 398 LD_C,
@@ -444,6 +447,9 @@ public:
444 FMNMX_C, 447 FMNMX_C,
445 FMNMX_R, 448 FMNMX_R,
446 FMNMX_IMM, 449 FMNMX_IMM,
450 IMNMX_C,
451 IMNMX_R,
452 IMNMX_IMM,
447 FSETP_C, // Set Predicate 453 FSETP_C, // Set Predicate
448 FSETP_R, 454 FSETP_R,
449 FSETP_IMM, 455 FSETP_IMM,
@@ -454,6 +460,10 @@ public:
454 ISETP_IMM, 460 ISETP_IMM,
455 ISETP_R, 461 ISETP_R,
456 PSETP, 462 PSETP,
463 XMAD_IMM,
464 XMAD_CR,
465 XMAD_RC,
466 XMAD_RR,
457 }; 467 };
458 468
459 enum class Type { 469 enum class Type {
@@ -565,6 +575,9 @@ private:
565 std::vector<Matcher> table = { 575 std::vector<Matcher> table = {
566#define INST(bitstring, op, type, name) Detail::GetMatcher(bitstring, op, type, name) 576#define INST(bitstring, op, type, name) Detail::GetMatcher(bitstring, op, type, name)
567 INST("111000110011----", Id::KIL, Type::Flow, "KIL"), 577 INST("111000110011----", Id::KIL, Type::Flow, "KIL"),
578 INST("0100110000000---", Id::BFE_C, Type::Flow, "BFE_C"),
579 INST("0101110000000---", Id::BFE_R, Type::Flow, "BFE_R"),
580 INST("0011100-00000---", Id::BFE_IMM, Type::Flow, "BFE_IMM"),
568 INST("111000100100----", Id::BRA, Type::Flow, "BRA"), 581 INST("111000100100----", Id::BRA, Type::Flow, "BRA"),
569 INST("1110111111011---", Id::LD_A, Type::Memory, "LD_A"), 582 INST("1110111111011---", Id::LD_A, Type::Memory, "LD_A"),
570 INST("1110111110010---", Id::LD_C, Type::Memory, "LD_C"), 583 INST("1110111110010---", Id::LD_C, Type::Memory, "LD_C"),
@@ -606,6 +619,9 @@ private:
606 INST("0100110001100---", Id::FMNMX_C, Type::Arithmetic, "FMNMX_C"), 619 INST("0100110001100---", Id::FMNMX_C, Type::Arithmetic, "FMNMX_C"),
607 INST("0101110001100---", Id::FMNMX_R, Type::Arithmetic, "FMNMX_R"), 620 INST("0101110001100---", Id::FMNMX_R, Type::Arithmetic, "FMNMX_R"),
608 INST("0011100-01100---", Id::FMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"), 621 INST("0011100-01100---", Id::FMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"),
622 INST("0100110000100---", Id::IMNMX_C, Type::Arithmetic, "FMNMX_IMM"),
623 INST("0101110000100---", Id::IMNMX_R, Type::Arithmetic, "FMNMX_IMM"),
624 INST("0011100-00100---", Id::IMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"),
609 INST("000001----------", Id::LOP32I, Type::Logic, "LOP32I"), 625 INST("000001----------", Id::LOP32I, Type::Logic, "LOP32I"),
610 INST("0100110001001---", Id::SHL_C, Type::Shift, "SHL_C"), 626 INST("0100110001001---", Id::SHL_C, Type::Shift, "SHL_C"),
611 INST("0101110001001---", Id::SHL_R, Type::Shift, "SHL_R"), 627 INST("0101110001001---", Id::SHL_R, Type::Shift, "SHL_R"),
@@ -629,6 +645,10 @@ private:
629 INST("010110110110----", Id::ISETP_R, Type::IntegerSetPredicate, "ISETP_R"), 645 INST("010110110110----", Id::ISETP_R, Type::IntegerSetPredicate, "ISETP_R"),
630 INST("0011011-0110----", Id::ISETP_IMM, Type::IntegerSetPredicate, "ISETP_IMM"), 646 INST("0011011-0110----", Id::ISETP_IMM, Type::IntegerSetPredicate, "ISETP_IMM"),
631 INST("0101000010010---", Id::PSETP, Type::PredicateSetPredicate, "PSETP"), 647 INST("0101000010010---", Id::PSETP, Type::PredicateSetPredicate, "PSETP"),
648 INST("0011011-00------", Id::XMAD_IMM, Type::Arithmetic, "XMAD_IMM"),
649 INST("0100111---------", Id::XMAD_CR, Type::Arithmetic, "XMAD_CR"),
650 INST("010100010-------", Id::XMAD_RC, Type::Arithmetic, "XMAD_RC"),
651 INST("0101101100------", Id::XMAD_RR, Type::Arithmetic, "XMAD_RR"),
632 }; 652 };
633#undef INST 653#undef INST
634 std::stable_sort(table.begin(), table.end(), [](const auto& a, const auto& b) { 654 std::stable_sort(table.begin(), table.end(), [](const auto& a, const auto& b) {
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index b6c6a4607..f84cedc1d 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1112,13 +1112,11 @@ private:
1112 break; 1112 break;
1113 } 1113 }
1114 case OpCode::Type::Memory: { 1114 case OpCode::Type::Memory: {
1115 const Attribute::Index attribute = instr.attribute.fmt20.index;
1116
1117 switch (opcode->GetId()) { 1115 switch (opcode->GetId()) {
1118 case OpCode::Id::LD_A: { 1116 case OpCode::Id::LD_A: {
1119 ASSERT_MSG(instr.attribute.fmt20.size == 0, "untested"); 1117 ASSERT_MSG(instr.attribute.fmt20.size == 0, "untested");
1120 regs.SetRegisterToInputAttibute(instr.gpr0, instr.attribute.fmt20.element, 1118 regs.SetRegisterToInputAttibute(instr.gpr0, instr.attribute.fmt20.element,
1121 attribute); 1119 instr.attribute.fmt20.index);
1122 break; 1120 break;
1123 } 1121 }
1124 case OpCode::Id::LD_C: { 1122 case OpCode::Id::LD_C: {
@@ -1150,12 +1148,11 @@ private:
1150 } 1148 }
1151 case OpCode::Id::ST_A: { 1149 case OpCode::Id::ST_A: {
1152 ASSERT_MSG(instr.attribute.fmt20.size == 0, "untested"); 1150 ASSERT_MSG(instr.attribute.fmt20.size == 0, "untested");
1153 regs.SetOutputAttributeToRegister(attribute, instr.attribute.fmt20.element, 1151 regs.SetOutputAttributeToRegister(instr.attribute.fmt20.index,
1154 instr.gpr0); 1152 instr.attribute.fmt20.element, instr.gpr0);
1155 break; 1153 break;
1156 } 1154 }
1157 case OpCode::Id::TEX: { 1155 case OpCode::Id::TEX: {
1158 ASSERT_MSG(instr.attribute.fmt20.size == 4, "untested");
1159 const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8); 1156 const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
1160 const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); 1157 const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
1161 const std::string sampler = GetSampler(instr.sampler); 1158 const std::string sampler = GetSampler(instr.sampler);
@@ -1168,7 +1165,7 @@ private:
1168 const std::string texture = "texture(" + sampler + ", coords)"; 1165 const std::string texture = "texture(" + sampler + ", coords)";
1169 1166
1170 size_t dest_elem{}; 1167 size_t dest_elem{};
1171 for (size_t elem = 0; elem < instr.attribute.fmt20.size; ++elem) { 1168 for (size_t elem = 0; elem < 4; ++elem) {
1172 if (!instr.tex.IsComponentEnabled(elem)) { 1169 if (!instr.tex.IsComponentEnabled(elem)) {
1173 // Skip disabled components 1170 // Skip disabled components
1174 continue; 1171 continue;
@@ -1181,7 +1178,6 @@ private:
1181 break; 1178 break;
1182 } 1179 }
1183 case OpCode::Id::TEXS: { 1180 case OpCode::Id::TEXS: {
1184 ASSERT_MSG(instr.attribute.fmt20.size == 4, "untested");
1185 const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8); 1181 const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
1186 const std::string op_b = regs.GetRegisterAsFloat(instr.gpr20); 1182 const std::string op_b = regs.GetRegisterAsFloat(instr.gpr20);
1187 const std::string sampler = GetSampler(instr.sampler); 1183 const std::string sampler = GetSampler(instr.sampler);