diff --git a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp index 33dfafe78e..0778141e1f 100644 --- a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp @@ -32,7 +32,7 @@ enum VectorLane : u8 W = 3, }; -u32 FragmentProgramDecompiler::get_src_vector_mask(u32 opcode, int operand) +u32 FragmentProgramDecompiler::get_src_vector_mask(u32 opcode, u32 operand) { auto decode = [&](const std::string& expr) -> u32 { @@ -59,8 +59,6 @@ u32 FragmentProgramDecompiler::get_src_vector_mask(u32 opcode, int operand) constexpr u32 xyzw = 0b1111; constexpr u32 use_dst_mask = 1u << 31; - u32 temp = 0; - switch (opcode) { case RSX_FP_OPCODE_NOP: @@ -672,11 +670,13 @@ void FragmentProgramDecompiler::AddCodeCond(const std::string& lhs, const std::s AddCode(lhs + " = _select(" + lhs + ", " + src_prefix + rhs + ", " + cond + ");"); } -template std::string FragmentProgramDecompiler::GetSRC(T src) +template + requires std::is_same_v || std::is_same_v || std::is_same_v +std::string FragmentProgramDecompiler::GetSRC(T src) { std::string ret; u32 precision_modifier = 0; - int operand_idx = -1; + u32 operand_idx = umax; if constexpr (std::is_same_v) { @@ -693,8 +693,11 @@ template std::string FragmentProgramDecompiler::GetSRC(T src) precision_modifier = src1.src2_prec_mod; operand_idx = 2; } - - ensure(operand_idx != -1); + else + { + // Unreachable unless we add another SRC type + fmt::throw_exception("Invalid SRC input"); + } switch (src.reg_type) { diff --git a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h index 2fea76ef9e..60b493d3a6 100644 --- a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.h @@ -80,7 +80,11 @@ class FragmentProgramDecompiler void AddCodeCond(const std::string& lhs, const std::string& rhs); std::string GetRawCond(); std::string GetCond(); - template std::string GetSRC(T src); + + template + requires std::is_same_v || std::is_same_v || std::is_same_v + std::string GetSRC(T src); + std::string BuildCode(); static u32 GetData(const u32 d) { return d << 16 | d >> 16; } @@ -103,7 +107,7 @@ class FragmentProgramDecompiler * Calculates the lane mask for a given input * This is a temporary workaround until the decompiler is rewritten with some IR to allow granular split/gather passes */ - u32 get_src_vector_mask(u32 opcode, int operand); + u32 get_src_vector_mask(u32 opcode, u32 operand); protected: const RSXFragmentProgram &m_prog;