diff --git a/plugins/GSdx/GSDrawingContext.cpp b/plugins/GSdx/GSDrawingContext.cpp index 6fb066bd36..cb70ea406c 100644 --- a/plugins/GSdx/GSDrawingContext.cpp +++ b/plugins/GSdx/GSDrawingContext.cpp @@ -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); + } +} diff --git a/plugins/GSdx/GSDrawingContext.h b/plugins/GSdx/GSDrawingContext.h index 4cdd59f38b..84964aad3e 100644 --- a/plugins/GSdx/GSDrawingContext.h +++ b/plugins/GSdx/GSDrawingContext.h @@ -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() diff --git a/plugins/GSdx/Renderers/HW/GSRendererHW.cpp b/plugins/GSdx/Renderers/HW/GSRendererHW.cpp index 584fd53970..3543934d32 100644 --- a/plugins/GSdx/Renderers/HW/GSRendererHW.cpp +++ b/plugins/GSdx/Renderers/HW/GSRendererHW.cpp @@ -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