Get the offset hack working normally again.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3011 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2010-05-15 04:51:15 +00:00
parent bd2a211144
commit 58697dbe8f
4 changed files with 35 additions and 28 deletions

View File

@ -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);

View File

@ -27,5 +27,6 @@ GSTexture::GSTexture()
, m_size(0, 0)
, m_type(None)
, m_msaa(false)
, LikelyOffset (false)
{
}

View File

@ -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;
};

View File

@ -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)