HostDisplay: Remove parameters which get pulled from config

No point duplicating them.
This commit is contained in:
Connor McLaughlin 2022-10-13 23:07:23 +10:00
parent 43e959bdc9
commit 11ba87059e
14 changed files with 42 additions and 74 deletions

View File

@ -67,10 +67,8 @@ public:
virtual bool HasRenderDevice() const = 0; virtual bool HasRenderDevice() const = 0;
virtual bool HasRenderSurface() const = 0; virtual bool HasRenderSurface() const = 0;
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, virtual bool CreateRenderDevice(const WindowInfo& wi) = 0;
bool threaded_presentation) = 0; virtual bool InitializeRenderDevice() = 0;
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) = 0;
virtual bool MakeRenderContextCurrent() = 0; virtual bool MakeRenderContextCurrent() = 0;
virtual bool DoneRenderContextCurrent() = 0; virtual bool DoneRenderContextCurrent() = 0;
virtual void DestroyRenderSurface() = 0; virtual void DestroyRenderSurface() = 0;

View File

@ -649,15 +649,9 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api)
if (wi.has_value()) if (wi.has_value())
{ {
g_host_display = Host::CreateDisplayForAPI(api); g_host_display = Host::CreateDisplayForAPI(api);
if (g_host_display) if (g_host_display && !g_host_display->CreateRenderDevice(wi.value()))
{
if (!g_host_display->CreateRenderDevice(wi.value(), g_settings.gpu_adapter, g_settings.gpu_use_debug_device,
g_settings.gpu_threaded_presentation))
{
g_host_display.reset(); g_host_display.reset();
} }
}
}
if (g_host_display) if (g_host_display)
g_host_display->DoneRenderContextCurrent(); g_host_display->DoneRenderContextCurrent();
@ -676,9 +670,7 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api)
return false; return false;
} }
if (!g_host_display->MakeRenderContextCurrent() || if (!g_host_display->MakeRenderContextCurrent() || !g_host_display->InitializeRenderDevice() ||
!g_host_display->InitializeRenderDevice(EmuFolders::Cache, g_settings.gpu_use_debug_device,
g_settings.gpu_threaded_presentation) ||
!ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources()) !ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources())
{ {
ImGuiManager::Shutdown(); ImGuiManager::Shutdown();

View File

@ -162,8 +162,7 @@ bool MainWindow::createDisplay(bool fullscreen, bool render_to_main)
g_emu_thread->connectDisplaySignals(m_display_widget); g_emu_thread->connectDisplaySignals(m_display_widget);
if (!g_host_display->CreateRenderDevice(wi.value(), g_settings.gpu_adapter, g_settings.gpu_use_debug_device, if (!g_host_display->CreateRenderDevice(wi.value()))
g_settings.gpu_threaded_presentation))
{ {
QMessageBox::critical(this, tr("Error"), tr("Failed to create host display device context.")); QMessageBox::critical(this, tr("Error"), tr("Failed to create host display device context."));
destroyDisplayWidget(true); destroyDisplayWidget(true);

View File

@ -732,9 +732,7 @@ bool EmuThread::acquireHostDisplay(RenderAPI api)
return false; return false;
} }
if (!g_host_display->MakeRenderContextCurrent() || if (!g_host_display->MakeRenderContextCurrent() || !g_host_display->InitializeRenderDevice() ||
!g_host_display->InitializeRenderDevice(EmuFolders::Cache, g_settings.gpu_use_debug_device,
g_settings.gpu_threaded_presentation) ||
!ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources()) !ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources())
{ {
ImGuiManager::Shutdown(); ImGuiManager::Shutdown();

View File

@ -38,15 +38,13 @@ bool RegTestHostDisplay::HasRenderSurface() const
return true; return true;
} }
bool RegTestHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool RegTestHostDisplay::CreateRenderDevice(const WindowInfo& wi)
bool threaded_presentation)
{ {
m_window_info = wi; m_window_info = wi;
return true; return true;
} }
bool RegTestHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool RegTestHostDisplay::InitializeRenderDevice()
bool threaded_presentation)
{ {
return true; return true;
} }

View File

@ -15,10 +15,8 @@ public:
bool HasRenderDevice() const override; bool HasRenderDevice() const override;
bool HasRenderSurface() const override; bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool CreateRenderDevice(const WindowInfo& wi) override;
bool threaded_presentation) override; bool InitializeRenderDevice() override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
bool MakeRenderContextCurrent() override; bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override; bool DoneRenderContextCurrent() override;

View File

