GS: Make ClearDepth() take a value

This commit is contained in:
Stenzek 2023-04-28 18:05:04 +10:00 committed by Connor McLaughlin
parent a480c972f7
commit f6bcfc3abd
15 changed files with 26 additions and 27 deletions

View File

@ -323,7 +323,7 @@ GSTexture* GSDevice::FetchSurface(GSTexture::Type type, int width, int height, i
case GSTexture::Type::DepthStencil:
{
if (clear)
ClearDepth(t);
ClearDepth(t, 0.0f);
else
InvalidateRenderTarget(t);
}

View File

@ -880,7 +880,7 @@ public:
virtual void ClearRenderTarget(GSTexture* t, const GSVector4& c) = 0;
virtual void ClearRenderTarget(GSTexture* t, u32 c) = 0;
virtual void InvalidateRenderTarget(GSTexture* t) = 0;
virtual void ClearDepth(GSTexture* t) = 0;
virtual void ClearDepth(GSTexture* t, float d) = 0;
virtual void PushDebugGroup(const char* fmt, ...) = 0;
virtual void PopDebugGroup() = 0;

View File

@ -1081,9 +1081,9 @@ void GSDevice11::InvalidateRenderTarget(GSTexture* t)
m_ctx->DiscardView(static_cast<ID3D11RenderTargetView*>(*static_cast<GSTexture11*>(t)));
}
void GSDevice11::ClearDepth(GSTexture* t)
void GSDevice11::ClearDepth(GSTexture* t, float d)
{
m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_DEPTH, 0.0f, 0);
m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_DEPTH, d, 0);
}
void GSDevice11::ClearStencil(GSTexture* t, u8 c)

View File

@ -312,7 +312,7 @@ public:
void ClearRenderTarget(GSTexture* t, const GSVector4& c) override;
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t) override;
void ClearDepth(GSTexture* t, float v) override;
void ClearStencil(GSTexture* t, u8 c);
void PushDebugGroup(const char* fmt, ...) override;

View File

