From b722dfd013862d9e346091acbcfc76b943214dda Mon Sep 17 00:00:00 2001 From: "sudonim1@gmail.com" Date: Mon, 11 Jun 2012 10:57:32 +0000 Subject: [PATCH] GSDX: Added a compatibility check to the framebuffer handling for the texture cache and made it preferred and added a writeback as a fallback. Compat should be back to normal? git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5288 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSTextureCache.cpp | 45 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 723293bf0a..7a1ae9d91c 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -132,17 +132,14 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con } } - if(psm.pal > 0) + if (src->m_palette) { int size = psm.pal * sizeof(clut[0]); - if(src->m_palette) + if(src->m_initpalette || !GSVector4i::update(src->m_clut, clut, size)) { - if(src->m_initpalette || !GSVector4i::update(src->m_clut, clut, size)) - { - src->m_palette->Update(GSVector4i(0, 0, psm.pal, 1), src->m_clut, size); - src->m_initpalette = false; - } + src->m_palette->Update(GSVector4i(0, 0, psm.pal, 1), src->m_clut, size); + src->m_initpalette = false; } } @@ -595,16 +592,9 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con else src->m_spritehack_t = false; - if (m_paltex && psm.pal > 0) - { - src->m_texture = m_renderer->m_dev->CreateTexture(tw, th, Get8bitFormat()); - src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); - } - else if (dst == NULL || dst->m_type != RenderTarget /* TODO */) - { - src->m_texture = m_renderer->m_dev->CreateTexture(tw, th); - } - else + if (dst && dst->m_type == RenderTarget + && (dst->m_TEX0.PSM == TEX0.PSM || dst->m_TEX0.PSM == PSM_PSMCT32 && TEX0.PSM == PSM_PSMCT24 + || m_paltex && dst->m_TEX0.PSM == PSM_PSMCT32 && TEX0.PSM == PSM_PSMT8H)) { // TODO: clean up this mess @@ -709,7 +699,14 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con GSVector4 sr(0, 0, w, h); GSTexture* st = src->m_texture ? src->m_texture : dst->m_texture; - GSTexture* dt = m_renderer->m_dev->CreateRenderTarget(w, h, false); + GSTexture *dt; + if (m_paltex && psm.pal > 0) + { + dt = m_renderer->m_dev->CreateRenderTarget(w, h, false, Get8bitFormat()); + src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); + } + else + dt = m_renderer->m_dev->CreateRenderTarget(w, h, false); if(!src->m_texture) { @@ -769,6 +766,18 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con dst->m_texture->OffsetHack_modx = modx; dst->m_texture->OffsetHack_mody = mody; } + else + { + if (dst) + Read(dst, dst->m_valid); + if (m_paltex && psm.pal > 0) + { + src->m_texture = m_renderer->m_dev->CreateTexture(tw, th, Get8bitFormat()); + src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); + } + else + src->m_texture = m_renderer->m_dev->CreateTexture(tw, th); + } if(src->m_texture == NULL) {