Skip to content

Commit

Permalink
Testing further tweaks to bring it closer to SW
Browse files Browse the repository at this point in the history
  • Loading branch information
refractionpcsx2 committed Feb 27, 2025
1 parent b6dc088 commit 8f2e653
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5165,20 +5165,25 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
{
if (!m_downscale_source && tex->m_scale > 1.0f)
{
const GSVertex* v = &m_vertex.buff[0];
if (PRIM->FST)
{
m_conf.cb_vs.texture_offset.x = 6.0f + (0.25f * tex->m_scale);
m_conf.cb_vs.texture_offset.y = 6.0f + (0.25f * tex->m_scale);
const int x1_frac = (((v[1].XYZ.X - m_context->XYOFFSET.OFX) >> 4) & 0xf);
const int y1_frac = (((v[1].XYZ.Y - m_context->XYOFFSET.OFY) >> 4) & 0xf);

if (!(x1_frac & 8))
m_conf.cb_vs.texture_offset.x = 6.0f + (0.25f * tex->m_scale);
if (!(y1_frac & 8))
m_conf.cb_vs.texture_offset.y = 6.0f + (0.25f * tex->m_scale);
}
else
{
const GSVertex* v = &m_vertex.buff[0];
const float tw = static_cast<float>(1 << m_cached_ctx.TEX0.TW);
const float th = static_cast<float>(1 << m_cached_ctx.TEX0.TH);
const float q = v[0].RGBAQ.Q;

m_conf.cb_vs.texture_offset.x = 0.5f * q / tw;
m_conf.cb_vs.texture_offset.y = 0.5f * q / th;
m_conf.cb_vs.texture_offset.x = (0.5f * tex->m_scale) * q / tw;
m_conf.cb_vs.texture_offset.y = (0.5f * tex->m_scale) * q / th;
}
}
}
Expand Down Expand Up @@ -5237,14 +5242,18 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
{
if (!m_downscale_source && tex->m_scale > 1.0f)
{
const GSVertex* v = &m_vertex.buff[0];
const int x1_frac = (((v[1].XYZ.X - m_context->XYOFFSET.OFX) >> 4) & 0xf);
const int y1_frac = (((v[1].XYZ.Y - m_context->XYOFFSET.OFY) >> 4) & 0xf);
if (PRIM->FST)
{
m_conf.cb_vs.texture_offset.x = 6.0f + (0.25f * tex->m_scale);
m_conf.cb_vs.texture_offset.y = 6.0f + (0.25f * tex->m_scale);
if (!(x1_frac & 8))
m_conf.cb_vs.texture_offset.x = 6.0f + (0.25f * tex->m_scale);
if (!(y1_frac & 8))
m_conf.cb_vs.texture_offset.y = 6.0f + (0.25f * tex->m_scale);
}
else
{
const GSVertex* v = &m_vertex.buff[0];
const float tw = static_cast<float>(1 << m_cached_ctx.TEX0.TW);
const float th = static_cast<float>(1 << m_cached_ctx.TEX0.TH);
const float q = v[0].RGBAQ.Q;
Expand Down Expand Up @@ -6346,10 +6355,27 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
const int unscaled_y = rt_or_ds ? rt_or_ds->GetUnscaledHeight() : 0;
sx = 2.0f / (unscaled_x << 4);
sy = 2.0f / (unscaled_y << 4);
if ((!tex || !tex->m_from_target || tex->m_scale > 1.0f) && GSConfig.UserHacks_HalfPixelOffset == GSHalfPixelOffset::NativeWTexOffset)

if (GSConfig.UserHacks_HalfPixelOffset == GSHalfPixelOffset::NativeWTexOffset)
{
ox2 = (-1.0f / (unscaled_x * rtscale));
oy2 = (-1.0f / (unscaled_y * rtscale));

// Having the vertex negatively offset is a common thing for copying sprites but this causes problems when upscaling, so we need to further adjust the offset.
if (m_vt.m_primclass == GS_SPRITE_CLASS && rtscale > 1.0f && PRIM->FST)
{
const GSVertex* v = &m_vertex.buff[0];
const int x1_frac = (((v[1].XYZ.X - m_context->XYOFFSET.OFX) >> 4) & 0xf);
const int y1_frac = (((v[1].XYZ.Y - m_context->XYOFFSET.OFY) >> 4) & 0xf);
if (x1_frac & 8)
{
ox2 *= 1.0f + (((x1_frac / 16.0f) - 0.1f) * rtscale);
}
if (y1_frac & 8)
{
oy2 *= 1.0f + (((y1_frac / 16.0f) - 0.1f) * rtscale);
}
}
}
else
{
Expand Down

0 comments on commit 8f2e653

Please sign in to comment.