From fde6099769db301436159a73e23c29e24df3450b Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 21 Jul 2017 18:23:24 -0500 Subject: [PATCH] rsx: Fix vertex decompiler to support 2 arg destination --- rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp | 3 +++ rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp index 9a1e5a4a00..34ca3d8c89 100644 --- a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp @@ -63,6 +63,9 @@ std::string CgBinaryDisasm::GetDSTDisasm(bool isSca) LOG_ERROR(RSX, "dst index out of range: %u", d3.dst); ret += fmt::format("o[%d]", d3.dst) + GetVecMaskDisasm(); + // Vertex Program supports double destinations, notably in MOV + if (d0.dst_tmp != 0x3f) + ret += fmt::format(" R%d", d0.dst_tmp) + GetVecMaskDisasm(); break; } diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp index 51f52f0d17..d56696a2bd 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp @@ -41,16 +41,21 @@ std::string VertexProgramDecompiler::GetDST(bool isSca) { std::string ret; + std::string mask = GetMask(isSca); + switch (isSca ? 0x1f : d3.dst) { case 0x1f: - ret += m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), std::string("tmp") + std::to_string(isSca ? d3.sca_dst_tmp : d0.dst_tmp)); + ret += m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), std::string("tmp") + std::to_string(isSca ? d3.sca_dst_tmp : d0.dst_tmp)) + mask; break; default: if (d3.dst > 15) LOG_ERROR(RSX, "dst index out of range: %u", d3.dst); - ret += m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), std::string("dst_reg") + std::to_string(d3.dst), d3.dst == 0 ? getFloatTypeName(4) + "(0.0f, 0.0f, 0.0f, 1.0f)" : getFloatTypeName(4) + "(0.0, 0.0, 0.0, 0.0)"); + ret += m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), std::string("dst_reg") + std::to_string(d3.dst), d3.dst == 0 ? getFloatTypeName(4) + "(0.0f, 0.0f, 0.0f, 1.0f)" : getFloatTypeName(4) + "(0.0, 0.0, 0.0, 0.0)") + mask; + // Handle double destination register as 'dst_reg = tmp' + if (d0.dst_tmp != 0x3f) + ret += " = " + m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), std::string("tmp") + std::to_string(d0.dst_tmp)) + mask; break; } @@ -157,7 +162,7 @@ void VertexProgramDecompiler::SetDST(bool is_sca, std::string value) } else if (d3.dst != 0x1f || (is_sca ? d3.sca_dst_tmp != 0x3f : d0.dst_tmp != 0x3f)) { - dest = GetDST(is_sca) + mask; + dest = GetDST(is_sca); } //std::string code;