From 6e5e765498f6e716ff6d4c91beafb97dc3738421 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 8 Jan 2026 10:30:08 +0200 Subject: [PATCH] more vulkan settings --- src/common/config.cpp | 44 ------------------- src/common/config.h | 6 --- src/core/emulator_settings.h | 23 +++++----- src/emulator.cpp | 13 ++++-- src/video_core/cache_storage.cpp | 31 ++++++++----- src/video_core/renderdoc.cpp | 7 +-- .../vk_pipeline_serialization.cpp | 4 +- 7 files changed, 49 insertions(+), 79 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 99c48d197..59aea14d0 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -158,11 +158,6 @@ static ConfigEntry shouldDumpShaders(false); static ConfigEntry shouldPatchShaders(false); static ConfigEntry vblankFrequency(60); -// Vulkan -static ConfigEntry rdocEnable(false); -static ConfigEntry pipelineCacheEnable(false); -static ConfigEntry pipelineCacheArchive(false); - // Debug static ConfigEntry isFpsColor(true); static ConfigEntry showFpsCounter(false); @@ -268,18 +263,6 @@ bool patchShaders() { return shouldPatchShaders.get(); } -bool isRdocEnabled() { - return rdocEnable.get(); -} - -bool isPipelineCacheEnabled() { - return pipelineCacheEnable.get(); -} - -bool isPipelineCacheArchived() { - return pipelineCacheArchive.get(); -} - bool fpsColor() { return isFpsColor.get(); } @@ -304,18 +287,6 @@ void setDumpShaders(bool enable, bool is_game_specific) { shouldDumpShaders.set(enable, is_game_specific); } -void setRdocEnabled(bool enable, bool is_game_specific) { - rdocEnable.set(enable, is_game_specific); -} - -void setPipelineCacheEnabled(bool enable, bool is_game_specific) { - pipelineCacheEnable.set(enable, is_game_specific); -} - -void setPipelineCacheArchived(bool enable, bool is_game_specific) { - pipelineCacheArchive.set(enable, is_game_specific); -} - void setVblankFreq(u32 value, bool is_game_specific) { vblankFrequency.set(value, is_game_specific); } @@ -429,13 +400,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { vblankFrequency.setFromToml(gpu, "vblankFrequency", is_game_specific); } - if (data.contains("Vulkan")) { - const toml::value& vk = data.at("Vulkan"); - rdocEnable.setFromToml(vk, "rdocEnable", is_game_specific); - pipelineCacheEnable.setFromToml(vk, "pipelineCacheEnable", is_game_specific); - pipelineCacheArchive.setFromToml(vk, "pipelineCacheArchive", is_game_specific); - } - string current_version = {}; if (data.contains("Debug")) { const toml::value& debug = data.at("Debug"); @@ -526,9 +490,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { shouldDumpShaders.setTomlValue(data, "GPU", "dumpShaders", is_game_specific); vblankFrequency.setTomlValue(data, "GPU", "vblankFrequency", is_game_specific); - rdocEnable.setTomlValue(data, "Vulkan", "rdocEnable", is_game_specific); - pipelineCacheEnable.setTomlValue(data, "Vulkan", "pipelineCacheEnable", is_game_specific); - pipelineCacheArchive.setTomlValue(data, "Vulkan", "pipelineCacheArchive", is_game_specific); m_language.setTomlValue(data, "Settings", "consoleLanguage", is_game_specific); @@ -576,11 +537,6 @@ void setDefaultValues(bool is_game_specific) { shouldDumpShaders.setDefault(is_game_specific); vblankFrequency.setDefault(is_game_specific); - // GS - Vulkan - rdocEnable.set(false, is_game_specific); - pipelineCacheEnable.set(false, is_game_specific); - pipelineCacheArchive.set(false, is_game_specific); - // GS - Settings m_language.setDefault(is_game_specific); diff --git a/src/common/config.h b/src/common/config.h index 29e81b7a9..97a29387a 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -37,12 +37,6 @@ u32 vblankFreq(); void setVblankFreq(u32 value, bool is_game_specific = false); s16 getCursorState(); void setCursorState(s16 cursorState, bool is_game_specific = false); -bool isRdocEnabled(); -bool isPipelineCacheEnabled(); -bool isPipelineCacheArchived(); -void setRdocEnabled(bool enable, bool is_game_specific = false); -void setPipelineCacheEnabled(bool enable, bool is_game_specific = false); -void setPipelineCacheArchived(bool enable, bool is_game_specific = false); int getCursorHideTimeout(); void setCursorHideTimeout(int newcursorHideTimeout, bool is_game_specific = false); u32 GetLanguage(); diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index e91c2d4f9..46d1cd6bc 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -265,8 +265,8 @@ struct VulkanSettings { Setting vkcrash_diagnostic_enabled{false}; Setting vkhost_markers{false}; Setting vkguest_markers{false}; - Setting vkpipeline_cache_enabled{false}; - Setting vkpipeline_cache_archive{false}; + Setting pipeline_cache_enabled{false}; + Setting pipeline_cache_archived{false}; std::vector GetOverrideableFields() const { return std::vector{ make_override("gpu_id", &VulkanSettings::gpu_id), @@ -282,19 +282,20 @@ struct VulkanSettings { &VulkanSettings::vkvalidation_gpu_enabled), make_override("vkcrash_diagnostic_enabled", &VulkanSettings::vkcrash_diagnostic_enabled), - make_override("host_markers", &VulkanSettings::vkhost_markers), - make_override("guest_markers", &VulkanSettings::vkguest_markers), - make_override("vkpipeline_cache_enabled", - &VulkanSettings::vkpipeline_cache_enabled), - make_override("vkpipeline_cache_archive", - &VulkanSettings::vkpipeline_cache_archive), + make_override("vkhost_markers", &VulkanSettings::vkhost_markers), + make_override("vkguest_markers", &VulkanSettings::vkguest_markers), + make_override("pipeline_cache_enabled", + &VulkanSettings::pipeline_cache_enabled), + make_override("pipeline_cache_archived", + &VulkanSettings::pipeline_cache_archived), }; } }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(VulkanSettings, gpu_id, full_screen, renderdoc_enabled, vkvalidation_enabled, vkvalidation_core_enabled, vkvalidation_sync_enabled, vkvalidation_gpu_enabled, - vkcrash_diagnostic_enabled, vkhost_markers, vkguest_markers) + vkcrash_diagnostic_enabled, vkhost_markers, vkguest_markers, + pipeline_cache_enabled, pipeline_cache_archived) // ------------------------------- // User settings // ------------------------------- @@ -440,8 +441,8 @@ public: SETTING_FORWARD_BOOL(m_vulkan, VkCrashDiagnosticEnabled, vkcrash_diagnostic_enabled) SETTING_FORWARD_BOOL(m_vulkan, VkHostMarkersEnabled, vkhost_markers) SETTING_FORWARD_BOOL(m_vulkan, VkGuestMarkersEnabled, vkguest_markers) - SETTING_FORWARD_BOOL(m_vulkan, VkPipelineCacheEnabled, vkpipeline_cache_enabled) - SETTING_FORWARD_BOOL(m_vulkan, VkPipelineCacheArchive, vkpipeline_cache_archive) + SETTING_FORWARD_BOOL(m_vulkan, PipelineCacheEnabled, pipeline_cache_enabled) + SETTING_FORWARD_BOOL(m_vulkan, PipelineCacheArchived, pipeline_cache_archived) #undef SETTING_FORWARD #undef SETTING_FORWARD_BOOL diff --git a/src/emulator.cpp b/src/emulator.cpp index 93ea2b53f..4b8933e2c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -227,15 +227,22 @@ void Emulator::Run(std::filesystem::path file, std::vector args, EmulatorSettings::GetInstance()->IsVkValidationEnabled()); LOG_INFO(Config, "Vulkan vkValidationCore: {}", EmulatorSettings::GetInstance()->IsVkValidationCoreEnabled()); - LOG_INFO(Config, "Vulkan vkValidationSync: {}", EmulatorSettings::GetInstance()->IsVkValidationSyncEnabled()); + LOG_INFO(Config, "Vulkan vkValidationSync: {}", + EmulatorSettings::GetInstance()->IsVkValidationSyncEnabled()); LOG_INFO(Config, "Vulkan vkValidationGpu: {}", EmulatorSettings::GetInstance()->IsVkValidationGpuEnabled()); - LOG_INFO(Config, "Vulkan crashDiagnostics: {}", EmulatorSettings::GetInstance()->IsVkCrashDiagnosticEnabled()); + LOG_INFO(Config, "Vulkan crashDiagnostics: {}", + EmulatorSettings::GetInstance()->IsVkCrashDiagnosticEnabled()); LOG_INFO(Config, "Vulkan hostMarkers: {}", EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()); LOG_INFO(Config, "Vulkan guestMarkers: {}", EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled()); - LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled()); + LOG_INFO(Config, "Vulkan rdocEnable: {}", + EmulatorSettings::GetInstance()->IsRenderdocEnabled()); + LOG_INFO(Config, "Vulkan PipelineCacheEnabled: {}", + EmulatorSettings::GetInstance()->IsPipelineCacheEnabled()); + LOG_INFO(Config, "Vulkan PipelineCacheArchived: {}", + EmulatorSettings::GetInstance()->IsPipelineCacheArchived()); hwinfo::Memory ram; hwinfo::OS os; diff --git a/src/video_core/cache_storage.cpp b/src/video_core/cache_storage.cpp index 1c46a4cf5..37f91d3b5 100644 --- a/src/video_core/cache_storage.cpp +++ b/src/video_core/cache_storage.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/config.h" @@ -7,6 +7,7 @@ #include "common/polyfill_thread.h" #include "common/thread.h" +#include "core/emulator_settings.h" #include "video_core/cache_storage.h" #include "video_core/renderer_vulkan/vk_instance.h" #include "video_core/renderer_vulkan/vk_pipeline_cache.h" @@ -95,7 +96,7 @@ void DataBase::Open() { const auto& game_info = Common::ElfInfo::Instance(); using namespace Common::FS; - if (Config::isPipelineCacheArchived()) { + if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) { mz_zip_zero_struct(&zip_ar); cache_path = GetUserPath(PathType::CacheDir) / @@ -128,7 +129,7 @@ void DataBase::Close() { io_worker.request_stop(); io_worker.join(); - if (Config::isPipelineCacheArchived()) { + if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) { mz_zip_writer_finalize_archive(&zip_ar); mz_zip_writer_end(&zip_ar); } @@ -142,7 +143,7 @@ bool WriteVector(const BlobType type, std::filesystem::path&& path_, std::vector auto request = std::packaged_task{[=]() { auto path{path_}; path.replace_extension(GetBlobFileExtension(type)); - if (Config::isPipelineCacheArchived()) { + if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) { ASSERT_MSG(!ar_is_read_only, "The archive is read-only. Did you forget to call `FinishPreload`?"); if (!mz_zip_writer_add_mem(&zip_ar, path.string().c_str(), v.data(), @@ -169,7 +170,7 @@ template void LoadVector(BlobType type, std::filesystem::path& path, std::vector& v) { using namespace Common::FS; path.replace_extension(GetBlobFileExtension(type)); - if (Config::isPipelineCacheArchived()) { + if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) { int index{-1}; index = mz_zip_reader_locate_file(&zip_ar, path.string().c_str(), nullptr, 0); if (index < 0) { @@ -192,7 +193,9 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector&& da return false; } - auto path = Config::isPipelineCacheArchived() ? std::filesystem::path{name} : cache_path / name; + auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived() + ? std::filesystem::path{name} + : cache_path / name; return WriteVector(type, std::move(path), std::move(data)); } @@ -201,7 +204,9 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector&& d return false; } - auto path = Config::isPipelineCacheArchived() ? std::filesystem::path{name} : cache_path / name; + auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived() + ? std::filesystem::path{name} + : cache_path / name; return WriteVector(type, std::move(path), std::move(data)); } @@ -210,7 +215,9 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector& dat return; } - auto path = Config::isPipelineCacheArchived() ? std::filesystem::path{name} : cache_path / name; + auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived() + ? std::filesystem::path{name} + : cache_path / name; return LoadVector(type, path, data); } @@ -219,13 +226,15 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector& da return; } - auto path = Config::isPipelineCacheArchived() ? std::filesystem::path{name} : cache_path / name; + auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived() + ? std::filesystem::path{name} + : cache_path / name; return LoadVector(type, path, data); } void DataBase::ForEachBlob(BlobType type, const std::function&& data)>& func) { const auto& ext = GetBlobFileExtension(type); - if (Config::isPipelineCacheArchived()) { + if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) { const auto num_files = mz_zip_reader_get_num_files(&zip_ar); for (int index = 0; index < num_files; ++index) { std::array file_name{}; @@ -255,7 +264,7 @@ void DataBase::ForEachBlob(BlobType type, const std::functionIsPipelineCacheArchived()) { mz_zip_writer_init_from_reader(&zip_ar, cache_path.string().c_str()); ar_is_read_only = false; } diff --git a/src/video_core/renderdoc.cpp b/src/video_core/renderdoc.cpp index 4cf2ddd53..3ac5a505b 100644 --- a/src/video_core/renderdoc.cpp +++ b/src/video_core/renderdoc.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/assert.h" #include "common/config.h" +#include "core/emulator_settings.h" #include "video_core/renderdoc.h" #include @@ -31,7 +32,7 @@ void LoadRenderDoc() { // Check if we are running by RDoc GUI HMODULE mod = GetModuleHandleA("renderdoc.dll"); - if (!mod && Config::isRdocEnabled()) { + if (!mod && EmulatorSettings::GetInstance()->IsRenderdocEnabled()) { // If enabled in config, try to load RDoc runtime in offline mode HKEY h_reg_key; LONG result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, @@ -67,7 +68,7 @@ void LoadRenderDoc() { #endif // Check if we are running by RDoc GUI void* mod = dlopen(RENDERDOC_LIB, RTLD_NOW | RTLD_NOLOAD); - if (!mod && Config::isRdocEnabled()) { + if (!mod && EmulatorSettings::GetInstance()->IsRenderdocEnabled()) { // If enabled in config, try to load RDoc runtime in offline mode if ((mod = dlopen(RENDERDOC_LIB, RTLD_NOW))) { const auto RENDERDOC_GetAPI = diff --git a/src/video_core/renderer_vulkan/vk_pipeline_serialization.cpp b/src/video_core/renderer_vulkan/vk_pipeline_serialization.cpp index 61c4bac7e..215bc571f 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_serialization.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_serialization.cpp @@ -9,6 +9,8 @@ #include "video_core/renderer_vulkan/vk_instance.h" #include "video_core/renderer_vulkan/vk_pipeline_cache.h" #include "video_core/renderer_vulkan/vk_shader_util.h" +#include "core/emulator_settings.h" + namespace Serialization { /* You should increment versions below once corresponding serialization scheme is changed. */ @@ -295,7 +297,7 @@ bool PipelineCache::LoadPipelineStage(Serialization::Archive& ar, size_t stage) } void PipelineCache::WarmUp() { - if (!Config::isPipelineCacheEnabled()) { + if (!EmulatorSettings::GetInstance()->IsPipelineCacheEnabled()) { return; }