From acf7b81b9a3eade9cdd063d365fd5dcd7b034205 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 8 May 2023 00:52:13 +0200 Subject: [PATCH] early-access version 3567 --- README.md | 2 +- src/common/settings.cpp | 1 + src/common/settings.h | 1 + src/core/file_sys/vfs_layered.cpp | 9 +++++--- src/core/file_sys/vfs_vector.cpp | 19 +++++++++++++++ src/core/file_sys/vfs_vector.h | 4 ++++ .../renderer_vulkan/vk_pipeline_cache.cpp | 3 ++- 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 +- 17 files changed, 97 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cc874a5e9..16563faad 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3566. +This is the source code for early-access 3567. ## Legal Notice diff --git a/src/common/settings.cpp b/src/common/settings.cpp index d4280396d..b5f08d082 100755 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -232,6 +232,7 @@ void RestoreGlobalState(bool is_powered_on) { values.bg_red.SetGlobal(true); values.bg_green.SetGlobal(true); values.bg_blue.SetGlobal(true); + values.enable_compute_pipelines.SetGlobal(true); // System values.language_index.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index 3fc3e2c96..eb1bc34ed 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -472,6 +472,7 @@ struct Values { SwitchableSetting use_fast_gpu_time{true, "use_fast_gpu_time"}; SwitchableSetting use_vulkan_driver_pipeline_cache{true, "use_vulkan_driver_pipeline_cache"}; + SwitchableSetting enable_compute_pipelines{false, "enable_compute_pipelines"}; SwitchableSetting bg_red{0, "bg_red"}; SwitchableSetting bg_green{0, "bg_green"}; diff --git a/src/core/file_sys/vfs_layered.cpp b/src/core/file_sys/vfs_layered.cpp index 1ed48d117..96184852f 100755 --- a/src/core/file_sys/vfs_layered.cpp +++ b/src/core/file_sys/vfs_layered.cpp @@ -4,6 +4,7 @@ #include #include #include "core/file_sys/vfs_layered.h" +#include "core/file_sys/vfs_types.h" namespace FileSys { @@ -58,11 +59,13 @@ std::string LayeredVfsDirectory::GetFullPath() const { std::vector LayeredVfsDirectory::GetFiles() const { std::vector out; + std::map> out_positions; + for (const auto& layer : dirs) { for (const auto& file : layer->GetFiles()) { - if (std::find_if(out.begin(), out.end(), [&file](const VirtualFile& comp) { - return comp->GetName() == file->GetName(); - }) == out.end()) { + auto file_name = file->GetName(); + if (!out_positions.contains(file_name)) { + out_positions.emplace(std::move(file_name), out.size()); out.push_back(file); } } diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 809d3c4ba..8574e9b99 100755 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -67,6 +67,23 @@ VectorVfsDirectory::VectorVfsDirectory(std::vector files_, VectorVfsDirectory::~VectorVfsDirectory() = default; +VirtualFile VectorVfsDirectory::GetFile(std::string_view file_name) const { + if (!optimized_file_index_built) { + optimized_file_index.clear(); + for (size_t i = 0; i < files.size(); i++) { + optimized_file_index.emplace(files[i]->GetName(), i); + } + optimized_file_index_built = true; + } + + const auto it = optimized_file_index.find(file_name); + if (it != optimized_file_index.end()) { + return files[it->second]; + } + + return nullptr; +} + std::vector VectorVfsDirectory::GetFiles() const { return files; } @@ -107,6 +124,7 @@ bool VectorVfsDirectory::DeleteSubdirectory(std::string_view subdir_name) { } bool VectorVfsDirectory::DeleteFile(std::string_view file_name) { + optimized_file_index_built = false; return FindAndRemoveVectorElement(files, file_name); } @@ -124,6 +142,7 @@ VirtualFile VectorVfsDirectory::CreateFile(std::string_view file_name) { } void VectorVfsDirectory::AddFile(VirtualFile file) { + optimized_file_index_built = false; files.push_back(std::move(file)); } diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index 709a45a85..ee9f784ed 100755 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -105,6 +105,7 @@ public: VirtualDir parent = nullptr); ~VectorVfsDirectory() override; + VirtualFile GetFile(std::string_view file_name) const override; std::vector GetFiles() const override; std::vector GetSubdirectories() const override; bool IsWritable() const override; @@ -126,6 +127,9 @@ private: VirtualDir parent; std::string name; + + mutable std::map> optimized_file_index; + mutable bool optimized_file_index_built{}; }; } // namespace FileSys diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index fa01da590..3fbc12861 100755 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -698,7 +698,8 @@ std::unique_ptr PipelineCache::CreateComputePipeline( PipelineStatistics* statistics, bool build_in_parallel) try { // TODO: Remove this when Intel fixes their shader compiler. // https://github.com/IGCIT/Intel-GPU-Community-Issue-Tracker-IGCIT/issues/159 - if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { + if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS && + !Settings::values.enable_compute_pipelines.GetValue()) { LOG_ERROR(Render_Vulkan, "Skipping 0x{:016x}", key.Hash()); return nullptr; } diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 743e4f393..d96b97162 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -715,6 +715,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); @@ -1364,6 +1365,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 ae0a85ac8..e0abbd8ca 100755 --- 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 0785a9f51..41eb4c4eb 100755 --- 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 ea249e9bb..a304a13bd 100755 --- 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 01237228f..87ad6d5c9 100755 --- 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 0dcdd24b1..498afa308 100755 --- 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(); @@ -27,6 +29,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()); @@ -36,6 +39,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( @@ -74,6 +79,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) { @@ -104,6 +112,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; } @@ -125,6 +135,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))); @@ -132,3 +145,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 4356b07c2..97d1b0943 100755 --- 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(); @@ -44,6 +46,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 ae85886ee..de596d3ac 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -136,6 +136,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 9dc1d5b95..7d25300b2 100755 --- 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 4e3fee9aa..b2d3aee24 100755 --- 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; };