gsdx-texture-cache: Improve fix for snow engine game

Instead to hardcode the half-buffer size to 0x140, the new code
compute it.

To avoid regression, I limit the code to big target (>= 1024 pixels)
This commit is contained in:
Gregory Hainaut 2015-06-03 08:40:49 +02:00
parent 65b83a36a7
commit 7d124e6a83
1 changed files with 10 additions and 13 deletions

View File

@ -134,12 +134,10 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
break; break;
} else if ((t->m_TEX0.TBW == 20) && (t->m_TEX0.PSM == 2) && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0 + 0x140, t->m_TEX0.PSM)) { } else if ((t->m_TEX0.TBW >= 16) && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0 + t->m_TEX0.TBW * 0x10, t->m_TEX0.PSM)) {
// try to detect render target bigger than 1024 Texels // Detect half of the render target (fix snow engine game)
// 0x140: In 16 bits format, pages are 64 pixels and 8KB // Target Page (8KB) have always a width of 64 pixels
// Half of 1280 is 640 so 10 pages // Half of the Target is TBW/2 pages * 8KB / (1 block * 256B) = 0x10
// TBP0 unit is block of 256B => (10 pages * 8 KB) / (1 block * 256B) = 320 = 0x140
half_right = true; half_right = true;
dst = t; dst = t;
@ -154,7 +152,7 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
{ {
#ifdef ENABLE_OGL_DEBUG #ifdef ENABLE_OGL_DEBUG
if (dst) { if (dst) {
GL_CACHE("TC: dst hit: %d (0x%x)", GL_CACHE("TC: dst hit (%s): %d (0x%x)", half_right ? "half" : "full",
dst->m_texture ? dst->m_texture->GetID() : 0, dst->m_texture ? dst->m_texture->GetID() : 0,
TEX0.TBP0); TEX0.TBP0);
} else { } else {
@ -364,12 +362,11 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b
} }
} }
if ((bw == 20) && (psm == 2)) { if (bw >= 16) {
// try to detect render target bigger than 1024 Texels // Detect half of the render target (fix snow engine game)
// 0x140: In 16 bits format, pages are 64 pixels and 8KB // Target Page (8KB) have always a width of 64 pixels
// Half of 1280 is 640 so 10 pages // Half of the Target is TBW/2 pages * 8KB / (1 block * 256B) = 0x10
// TBP0 unit is block of 256B => (10 pages * 8 KB) / (1 block * 256B) = 320 = 0x140 uint32 bbp = bp + bw * 0x10;
uint32 bbp = bp + 0x140;
const list<Source*>& m = m_src.m_map[bbp >> 5]; const list<Source*>& m = m_src.m_map[bbp >> 5];