Permalink
Browse files

gsdx: Handle illegal 8 bits format. Found the most silly GS dev trick

Fix Berserk #1526 Well done guys but we're more clever than you ;)

So instead to mask the color channels as any guy that RTFM, they decided to use the illegal 8H frame format
  • Loading branch information...
gregory38 committed Oct 3, 2016
1 parent 6fd46eb commit 9b93c073390de7c5f88e944bc9d26f9cf17ba9ee
Showing with 14 additions and 1 deletion.
  1. +14 −1 plugins/GSdx/GSState.cpp
@@ -1285,9 +1285,16 @@ template<int i> void GSState::GIFRegHandlerFRAME(const GIFReg* RESTRICT r)
m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset(r->FRAME, m_env.CTXT[i].ZBUF);
m_env.CTXT[i].offset.fzb4 = m_mem.GetPixelOffset4(r->FRAME, m_env.CTXT[i].ZBUF);
}

m_env.CTXT[i].FRAME = (GSVector4i)r->FRAME;

// Berserk uses the format to only update the alpha channel
if (m_env.CTXT[i].FRAME.PSM == PSM_PSMT8H) {
GL_INS("CORRECT FRAME FORMAT replaces PSM_PSMT8H by PSM_PSMCT32/0x00FF_FFFF");
m_env.CTXT[i].FRAME.PSM = PSM_PSMCT32;
m_env.CTXT[i].FRAME.FBMSK = 0x00FFFFFF;
}

#ifdef DISABLE_BITMASKING
m_env.CTXT[i].FRAME.FBMSK = GSVector4i::store(GSVector4i::load((int)m_env.CTXT[i].FRAME.FBMSK).eq8(GSVector4i::xffffffff()));
#endif
@@ -1570,6 +1577,12 @@ void GSState::FlushPrim()
m_perfmon.Put(GSPerfMon::Draw, 1);
m_perfmon.Put(GSPerfMon::Prim, m_index.tail / GSUtil::GetVertexCount(PRIM->PRIM));
}
else
{
#ifdef ENABLE_OGL_DEBUG
fprintf(stderr, "%d:Skip draw call due to invalid format %x/%x\n", s_n, m_context->FRAME.PSM, m_context->ZBUF.PSM);
#endif
}

m_index.tail = 0;

0 comments on commit 9b93c07

Please sign in to comment.