mirror of https://github.com/PCSX2/pcsx2.git
HostDisplay: Remove DestroyRenderDevice()/move to destructor
Saves having to remember to call this any time you destroy the display object.
This commit is contained in:
parent
5c88c585a0
commit
9199f48a3c
|
@ -687,12 +687,8 @@ void EmuThread::releaseHostDisplay()
|
|||
{
|
||||
ImGuiManager::Shutdown();
|
||||
|
||||
if (s_host_display)
|
||||
s_host_display->DestroyRenderDevice();
|
||||
|
||||
emit onDestroyDisplayRequested();
|
||||
|
||||
s_host_display.reset();
|
||||
emit onDestroyDisplayRequested();
|
||||
}
|
||||
|
||||
HostDisplay* Host::GetHostDisplay()
|
||||
|
|
|
@ -95,8 +95,9 @@ D3D11HostDisplay::D3D11HostDisplay() = default;
|
|||
|
||||
D3D11HostDisplay::~D3D11HostDisplay()
|
||||
{
|
||||
pxAssertMsg(!m_context, "Context should have been destroyed by now");
|
||||
pxAssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now");
|
||||
D3D11HostDisplay::DestroyRenderSurface();
|
||||
m_context.Reset();
|
||||
m_device.Reset();
|
||||
}
|
||||
|
||||
HostDisplay::RenderAPI D3D11HostDisplay::GetRenderAPI() const
|
||||
|
@ -332,13 +333,6 @@ bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
|
|||
return true;
|
||||
}
|
||||
|
||||
void D3D11HostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
DestroyRenderSurface();
|
||||
m_context.Reset();
|
||||
m_device.Reset();
|
||||
}
|
||||
|
||||
bool D3D11HostDisplay::MakeRenderContextCurrent()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
|
||||
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, VsyncMode vsync, bool threaded_presentation, bool debug_device) override;
|
||||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
void DestroyRenderDevice() override;
|
||||
|
||||
bool MakeRenderContextCurrent() override;
|
||||
bool DoneRenderContextCurrent() override;
|
||||
|
|
|
@ -51,8 +51,12 @@ D3D12HostDisplay::D3D12HostDisplay() = default;
|
|||
|
||||
D3D12HostDisplay::~D3D12HostDisplay()
|
||||
{
|
||||
pxAssertMsg(!g_d3d12_context, "Context should have been destroyed by now");
|
||||
pxAssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now");
|
||||
if (g_d3d12_context)
|
||||
{
|
||||
g_d3d12_context->WaitForGPUIdle();
|
||||
D3D12HostDisplay::DestroyRenderSurface();
|
||||
g_d3d12_context->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
HostDisplay::RenderAPI D3D12HostDisplay::GetRenderAPI() const
|
||||
|
@ -204,15 +208,6 @@ bool D3D12HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
|
|||
return true;
|
||||
}
|
||||
|
||||
void D3D12HostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
g_d3d12_context->ExecuteCommandList(true);
|
||||
|
||||
DestroyRenderSurface();
|
||||
if (g_d3d12_context)
|
||||
g_d3d12_context->Destroy();
|
||||
}
|
||||
|
||||
bool D3D12HostDisplay::MakeRenderContextCurrent()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
|
||||
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, VsyncMode vsync, bool threaded_presentation, bool debug_device) override;
|
||||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
void DestroyRenderDevice() override;
|
||||
|
||||
bool MakeRenderContextCurrent() override;
|
||||
bool DoneRenderContextCurrent() override;
|
||||
|
|
|
@ -56,7 +56,6 @@ public:
|
|||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
bool MakeRenderContextCurrent() override;
|
||||
bool DoneRenderContextCurrent() override;
|
||||
void DestroyRenderDevice() override;
|
||||
void DestroyRenderSurface() override;
|
||||
bool ChangeRenderWindow(const WindowInfo& wi) override;
|
||||
bool SupportsFullscreen() const override;
|
||||
|
|
|
@ -49,6 +49,9 @@ MetalHostDisplay::MetalHostDisplay()
|
|||
|
||||
MetalHostDisplay::~MetalHostDisplay()
|
||||
{
|
||||
MetalHostDisplay::DestroyRenderSurface();
|
||||
m_queue = nullptr;
|
||||
m_dev.Reset();
|
||||
}
|
||||
|
||||
HostDisplay::AdapterAndModeList GetMetalAdapterAndModeList()
|
||||
|
@ -158,13 +161,6 @@ bool MetalHostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
|
|||
bool MetalHostDisplay::MakeRenderContextCurrent() { return true; }
|
||||
bool MetalHostDisplay::DoneRenderContextCurrent() { return true; }
|
||||
|
||||
void MetalHostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
DestroyRenderSurface();
|
||||
m_queue = nullptr;
|
||||
m_dev.Reset();
|
||||
}
|
||||
|
||||
void MetalHostDisplay::DestroyRenderSurface()
|
||||
{
|
||||
if (!m_layer)
|
||||
|
|
|
@ -53,7 +53,11 @@ OpenGLHostDisplay::OpenGLHostDisplay() = default;
|
|||
|
||||
OpenGLHostDisplay::~OpenGLHostDisplay()
|
||||
{
|
||||
pxAssertMsg(!m_gl_context, "Context should have been destroyed by now");
|
||||
if (m_gl_context)
|
||||
{
|
||||
m_gl_context->DoneCurrent();
|
||||
m_gl_context.reset();
|
||||
}
|
||||
}
|
||||
|
||||
HostDisplay::RenderAPI OpenGLHostDisplay::GetRenderAPI() const
|
||||
|
@ -239,15 +243,6 @@ bool OpenGLHostDisplay::DoneRenderContextCurrent()
|
|||
return m_gl_context->DoneCurrent();
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
if (!m_gl_context)
|
||||
return;
|
||||
|
||||
m_gl_context->DoneCurrent();
|
||||
m_gl_context.reset();
|
||||
}
|
||||
|
||||
bool OpenGLHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
||||
{
|
||||
pxAssert(m_gl_context);
|
||||
|
|
|
@ -40,7 +40,6 @@ public:
|
|||
|
||||
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, VsyncMode vsync, bool threaded_presentation, bool debug_device) override;
|
||||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
void DestroyRenderDevice() override;
|
||||
|
||||
bool MakeRenderContextCurrent() override;
|
||||
bool DoneRenderContextCurrent() override;
|
||||
|
|
|
@ -51,8 +51,14 @@ VulkanHostDisplay::VulkanHostDisplay() = default;
|
|||
|
||||
VulkanHostDisplay::~VulkanHostDisplay()
|
||||
{
|
||||
pxAssertRel(!g_vulkan_context, "Context should have been destroyed by now");
|
||||
pxAssertRel(!m_swap_chain, "Swap chain should have been destroyed by now");
|
||||
if (g_vulkan_context)
|
||||
{
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
m_swap_chain.reset();
|
||||
|
||||
Vulkan::ShaderCache::Destroy();
|
||||
Vulkan::Context::Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
HostDisplay::RenderAPI VulkanHostDisplay::GetRenderAPI() const
|
||||
|
@ -163,7 +169,6 @@ HostDisplay::AdapterAndModeList VulkanHostDisplay::GetAdapterAndModeList()
|
|||
|
||||
void VulkanHostDisplay::DestroyRenderSurface()
|
||||
{
|
||||
m_window_info = {};
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
m_swap_chain.reset();
|
||||
}
|
||||
|
@ -320,18 +325,6 @@ bool VulkanHostDisplay::UpdateImGuiFontTexture()
|
|||
return ImGui_ImplVulkan_CreateFontsTexture();
|
||||
}
|
||||
|
||||
void VulkanHostDisplay::DestroyRenderDevice()
|
||||
{
|
||||
if (!g_vulkan_context)
|
||||
return;
|
||||
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
m_swap_chain.reset();
|
||||
|
||||
Vulkan::ShaderCache::Destroy();
|
||||
Vulkan::Context::Destroy();
|
||||
}
|
||||
|
||||
bool VulkanHostDisplay::MakeRenderContextCurrent()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -29,7 +29,6 @@ public:
|
|||
|
||||
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, VsyncMode vsync, bool threaded_presentation, bool debug_device) override;
|
||||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
void DestroyRenderDevice() override;
|
||||
|
||||
bool MakeRenderContextCurrent() override;
|
||||
bool DoneRenderContextCurrent() override;
|
||||
|
|
|
@ -101,7 +101,6 @@ public:
|
|||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) = 0;
|
||||
virtual bool MakeRenderContextCurrent() = 0;
|
||||
virtual bool DoneRenderContextCurrent() = 0;
|
||||
virtual void DestroyRenderDevice() = 0;
|
||||
virtual void DestroyRenderSurface() = 0;
|
||||
virtual bool ChangeRenderWindow(const WindowInfo& wi) = 0;
|
||||
virtual bool SupportsFullscreen() const = 0;
|
||||
|
|
|
@ -121,7 +121,6 @@ HostDisplay* Host::AcquireHostDisplay(HostDisplay::RenderAPI api)
|
|||
!s_host_display->InitializeRenderDevice(EmuFolders::Cache, GSConfig.UseDebugDevice) ||
|
||||
!ImGuiManager::Initialize())
|
||||
{
|
||||
s_host_display->DestroyRenderDevice();
|
||||
s_host_display.reset();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -137,10 +136,7 @@ void Host::ReleaseHostDisplay()
|
|||
ImGuiManager::Shutdown();
|
||||
|
||||
if (s_host_display)
|
||||
{
|
||||
s_host_display->DestroyRenderDevice();
|
||||
s_host_display.reset();
|
||||
}
|
||||
|
||||
sApp.CloseGsPanel();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue