Skip to content

Commit

Permalink
GS/HW: Allow bilinear from colour backed Z formats
Browse files Browse the repository at this point in the history
Fixes the haze effect in GTA: San Andreas from being extra blurry.
Improves shadows in Everybody's Golf and Tennis.
  • Loading branch information
stenzek committed Oct 12, 2023
1 parent b092407 commit 99554f5
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4210,10 +4210,10 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
m_conf.ps.wms = (wms & 2 || target_region) ? wms : 0;
m_conf.ps.wmt = (wmt & 2 || target_region) ? wmt : 0;

// Depth + bilinear filtering isn't done yet (And I'm not sure we need it anyway but a game will prove me wrong)
// So of course, GTA set the linear mode, but sampling is done at texel center so it is equivalent to nearest sampling
// Depth + bilinear filtering isn't done yet. But if the game has just set a Z24 swizzle on a colour texture, we can
// just pretend it's not a depth format, since in the texture cache, it's not.
// Other games worth testing: Area 51, Burnout
if (psm.depth && m_vt.IsLinear())
if (psm.depth && m_vt.IsLinear() && tex->GetTexture()->IsDepthStencil())
GL_INS("WARNING: Depth + bilinear filtering not supported");

// Performance note:
Expand Down Expand Up @@ -4293,22 +4293,14 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
}

// Depth format
if (tex->m_texture->GetType() == GSTexture::Type::DepthStencil)
if (tex->m_texture->IsDepthStencil())
{
// Require a float conversion if the texure is a depth format
m_conf.ps.depth_fmt = (psm.bpp == 16) ? 2 : 1;

// Don't force interpolation on depth format
bilinear &= m_vt.IsLinear();
}
else if (psm.depth)
{
// Use Integral scaling
m_conf.ps.depth_fmt = 3;

// Don't force interpolation on depth format
bilinear &= m_vt.IsLinear();
}

const GSVector4 half_pixel = RealignTargetTextureCoordinate(tex);
m_conf.cb_vs.texture_offset = GSVector2(half_pixel.x, half_pixel.y);
Expand Down

0 comments on commit 99554f5

Please sign in to comment.