GS/HW: Don't clear temporary copies for HDR/DS

Invalidating is enough here.
This commit is contained in:
Connor McLaughlin 2022-04-23 15:27:09 +10:00 committed by refractionpcsx2
parent cf1d67d927
commit 568ebc6199
4 changed files with 13 additions and 12 deletions

View File

@ -3179,18 +3179,22 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c
{
// Optimisation aims to reduce the amount of texture loaded to only the bit which will be read
GSVector4 st = m_vt.m_min.t.xyxy(m_vt.m_max.t);
if (linear)
st += GSVector4(-0.5f, 0.5f).xxyy();
// Adjust texture range when sprites get scissor clipped. Since we linearly interpolate, this
// optimization doesn't work when perspective correction is enabled.
if (m_vt.m_primclass == GS_SPRITE_CLASS && PRIM->FST == 1)
{
const GSVector4i int_rc(m_vt.m_min.p.xyxy(m_vt.m_max.p));
// When coordinates are fractional, GS appears to draw to the right/bottom (effectively
// taking the ceiling), not to the top/left (taking the floor).
const GSVector4i int_rc(m_vt.m_min.p.ceil().xyxy(m_vt.m_max.p.floor()));
const GSVector4i scissored_rc(int_rc.rintersect(GSVector4i(m_context->scissor.in)));
if (!int_rc.eq(scissored_rc))
{
// draw will get scissored, adjust UVs to suit
const GSVector2 pos_range(m_vt.m_max.p.x - m_vt.m_min.p.x, m_vt.m_max.p.y - m_vt.m_min.p.y);
const GSVector2 uv_range(st.z - st.x, st.w - st.y);
const GSVector2 uv_range(m_vt.m_max.t.x - m_vt.m_min.t.x, m_vt.m_max.t.y - m_vt.m_min.t.y);
const GSVector2 grad(uv_range / pos_range);
// we need to check that it's not going to repeat over the non-clipped part
@ -3211,9 +3215,6 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c
}
}
if (linear)
st += GSVector4(-0.5f, 0.5f).xxyy();
GSVector4i uv = GSVector4i(st.floor());
uses_border = GSVector4::cast((uv < vr).blend32<0xc>(uv >= vr)).mask();

View File

@ -2463,7 +2463,7 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config)
EndRenderPass();
GL_PUSH_("HDR Render Target Setup");
hdr_rt = static_cast<GSTexture12*>(CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::FloatColor));
hdr_rt = static_cast<GSTexture12*>(CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::FloatColor, false));
if (!hdr_rt)
{
Console.WriteLn("Failed to allocate HDR render target, aborting draw.");
@ -2492,7 +2492,7 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config)
else if (config.require_one_barrier)
{
// requires a copy of the RT
draw_rt_clone = static_cast<GSTexture12*>(CreateTexture(rtsize.x, rtsize.y, false, GSTexture::Format::Color, true));
draw_rt_clone = static_cast<GSTexture12*>(CreateTexture(rtsize.x, rtsize.y, false, GSTexture::Format::Color, false));
if (draw_rt_clone)
{
EndRenderPass();
@ -2510,7 +2510,7 @@ void GSDevice12::RenderHW(GSHWDrawConfig& config)
if (config.tex && config.tex == config.ds)
{
// requires a copy of the depth buffer. this is mainly for ico.
copy_ds = static_cast<GSTexture12*>(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, true));
copy_ds = static_cast<GSTexture12*>(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, false));
if (copy_ds)
{
EndRenderPass();

View File

@ -1840,7 +1840,7 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
if (config.ps.hdr)
{
GSVector2i size = config.rt->GetSize();
hdr_rt = CreateRenderTarget(size.x, size.y, GSTexture::Format::FloatColor);
hdr_rt = CreateRenderTarget(size.x, size.y, GSTexture::Format::FloatColor, false);
hdr_rt->CommitRegion(GSVector2i(config.drawarea.z, config.drawarea.w));
OMSetRenderTargets(hdr_rt, config.ds, &config.scissor);

View File

@ -2876,7 +2876,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
EndRenderPass();
GL_PUSH_("HDR Render Target Setup");
hdr_rt = static_cast<GSTextureVK*>(CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::FloatColor));
hdr_rt = static_cast<GSTextureVK*>(CreateRenderTarget(rtsize.x, rtsize.y, GSTexture::Format::FloatColor, false));
if (!hdr_rt)
{
Console.WriteLn("Failed to allocate HDR render target, aborting draw.");
@ -2905,7 +2905,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
else if (config.require_one_barrier && !m_features.texture_barrier)
{
// requires a copy of the RT
draw_rt_clone = static_cast<GSTextureVK*>(CreateTexture(rtsize.x, rtsize.y, false, GSTexture::Format::Color, true));
draw_rt_clone = static_cast<GSTextureVK*>(CreateTexture(rtsize.x, rtsize.y, false, GSTexture::Format::Color, false));
if (draw_rt_clone)
{
EndRenderPass();
@ -2922,7 +2922,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
if (config.tex && config.tex == config.ds)
{
// requires a copy of the depth buffer. this is mainly for ico.
copy_ds = static_cast<GSTextureVK*>(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, true));
copy_ds = static_cast<GSTextureVK*>(CreateDepthStencil(rtsize.x, rtsize.y, GSTexture::Format::DepthStencil, false));
if (copy_ds)
{
EndRenderPass();