Skip to content

Commit

Permalink
GS: Further transfer optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
refractionpcsx2 committed Oct 3, 2023
1 parent 2dc3bf1 commit f8c1b84
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 124 deletions.
38 changes: 19 additions & 19 deletions pcsx2/GS/GSRegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,6 @@ struct alignas(32) GIFPath

enum
{
TYPE_UNKNOWN,
TYPE_ADONLY,
TYPE_STQRGBAXYZF2,
TYPE_STQRGBAXYZ2,
TYPE_UVRGBAXYZ2,
Expand All @@ -1145,6 +1143,8 @@ struct alignas(32) GIFPath
TYPE_STQXYZ2,
TYPE_RGBAUVXYZF2,
TYPE_UVRGBAXYZF2,
TYPE_ADONLY,
TYPE_UNKNOWN,
};

__forceinline void SetTag(const void* mem)
Expand All @@ -1153,8 +1153,8 @@ struct alignas(32) GIFPath

// the compiler has a hard time not reloading every time a field of src is accessed

u32 a = src->U32[0];
u32 b = src->U32[1];
const u32 a = src->U32[0];
const u32 b = src->U32[1];

tag.U32[0] = a;
tag.U32[1] = b;
Expand All @@ -1164,7 +1164,7 @@ struct alignas(32) GIFPath
if (nloop == 0)
return;

GSVector4i v = GSVector4i::loadl(&src->REGS); // REGS not stored to tag.REGS, only into this->regs, restored before saving the state though
const GSVector4i v = GSVector4i::loadl(&src->REGS); // REGS not stored to tag.REGS, only into this->regs, restored before saving the state though

nreg = (b & 0xf0000000) ? (b >> 28) : 16; // src->NREG
regs = v.upl8(v >> 4) & GSVector4i::x0f(nreg);
Expand All @@ -1178,49 +1178,49 @@ struct alignas(32) GIFPath
{
type = TYPE_ADONLY;
}
else
else if(nloop > 4)
{
switch (nreg)
{
case 1:
break;
case 2:
if (regs.eq8(GSVector4i::cxpr(0x00000401)).mask() == (1 << 2) - 1)
if (regs.U32[0] == 0x00000401)
type = TYPE_RGBAXYZF2;
else if (regs.eq8(GSVector4i::cxpr(0x0000040)).mask() == (1 << 2) - 1)
else if (regs.U32[0] == 0x00000403)
type = TYPE_STQXYZF2;
else if (regs.eq8(GSVector4i::cxpr(0x00000402)).mask() == (1 << 2) - 13)
else if (regs.U32[0] == 0x00000402)
type = TYPE_UVXYZF2;
else if (regs.eq8(GSVector4i::cxpr(0x00000501)).mask() == (1 << 2) - 1)
else if (regs.U32[0] == 0x00000501)
type = TYPE_RGBAXYZ2;
else if (regs.eq8(GSVector4i::cxpr(0x00000502)).mask() == (1 << 2) - 1)
else if (regs.U32[0] == 0x00000502)
type = TYPE_STQXYZ2;
else if (regs.eq8(GSVector4i::cxpr(0x00000503)).mask() == (1 << 2) - 1)
else if (regs.U32[0] == 0x00000503)
type = TYPE_UVXYZ2;
break;
case 3:
// many games, TODO: formats mixed with NOPs (xeno2: 040f010f02, 04010f020f, mgs3: 04010f0f02, 0401020f0f, 04010f020f)
if (regs.eq8(GSVector4i::cxpr(0x00040102)).mask() == (1 << 3) - 1)
if (regs.U32[0] == 0x00040102)
type = TYPE_STQRGBAXYZF2;
// GoW (has other crazy formats, like ...030503050103)
else if (regs.eq8(GSVector4i::cxpr(0x00050102)).mask() == (1 << 3) - 1)
else if (regs.U32[0] == 0x00050102)
type = TYPE_STQRGBAXYZ2;
// TODO: common types with UV instead
else if (regs.eq8(GSVector4i::cxpr(0x00050103)).mask() == (1 << 3) - 1)
else if (regs.U32[0] == 0x00050103)
type = TYPE_UVRGBAXYZ2;
else if (regs.eq8(GSVector4i::cxpr(0x00040103)).mask() == (1 << 3) - 1)
else if (regs.U32[0] == 0x00040103)
type = TYPE_UVRGBAXYZF2;
else if (regs.eq8(GSVector4i::cxpr(0x00040301)).mask() == (1 << 3) - 1)
else if (regs.U32[0] == 0x00040301)
type = TYPE_RGBAUVXYZF2;
break;
case 4:
if (regs.eq8(GSVector4i(0x04030403)).mask() == (1 << 4) - 1)
if (regs.U32[0] == 0x04030403)
{
type = TYPE_UVXYZF2;
nreg = 2;
nloop *= 2;
}
else if (regs.eq8(GSVector4i::cxpr(0x05030503)).mask() == (1 << 4) - 1)
else if (regs.U32[0] == 0x05030503)
{
type = TYPE_UVXYZ2;
nreg = 2;
Expand Down
Loading

0 comments on commit f8c1b84

Please sign in to comment.