GS: Move clear functions to base GSDevice class

This commit is contained in:
Stenzek 2023-07-04 17:39:04 +10:00 committed by Connor McLaughlin
parent e5a5cf0ef0
commit 33af3392aa
12 changed files with 18 additions and 107 deletions

View File

@ -228,6 +228,21 @@ bool GSDevice::GetHostRefreshRate(float* refresh_rate)
return WindowInfo::QueryRefreshRateForWindow(m_window_info, refresh_rate); return WindowInfo::QueryRefreshRateForWindow(m_window_info, refresh_rate);
} }
void GSDevice::ClearRenderTarget(GSTexture* t, u32 c)
{
t->SetClearColor(c);
}
void GSDevice::ClearDepth(GSTexture* t, float d)
{
t->SetClearDepth(d);
}
void GSDevice::InvalidateRenderTarget(GSTexture* t)
{
t->SetState(GSTexture::State::Invalidated);
}
bool GSDevice::UpdateImGuiFontTexture() bool GSDevice::UpdateImGuiFontTexture()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();

View File

@ -877,9 +877,9 @@ public:
/// Returns the amount of GPU time utilized since the last time this method was called. /// Returns the amount of GPU time utilized since the last time this method was called.
virtual float GetAndResetAccumulatedGPUTime() = 0; virtual float GetAndResetAccumulatedGPUTime() = 0;
virtual void ClearRenderTarget(GSTexture* t, u32 c) = 0; void ClearRenderTarget(GSTexture* t, u32 c);
virtual void InvalidateRenderTarget(GSTexture* t) = 0; void ClearDepth(GSTexture* t, float d);
virtual void ClearDepth(GSTexture* t, float d) = 0; void InvalidateRenderTarget(GSTexture* t);
virtual void PushDebugGroup(const char* fmt, ...) = 0; virtual void PushDebugGroup(const char* fmt, ...) = 0;
virtual void PopDebugGroup() = 0; virtual void PopDebugGroup() = 0;

View File

@ -1057,21 +1057,6 @@ void GSDevice11::DrawIndexedPrimitive(int offset, int count)
m_ctx->DrawIndexed(count, m_index.start + offset, m_vertex.start); m_ctx->DrawIndexed(count, m_index.start + offset, m_vertex.start);
} }
void GSDevice11::ClearRenderTarget(GSTexture* t, u32 c)
{
t->SetClearColor(c);
}
void GSDevice11::InvalidateRenderTarget(GSTexture* t)
{
t->SetState(GSTexture::State::Invalidated);
}
void GSDevice11::ClearDepth(GSTexture* t, float d)
{
t->SetClearDepth(d);
}
void GSDevice11::CommitClear(GSTexture* t) void GSDevice11::CommitClear(GSTexture* t)
{ {
GSTexture11* T = static_cast<GSTexture11*>(t); GSTexture11* T = static_cast<GSTexture11*>(t);

View File

@ -309,10 +309,6 @@ public:
void DrawIndexedPrimitive(); void DrawIndexedPrimitive();
void DrawIndexedPrimitive(int offset, int count); void DrawIndexedPrimitive(int offset, int count);
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t, float v) override;
void PushDebugGroup(const char* fmt, ...) override; void PushDebugGroup(const char* fmt, ...) override;
void PopDebugGroup() override; void PopDebugGroup() override;
void InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) override; void InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) override;

View File

@ -639,30 +639,6 @@ void GSDevice12::DrawIndexedPrimitive(int offset, int count)
g_d3d12_context->GetCommandList()->DrawIndexedInstanced(count, 1, m_index.start + offset, m_vertex.start, 0); g_d3d12_context->GetCommandList()->DrawIndexedInstanced(count, 1, m_index.start + offset, m_vertex.start, 0);
} }
void GSDevice12::ClearRenderTarget(GSTexture* t, u32 c)
{
if (m_current_render_target == t)
EndRenderPass();
t->SetClearColor(c);
}
void GSDevice12::InvalidateRenderTarget(GSTexture* t)
{
if (m_current_render_target == t || m_current_depth_target == t)
EndRenderPass();
t->SetState(GSTexture::State::Invalidated);
}
void GSDevice12::ClearDepth(GSTexture* t, float d)
{
if (m_current_depth_target == t)
EndRenderPass();
t->SetClearDepth(d);
}
void GSDevice12::LookupNativeFormat(GSTexture::Format format, DXGI_FORMAT* d3d_format, DXGI_FORMAT* srv_format, void GSDevice12::LookupNativeFormat(GSTexture::Format format, DXGI_FORMAT* d3d_format, DXGI_FORMAT* srv_format,
DXGI_FORMAT* rtv_format, DXGI_FORMAT* dsv_format) const DXGI_FORMAT* rtv_format, DXGI_FORMAT* dsv_format) const
{ {

View File

@ -279,10 +279,6 @@ public:
void DrawIndexedPrimitive(); void DrawIndexedPrimitive();
void DrawIndexedPrimitive(int offset, int count); void DrawIndexedPrimitive(int offset, int count);
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override; std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, u32 destX, u32 destY) override; void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, u32 destX, u32 destY) override;

