From befbc7bc2e1587567e1f330b74fb35a1f70ec929 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 7 Feb 2023 20:06:29 +1000 Subject: [PATCH] HostDisplay: Fix cursor texture leak --- src/core/host_display.cpp | 5 +++++ src/core/host_display.h | 2 +- src/frontend-common/d3d11_host_display.cpp | 2 ++ src/frontend-common/d3d12_host_display.cpp | 2 ++ src/frontend-common/opengl_host_display.cpp | 2 ++ src/frontend-common/vulkan_host_display.cpp | 2 ++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/host_display.cpp b/src/core/host_display.cpp index 7d4bffeea..bb6f189b0 100644 --- a/src/core/host_display.cpp +++ b/src/core/host_display.cpp @@ -32,6 +32,11 @@ RenderAPI HostDisplay::GetPreferredAPI() #endif } +void HostDisplay::DestroyResources() +{ + m_cursor_texture.reset(); +} + bool HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, u32 pitch) { void* map_ptr; diff --git a/src/core/host_display.h b/src/core/host_display.h index 279409142..f406ef4de 100644 --- a/src/core/host_display.h +++ b/src/core/host_display.h @@ -81,7 +81,7 @@ public: virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) = 0; virtual AdapterAndModeList GetAdapterAndModeList() = 0; virtual bool CreateResources() = 0; - virtual void DestroyResources() = 0; + virtual void DestroyResources(); virtual bool SetPostProcessingChain(const std::string_view& config) = 0; diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index 8ac7d01de..8d40248b5 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -633,6 +633,8 @@ bool D3D11HostDisplay::CreateResources() void D3D11HostDisplay::DestroyResources() { + HostDisplay::DestroyResources(); + m_post_processing_chain.ClearStages(); m_post_processing_input_texture.Destroy(); m_post_processing_stages.clear(); diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index d502f0dbb..f23cf2226 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -545,6 +545,8 @@ bool D3D12HostDisplay::CreateResources() void D3D12HostDisplay::DestroyResources() { + HostDisplay::DestroyResources(); + m_post_processing_cbuffer.Destroy(false); m_post_processing_chain.ClearStages(); m_post_processing_input_texture.Destroy(); diff --git a/src/frontend-common/opengl_host_display.cpp b/src/frontend-common/opengl_host_display.cpp index 9acaf3c86..8546927b2 100644 --- a/src/frontend-common/opengl_host_display.cpp +++ b/src/frontend-common/opengl_host_display.cpp @@ -617,6 +617,8 @@ void main() void OpenGLHostDisplay::DestroyResources() { + HostDisplay::DestroyResources(); + m_post_processing_chain.ClearStages(); m_post_processing_input_texture.Destroy(); m_post_processing_ubo.reset(); diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 606adf038..c13692f62 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -545,6 +545,8 @@ void main() void VulkanHostDisplay::DestroyResources() { + HostDisplay::DestroyResources(); + Vulkan::Util::SafeDestroyPipelineLayout(m_post_process_pipeline_layout); Vulkan::Util::SafeDestroyPipelineLayout(m_post_process_ubo_pipeline_layout); Vulkan::Util::SafeDestroyDescriptorSetLayout(m_post_process_descriptor_set_layout);