From 949b05f517ee0147c422804b603aa14fba1df020 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 13 Jan 2019 17:29:06 +0300 Subject: [PATCH] [CPU] Fix saturation in D3DCOLOR vpkd3d --- src/xenia/cpu/backend/x64/x64_seq_vector.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xenia/cpu/backend/x64/x64_seq_vector.cc b/src/xenia/cpu/backend/x64/x64_seq_vector.cc index 89d3bee14..8c157d7e2 100644 --- a/src/xenia/cpu/backend/x64/x64_seq_vector.cc +++ b/src/xenia/cpu/backend/x64/x64_seq_vector.cc @@ -1843,9 +1843,11 @@ struct PACK : Sequence> { src = i.src1; } // Saturate to [3,3....] so that only values between 3...[00] and 3...[FF] - // are valid. - e.vminps(i.dest, src, e.GetXmmConstPtr(XMMPackD3DCOLORSat)); - e.vmaxps(i.dest, i.dest, e.GetXmmConstPtr(XMM3333)); + // are valid - max before min to pack NaN as zero (Red Dead Redemption is + // heavily affected by the order - packs 0xFFFFFFFF in matrix code to get 0 + // constant). + e.vmaxps(i.dest, src, e.GetXmmConstPtr(XMM3333)); + e.vminps(i.dest, i.dest, e.GetXmmConstPtr(XMMPackD3DCOLORSat)); // Extract bytes. // RGBA (XYZW) -> ARGB (WXYZ) // w = ((src1.uw & 0xFF) << 24) | ((src1.ux & 0xFF) << 16) |