From c0e69ff9ab400c3ac1f6f66b925854992d498861 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Mon, 17 Feb 2025 23:26:28 -0600 Subject: [PATCH] Interpreter: Accurate CLIP --- pcsx2/VUops.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index 04fc191a89..129742e985 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -1703,15 +1703,19 @@ static __fi void _vuITOF15(VURegs* VU) static __fi void _vuCLIP(VURegs* VU) { - float value = fabs(vuDouble(VU->VF[_Ft_].i.w)); + s32 value = VU->VF[_Ft_].i.w; + // If denormal, set to the highest possible denormal value so only non-denormals compare higher + value = (value & 0x7f800000) ? value & 0x7fffffff : 0x007fffff; + const u32 pos = 0x00000000; + const u32 neg = 0x80000000; VU->clipflag <<= 6; - if ( vuDouble(VU->VF[_Fs_].i.x) > +value ) VU->clipflag|= 0x01; - if ( vuDouble(VU->VF[_Fs_].i.x) < -value ) VU->clipflag|= 0x02; - if ( vuDouble(VU->VF[_Fs_].i.y) > +value ) VU->clipflag|= 0x04; - if ( vuDouble(VU->VF[_Fs_].i.y) < -value ) VU->clipflag|= 0x08; - if ( vuDouble(VU->VF[_Fs_].i.z) > +value ) VU->clipflag|= 0x10; - if ( vuDouble(VU->VF[_Fs_].i.z) < -value ) VU->clipflag|= 0x20; + if (static_cast(VU->VF[_Fs_].i.x ^ pos) > value) VU->clipflag |= 0x01; + if (static_cast(VU->VF[_Fs_].i.x ^ neg) > value) VU->clipflag |= 0x02; + if (static_cast(VU->VF[_Fs_].i.y ^ pos) > value) VU->clipflag |= 0x04; + if (static_cast(VU->VF[_Fs_].i.y ^ neg) > value) VU->clipflag |= 0x08; + if (static_cast(VU->VF[_Fs_].i.z ^ pos) > value) VU->clipflag |= 0x10; + if (static_cast(VU->VF[_Fs_].i.z ^ neg) > value) VU->clipflag |= 0x20; VU->clipflag = VU->clipflag & 0xFFFFFF; }