View File

@ -404,10 +404,6 @@ public:
float GetAndResetAccumulatedGPUTime() override; float GetAndResetAccumulatedGPUTime() override;
void AccumulateCommandBufferTime(id<MTLCommandBuffer> buffer); void AccumulateCommandBufferTime(id<MTLCommandBuffer> buffer);
void ClearRenderTarget(GSTexture* t, u32 c) 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; std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;
void ClearSamplerCache() override; void ClearSamplerCache() override;

View File

@ -1424,21 +1424,6 @@ void GSDeviceMTL::AccumulateCommandBufferTime(id<MTLCommandBuffer> buffer)
#pragma clang diagnostic pop #pragma clang diagnostic pop
} }
void GSDeviceMTL::ClearRenderTarget(GSTexture* t, uint32 c)
{
t->SetClearColor(c);
}
void GSDeviceMTL::ClearDepth(GSTexture* t, float d)
{
t->SetClearDepth(d);
}
void GSDeviceMTL::InvalidateRenderTarget(GSTexture* t)
{
t->SetState(GSTexture::State::Invalidated);
}
std::unique_ptr<GSDownloadTexture> GSDeviceMTL::CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) std::unique_ptr<GSDownloadTexture> GSDeviceMTL::CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format)
{ {
return GSDownloadTextureMTL::Create(this, width, height, format); return GSDownloadTextureMTL::Create(this, width, height, format);

View File

@ -961,21 +961,6 @@ void GSDeviceOGL::CommitClear(GSTexture* t, bool use_write_fbo)
} }
} }
void GSDeviceOGL::ClearRenderTarget(GSTexture* t, u32 c)
{
t->SetClearColor(c);
}
void GSDeviceOGL::InvalidateRenderTarget(GSTexture* t)
{
t->SetState(GSTexture::State::Invalidated);
}
void GSDeviceOGL::ClearDepth(GSTexture* t, float d)
{
t->SetClearDepth(d);
}
std::unique_ptr<GSDownloadTexture> GSDeviceOGL::CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) std::unique_ptr<GSDownloadTexture> GSDeviceOGL::CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format)
{ {
return GSDownloadTextureOGL::Create(width, height, format); return GSDownloadTextureOGL::Create(width, height, format);

View File

@ -311,10 +311,6 @@ public:
void DrawIndexedPrimitive(); void DrawIndexedPrimitive();
void DrawIndexedPrimitive(int offset, int count); void DrawIndexedPrimitive(int offset, int count);
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override; std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;
GSTexture* InitPrimDateTexture(GSTexture* rt, const GSVector4i& area, bool datm); GSTexture* InitPrimDateTexture(GSTexture* rt, const GSVector4i& area, bool datm);

View File

@ -790,21 +790,6 @@ void GSDeviceVK::DrawIndexedPrimitive(int offset, int count)
vkCmdDrawIndexed(g_vulkan_context->GetCurrentCommandBuffer(), count, 1, m_index.start + offset, m_vertex.start, 0); vkCmdDrawIndexed(g_vulkan_context->GetCurrentCommandBuffer(), count, 1, m_index.start + offset, m_vertex.start, 0);
} }
void GSDeviceVK::ClearRenderTarget(GSTexture* t, u32 c)
{
t->SetClearColor(c);
}
void GSDeviceVK::InvalidateRenderTarget(GSTexture* t)
{
t->SetState(GSTexture::State::Invalidated);
}
void GSDeviceVK::ClearDepth(GSTexture* t, float d)
{
t->SetClearDepth(d);
}
VkFormat GSDeviceVK::LookupNativeFormat(GSTexture::Format format) const VkFormat GSDeviceVK::LookupNativeFormat(GSTexture::Format format) const
{ {
static constexpr std::array<VkFormat, static_cast<int>(GSTexture::Format::BC7) + 1> s_format_mapping = {{ static constexpr std::array<VkFormat, static_cast<int>(GSTexture::Format::BC7) + 1> s_format_mapping = {{

View File

@ -265,10 +265,6 @@ public:
void DrawIndexedPrimitive(); void DrawIndexedPrimitive();
void DrawIndexedPrimitive(int offset, int count); void DrawIndexedPrimitive(int offset, int count);
void ClearRenderTarget(GSTexture* t, u32 c) override;
void InvalidateRenderTarget(GSTexture* t) override;
void ClearDepth(GSTexture* t, float d) override;
std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override; std::unique_ptr<GSDownloadTexture> CreateDownloadTexture(u32 width, u32 height, GSTexture::Format format) override;
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, u32 destX, u32 destY) override; void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, u32 destX, u32 destY) override;