@ -666,7 +666,7 @@ void GSDevice12::InvalidateRenderTarget(GSTexture* t)
t->SetState(GSTexture::State::Invalidated);
}
void GSDevice12::ClearDepth(GSTexture* t)
void GSDevice12::ClearDepth(GSTexture* t, float d)
{
if (!t)
return;
@ -674,7 +674,7 @@ void GSDevice12::ClearDepth(GSTexture* t)
if (m_current_depth_target == t)
EndRenderPass();
static_cast<GSTexture12*>(t)->SetClearDepth(0.0f);
static_cast<GSTexture12*>(t)->SetClearDepth(d);
}
void GSDevice12::LookupNativeFormat(GSTexture::Format format, DXGI_FORMAT* d3d_format, DXGI_FORMAT* srv_format,

View File

@ -282,7 +282,7 @@ public:
void ClearRenderTarget(GSTexture* t, const GSVector4& c) override;
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;

View File

@ -818,7 +818,7 @@ bool GSHwHack::OI_FFX(GSRendererHW& r, GSTexture* rt, GSTexture* ds, GSTextureCa
{
// random battle transition (z buffer written directly, clear it now)
GL_INS("OI_FFX ZB clear");
g_gs_device->ClearDepth(ds);
g_gs_device->ClearDepth(ds, 0.0f);
}
return true;
@ -862,7 +862,7 @@ bool GSHwHack::OI_RozenMaidenGebetGarden(GSRendererHW& r, GSTexture* rt, GSTextu
if (GSTextureCache::Target* tmp_ds = g_texture_cache->LookupTarget(TEX0, r.GetTargetSize(), r.GetTextureScaleFactor(), GSTextureCache::DepthStencil))
{
GL_INS("OI_RozenMaidenGebetGarden ZB clear");
g_gs_device->ClearDepth(tmp_ds->m_texture);
g_gs_device->ClearDepth(tmp_ds->m_texture, 0.0f);
}
return false;
@ -948,7 +948,7 @@ bool GSHwHack::OI_ArTonelico2(GSRendererHW& r, GSTexture* rt, GSTexture* ds, GST
if (r.m_vertex.next == 2 && !RPRIM->TME && RFRAME.FBW == 10 && v->XYZ.Z == 0 && RTEST.ZTST == ZTST_ALWAYS)
{
GL_INS("OI_ArTonelico2");
g_gs_device->ClearDepth(ds);
g_gs_device->ClearDepth(ds, 0.0f);
}
return true;
@ -985,7 +985,7 @@ bool GSHwHack::GSC_Battlefield2(GSRendererHW& r, int& skip)
GSTextureCache::Target* dst = g_texture_cache->LookupTarget(TEX0, r.GetTargetSize(), r.GetTextureScaleFactor(), GSTextureCache::DepthStencil);
if (dst)
{
g_gs_device->ClearDepth(dst->m_texture);
g_gs_device->ClearDepth(dst->m_texture, 0.0f);
}
}
}

View File

@ -5146,7 +5146,7 @@ void GSRendererHW::OI_DoubleHalfClear(GSTextureCache::Target*& rt, GSTextureCach
{
// Only pure clear are supported for depth
ASSERT(color == 0);
g_gs_device->ClearDepth(tex);
g_gs_device->ClearDepth(tex, 0.0f);
}
else
{
@ -5168,7 +5168,7 @@ void GSRendererHW::OI_DoubleHalfClear(GSTextureCache::Target*& rt, GSTextureCach
{
// Only pure clear are supported for depth
ASSERT(color == 0);
g_gs_device->ClearDepth(ds->m_texture);
g_gs_device->ClearDepth(ds->m_texture, 0.0f);
ds->UpdateValidity(ds->GetUnscaledRect());
}
else

View File

@ -4870,7 +4870,7 @@ bool GSTextureCache::Target::ResizeTexture(int new_unscaled_width, int new_unsca
if (tex->GetType() != GSTexture::Type::DepthStencil)
g_gs_device->ClearRenderTarget(tex, tex->GetClearColor());
else
g_gs_device->ClearDepth(tex/*, tex->GetClearDepth()*/);
g_gs_device->ClearDepth(tex, tex->GetClearDepth());
}
else
{

View File

@ -406,7 +406,7 @@ public:
void ClearRenderTarget(GSTexture* t, const GSVector4& c) override;
void ClearRenderTarget(GSTexture* t, u32 c) override;
void ClearDepth(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
void InvalidateRenderTarget(GSTexture* t) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;

View File

@ -554,7 +554,7 @@ GSTexture* GSDeviceMTL::CreateSurface(GSTexture::Type type, int width, int heigh
ClearRenderTarget(t, 0);
break;
case GSTexture::Type::DepthStencil:
ClearDepth(t);
ClearDepth(t, 0.0f);
break;
default:
break;
@ -1442,10 +1442,10 @@ void GSDeviceMTL::ClearRenderTarget(GSTexture* t, uint32 c)
ClearRenderTarget(t, color);
}
void GSDeviceMTL::ClearDepth(GSTexture* t)
void GSDeviceMTL::ClearDepth(GSTexture* t, float d)
{
if (!t) return;
t->SetClearDepth(0);
t->SetClearDepth(d);
}
void GSDeviceMTL::InvalidateRenderTarget(GSTexture* t)

View File

@ -939,7 +939,7 @@ void GSDeviceOGL::InvalidateRenderTarget(GSTexture* t)
}
}
void GSDeviceOGL::ClearDepth(GSTexture* t)
void GSDeviceOGL::ClearDepth(GSTexture* t, float d)
{
if (!t)
return;
@ -956,15 +956,14 @@ void GSDeviceOGL::ClearDepth(GSTexture* t)
// TODO: check size of scissor before toggling it
glDisable(GL_SCISSOR_TEST);
const float c = 0.0f;
if (GLState::depth_mask)
{
glClearBufferfv(GL_DEPTH, 0, &c);
glClearBufferfv(GL_DEPTH, 0, &d);
}
else
{
glDepthMask(true);
glClearBufferfv(GL_DEPTH, 0, &c);
glClearBufferfv(GL_DEPTH, 0, &d);
glDepthMask(false);
}
glEnable(GL_SCISSOR_TEST);

View File

@ -313,7 +313,7 @@ public:
void ClearRenderTarget(GSTexture* t, const GSVector4& c) override;
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
void ClearStencil(GSTexture* t, u8 c);
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;

View File

@ -814,7 +814,7 @@ void GSDeviceVK::InvalidateRenderTarget(GSTexture* t)
t->SetState(GSTexture::State::Invalidated);
}
void GSDeviceVK::ClearDepth(GSTexture* t)
void GSDeviceVK::ClearDepth(GSTexture* t, float d)
{
if (!t)
return;
@ -822,7 +822,7 @@ void GSDeviceVK::ClearDepth(GSTexture* t)
if (m_current_depth_target == t)
EndRenderPass();
static_cast<GSTextureVK*>(t)->SetClearDepth(0.0f);
static_cast<GSTextureVK*>(t)->SetClearDepth(d);
}
VkFormat GSDeviceVK::LookupNativeFormat(GSTexture::Format format) const

View File

@ -268,7 +268,7 @@ public:
void ClearRenderTarget(GSTexture* t, const GSVector4& c) override;
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;