[CPU] Fix saturation in D3DCOLOR vpkd3d

This commit is contained in:
Triang3l 2019-01-13 17:29:06 +03:00
parent ae6fd98c3c
commit 949b05f517
1 changed files with 5 additions and 3 deletions

View File

@ -1843,9 +1843,11 @@ struct PACK : Sequence<PACK, I<OPCODE_PACK, V128Op, V128Op, V128Op>> {
src = i.src1; src = i.src1;
} }
// Saturate to [3,3....] so that only values between 3...[00] and 3...[FF] // Saturate to [3,3....] so that only values between 3...[00] and 3...[FF]
// are valid. // are valid - max before min to pack NaN as zero (Red Dead Redemption is
e.vminps(i.dest, src, e.GetXmmConstPtr(XMMPackD3DCOLORSat)); // heavily affected by the order - packs 0xFFFFFFFF in matrix code to get 0
e.vmaxps(i.dest, i.dest, e.GetXmmConstPtr(XMM3333)); // constant).
e.vmaxps(i.dest, src, e.GetXmmConstPtr(XMM3333));
e.vminps(i.dest, i.dest, e.GetXmmConstPtr(XMMPackD3DCOLORSat));
// Extract bytes. // Extract bytes.
// RGBA (XYZW) -> ARGB (WXYZ) // RGBA (XYZW) -> ARGB (WXYZ)
// w = ((src1.uw & 0xFF) << 24) | ((src1.ux & 0xFF) << 16) | // w = ((src1.uw & 0xFF) << 24) | ((src1.ux & 0xFF) << 16) |