From 55c77dd25b7ab7a12acb764d27ada77c9d16cb00 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 2 May 2023 16:48:45 -0700 Subject: [PATCH] yuzu-qt/config: Add option to disable compute on Intel This option is only visible if an Intel GPU using the proprietary driver is found during Vulkan device enumeration. configure_graphics: More directly get driver id Vulkan::Device does quite a bit more than we need just to see the driver ID here. --- src/yuzu/configuration/config.cpp | 2 ++ src/yuzu/configuration/configure_dialog.cpp | 3 ++- src/yuzu/configuration/configure_dialog.h | 2 +- src/yuzu/configuration/configure_graphics.cpp | 23 +++++++++++++++---- src/yuzu/configuration/configure_graphics.h | 6 ++++- .../configure_graphics_advanced.cpp | 17 ++++++++++++++ .../configure_graphics_advanced.h | 3 +++ .../configure_graphics_advanced.ui | 11 +++++++++ src/yuzu/configuration/configure_per_game.cpp | 3 ++- src/yuzu/configuration/configure_per_game.h | 2 +- 10 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index a85eb4687..b52203ff1 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -714,6 +714,7 @@ void Config::ReadRendererValues() { ReadGlobalSetting(Settings::values.use_asynchronous_shaders); ReadGlobalSetting(Settings::values.use_fast_gpu_time); ReadGlobalSetting(Settings::values.use_vulkan_driver_pipeline_cache); + ReadGlobalSetting(Settings::values.enable_compute_pipelines); ReadGlobalSetting(Settings::values.bg_red); ReadGlobalSetting(Settings::values.bg_green); ReadGlobalSetting(Settings::values.bg_blue); @@ -1362,6 +1363,7 @@ void Config::SaveRendererValues() { WriteGlobalSetting(Settings::values.use_asynchronous_shaders); WriteGlobalSetting(Settings::values.use_fast_gpu_time); WriteGlobalSetting(Settings::values.use_vulkan_driver_pipeline_cache); + WriteGlobalSetting(Settings::values.enable_compute_pipelines); WriteGlobalSetting(Settings::values.bg_red); WriteGlobalSetting(Settings::values.bg_green); WriteGlobalSetting(Settings::values.bg_blue); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 2aaefcc05..8e76a819a 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -36,8 +36,9 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, debug_tab_tab{std::make_unique(system_, this)}, filesystem_tab{std::make_unique(this)}, general_tab{std::make_unique(system_, this)}, - graphics_tab{std::make_unique(system_, this)}, graphics_advanced_tab{std::make_unique(system_, this)}, + graphics_tab{std::make_unique( + system_, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, this)}, hotkeys_tab{std::make_unique(system_.HIDCore(), this)}, input_tab{std::make_unique(system_, this)}, network_tab{std::make_unique(system_, this)}, diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 1f724834a..a086a07c4 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h @@ -72,8 +72,8 @@ private: std::unique_ptr debug_tab_tab; std::unique_ptr filesystem_tab; std::unique_ptr general_tab; - std::unique_ptr graphics_tab; std::unique_ptr graphics_advanced_tab; + std::unique_ptr graphics_tab; std::unique_ptr hotkeys_tab; std::unique_ptr input_tab; std::unique_ptr network_tab; diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 76e5b7499..f316b598c 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Include this early to include Vulkan headers how we want to +#include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" #include +#include #include #include #include @@ -74,8 +76,11 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) } } -ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique()}, system{system_} { +ConfigureGraphics::ConfigureGraphics(const Core::System& system_, + const std::function& expose_compute_option_, + QWidget* parent) + : QWidget(parent), ui{std::make_unique()}, + expose_compute_option{expose_compute_option_}, system{system_} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); @@ -513,8 +518,7 @@ void ConfigureGraphics::RetrieveVulkanDevices() try { const Common::DynamicLibrary library = OpenLibrary(); const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1, wsi.type); const std::vector physical_devices = instance.EnumeratePhysicalDevices(); - vk::SurfaceKHR surface = //< needed to view present modes for a device - CreateSurface(instance, wsi); + vk::SurfaceKHR surface = CreateSurface(instance, wsi); vulkan_devices.clear(); vulkan_devices.reserve(physical_devices.size()); @@ -527,6 +531,17 @@ void ConfigureGraphics::RetrieveVulkanDevices() try { physical_device.GetSurfacePresentModesKHR(*surface); vulkan_devices.push_back(QString::fromStdString(name)); device_present_modes.push_back(present_modes); + + VkPhysicalDeviceDriverProperties driver_properties{}; + driver_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; + driver_properties.pNext = nullptr; + VkPhysicalDeviceProperties2 properties{}; + properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; + properties.pNext = &driver_properties; + dld.vkGetPhysicalDeviceProperties2(physical_device, &properties); + if (driver_properties.driverID == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { + expose_compute_option(); + } } } catch (const Vulkan::vk::Exception& exception) { LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 901f604a5..364b1cac2 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -37,7 +38,9 @@ class ConfigureGraphics : public QWidget { Q_OBJECT public: - explicit ConfigureGraphics(const Core::System& system_, QWidget* parent = nullptr); + explicit ConfigureGraphics(const Core::System& system_, + const std::function& expose_compute_option_, + QWidget* parent = nullptr); ~ConfigureGraphics() override; void ApplyConfiguration(); @@ -81,6 +84,7 @@ private: // selection in the combobox u32 vulkan_device{}; Settings::ShaderBackend shader_backend{}; + const std::function& expose_compute_option; const Core::System& system; }; diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 005b022ca..7975285a7 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -12,6 +12,8 @@ ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_ ui->setupUi(this); + ui->enable_compute_pipelines_checkbox->setVisible(false); + SetupPerGameUI(); SetConfiguration(); @@ -26,6 +28,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { ui->async_astc->setEnabled(runtime_lock); ui->use_asynchronous_shaders->setEnabled(runtime_lock); ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); + ui->enable_compute_pipelines_checkbox->setEnabled(runtime_lock); ui->async_present->setChecked(Settings::values.async_presentation.GetValue()); ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue()); @@ -34,6 +37,8 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); ui->use_vulkan_driver_pipeline_cache->setChecked( Settings::values.use_vulkan_driver_pipeline_cache.GetValue()); + ui->enable_compute_pipelines_checkbox->setChecked( + Settings::values.enable_compute_pipelines.GetValue()); if (Settings::IsConfiguringGlobal()) { ui->gpu_accuracy->setCurrentIndex( @@ -70,6 +75,9 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vulkan_driver_pipeline_cache, ui->use_vulkan_driver_pipeline_cache, use_vulkan_driver_pipeline_cache); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_compute_pipelines, + ui->enable_compute_pipelines_checkbox, + enable_compute_pipelines); } void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { @@ -99,6 +107,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { Settings::values.use_vulkan_driver_pipeline_cache.UsingGlobal()); ui->anisotropic_filtering_combobox->setEnabled( Settings::values.max_anisotropy.UsingGlobal()); + ui->enable_compute_pipelines_checkbox->setEnabled( + Settings::values.enable_compute_pipelines.UsingGlobal()); return; } @@ -118,6 +128,9 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { ConfigurationShared::SetColoredTristate(ui->use_vulkan_driver_pipeline_cache, Settings::values.use_vulkan_driver_pipeline_cache, use_vulkan_driver_pipeline_cache); + ConfigurationShared::SetColoredTristate(ui->enable_compute_pipelines_checkbox, + Settings::values.enable_compute_pipelines, + enable_compute_pipelines); ConfigurationShared::SetColoredComboBox( ui->gpu_accuracy, ui->label_gpu_accuracy, static_cast(Settings::values.gpu_accuracy.GetValue(true))); @@ -125,3 +138,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { ui->anisotropic_filtering_combobox, ui->af_label, static_cast(Settings::values.max_anisotropy.GetValue(true))); } + +void ConfigureGraphicsAdvanced::ExposeComputeOption() { + ui->enable_compute_pipelines_checkbox->setVisible(true); +} diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index ff5060957..2d8c7fd2d 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -28,6 +28,8 @@ public: void ApplyConfiguration(); void SetConfiguration(); + void ExposeComputeOption(); + private: void changeEvent(QEvent* event) override; void RetranslateUI(); @@ -43,6 +45,7 @@ private: ConfigurationShared::CheckState use_asynchronous_shaders; ConfigurationShared::CheckState use_fast_gpu_time; ConfigurationShared::CheckState use_vulkan_driver_pipeline_cache; + ConfigurationShared::CheckState enable_compute_pipelines; const Core::System& system; }; diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index d073fe9b1..a222d294b 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -126,6 +126,17 @@ + + + + Enable compute pipelines, required by some games. This setting only exists for Intel proprietary drivers, and may crash if enabled. +Compute pipelines are always enabled on all other drivers. + + + Enable Compute Pipelines (Intel Vulkan only) + + + diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 7e757eafd..7ac162586 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -48,8 +48,9 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st audio_tab = std::make_unique(system_, this); cpu_tab = std::make_unique(system_, this); general_tab = std::make_unique(system_, this); - graphics_tab = std::make_unique(system_, this); graphics_advanced_tab = std::make_unique(system_, this); + graphics_tab = std::make_unique( + system_, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, this); input_tab = std::make_unique(system_, game_config.get(), this); system_tab = std::make_unique(system_, this); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 4ecc43541..85752f1fa 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -75,8 +75,8 @@ private: std::unique_ptr audio_tab; std::unique_ptr cpu_tab; std::unique_ptr general_tab; - std::unique_ptr graphics_tab; std::unique_ptr graphics_advanced_tab; + std::unique_ptr graphics_tab; std::unique_ptr input_tab; std::unique_ptr system_tab; };