@ -197,11 +197,10 @@ void D3D11HostDisplay::SetVSync(bool enabled)
m_vsync = enabled; m_vsync = enabled;
} }
bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi)
bool threaded_presentation)
{ {
UINT create_flags = 0; UINT create_flags = 0;
if (debug_device) if (g_settings.gpu_use_debug_device)
create_flags |= D3D11_CREATE_DEVICE_DEBUG; create_flags |= D3D11_CREATE_DEVICE_DEBUG;
ComPtr<IDXGIFactory> temp_dxgi_factory; ComPtr<IDXGIFactory> temp_dxgi_factory;
@ -217,17 +216,17 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
} }
u32 adapter_index; u32 adapter_index;
if (!adapter_name.empty()) if (!g_settings.gpu_adapter.empty())
{ {
AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get())); AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get()));
for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++) for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++)
{ {
if (adapter_name == adapter_info.adapter_names[adapter_index]) if (g_settings.gpu_adapter == adapter_info.adapter_names[adapter_index])
break; break;
} }
if (adapter_index == static_cast<u32>(adapter_info.adapter_names.size())) if (adapter_index == static_cast<u32>(adapter_info.adapter_names.size()))
{ {
Log_WarningPrintf("Could not find adapter '%s', using first (%s)", std::string(adapter_name).c_str(), Log_WarningPrintf("Could not find adapter '%s', using first (%s)", g_settings.gpu_adapter.c_str(),
adapter_info.adapter_names[0].c_str()); adapter_info.adapter_names[0].c_str());
adapter_index = 0; adapter_index = 0;
} }
@ -261,7 +260,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
return false; return false;
} }
if (debug_device && IsDebuggerPresent()) if (g_settings.gpu_use_debug_device && IsDebuggerPresent())
{ {
ComPtr<ID3D11InfoQueue> info; ComPtr<ID3D11InfoQueue> info;
hr = m_device.As(&info); hr = m_device.As(&info);
@ -321,8 +320,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
return true; return true;
} }
bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool D3D11HostDisplay::InitializeRenderDevice()
bool threaded_presentation)
{ {
if (!CreateResources()) if (!CreateResources())
return false; return false;

View File

@ -30,10 +30,8 @@ public:
bool HasRenderDevice() const override; bool HasRenderDevice() const override;
bool HasRenderSurface() const override; bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool CreateRenderDevice(const WindowInfo& wi) override;
bool threaded_presentation) override; bool InitializeRenderDevice() override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
bool MakeRenderContextCurrent() override; bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override; bool DoneRenderContextCurrent() override;

View File

@ -142,8 +142,7 @@ void D3D12HostDisplay::SetVSync(bool enabled)
m_vsync = enabled; m_vsync = enabled;
} }
bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi)
bool threaded_presentation)
{ {
ComPtr<IDXGIFactory> temp_dxgi_factory; ComPtr<IDXGIFactory> temp_dxgi_factory;
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
@ -159,18 +158,18 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
} }
u32 adapter_index; u32 adapter_index;
if (!adapter_name.empty()) if (!g_settings.gpu_adapter.empty())
{ {
AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get())); AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get()));
for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++) for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++)
{ {
if (adapter_name == adapter_info.adapter_names[adapter_index]) if (g_settings.gpu_adapter == adapter_info.adapter_names[adapter_index])
break; break;
} }
if (adapter_index == static_cast<u32>(adapter_info.adapter_names.size())) if (adapter_index == static_cast<u32>(adapter_info.adapter_names.size()))
{ {
Log_WarningPrintf("Could not find adapter '%*s', using first (%s)", static_cast<int>(adapter_name.size()), Log_WarningPrintf("Could not find adapter '%s', using first (%s)", g_settings.gpu_adapter.c_str(),
adapter_name.data(), adapter_info.adapter_names[0].c_str()); adapter_info.adapter_names[0].c_str());
adapter_index = 0; adapter_index = 0;
} }
} }
@ -180,7 +179,7 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
adapter_index = 0; adapter_index = 0;
} }
if (!D3D12::Context::Create(temp_dxgi_factory.Get(), adapter_index, debug_device)) if (!D3D12::Context::Create(temp_dxgi_factory.Get(), adapter_index, g_settings.gpu_use_debug_device))
return false; return false;
if (FAILED(hr)) if (FAILED(hr))
@ -214,8 +213,7 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
return true; return true;
} }
bool D3D12HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool D3D12HostDisplay::InitializeRenderDevice()
bool threaded_presentation)
{ {
if (!CreateResources()) if (!CreateResources())
return false; return false;

View File

@ -32,10 +32,8 @@ public:
bool HasRenderDevice() const override; bool HasRenderDevice() const override;
bool HasRenderSurface() const override; bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool CreateRenderDevice(const WindowInfo& wi) override;
bool threaded_presentation) override; bool InitializeRenderDevice() override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
bool MakeRenderContextCurrent() override; bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override; bool DoneRenderContextCurrent() override;

View File

@ -281,8 +281,7 @@ bool OpenGLHostDisplay::HasRenderSurface() const
return m_window_info.type != WindowInfo::Type::Surfaceless; return m_window_info.type != WindowInfo::Type::Surfaceless;
} }
bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi)
bool threaded_presentation)
{ {
m_gl_context = GL::Context::Create(wi); m_gl_context = GL::Context::Create(wi);
if (!m_gl_context) if (!m_gl_context)
@ -296,8 +295,7 @@ bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
return true; return true;
} }
bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool OpenGLHostDisplay::InitializeRenderDevice()
bool threaded_presentation)
{ {
m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_0); m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_0);
if (!m_use_gles2_draw_path) if (!m_use_gles2_draw_path)
@ -316,7 +314,7 @@ bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_dir
Log_VerbosePrintf("Using GLES2 draw path: %s", m_use_gles2_draw_path ? "yes" : "no"); Log_VerbosePrintf("Using GLES2 draw path: %s", m_use_gles2_draw_path ? "yes" : "no");
Log_VerbosePrintf("Using PBO for streaming: %s", m_use_pbo_for_pixels ? "yes" : "no"); Log_VerbosePrintf("Using PBO for streaming: %s", m_use_pbo_for_pixels ? "yes" : "no");
if (debug_device && GLAD_GL_KHR_debug) if (g_settings.gpu_use_debug_device && GLAD_GL_KHR_debug)
{ {
if (GetRenderAPI() == RenderAPI::OpenGLES) if (GetRenderAPI() == RenderAPI::OpenGLES)
glDebugMessageCallbackKHR(GLDebugCallback, nullptr); glDebugMessageCallbackKHR(GLDebugCallback, nullptr);

View File

@ -23,10 +23,8 @@ public:
bool HasRenderDevice() const override; bool HasRenderDevice() const override;
bool HasRenderSurface() const override; bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool CreateRenderDevice(const WindowInfo& wi) override;
bool threaded_presentation) override; bool InitializeRenderDevice() override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
bool MakeRenderContextCurrent() override; bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override; bool DoneRenderContextCurrent() override;

View File

@ -214,17 +214,19 @@ void VulkanHostDisplay::SetVSync(bool enabled)
m_swap_chain->SetVSync(enabled); m_swap_chain->SetVSync(enabled);
} }
bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi)
bool threaded_presentation)
{ {
WindowInfo local_wi(wi); WindowInfo local_wi(wi);
if (!Vulkan::Context::Create(adapter_name, &local_wi, &m_swap_chain, threaded_presentation, debug_device, false)) if (!Vulkan::Context::Create(g_settings.gpu_adapter, &local_wi, &m_swap_chain, g_settings.gpu_threaded_presentation,
g_settings.gpu_use_debug_device, false))
{ {
Log_ErrorPrintf("Failed to create Vulkan context"); Log_ErrorPrintf("Failed to create Vulkan context");
m_window_info = {}; m_window_info = {};
return false; return false;
} }
Vulkan::ShaderCache::Create(EmuFolders::Cache, SHADER_CACHE_VERSION, g_settings.gpu_use_debug_device);
m_is_adreno = (g_vulkan_context->GetDeviceProperties().vendorID == 0x5143 || m_is_adreno = (g_vulkan_context->GetDeviceProperties().vendorID == 0x5143 ||
g_vulkan_context->GetDeviceDriverProperties().driverID == VK_DRIVER_ID_QUALCOMM_PROPRIETARY); g_vulkan_context->GetDeviceDriverProperties().driverID == VK_DRIVER_ID_QUALCOMM_PROPRIETARY);
@ -232,11 +234,8 @@ bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
return true; return true;
} }
bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool VulkanHostDisplay::InitializeRenderDevice()
bool threaded_presentation)
{ {
Vulkan::ShaderCache::Create(shader_cache_directory, SHADER_CACHE_VERSION, debug_device);
if (!CreateResources()) if (!CreateResources())
return false; return false;

View File

@ -27,10 +27,8 @@ public:
bool HasRenderDevice() const override; bool HasRenderDevice() const override;
bool HasRenderSurface() const override; bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool CreateRenderDevice(const WindowInfo& wi) override;
bool threaded_presentation) override; bool InitializeRenderDevice() override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
bool MakeRenderContextCurrent() override; bool MakeRenderContextCurrent() override;
bool DoneRenderContextCurrent() override; bool DoneRenderContextCurrent() override;