Skip to content

Commit

Permalink
GS/HW: Restore off-by-one clamp when upscaling
Browse files Browse the repository at this point in the history
Xenosaga and VP2 break otherwise.

Xenosaga draws a line around the RT, which is offset by 1 row/column,
which the off-by-one clamp was previously masking.

VP2 is just a can of worms I don't have the energy to deal with at the
moment.
  • Loading branch information
stenzek committed Oct 15, 2023
1 parent 3270a38 commit d1d9903
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4377,10 +4377,13 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
if (complex_wms_wmt)
{
// Add 0.5 to the coordinates because the region clamp is inclusive, size is exclusive. We use 0.5 because we want to clamp
// to the last texel in the image, not halfway between it and wrapping around.
// to the last texel in the image, not halfway between it and wrapping around. We *should* be doing this when upscaling,
// but having it off-by-one masks some draw issues in VP2 and Xenosaga. TODO: Fix the underlying draw issues.
const GSVector4i clamp(m_cached_ctx.CLAMP.MINU, m_cached_ctx.CLAMP.MINV, m_cached_ctx.CLAMP.MAXU, m_cached_ctx.CLAMP.MAXV);
const GSVector4 region_repeat = GSVector4::cast(clamp);
const GSVector4 region_clamp = (GSVector4(clamp) + GSVector4::cxpr(0.0f, 0.0f, 0.5f, 0.5f)) / WH.xyxy();
const GSVector4 region_clamp_offset =
(tex->GetScale() != 1.0f) ? GSVector4::cxpr(0.0f, 0.0f, 0.0f, 0.0f) : GSVector4::cxpr(0.0f, 0.0f, 0.5f, 0.5f);
const GSVector4 region_clamp = (GSVector4(clamp) + region_clamp_offset) / WH.xyxy();
if (wms >= CLAMP_REGION_CLAMP)
{
m_conf.cb_ps.MinMax.x = (wms == CLAMP_REGION_CLAMP && !m_conf.ps.depth_fmt) ? region_clamp.x : region_repeat.x;
Expand Down

0 comments on commit d1d9903

Please sign in to comment.