Skip to content

Commit

Permalink
GS/TextureCache: Remove redundant parameter to RTA{De,C}orrect
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Apr 1, 2024
1 parent c9fdd01 commit 64a471b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 43 deletions.
6 changes: 1 addition & 5 deletions pcsx2/GS/Renderers/HW/GSHwHack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,7 @@ bool GSHwHack::MV_Ico(GSRendererHW& r)
const GSVector4i draw_rc = GSVector4i(0, 0, RWIDTH, RHEIGHT).rintersect(dst->GetUnscaledRect());
dst->UpdateValidChannels(PSMCT32, 0);
dst->UpdateValidity(draw_rc);

if (dst->m_rt_alpha_scale)
{
dst->RTADecorrect(dst);
}
dst->RTADecorrect();

GSHWDrawConfig& config = GSRendererHW::GetInstance()->BeginHLEHardwareDraw(
dst->GetTexture(), nullptr, dst->GetScale(), src->GetTexture(), src->GetScale(), draw_rc);
Expand Down
14 changes: 7 additions & 7 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4368,7 +4368,7 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, bool& DAT
const bool rta_correction = m_can_correct_alpha && !blend_ad_alpha_masked && m_conf.ps.blend_c == 1 && !(blend_flag & BLEND_A_MAX);
if (rta_correction)
{
rt->RTACorrect(rt);
rt->RTACorrect();
m_conf.ps.rta_correction = rt->m_rt_alpha_scale;
m_conf.rt = rt->m_texture;
}
Expand Down Expand Up @@ -5411,7 +5411,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
{
m_can_correct_alpha = false;

rt->RTADecorrect(rt);
rt->RTADecorrect();
m_conf.rt = rt->m_texture;

if (req_src_update)
Expand All @@ -5427,7 +5427,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
else if (m_cached_ctx.FRAME.FBMSK & 0xFFFC0000)
{
m_can_correct_alpha = false;
rt->RTADecorrect(rt);
rt->RTADecorrect();
m_conf.rt = rt->m_texture;

if (req_src_update)
Expand All @@ -5440,7 +5440,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
if (m_conf.ps.tales_of_abyss_hle || (tex && tex->m_from_target && tex->m_from_target == rt && m_conf.ps.channel == ChannelFetch_ALPHA) || partial_fbmask || rt->m_alpha_max > 128)
{
m_can_correct_alpha = false;
rt->RTADecorrect(rt);
rt->RTADecorrect();
m_conf.rt = rt->m_texture;

if (req_src_update)
Expand All @@ -5455,7 +5455,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
else
{
m_can_correct_alpha = false;
rt->RTADecorrect(rt);
rt->RTADecorrect();
m_conf.rt = rt->m_texture;

if (req_src_update)
Expand Down Expand Up @@ -5489,7 +5489,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta

if (!full_cover)
{
rt->RTACorrect(rt);
rt->RTACorrect();
m_conf.rt = rt->m_texture;
}
else
Expand Down Expand Up @@ -5959,7 +5959,7 @@ GSRendererHW::CLUTDrawTestResult GSRendererHW::PossibleCLUTDraw()
m_cached_ctx.TEX0.TBP0, m_cached_ctx.TEX0.TBW, m_cached_ctx.TEX0.PSM, r);
if (tgt)
{
tgt->RTADecorrect(tgt);
tgt->RTADecorrect();
bool is_dirty = false;
for (const GSDirtyRect& rc : tgt->m_dirty)
{
Expand Down
60 changes: 31 additions & 29 deletions pcsx2/GS/Renderers/HW/GSTextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const bool is_depth, c
dst = t;

if (GSUtil::GetChannelMask(TEX0.PSM) & 0x8)
t->RTADecorrect(t);
t->RTADecorrect();

inside_target = false;
break;
Expand Down Expand Up @@ -1339,7 +1339,7 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const bool is_color, const
// The hack can fix glitches in some games.
if (!t->m_drawn_since_read.rempty())
{
t->RTADecorrect(t);
t->RTADecorrect();

Read(t, t->m_drawn_since_read);

Expand Down Expand Up @@ -2244,7 +2244,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
}
else if (dst_match->m_texture->GetState() == GSTexture::State::Dirty)
{
dst_match->RTADecorrect(dst_match);
dst_match->RTADecorrect();
g_gs_device->StretchRect(dst_match->m_texture, sRect, dst->m_texture, dRect, shader, false);
g_perfmon.Put(GSPerfMon::TextureCopies, 1);
}
Expand Down Expand Up @@ -2669,53 +2669,55 @@ GSTextureCache::Target* GSTextureCache::LookupDisplayTarget(GIFRegTEX0 TEX0, con
return can_create ? CreateTarget(TEX0, size, size, scale, RenderTarget, true, 0, true) : nullptr;
}

void GSTextureCache::Target::RTACorrect(Target* rt)
void GSTextureCache::Target::RTACorrect()
{
if (rt && !rt->m_rt_alpha_scale && rt->m_type == RenderTarget)
if (!m_rt_alpha_scale && m_type == RenderTarget)
{
if (rt->m_alpha_max > 0)
if (m_alpha_max > 0)
{
const GSVector2i rtsize(rt->m_texture->GetSize());
const GSVector4i valid_rect = GSVector4i(GSVector4(rt->m_valid) * GSVector4(rt->m_scale));
const GSVector2i rtsize(m_texture->GetSize());
const GSVector4i valid_rect = GSVector4i(GSVector4(m_valid) * GSVector4(m_scale));
GL_PUSH("RTACorrect(valid=({},{}=>{},{}))", m_valid.x, m_valid.y, m_valid.z, m_valid.w);

if (GSTexture* temp_rt = g_gs_device->CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::Color, !GSVector4i::loadh(rtsize).eq(valid_rect)))
{
// Only copy up the valid area, since there's no point in "correcting" nothing.
const GSVector4 dRect(rt->m_texture->GetRect().rintersect(valid_rect));
const GSVector4 dRect(m_texture->GetRect().rintersect(valid_rect));
const GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy();
g_gs_device->StretchRect(rt->m_texture, sRect, temp_rt, dRect, ShaderConvert::RTA_CORRECTION, false);
g_gs_device->StretchRect(m_texture, sRect, temp_rt, dRect, ShaderConvert::RTA_CORRECTION, false);
g_perfmon.Put(GSPerfMon::TextureCopies, 1);
g_gs_device->Recycle(rt->m_texture);
rt->m_texture = temp_rt;
g_gs_device->Recycle(m_texture);
m_texture = temp_rt;
}
}

rt->m_rt_alpha_scale = true;
m_rt_alpha_scale = true;
}
}

void GSTextureCache::Target::RTADecorrect(Target* rt)
void GSTextureCache::Target::RTADecorrect()
{
if (rt->m_rt_alpha_scale && rt->m_type == RenderTarget)
if (m_rt_alpha_scale && m_type == RenderTarget)
{
if (rt->m_alpha_max > 0)
if (m_alpha_max > 0)
{
const GSVector2i rtsize(rt->m_texture->GetSize());
const GSVector4i valid_rect = GSVector4i(GSVector4(rt->m_valid) * GSVector4(rt->m_scale));
const GSVector2i rtsize(m_texture->GetSize());
const GSVector4i valid_rect = GSVector4i(GSVector4(m_valid) * GSVector4(m_scale));
GL_PUSH("RTADecorrect(valid=({},{}=>{},{}))", m_valid.x, m_valid.y, m_valid.z, m_valid.w);

if (GSTexture* temp_rt = g_gs_device->CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::Color, !GSVector4i::loadh(rtsize).eq(valid_rect)))
{
// Only copy up the valid area, since there's no point in "correcting" nothing.
const GSVector4 dRect(rt->m_texture->GetRect().rintersect(valid_rect));
const GSVector4 dRect(m_texture->GetRect().rintersect(valid_rect));
const GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy();
g_gs_device->StretchRect(rt->m_texture, sRect, temp_rt, dRect, ShaderConvert::RTA_DECORRECTION, false);
g_gs_device->StretchRect(m_texture, sRect, temp_rt, dRect, ShaderConvert::RTA_DECORRECTION, false);
g_perfmon.Put(GSPerfMon::TextureCopies, 1);
g_gs_device->Recycle(rt->m_texture);
rt->m_texture = temp_rt;
g_gs_device->Recycle(m_texture);
m_texture = temp_rt;
}
}

rt->m_rt_alpha_scale = false;
m_rt_alpha_scale = false;
}
}

Expand Down Expand Up @@ -3716,8 +3718,8 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u
const bool cover_whole_target = dst->m_type == RenderTarget && GSVector4i(dx, dy, dx + w, dy + h).rintersect(dst->m_valid).eq(dst->m_valid);
if (!cover_whole_target)
{
src->RTADecorrect(src);
dst->RTADecorrect(dst);
src->RTADecorrect();
dst->RTADecorrect();
}

// If the copies overlap, this is a validation error, so we need to copy to a temporary texture first.
Expand Down Expand Up @@ -3888,7 +3890,7 @@ bool GSTextureCache::ShuffleMove(u32 BP, u32 BW, u32 PSM, int sx, int sy, int dx
const GSVector4i bbox = write_rg ? GSVector4i(dx, dy, dx + w, dy + h) : GSVector4i(sx, sy, sx + w, sy + h);

if (read_ba || !write_rg)
tgt->RTADecorrect(tgt);
tgt->RTADecorrect();

GSHWDrawConfig& config = GSRendererHW::GetInstance()->BeginHLEHardwareDraw(tgt->m_texture, nullptr, tgt->m_scale, tgt->m_texture, tgt->m_scale, bbox);
config.colormask.wrgba = (write_rg ? (1 | 2) : (4 | 8));
Expand Down Expand Up @@ -4665,7 +4667,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
if (dst->m_rt_alpha_scale)
{
dst->RTADecorrect(dst);
dst->RTADecorrect();
sTex = dst->m_texture;
}

Expand Down Expand Up @@ -5411,7 +5413,7 @@ GSTexture* GSTextureCache::LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVec
offset = this_offset;
*scale = t->m_scale;

t->RTADecorrect(t);
t->RTADecorrect();

return t->m_texture;
}
Expand Down Expand Up @@ -6127,7 +6129,7 @@ void GSTextureCache::Target::Update(bool cannot_scale)
if (m_type == RenderTarget && transferring_alpha && bpp >= 16)
{
if (alpha_minmax.second > 128 || (m_TEX0.PSM & 0xf) == PSMCT24)
this->RTADecorrect(this);
RTADecorrect();
else if (!cannot_scale && total_rect.eq(m_valid))
m_rt_alpha_scale = true;
}
Expand Down
4 changes: 2 additions & 2 deletions pcsx2/GS/Renderers/HW/GSTextureCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ class GSTextureCache
void ResizeValidity(const GSVector4i& rect);
void UpdateValidity(const GSVector4i& rect, bool can_resize = true);

void RTACorrect(Target* rt);
void RTADecorrect(Target* rt);
void RTACorrect();
void RTADecorrect();

void Update(bool cannot_scale = false);

Expand Down

0 comments on commit 64a471b

Please sign in to comment.