From 07cb37c2c1970c4c8185a82d2b60be5a2a6a9804 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 25 Apr 2021 07:09:50 -0700 Subject: [PATCH] Compat: Remove single/double sincos path. New implementation should work for both cases. --- Core/Compatibility.cpp | 1 - Core/Compatibility.h | 1 - Core/MIPS/MIPSVFPUUtils.cpp | 67 +++---------------------------------- Core/MIPS/MIPSVFPUUtils.h | 8 ++--- Core/System.cpp | 2 +- assets/compat.ini | 6 ---- unittest/JitHarness.cpp | 2 +- unittest/UnitTest.cpp | 2 +- 8 files changed, 12 insertions(+), 77 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 45a5bb25bd..4522573def 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -75,7 +75,6 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "MemstickFixedFree", &flags_.MemstickFixedFree); CheckSetting(iniFile, gameID, "DateLimited", &flags_.DateLimited); CheckSetting(iniFile, gameID, "ReinterpretFramebuffers", &flags_.ReinterpretFramebuffers); - CheckSetting(iniFile, gameID, "DoublePrecisionSinCos", &flags_.DoublePrecisionSinCos); CheckSetting(iniFile, gameID, "ShaderColorBitmask", &flags_.ShaderColorBitmask); CheckSetting(iniFile, gameID, "DisableFirstFrameReadback", &flags_.DisableFirstFrameReadback); CheckSetting(iniFile, gameID, "DisableRangeCulling", &flags_.DisableRangeCulling); diff --git a/Core/Compatibility.h b/Core/Compatibility.h index da0e36c1f6..48eeddc197 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -73,7 +73,6 @@ struct CompatFlags { bool MemstickFixedFree; bool DateLimited; bool ReinterpretFramebuffers; - bool DoublePrecisionSinCos; bool ShaderColorBitmask; bool DisableFirstFrameReadback; bool DisableRangeCulling; diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index be434207c4..e5d06e8c30 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -885,58 +885,7 @@ float vfpu_rsqrt(float a) { return val.f; } -float vfpu_sin_single(float angle) { - angle -= floorf(angle * 0.25f) * 4.f; - if (angle == 0.0f || angle == 2.0f) { - return 0.0f; - } else if (angle == 1.0f) { - return 1.0f; - } else if (angle == 3.0f) { - return -1.0f; - } - angle *= (float)M_PI_2; - return sinf(angle); -} - -float vfpu_cos_single(float angle) { - angle -= floorf(angle * 0.25f) * 4.f; - if (angle == 1.0f || angle == 3.0f) { - return 0.0f; - } else if (angle == 0.0f) { - return 1.0f; - } else if (angle == 2.0f) { - return -1.0f; - } - angle *= (float)M_PI_2; - return cosf(angle); -} - -void vfpu_sincos_single(float angle, float &sine, float &cosine) { - angle -= floorf(angle * 0.25f) * 4.f; - if (angle == 0.0f) { - sine = 0.0f; - cosine = 1.0f; - } else if (angle == 1.0f) { - sine = 1.0f; - cosine = 0.0f; - } else if (angle == 2.0f) { - sine = 0.0f; - cosine = -1.0f; - } else if (angle == 3.0f) { - sine = -1.0f; - cosine = 0.0f; - } else { - angle *= (float)M_PI_2; -#if defined(__linux__) - sincosf(angle, &sine, &cosine); -#else - sine = sinf(angle); - cosine = cosf(angle); -#endif - } -} - -float vfpu_sin_mod2(float a) { +float vfpu_sin(float a) { float2int val; val.f = a; @@ -980,7 +929,7 @@ float vfpu_sin_mod2(float a) { return val.f; } -float vfpu_cos_mod2(float a) { +float vfpu_cos(float a) { float2int val; val.f = a; bool negate = false; @@ -1025,7 +974,7 @@ float vfpu_cos_mod2(float a) { return negate ? -val.f : val.f; } -void vfpu_sincos_mod2(float a, float &s, float &c) { +void vfpu_sincos(float a, float &s, float &c) { float2int val; val.f = a; // For sin, negate the input, for cos negate the output. @@ -1106,12 +1055,6 @@ void vfpu_sincos_mod2(float a, float &s, float &c) { return ; } -float (*vfpu_sin)(float); -float (*vfpu_cos)(float); -void (*vfpu_sincos)(float, float&, float&); - -void InitVFPUSinCos(bool useDoublePrecision) { - vfpu_sin = useDoublePrecision ? vfpu_sin_mod2 : vfpu_sin_single; - vfpu_cos = useDoublePrecision ? vfpu_cos_mod2 : vfpu_cos_single; - vfpu_sincos = useDoublePrecision ? vfpu_sincos_mod2 : vfpu_sincos_single; +void InitVFPUSinCos() { + // TODO: Could prepare a CORDIC table here. } diff --git a/Core/MIPS/MIPSVFPUUtils.h b/Core/MIPS/MIPSVFPUUtils.h index b89335a257..8200e8c87d 100644 --- a/Core/MIPS/MIPSVFPUUtils.h +++ b/Core/MIPS/MIPSVFPUUtils.h @@ -50,9 +50,9 @@ inline int Xpose(int v) { // // Messing around with the modulo functions? try https://www.desmos.com/calculator. -extern float (*vfpu_sin)(float); -extern float (*vfpu_cos)(float); -extern void (*vfpu_sincos)(float, float&, float&); +extern float vfpu_sin(float); +extern float vfpu_cos(float); +extern void vfpu_sincos(float, float&, float&); inline float vfpu_asin(float angle) { return asinf(angle) / M_PI_2; @@ -215,4 +215,4 @@ int GetVectorOverlap(int reg1, VectorSize size1, int reg2, VectorSize size2); bool GetVFPUCtrlMask(int reg, u32 *mask); float Float16ToFloat32(unsigned short l); -void InitVFPUSinCos(bool useDoublePrecision); +void InitVFPUSinCos(); diff --git a/Core/System.cpp b/Core/System.cpp index 19690bb537..60a2e03b6b 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -284,7 +284,7 @@ bool CPU_Init() { // likely to collide with any commercial ones. coreParameter.compat.Load(g_paramSFO.GetDiscID()); - InitVFPUSinCos(true); + InitVFPUSinCos(); if (allowPlugins) HLEPlugins::Init(); diff --git a/assets/compat.ini b/assets/compat.ini index 91792cf9c0..2b2d0e7f00 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -989,12 +989,6 @@ ULJM05533 = true NPJH50006 = true ULES01301 = true -[DoublePrecisionSinCos] -# Hitman Reborn Battle Arena 2 (#12900) -ULJS00218 = true -# Hitman Reborn Battle Arena -ULJS00157 = true - [DisableFirstFrameReadback] # Wipeout Pure: Temporary workaround for lens flare flicker. See #13344 UCUS98612 = true diff --git a/unittest/JitHarness.cpp b/unittest/JitHarness.cpp index 9745cc50eb..6743a5a62e 100644 --- a/unittest/JitHarness.cpp +++ b/unittest/JitHarness.cpp @@ -92,7 +92,7 @@ static void SetupJitHarness() { Memory::Init(); mipsr4k.Reset(); CoreTiming::Init(); - InitVFPUSinCos(true); + InitVFPUSinCos(); } static void DestroyJitHarness() { diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index f337af9b96..bc91182cde 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -303,7 +303,7 @@ bool TestParsers() { bool TestVFPUSinCos() { float sine, cosine; - InitVFPUSinCos(false); + InitVFPUSinCos(); EXPECT_FALSE(vfpu_sincos == nullptr); vfpu_sincos(0.0f, sine, cosine); EXPECT_EQ_FLOAT(sine, 0.0f);