From 2409486c2dc51346d6c04c4ff9297b9fce66d8b5 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sun, 18 Oct 2020 17:24:43 +0100 Subject: [PATCH] VIF: Fixed undefined behaviour of Unpack V3-16 in final QW write. Fixes Homerun --- pcsx2/Vif_Unpack.cpp | 3 ++- pcsx2/x86/newVif_Dynarec.cpp | 2 +- pcsx2/x86/newVif_UnpackSSE.cpp | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pcsx2/Vif_Unpack.cpp b/pcsx2/Vif_Unpack.cpp index 8f8f4a4e26..451c81c2cb 100644 --- a/pcsx2/Vif_Unpack.cpp +++ b/pcsx2/Vif_Unpack.cpp @@ -239,7 +239,8 @@ _vifT void vifUnpackSetup(const u32 *data) { //Ugh things are never easy. //Alright, in most cases with V2 and V3 we only need to know if its offset 32bits. //However in V3-16 if the data it requires ends on a QW boundary of the source data - //the W vector becomes 0, so we need to know how far through the current QW the data begins + //the W vector becomes 0, so we need to know how far through the current QW the data begins. + //same happens with V3 8 vifX.start_aligned = 4-((vifX.vifpacketsize-1) & 0x3); //DevCon.Warning("Aligned %d packetsize at data start %d", vifX.start_aligned, vifX.vifpacketsize - 1); } diff --git a/pcsx2/x86/newVif_Dynarec.cpp b/pcsx2/x86/newVif_Dynarec.cpp index f44206551c..c447b7b110 100644 --- a/pcsx2/x86/newVif_Dynarec.cpp +++ b/pcsx2/x86/newVif_Dynarec.cpp @@ -184,7 +184,7 @@ void VifUnpackSSE_Dynarec::ModUnpack( int upknum, bool PostOp ) case 8: if(PostOp) { UnpkLoopIteration++; UnpkLoopIteration = UnpkLoopIteration & 0x1; } break; case 9: if (!PostOp) { UnpkLoopIteration++; } break; - case 10: break; + case 10:if (!PostOp) { UnpkLoopIteration++; } break; case 12: break; case 13: break; diff --git a/pcsx2/x86/newVif_UnpackSSE.cpp b/pcsx2/x86/newVif_UnpackSSE.cpp index 9aa1faa674..fad4a67ce6 100644 --- a/pcsx2/x86/newVif_UnpackSSE.cpp +++ b/pcsx2/x86/newVif_UnpackSSE.cpp @@ -289,6 +289,8 @@ void VifUnpackSSE_Base::xUPK_V3_8() const { xPUNPCK.LWD(destReg, destReg); xShiftR (destReg, 24); } + if (UnpkLoopIteration != IsAligned) + xAND.PS(destReg, ptr128[SSEXYZWMask[0]]); } void VifUnpackSSE_Base::xUPK_V4_32() const {