Skip to content

Commit

Permalink
Revert "gsdx state: TEX0 write behavior might depends on the context"
Browse files Browse the repository at this point in the history
This reverts commit b34243f.

Unfortunately we have a regression on GT4. I'm doomed
  • Loading branch information
gregory38 committed Sep 28, 2016
1 parent 90ad9cf commit 8d4fadb
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions plugins/GSdx/GSState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,7 @@ void GSState::GIFRegHandlerXYZ2(const GIFReg* RESTRICT r)

template<int i> void GSState::ApplyTEX0(GIFRegTEX0& TEX0)
{
// Mask invalid bit before any comparison
TEX0.CPSM &= 0xa; // 1010b
// even if TEX0 did not change, a new palette may have been uploaded and will overwrite the currently queued for drawing

// Handle invalid PSM here
switch (TEX0.PSM) {
Expand All @@ -848,20 +847,6 @@ template<int i> void GSState::ApplyTEX0(GIFRegTEX0& TEX0)
break;
}

if (PRIM->CTXT != i) {
// Context isn't current. Only update the register value.
// Handling (real write of the clut buffer) will be done when ctxt will be switched
if((TEX0.u32[0] ^ m_env.CTXT[i].TEX0.u32[0]) & 0x3ffffff) // TBP0 TBW PSM
{
m_env.CTXT[i].offset.tex = m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
}

m_env.CTXT[i].TEX0 = (GSVector4i)TEX0;
return;
}

// even if TEX0 did not change, a new palette may have been uploaded and will overwrite the currently queued for drawing

bool wt = m_mem.m_clut.WriteTest(TEX0, m_env.TEXCLUT);

// clut loading already covered with WriteTest, for drawing only have to check CPSM and CSA (MGS3 intro skybox would be drawn piece by piece without this)
Expand All @@ -873,6 +858,7 @@ template<int i> void GSState::ApplyTEX0(GIFRegTEX0& TEX0)
Flush();
}

TEX0.CPSM &= 0xa; // 1010b

if((TEX0.u32[0] ^ m_env.CTXT[i].TEX0.u32[0]) & 0x3ffffff) // TBP0 TBW PSM
{
Expand Down Expand Up @@ -2446,21 +2432,9 @@ void GSState::SetGameCRC(uint32 crc, int options)

void GSState::UpdateContext()
{
bool context_switch = (m_context != &m_env.CTXT[PRIM->CTXT]);

m_context = &m_env.CTXT[PRIM->CTXT];

UpdateScissor();

if (context_switch) {
// Harley davidson sets TEX0 register before the context. Re-apply it now
// so clut is properly loaded
if (m_context == &m_env.CTXT[1]) {
ApplyTEX0<1>(m_env.CTXT[PRIM->CTXT].TEX0);
} else {
ApplyTEX0<0>(m_env.CTXT[PRIM->CTXT].TEX0);
}
}
}

void GSState::UpdateScissor()
Expand Down

1 comment on commit 8d4fadb

@ramapcsx2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're doing great @gregory38. I'm sure you'll nail it ;p

Please sign in to comment.