diff --git a/src/core/host_display.h b/src/core/host_display.h index 54ee8b864..403e04304 100644 --- a/src/core/host_display.h +++ b/src/core/host_display.h @@ -67,10 +67,8 @@ public: virtual bool HasRenderDevice() const = 0; virtual bool HasRenderSurface() const = 0; - virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) = 0; - virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) = 0; + virtual bool CreateRenderDevice(const WindowInfo& wi) = 0; + virtual bool InitializeRenderDevice() = 0; virtual bool MakeRenderContextCurrent() = 0; virtual bool DoneRenderContextCurrent() = 0; virtual void DestroyRenderSurface() = 0; diff --git a/src/duckstation-nogui/nogui_host.cpp b/src/duckstation-nogui/nogui_host.cpp index 18c342bc4..cea402fc4 100644 --- a/src/duckstation-nogui/nogui_host.cpp +++ b/src/duckstation-nogui/nogui_host.cpp @@ -649,14 +649,8 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api) if (wi.has_value()) { g_host_display = Host::CreateDisplayForAPI(api); - if (g_host_display) - { - 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(); - } - } + if (g_host_display && !g_host_display->CreateRenderDevice(wi.value())) + g_host_display.reset(); } if (g_host_display) @@ -676,9 +670,7 @@ bool NoGUIHost::AcquireHostDisplay(RenderAPI api) return false; } - if (!g_host_display->MakeRenderContextCurrent() || - !g_host_display->InitializeRenderDevice(EmuFolders::Cache, g_settings.gpu_use_debug_device, - g_settings.gpu_threaded_presentation) || + if (!g_host_display->MakeRenderContextCurrent() || !g_host_display->InitializeRenderDevice() || !ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources()) { ImGuiManager::Shutdown(); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 6137c57ef..0f2450887 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -162,8 +162,7 @@ bool MainWindow::createDisplay(bool fullscreen, bool render_to_main) g_emu_thread->connectDisplaySignals(m_display_widget); - if (!g_host_display->CreateRenderDevice(wi.value(), g_settings.gpu_adapter, g_settings.gpu_use_debug_device, - g_settings.gpu_threaded_presentation)) + if (!g_host_display->CreateRenderDevice(wi.value())) { QMessageBox::critical(this, tr("Error"), tr("Failed to create host display device context.")); destroyDisplayWidget(true); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index deaa36703..f7f5c5a81 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -732,9 +732,7 @@ bool EmuThread::acquireHostDisplay(RenderAPI api) return false; } - if (!g_host_display->MakeRenderContextCurrent() || - !g_host_display->InitializeRenderDevice(EmuFolders::Cache, g_settings.gpu_use_debug_device, - g_settings.gpu_threaded_presentation) || + if (!g_host_display->MakeRenderContextCurrent() || !g_host_display->InitializeRenderDevice() || !ImGuiManager::Initialize() || !CommonHost::CreateHostDisplayResources()) { ImGuiManager::Shutdown(); diff --git a/src/duckstation-regtest/regtest_host_display.cpp b/src/duckstation-regtest/regtest_host_display.cpp index cb8bd9ca0..4af566ec9 100644 --- a/src/duckstation-regtest/regtest_host_display.cpp +++ b/src/duckstation-regtest/regtest_host_display.cpp @@ -38,15 +38,13 @@ bool RegTestHostDisplay::HasRenderSurface() const return true; } -bool RegTestHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) +bool RegTestHostDisplay::CreateRenderDevice(const WindowInfo& wi) { m_window_info = wi; return true; } -bool RegTestHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) +bool RegTestHostDisplay::InitializeRenderDevice() { return true; } diff --git a/src/duckstation-regtest/regtest_host_display.h b/src/duckstation-regtest/regtest_host_display.h index 3672423da..9bb195982 100644 --- a/src/duckstation-regtest/regtest_host_display.h +++ b/src/duckstation-regtest/regtest_host_display.h @@ -15,10 +15,8 @@ public: bool HasRenderDevice() const override; bool HasRenderSurface() const override; - bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) override; - bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) override; + bool CreateRenderDevice(const WindowInfo& wi) override; + bool InitializeRenderDevice() override; bool MakeRenderContextCurrent() override; bool DoneRenderContextCurrent() override; diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index 309f9b99a..9c4e83480 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -197,11 +197,10 @@ void D3D11HostDisplay::SetVSync(bool enabled) m_vsync = enabled; } -bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) +bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi) { UINT create_flags = 0; - if (debug_device) + if (g_settings.gpu_use_debug_device) create_flags |= D3D11_CREATE_DEVICE_DEBUG; ComPtr temp_dxgi_factory; @@ -217,17 +216,17 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view } u32 adapter_index; - if (!adapter_name.empty()) + if (!g_settings.gpu_adapter.empty()) { AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get())); for (adapter_index = 0; adapter_index < static_cast(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; } if (adapter_index == static_cast(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_index = 0; } @@ -261,7 +260,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view return false; } - if (debug_device && IsDebuggerPresent()) + if (g_settings.gpu_use_debug_device && IsDebuggerPresent()) { ComPtr info; hr = m_device.As(&info); @@ -321,8 +320,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view return true; } -bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) +bool D3D11HostDisplay::InitializeRenderDevice() { if (!CreateResources()) return false; diff --git a/src/frontend-common/d3d11_host_display.h b/src/frontend-common/d3d11_host_display.h index 1ce251b48..52f550530 100644 --- a/src/frontend-common/d3d11_host_display.h +++ b/src/frontend-common/d3d11_host_display.h @@ -30,10 +30,8 @@ public: bool HasRenderDevice() const override; bool HasRenderSurface() const override; - bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) override; - bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) override; + bool CreateRenderDevice(const WindowInfo& wi) override; + bool InitializeRenderDevice() override; bool MakeRenderContextCurrent() override; bool DoneRenderContextCurrent() override; diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index 1aa94773c..8368bce43 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -142,8 +142,7 @@ void D3D12HostDisplay::SetVSync(bool enabled) m_vsync = enabled; } -bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) +bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi) { ComPtr temp_dxgi_factory; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) @@ -159,18 +158,18 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view } u32 adapter_index; - if (!adapter_name.empty()) + if (!g_settings.gpu_adapter.empty()) { AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get())); for (adapter_index = 0; adapter_index < static_cast(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; } if (adapter_index == static_cast(adapter_info.adapter_names.size())) { - Log_WarningPrintf("Could not find adapter '%*s', using first (%s)", static_cast(adapter_name.size()), - adapter_name.data(), adapter_info.adapter_names[0].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_index = 0; } } @@ -180,7 +179,7 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view 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; if (FAILED(hr)) @@ -214,8 +213,7 @@ bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view return true; } -bool D3D12HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) +bool D3D12HostDisplay::InitializeRenderDevice() { if (!CreateResources()) return false; diff --git a/src/frontend-common/d3d12_host_display.h b/src/frontend-common/d3d12_host_display.h index 268f13cd4..bd5cd684d 100644 --- a/src/frontend-common/d3d12_host_display.h +++ b/src/frontend-common/d3d12_host_display.h @@ -32,10 +32,8 @@ public: bool HasRenderDevice() const override; bool HasRenderSurface() const override; - bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) override; - bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) override; + bool CreateRenderDevice(const WindowInfo& wi) override; + bool InitializeRenderDevice() override; bool MakeRenderContextCurrent() override; bool DoneRenderContextCurrent() override; diff --git a/src/frontend-common/opengl_host_display.cpp b/src/frontend-common/opengl_host_display.cpp index 9a174a970..154e2f5af 100644 --- a/src/frontend-common/opengl_host_display.cpp +++ b/src/frontend-common/opengl_host_display.cpp @@ -281,8 +281,7 @@ bool OpenGLHostDisplay::HasRenderSurface() const return m_window_info.type != WindowInfo::Type::Surfaceless; } -bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) +bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi) { m_gl_context = GL::Context::Create(wi); if (!m_gl_context) @@ -296,8 +295,7 @@ bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie return true; } -bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) +bool OpenGLHostDisplay::InitializeRenderDevice() { m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_0); 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 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) glDebugMessageCallbackKHR(GLDebugCallback, nullptr); diff --git a/src/frontend-common/opengl_host_display.h b/src/frontend-common/opengl_host_display.h index 9e693d156..15c061ca1 100644 --- a/src/frontend-common/opengl_host_display.h +++ b/src/frontend-common/opengl_host_display.h @@ -23,10 +23,8 @@ public: bool HasRenderDevice() const override; bool HasRenderSurface() const override; - bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) override; - bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) override; + bool CreateRenderDevice(const WindowInfo& wi) override; + bool InitializeRenderDevice() override; bool MakeRenderContextCurrent() override; bool DoneRenderContextCurrent() override; diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 769be0c94..0e88b023f 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -214,17 +214,19 @@ void VulkanHostDisplay::SetVSync(bool enabled) m_swap_chain->SetVSync(enabled); } -bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) +bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& 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"); m_window_info = {}; 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 || 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; } -bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) +bool VulkanHostDisplay::InitializeRenderDevice() { - Vulkan::ShaderCache::Create(shader_cache_directory, SHADER_CACHE_VERSION, debug_device); - if (!CreateResources()) return false; diff --git a/src/frontend-common/vulkan_host_display.h b/src/frontend-common/vulkan_host_display.h index 732001319..93878be5f 100644 --- a/src/frontend-common/vulkan_host_display.h +++ b/src/frontend-common/vulkan_host_display.h @@ -27,10 +27,8 @@ public: bool HasRenderDevice() const override; bool HasRenderSurface() const override; - bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, - bool threaded_presentation) override; - bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, - bool threaded_presentation) override; + bool CreateRenderDevice(const WindowInfo& wi) override; + bool InitializeRenderDevice() override; bool MakeRenderContextCurrent() override; bool DoneRenderContextCurrent() override;