gsdx: add a function to fix the TEX0 register value for HW renderer

Based on the SW renderer
This commit is contained in:
Gregory Hainaut 2019-02-15 14:35:21 +01:00 committed by lightningterror
parent 6df9eb8dab
commit 12dcb701c7
3 changed files with 35 additions and 0 deletions

View File

@ -137,3 +137,26 @@ GIFRegTEX0 GSDrawingContext::GetSizeFixedTEX0(int s_n, const GSVector4& st, bool
return res;
}
void GSDrawingContext::ComputeFixedTEX0(const GSVector4& st, bool linear)
{
GIFRegTEX0 reg = GetSizeFixedTEX0(0, st, linear, false);
if (reg.TW > TEX0.TW)
{
m_fixed_tex0 = true;
TEX0.TW = reg.TW;
}
if (reg.TH > TEX0.TH)
{
m_fixed_tex0 = true;
TEX0.TH = reg.TH;
}
if (m_fixed_tex0)
{
GL_INS("FixedTEX0 TW %d=>%d, TH %d=>%d wm %d,%d",
(int)stack.TEX0.TW, (int)TEX0.TW, (int)stack.TEX0.TH, (int)TEX0.TH,
(int)CLAMP.WMS, (int)CLAMP.WMT);
}
}

View File

@ -75,8 +75,12 @@ public:
GIFRegZBUF ZBUF;
} stack;
bool m_fixed_tex0;
GSDrawingContext()
{
m_fixed_tex0 = false;
memset(&offset, 0, sizeof(offset));
Reset();
@ -144,6 +148,7 @@ public:
GIFRegTEX0 GetSizeFixedTEX0(int s_n, const GSVector4& st, bool linear, bool mipmap = false);
void ComputeFixedTEX0(const GSVector4& st, bool linear);
bool HasFixedTEX0() const { return m_fixed_tex0;}
// Save & Restore before/after draw allow to correct/optimize current register for current draw
// Note: we could avoid the restore part if all renderer code is updated to use a local copy instead
@ -162,6 +167,9 @@ public:
stack.FBA = FBA;
stack.FRAME = FRAME;
stack.ZBUF = ZBUF;
// This function is called before the draw so take opportunity to reset m_fixed_tex0
m_fixed_tex0 = false;
}
void RestoreReg()

View File

@ -702,6 +702,10 @@ void GSRendererHW::Draw()
GSDrawingContext* context = m_context;
const GSLocalMemory::psm_t& tex_psm = GSLocalMemory::m_psm[m_context->TEX0.PSM];
// Fix TEX0 size
if(PRIM->TME && !IsMipMapActive())
m_context->ComputeFixedTEX0(m_vt.m_min.t.xyxy(m_vt.m_max.t), m_vt.IsLinear());
// skip alpha test if possible
// Note: do it first so we know if frame/depth writes are masked