GS/HW: Use sampler for clamp/repeat when it's redundant

But only for local memory sources (not targets), it causes issues with
upscaling otherwise.
This commit is contained in:
Stenzek 2023-02-10 00:34:16 +10:00 committed by refractionpcsx2
parent 5b5edc506d
commit 9b1163f959
1 changed files with 8 additions and 4 deletions

View File

@ -3142,11 +3142,15 @@ void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Source* tex)
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[tex->m_TEX0.PSM];
const GSLocalMemory::psm_t& cpsm = psm.pal > 0 ? GSLocalMemory::m_psm[m_context->TEX0.CPSM] : psm;
// Redundant clamp tests are restricted to local memory/1x sources only, if we're from a target,
// we keep the shader clamp. See #5851 on github, and the note in Draw().
[[maybe_unused]] static constexpr const char* clamp_modes[] = { "REPEAT", "CLAMP", "REGION_CLAMP", "REGION_REPEAT" };
const bool redundant_wms = IsRedundantClamp(m_context->CLAMP.WMS, m_context->CLAMP.MINU, m_context->CLAMP.MAXU, tex->m_TEX0.TW);
const bool redundant_wmt = IsRedundantClamp(m_context->CLAMP.WMT, m_context->CLAMP.MINV, m_context->CLAMP.MAXV, tex->m_TEX0.TH);
const u8 wms = EffectiveClamp(m_context->CLAMP.WMS, tex->m_region.HasX());
const u8 wmt = EffectiveClamp(m_context->CLAMP.WMT, tex->m_region.HasY());
const bool redundant_wms = !tex->m_target && IsRedundantClamp(m_context->CLAMP.WMS, m_context->CLAMP.MINU,
m_context->CLAMP.MAXU, tex->m_TEX0.TW);
const bool redundant_wmt = !tex->m_target && IsRedundantClamp(m_context->CLAMP.WMT, m_context->CLAMP.MINV,
m_context->CLAMP.MAXV, tex->m_TEX0.TH);
const u8 wms = EffectiveClamp(m_context->CLAMP.WMS, tex->m_region.HasX() || redundant_wms);
const u8 wmt = EffectiveClamp(m_context->CLAMP.WMT, tex->m_region.HasY() || redundant_wmt);
const bool complex_wms_wmt = !!((wms | wmt) & 2);
GL_CACHE("WMS: %s [%s%s] WMT: %s [%s%s] Complex: %d MINU: %d MINV: %d MINV: %d MAXV: %d",
clamp_modes[m_context->CLAMP.WMS], redundant_wms ? "redundant," : "", clamp_modes[wms],