From dc365e066d3ded8afc7811581be14d9d769bde69 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 25 Sep 2016 16:19:27 +0200 Subject: [PATCH] gsdx tc: remove old plain TEXA hack It must work fine without it now. From the google code comments: It would be nice to test those games * Ar Tonelico 2 (line in sprite regression?) * breath of fire dragon quarter (overlayed user interface in the game) v2: update Dx code to use the good format --- plugins/GSdx/GSRendererDX.cpp | 8 ++++++-- plugins/GSdx/GSRendererHW.cpp | 14 -------------- plugins/GSdx/GSTextureCache.cpp | 28 ++++------------------------ 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index d356cbdb35..a672643172 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -474,8 +474,12 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc { const GSLocalMemory::psm_t &psm = GSLocalMemory::m_psm[m_context->TEX0.PSM]; const GSLocalMemory::psm_t &cpsm = psm.pal > 0 ? GSLocalMemory::m_psm[m_context->TEX0.CPSM] : psm; + // The texture cache will handle various format conversion internally for non-target texture + // After the conversion the texture will be RGBA8 (aka 32 bits) hence the 0 below + int gpu_tex_fmt = (tex->m_target) ? cpsm.fmt : 0; + bool bilinear = m_filter == 2 ? m_vt.IsLinear() : m_filter != 0; - bool simple_sample = !tex->m_palette && cpsm.fmt == 0 && m_context->CLAMP.WMS < 3 && m_context->CLAMP.WMT < 3; + bool simple_sample = !tex->m_palette && gpu_tex_fmt == 0 && m_context->CLAMP.WMS < 3 && m_context->CLAMP.WMT < 3; // Don't force extra filtering on sprite (it creates various upscaling issue) bilinear &= !((m_vt.m_primclass == GS_SPRITE_CLASS) && m_userhacks_round_sprite_offset && !m_vt.IsLinear()); @@ -484,7 +488,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc if (ps_sel.shuffle) { ps_sel.fmt = 0; } else { - ps_sel.fmt = tex->m_palette ? cpsm.fmt | 4 : cpsm.fmt; + ps_sel.fmt = tex->m_palette ? gpu_tex_fmt | 4 : gpu_tex_fmt; } ps_sel.aem = m_env.TEXA.AEM; ps_sel.tfx = m_context->TEX0.TFX; diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index c34c69cb96..8c1edb6c13 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -548,16 +548,8 @@ void GSRendererHW::Draw() m_context->offset.tex = m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM); - /* - - // m_tc->LookupSource will mess with the palette, should not, but we do this after, until it is sorted out - if(tex_psm.pal > 0) - { m_mem.m_clut.Read32(context->TEX0, env.TEXA); - } - - */ GSVector4i r; @@ -565,12 +557,6 @@ void GSRendererHW::Draw() tex = tex_psm.depth ? m_tc->LookupDepthSource(TEX0, env.TEXA, r) : m_tc->LookupSource(TEX0, env.TEXA, r); - // FIXME: Could be removed on openGL - if(tex_psm.pal > 0) - { - m_mem.m_clut.Read32(TEX0, env.TEXA); - } - // Hypothesis: texture shuffle is used as a postprocessing effect so texture will be an old target. // Initially code also tested the RT but it gives too much false-positive // diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 84695dab38..29a7715fb4 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -178,17 +178,8 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con //const GSLocalMemory::psm_t& cpsm = psm.pal > 0 ? GSLocalMemory::m_psm[TEX0.CPSM] : psm; // Until DX is fixed - if (s_IS_OPENGL) { - if(psm_s.pal > 0) - m_renderer->m_mem.m_clut.Read32(TEX0, TEXA); - } else { - GIFRegTEXA plainTEXA; - - plainTEXA.AEM = 1; - plainTEXA.TA0 = 0; - plainTEXA.TA1 = 0x80; - m_renderer->m_mem.m_clut.Read32(TEX0, plainTEXA); - } + if(psm_s.pal > 0) + m_renderer->m_mem.m_clut.Read32(TEX0, TEXA); const uint32* clut = m_renderer->m_mem.m_clut; @@ -1671,17 +1662,6 @@ void GSTextureCache::Source::Flush(uint32 count) GSLocalMemory::readTexture rtx = psm.rtx; - GIFRegTEXA plainTEXA; - - // Until DX is fixed - if (s_IS_OPENGL) { - plainTEXA = m_TEXA; - } else { - plainTEXA.AEM = 1; - plainTEXA.TA0 = 0; - plainTEXA.TA1 = 0x80; - } - if(m_palette) { pitch >>= 2; @@ -1706,13 +1686,13 @@ void GSTextureCache::Source::Flush(uint32 count) if(m_texture->Map(m, &r)) { - (mem.*rtx)(off, r, m.bits, m.pitch, plainTEXA); + (mem.*rtx)(off, r, m.bits, m.pitch, m_TEXA); m_texture->Unmap(); } else { - (mem.*rtx)(off, r, buff, pitch, plainTEXA); + (mem.*rtx)(off, r, buff, pitch, m_TEXA); m_texture->Update(r, buff, pitch); }