From 2003890a48684d64384e5c66bc28836a3f15aa0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 May 2022 08:50:42 +0200 Subject: [PATCH] Hackery to help track down #15149. Runs without breaking on PC. --- Core/MIPS/MIPSIntVFPU.cpp | 4 ++-- Core/MIPS/MIPSVFPUUtils.cpp | 12 +++++++++++- Core/MIPS/MIPSVFPUUtils.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index 8f761b858d..13bb9b052d 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -235,7 +235,7 @@ namespace MIPSInt d[i] = Memory::Read_Float(addr + 4 * i); } } - WriteVector(d, V_Quad, vt); + WriteVector(d, V_Quad, vt, true); } break; @@ -247,7 +247,7 @@ namespace MIPSInt #ifndef COMMON_BIG_ENDIAN f = reinterpret_cast(Memory::GetPointer(addr)); if (f) - WriteVector(f, V_Quad, vt); + WriteVector(f, V_Quad, vt, true); #else float lvqd[4]; diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index 0f1d6688ab..723986da5a 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -22,6 +22,7 @@ #include "Common/BitScan.h" #include "Common/CommonFuncs.h" +#include "Common/Math/math_util.h" #include "Core/Reporting.h" #include "Core/MIPS/MIPS.h" #include "Core/MIPS/MIPSVFPUUtils.h" @@ -183,7 +184,7 @@ void ReadVector(float *rd, VectorSize size, int reg) { } } -void WriteVector(const float *rd, VectorSize size, int reg) { +void WriteVector(const float *rd, VectorSize size, int reg, bool is_svq) { if (size == V_Single) { // Optimize the common case. if (!currentMIPS->VfpuWriteMask(0)) { @@ -206,6 +207,15 @@ void WriteVector(const float *rd, VectorSize size, int reg) { default: _assert_msg_(false, "%s: Bad vector size", __FUNCTION__); } + // TEMP HACK for issue #15149 + // There's often garbage in the fourth coordinate so ignore it. + // Additionally, the SVQ instruction specifically stores some NaN data. + for (int i = 0; i < std::min(length, 3); i++) { + if (my_isnan(rd[i]) && !is_svq) { + DebugBreak(); + } + } + if (currentMIPS->VfpuWriteMask() == 0) { if (transpose) { const int base = mtx * 4 + col * 32; diff --git a/Core/MIPS/MIPSVFPUUtils.h b/Core/MIPS/MIPSVFPUUtils.h index df1a1b85b0..1bd3424c2a 100644 --- a/Core/MIPS/MIPSVFPUUtils.h +++ b/Core/MIPS/MIPSVFPUUtils.h @@ -150,7 +150,7 @@ u32 VFPURewritePrefix(int ctrl, u32 remove, u32 add); void ReadMatrix(float *rd, MatrixSize size, int reg); void WriteMatrix(const float *rs, MatrixSize size, int reg); -void WriteVector(const float *rs, VectorSize N, int reg); +void WriteVector(const float *rs, VectorSize N, int reg, bool is_svq = false); void ReadVector(float *rd, VectorSize N, int reg); void GetVectorRegs(u8 regs[4], VectorSize N, int vectorReg);