HostDisplay: Remove DestroyRenderDevice()

This commit is contained in:
Connor McLaughlin 2022-09-26 21:49:14 +10:00
parent 84917ec6aa
commit 6bafcea94f
13 changed files with 38 additions and 88 deletions

View file

@ -109,7 +109,6 @@ public:
bool threaded_presentation) = 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;

View file

@ -683,8 +683,8 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api)
{
ImGuiManager::Shutdown();
CommonHost::ReleaseHostDisplayResources();
g_host_display->DestroyRenderDevice();
g_host_display.reset();
g_nogui_window->DestroyPlatformWindow();
return false;
}
@ -718,7 +718,6 @@ void NoGUIHost::ReleaseHostDisplay()
CommonHost::ReleaseHostDisplayResources();
ImGuiManager::Shutdown();
g_host_display->DestroyRenderDevice();
g_host_display.reset();
g_nogui_window->ExecuteInMessageLoop([]() {
g_nogui_window->DestroyPlatformWindow();

View file

@ -204,11 +204,11 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
{
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
aml = FrontendCommon::D3D11HostDisplay::StaticGetAdapterAndModeList();
aml = D3D11HostDisplay::StaticGetAdapterAndModeList();
break;
case GPURenderer::HardwareD3D12:
aml = FrontendCommon::D3D12HostDisplay::StaticGetAdapterAndModeList();
aml = D3D12HostDisplay::StaticGetAdapterAndModeList();
break;
#endif
#ifdef WITH_VULKAN

View file

@ -739,9 +739,8 @@ bool EmuThread::acquireHostDisplay(RenderAPI api)
{
ImGuiManager::Shutdown();
CommonHost::ReleaseHostDisplayResources();
g_host_display->DestroyRenderDevice();
emit destroyDisplayRequested();
g_host_display.reset();
emit destroyDisplayRequested();
return false;
}
@ -811,9 +810,8 @@ void EmuThread::releaseHostDisplay()
CommonHost::ReleaseHostDisplayResources();
ImGuiManager::Shutdown();
g_host_display->DestroyRenderDevice();
emit destroyDisplayRequested();
g_host_display.reset();
emit destroyDisplayRequested();
m_is_fullscreen = false;
}

View file

@ -142,26 +142,26 @@ std::unique_ptr<HostDisplay> Host::CreateDisplayForAPI(RenderAPI api)
#ifdef WITH_OPENGL
case RenderAPI::OpenGL:
case RenderAPI::OpenGLES:
return std::make_unique<FrontendCommon::OpenGLHostDisplay>();
return std::make_unique<OpenGLHostDisplay>();
#endif
#ifdef _WIN32
case RenderAPI::D3D12:
return std::make_unique<FrontendCommon::D3D12HostDisplay>();
return std::make_unique<D3D12HostDisplay>();
case RenderAPI::D3D11:
return std::make_unique<FrontendCommon::D3D11HostDisplay>();
return std::make_unique<D3D11HostDisplay>();
#endif
default:
#if defined(_WIN32) && defined(_M_ARM64)
return std::make_unique<FrontendCommon::D3D12HostDisplay>();
return std::make_unique<D3D12HostDisplay>();
#elif defined(_WIN32)
return std::make_unique<FrontendCommon::D3D11HostDisplay>();
return std::make_unique<D3D11HostDisplay>();
#elif defined(WITH_OPENGL)
return std::make_unique<FrontendCommon::OpenGLHostDisplay>();
return std::make_unique<OpenGLHostDisplay>();
#elif defined(WITH_VULKAN)
return std::make_unique<FrontendCommon::VulkanHostDisplay>();
return std::make_unique<VulkanHostDisplay>();
#else
return {};
#endif

View file

@ -21,8 +21,6 @@ Log_SetChannel(D3D11HostDisplay);
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
namespace FrontendCommon {
class D3D11HostDisplayTexture final : public HostDisplayTexture
{
public:
@ -90,8 +88,10 @@ D3D11HostDisplay::D3D11HostDisplay() = default;
D3D11HostDisplay::~D3D11HostDisplay()
{
AssertMsg(!m_context, "Context should have been destroyed by now");
AssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now");
DestroyResources();
DestroyRenderSurface();
m_context.Reset();
m_device.Reset();
}
RenderAPI D3D11HostDisplay::GetRenderAPI() const
@ -337,14 +337,6 @@ bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
return true;
}
void D3D11HostDisplay::DestroyRenderDevice()
{
DestroyResources();
DestroyRenderSurface();
m_context.Reset();
m_device.Reset();
}
bool D3D11HostDisplay::MakeRenderContextCurrent()
{
return true;
@ -1006,7 +998,7 @@ bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config)
for (u32 i = 0; i < m_post_processing_chain.GetStageCount(); i++)
{
const PostProcessingShader& shader = m_post_processing_chain.GetShaderStage(i);
const FrontendCommon::PostProcessingShader& shader = m_post_processing_chain.GetShaderStage(i);
const std::string vs = shadergen.GeneratePostProcessingVertexShader(shader);
const std::string ps = shadergen.GeneratePostProcessingFragmentShader(shader);
@ -1255,5 +1247,3 @@ float D3D11HostDisplay::GetAndResetAccumulatedGPUTime()
m_accumulated_gpu_time = 0.0f;
return value;
}
} // namespace FrontendCommon

View file

@ -14,8 +14,6 @@
#include <vector>
#include <wrl/client.h>
namespace FrontendCommon {
class D3D11HostDisplay final : public HostDisplay
{
public:
@ -36,7 +34,6 @@ public:
bool threaded_presentation) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override;
@ -140,7 +137,7 @@ protected:
bool m_using_allow_tearing = false;
bool m_vsync = true;
PostProcessingChain m_post_processing_chain;
FrontendCommon::PostProcessingChain m_post_processing_chain;
D3D11::Texture m_post_processing_input_texture;
std::vector<PostProcessingStage> m_post_processing_stages;
@ -151,5 +148,3 @@ protected:
bool m_timestamp_query_started = false;
float m_accumulated_gpu_time = 0.0f;
};
} // namespace FrontendCommon

View file

@ -15,8 +15,6 @@
#include <dxgi1_5.h>
Log_SetChannel(D3D12HostDisplay);
namespace FrontendCommon {
static constexpr std::array<DXGI_FORMAT, static_cast<u32>(HostDisplayPixelFormat::Count)>
s_display_pixel_format_mapping = {{DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM}};
@ -66,8 +64,13 @@ D3D12HostDisplay::D3D12HostDisplay() = default;
D3D12HostDisplay::~D3D12HostDisplay()
{
AssertMsg(!g_d3d12_context, "Context should have been destroyed by now");
AssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now");
if (!g_d3d12_context)
return;
// DestroyRenderSurface() will exec the command list.
DestroyRenderSurface();
DestroyResources();
g_d3d12_context->Destroy();
}
RenderAPI D3D12HostDisplay::GetRenderAPI() const
@ -247,16 +250,6 @@ bool D3D12HostDisplay::InitializeRenderDevice(std::string_view shader_cache_dire
return true;
}
void D3D12HostDisplay::DestroyRenderDevice()
{
g_d3d12_context->ExecuteCommandList(true);
DestroyResources();
DestroyRenderSurface();
if (g_d3d12_context)
g_d3d12_context->Destroy();
}
bool D3D12HostDisplay::MakeRenderContextCurrent()
{
return true;
@ -889,5 +882,3 @@ bool D3D12HostDisplay::SetPostProcessingChain(const std::string_view& config)
{
return false;
}
} // namespace FrontendCommon

View file

@ -15,8 +15,6 @@
#include <vector>
#include <wrl/client.h>
namespace FrontendCommon {
class D3D12HostDisplay final : public HostDisplay
{
public:
@ -37,7 +35,6 @@ public:
bool threaded_presentation) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override;
@ -121,5 +118,3 @@ protected:
bool m_using_allow_tearing = false;
bool m_vsync = true;
};
} // namespace FrontendCommon

View file

@ -11,8 +11,6 @@
#include <tuple>
Log_SetChannel(OpenGLHostDisplay);
namespace FrontendCommon {
enum : u32
{
TEXTURE_STREAM_BUFFER_SIZE = 16 * 1024 * 1024,
@ -48,7 +46,13 @@ OpenGLHostDisplay::OpenGLHostDisplay() = default;
OpenGLHostDisplay::~OpenGLHostDisplay()
{
AssertMsg(!m_gl_context, "Context should have been destroyed by now");
if (!m_gl_context)
return;
DestroyResources();
m_gl_context->DoneCurrent();
m_gl_context.reset();
}
RenderAPI OpenGLHostDisplay::GetRenderAPI() const
@ -295,17 +299,6 @@ bool OpenGLHostDisplay::DoneRenderContextCurrent()
return m_gl_context->DoneCurrent();
}
void OpenGLHostDisplay::DestroyRenderDevice()
{
if (!m_gl_context)
return;
DestroyResources();
m_gl_context->DoneCurrent();
m_gl_context.reset();
}
bool OpenGLHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
{
Assert(m_gl_context);
@ -789,7 +782,7 @@ bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config)
for (u32 i = 0; i < m_post_processing_chain.GetStageCount(); i++)
{
const PostProcessingShader& shader = m_post_processing_chain.GetShaderStage(i);
const FrontendCommon::PostProcessingShader& shader = m_post_processing_chain.GetShaderStage(i);
const std::string vs = shadergen.GeneratePostProcessingVertexShader(shader);
const std::string ps = shadergen.GeneratePostProcessingFragmentShader(shader);
@ -1230,5 +1223,3 @@ bool OpenGLHostDisplayTexture::Update(u32 x, u32 y, u32 width, u32 height, const
return true;
}
} // namespace FrontendCommon

View file

@ -9,8 +9,6 @@
#include "postprocessing_chain.h"
#include <memory>
namespace FrontendCommon {
class OpenGLHostDisplay final : public HostDisplay
{
public:
@ -28,7 +26,6 @@ public:
bool threaded_presentation) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override;
@ -118,7 +115,7 @@ protected:
std::unique_ptr<GL::StreamBuffer> m_texture_stream_buffer;
std::vector<u8> m_texture_repack_buffer;
PostProcessingChain m_post_processing_chain;
FrontendCommon::PostProcessingChain m_post_processing_chain;
GL::Texture m_post_processing_input_texture;
std::unique_ptr<GL::StreamBuffer> m_post_processing_ubo;
std::vector<PostProcessingStage> m_post_processing_stages;
@ -133,5 +130,3 @@ protected:
bool m_use_gles2_draw_path = false;
bool m_use_pbo_for_pixels = false;
};
} // namespace FrontendCommon

View file

@ -583,8 +583,6 @@ bool VulkanHostDisplay::UpdateImGuiFontTexture()
return ImGui_ImplVulkan_CreateFontsTexture();
}
void VulkanHostDisplay::DestroyRenderDevice() {}
bool VulkanHostDisplay::MakeRenderContextCurrent()
{
return true;

View file

@ -30,7 +30,6 @@ public:
bool threaded_presentation) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override;