Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS: Some cleanup to GSClut. #10311

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions pcsx2/GS/GSClut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ bool GSClut::CanLoadCLUT(const GIFRegTEX0& TEX0, const bool update_CBP)
switch (TEX0.CLD)
{
case 0:
case 6: // FFX2 menu.
case 7: // Ford Mustang Racing, Bouken Jidai Katsugeki Goemon.
return false;
case 1:
break;
Expand All @@ -199,10 +201,6 @@ bool GSClut::CanLoadCLUT(const GIFRegTEX0& TEX0, const bool update_CBP)
if (update_CBP)
m_CBP[1] = TEX0.CBP;
break;
case 6:
return false; // ffx2 menu.
case 7:
return false; // ford mustang racing // Bouken Jidai Katsugeki Goemon.
default:
__assume(0);
}
Expand Down Expand Up @@ -288,8 +286,8 @@ void GSClut::WriteCLUT32_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCL
template <int n>
void GSClut::WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
GSOffset off = GSOffset::fromKnownPSM(TEX0.CBP, TEXCLUT.CBW, PSMCT16);
GSOffset::PAHelper pa = off.paMulti(TEXCLUT.COU << 4, TEXCLUT.COV);
const GSOffset off = GSOffset::fromKnownPSM(TEX0.CBP, TEXCLUT.CBW, PSMCT16);
const GSOffset::PAHelper pa = off.paMulti(TEXCLUT.COU << 4, TEXCLUT.COV);

u16* vm = m_mem->vm16();
u16* RESTRICT clut = m_clut + (TEX0.CSA << 4);
Expand All @@ -303,8 +301,8 @@ void GSClut::WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCL
template <int n>
void GSClut::WriteCLUT16S_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
GSOffset off = GSOffset::fromKnownPSM(TEX0.CBP, TEXCLUT.CBW, PSMCT16S);
GSOffset::PAHelper pa = off.paMulti(TEXCLUT.COU << 4, TEXCLUT.COV);
const GSOffset off = GSOffset::fromKnownPSM(TEX0.CBP, TEXCLUT.CBW, PSMCT16S);
const GSOffset::PAHelper pa = off.paMulti(TEXCLUT.COU << 4, TEXCLUT.COV);

u16* vm = m_mem->vm16();
u16* RESTRICT clut = m_clut + (TEX0.CSA << 4);
Expand Down Expand Up @@ -447,7 +445,7 @@ void GSClut::Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
if (src)
{
GSTexture* dst = is_4bit ? m_gpu_clut4 : m_gpu_clut8;
u32 dst_size = is_4bit ? 16 : 256;
const u32 dst_size = is_4bit ? 16 : 256;
const u32 dOffset = (TEX0.CSA & ((TEX0.CPSM == PSMCT16 || TEX0.CPSM == PSMCT16S) ? 15u : 31u)) << 4;
if (!dst)
{
Expand Down Expand Up @@ -507,9 +505,9 @@ void GSClut::GetAlphaMinMax32(int& amin_out, int& amax_out)
{
ASSERT(GSLocalMemory::m_psm[m_read.TEX0.PSM].pal == 16);

GSVector4i v0 = (p[0] >> 24).ps32(p[1] >> 24);
GSVector4i v1 = (p[2] >> 24).ps32(p[3] >> 24);
GSVector4i v2 = v0.pu16(v1);
const GSVector4i v0 = (p[0] >> 24).ps32(p[1] >> 24);
const GSVector4i v1 = (p[2] >> 24).ps32(p[3] >> 24);
const GSVector4i v2 = v0.pu16(v1);

amin = v2;
amax = v2;
Expand All @@ -522,8 +520,8 @@ void GSClut::GetAlphaMinMax32(int& amin_out, int& amax_out)
amin = amin.min_u8(amin.yxwzl());
amax = amax.max_u8(amax.yxwzl());

GSVector4i v0 = amin.upl8(amax).u8to16();
GSVector4i v1 = v0.yxwz();
const GSVector4i v0 = amin.upl8(amax).u8to16();
const GSVector4i v1 = v0.yxwz();

m_read.amin = v0.min_i16(v1).extract16<0>();
m_read.amax = v0.max_i16(v1).extract16<1>();
Expand Down Expand Up @@ -742,10 +740,10 @@ void GSClut::ExpandCLUT64_T32_I8(const u32* RESTRICT src, u64* RESTRICT dst)
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;

GSVector4i s0 = s[0];
GSVector4i s1 = s[1];
GSVector4i s2 = s[2];
GSVector4i s3 = s[3];
const GSVector4i s0 = s[0];
const GSVector4i s1 = s[1];
const GSVector4i s2 = s[2];
const GSVector4i s3 = s[3];

ExpandCLUT64_T32(s0, s0, s1, s2, s3, &d[0]);
ExpandCLUT64_T32(s1, s0, s1, s2, s3, &d[32]);
Expand Down Expand Up @@ -837,8 +835,8 @@ void GSClut::Expand16(const u16* RESTRICT src, u32* RESTRICT dst, int w, const G
const GSVector4i gm = m_gm;
const GSVector4i bm = m_bm;

GSVector4i TA0(TEXA.TA0 << 24);
GSVector4i TA1(TEXA.TA1 << 24);
const GSVector4i TA0(TEXA.TA0 << 24);
const GSVector4i TA1(TEXA.TA1 << 24);

GSVector4i c, cl, ch;

Expand Down