From 58697dbe8f20be5f3f5a814f8b5cfcb8079fd3b3 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Sat, 15 May 2010 04:51:15 +0000 Subject: [PATCH] GSdx: Get the offset hack working normally again. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3011 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSRendererDX.h | 18 +++++++-------- plugins/GSdx/GSTexture.cpp | 1 + plugins/GSdx/GSTexture.h | 4 ++++ plugins/GSdx/GSTextureCache.cpp | 40 ++++++++++++++++++--------------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index 9da6a6870f..5678e67e0b 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -210,16 +210,14 @@ public: // //The resulting shifted output aligns better with common blending / corona / blurring effects, //but introduces a few bad pixels on the edges. - - // Edit: Moved to CreateSource() in GSTextureCache.cpp - //if (UserHacks_HalfPixelOffset == true) - //{ - // //DX9 has pixelcenter set to 0.0, so give it some value here - // if (m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = oy2 = -0.00035f; } - // - // if (ox != 0) { ox2 *= upscale_Multiplier(); } - // if (oy != 0) { oy2 *= upscale_Multiplier(); } - //} + if (rt->LikelyOffset == true) + { + //DX9 has pixelcenter set to 0.0, so give it some value here + if (m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } + + ox2 *= rt->OffsetHack_modx; + oy2 *= rt->OffsetHack_mody; + } vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); diff --git a/plugins/GSdx/GSTexture.cpp b/plugins/GSdx/GSTexture.cpp index 885cf5fa79..45d0647979 100644 --- a/plugins/GSdx/GSTexture.cpp +++ b/plugins/GSdx/GSTexture.cpp @@ -27,5 +27,6 @@ GSTexture::GSTexture() , m_size(0, 0) , m_type(None) , m_msaa(false) + , LikelyOffset (false) { } diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index 1f66740a91..968a648690 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -59,4 +59,8 @@ public: int GetFormat() const {return m_format;} bool IsMSAA() const {return m_msaa;} + + bool LikelyOffset; + float OffsetHack_modx; + float OffsetHack_mody; }; diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 74056740c1..8abbbb7217 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -656,24 +656,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con } GSVector4 sr(0, 0, w, h); - - if (UserHacks_HalfPixelOffset && hack) - { - int multiplier = m_renderer->upscale_Multiplier(); - float modx; - float mody; - switch (multiplier) - { - case 2: modx = 1.0f; mody = 0.8f; break; - case 3: modx = 1.7f; mody = 1.5f; break; - case 4: modx = 2.5f; mody = 2.3f; break; - case 5: modx = 3.5f; mody = 3.2f; break; - case 6: modx = 4.3f; mody = 4.0f; break; - default: modx = 0.0f; mody = 0.0f; break; - } - sr -= GSVector4 (0.0f, 0.0f, modx, mody); - } - + GSTexture* st = src->m_texture ? src->m_texture : dst->m_texture; GSTexture* dt = m_renderer->m_dev->CreateRenderTarget(w, h, false); @@ -746,6 +729,27 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con dst->m_texture = tmp; } + + // Offset hack. Can be enabled via GSdx options. + // The offset will be used in Draw(). + float modx = 0.0f; + float mody = 0.0f; + if (UserHacks_HalfPixelOffset && hack) + { + int multiplier = m_renderer->upscale_Multiplier(); + switch (multiplier) + { + case 2: modx = 2.2f; mody = 2.2f; dst->m_texture->LikelyOffset = true; break; + case 3: modx = 3.1f; mody = 3.1f; dst->m_texture->LikelyOffset = true; break; + case 4: modx = 4.2f; mody = 4.2f; dst->m_texture->LikelyOffset = true; break; + case 5: modx = 5.3f; mody = 5.3f; dst->m_texture->LikelyOffset = true; break; + case 6: modx = 6.2f; mody = 6.2f; dst->m_texture->LikelyOffset = true; break; + default: modx = 0.0f; mody = 0.0f; dst->m_texture->LikelyOffset = false; break; + } + } + dst->m_texture->OffsetHack_modx = modx; + dst->m_texture->OffsetHack_mody = mody; + } if(src->m_texture == NULL)