From 153618c1a4d6cab8a319559b59bf076335c86de7 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 8 Jan 2026 11:05:48 +0200 Subject: [PATCH] even more settings --- src/common/config.cpp | 41 ------------------- src/common/config.h | 5 --- src/core/devtools/widget/frame_graph.cpp | 3 +- src/core/emulator_settings.h | 21 +++++++++- src/core/libraries/videoout/driver.cpp | 5 ++- src/emulator.cpp | 5 ++- .../frontend/translate/translate.cpp | 5 ++- .../passes/flatten_extended_userdata_pass.cpp | 6 +-- src/shader_recompiler/ir/program.cpp | 4 +- .../renderer_vulkan/vk_pipeline_cache.cpp | 4 +- 10 files changed, 39 insertions(+), 60 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index b6924b8bc..06a75a582 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -154,10 +154,6 @@ static ConfigEntry useUnifiedInputConfig(true); static ConfigEntry defaultControllerID(""); static ConfigEntry backgroundControllerInput(false); -static ConfigEntry shouldDumpShaders(false); -static ConfigEntry shouldPatchShaders(false); -static ConfigEntry vblankFrequency(60); - // Debug static ConfigEntry isFpsColor(true); static ConfigEntry showFpsCounter(false); @@ -255,13 +251,7 @@ bool getIsMotionControlsEnabled() { return isMotionControlsEnabled.get(); } -bool dumpShaders() { - return shouldDumpShaders.get(); -} -bool patchShaders() { - return shouldPatchShaders.get(); -} bool fpsColor() { return isFpsColor.get(); @@ -275,21 +265,6 @@ void setShowFpsCounter(bool enable, bool is_game_specific) { showFpsCounter.set(enable, is_game_specific); } -u32 vblankFreq() { - if (vblankFrequency.get() < 60) { - vblankFrequency = 60; - } - return vblankFrequency.get(); -} - -void setDumpShaders(bool enable, bool is_game_specific) { - shouldDumpShaders.set(enable, is_game_specific); -} - -void setVblankFreq(u32 value, bool is_game_specific) { - vblankFrequency.set(value, is_game_specific); -} - void setCursorState(s16 newCursorState, bool is_game_specific) { cursorState.set(newCursorState, is_game_specific); } @@ -392,13 +367,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { usbDeviceBackend.setFromToml(input, "usbDeviceBackend", is_game_specific); } - if (data.contains("GPU")) { - const toml::value& gpu = data.at("GPU"); - shouldDumpShaders.setFromToml(gpu, "dumpShaders", is_game_specific); - shouldPatchShaders.setFromToml(gpu, "patchShaders", is_game_specific); - vblankFrequency.setFromToml(gpu, "vblankFrequency", is_game_specific); - } - string current_version = {}; if (data.contains("Debug")) { const toml::value& debug = data.at("Debug"); @@ -487,8 +455,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { is_game_specific); usbDeviceBackend.setTomlValue(data, "Input", "usbDeviceBackend", is_game_specific); - shouldDumpShaders.setTomlValue(data, "GPU", "dumpShaders", is_game_specific); - vblankFrequency.setTomlValue(data, "GPU", "vblankFrequency", is_game_specific); m_language.setTomlValue(data, "Settings", "consoleLanguage", is_game_specific); @@ -502,7 +468,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { data["Input"]["useSpecialPad"] = useSpecialPad.base_value; data["Input"]["specialPadClass"] = specialPadClass.base_value; data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig.base_value; - data["GPU"]["patchShaders"] = shouldPatchShaders.base_value; data["Debug"]["FPSColor"] = isFpsColor.base_value; data["Debug"]["showFpsCounter"] = showFpsCounter.base_value; } @@ -532,10 +497,6 @@ void setDefaultValues(bool is_game_specific) { backgroundControllerInput.setDefault(is_game_specific); usbDeviceBackend.setDefault(is_game_specific); - // GS - GPU - shouldDumpShaders.setDefault(is_game_specific); - vblankFrequency.setDefault(is_game_specific); - // GS - Settings m_language.setDefault(is_game_specific); @@ -549,8 +510,6 @@ void setDefaultValues(bool is_game_specific) { controllerCustomColorRGB[1] = 0; controllerCustomColorRGB[2] = 255; - // GPU - shouldPatchShaders.base_value = false; // Debug isFpsColor.base_value = true; showFpsCounter.base_value = false; diff --git a/src/common/config.h b/src/common/config.h index 97a29387a..9552dedf6 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -31,10 +31,6 @@ int getVolumeSlider(); void setVolumeSlider(int volumeValue, bool is_game_specific = false); std::string getTrophyKey(); void setTrophyKey(std::string key); -bool dumpShaders(); -void setDumpShaders(bool enable, bool is_game_specific = false); -u32 vblankFreq(); -void setVblankFreq(u32 value, bool is_game_specific = false); s16 getCursorState(); void setCursorState(s16 cursorState, bool is_game_specific = false); int getCursorHideTimeout(); @@ -45,7 +41,6 @@ void setUseSpecialPad(bool use); bool getUseSpecialPad(); void setSpecialPadClass(int type); int getSpecialPadClass(); -bool patchShaders(); // no set bool fpsColor(); // no set bool getShowFpsCounter(); void setShowFpsCounter(bool enable, bool is_game_specific = false); diff --git a/src/core/devtools/widget/frame_graph.cpp b/src/core/devtools/widget/frame_graph.cpp index 6b63d4978..7af44e68d 100644 --- a/src/core/devtools/widget/frame_graph.cpp +++ b/src/core/devtools/widget/frame_graph.cpp @@ -6,6 +6,7 @@ #include "common/config.h" #include "common/singleton.h" #include "core/debug_state.h" +#include "core/emulator_settings.h" #include "imgui.h" #include "imgui_internal.h" @@ -29,7 +30,7 @@ void FrameGraph::DrawFrameGraph() { return; } - float target_dt = 1.0f / (float)Config::vblankFreq(); + float target_dt = 1.0f / (float)EmulatorSettings::GetInstance()->GetVblankFrequency(); float cur_pos_x = pos.x + full_width; pos.y += FRAME_GRAPH_PADDING_Y; const float final_pos_y = pos.y + FRAME_GRAPH_HEIGHT; diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index acf8c30a9..edbef95c2 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -377,6 +377,11 @@ public: void Set##Name(const decltype(group.field.value)& v) { \ group.field.value = v; \ } +#define SETTING_FORWARD_BOOL_READONLY(group, Name, field) \ + auto Is##Name() const { \ + return group.field.value; \ + } + // General settings SETTING_FORWARD(m_general, VolumeSlider, volume_slider) SETTING_FORWARD_BOOL(m_general, Neo, neo_mode) @@ -422,7 +427,21 @@ public: SETTING_FORWARD_BOOL(m_gpu, ReadbacksEnabled, readbacks_enabled) SETTING_FORWARD_BOOL(m_gpu, ReadbackLinearImagesEnabled, readback_linear_images_enabled) SETTING_FORWARD_BOOL(m_gpu, DirectMemoryAccessEnabled, direct_memory_access_enabled) - SETTING_FORWARD(m_gpu, VblankFrequency, vblank_frequency) + SETTING_FORWARD_BOOL_READONLY(m_gpu, PatchShaders, patch_shaders) + + u32 GetVblankFrequency() { + if (m_gpu.vblank_frequency.value < 60) { + m_gpu.vblank_frequency.value = 60; + } + return m_gpu.vblank_frequency.value; + } + void SetVblankFrequency(const u32& v) { + if (v < 60) { + m_gpu.vblank_frequency.value = 60; + } else { + m_gpu.vblank_frequency.value = v; + } + } // Input Settings SETTING_FORWARD(m_input, CursorState, cursor_state) diff --git a/src/core/libraries/videoout/driver.cpp b/src/core/libraries/videoout/driver.cpp index 4951c4f1a..ac1f8395c 100644 --- a/src/core/libraries/videoout/driver.cpp +++ b/src/core/libraries/videoout/driver.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/assert.h" @@ -12,6 +12,7 @@ #include "imgui/renderer/imgui_core.h" #include "video_core/amdgpu/liverpool.h" #include "video_core/renderer_vulkan/vk_presenter.h" +#include "core/emulator_settings.h" extern std::unique_ptr presenter; extern std::unique_ptr liverpool; @@ -267,7 +268,7 @@ void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_ } void VideoOutDriver::PresentThread(std::stop_token token) { - const std::chrono::nanoseconds vblank_period(1000000000 / Config::vblankFreq()); + const std::chrono::nanoseconds vblank_period(1000000000 / EmulatorSettings::GetInstance()->GetVblankFrequency()); Common::SetCurrentThreadName("shadPS4:PresentThread"); Common::SetCurrentThreadRealtime(vblank_period); diff --git a/src/emulator.cpp b/src/emulator.cpp index 4b8933e2c..c16ce5963 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -218,8 +218,9 @@ void Emulator::Run(std::filesystem::path file, std::vector args, EmulatorSettings::GetInstance()->IsReadbackLinearImagesEnabled()); LOG_INFO(Config, "GPU directMemoryAccess: {}", EmulatorSettings::GetInstance()->IsDirectMemoryAccessEnabled()); - LOG_INFO(Config, "GPU shouldDumpShaders: {}", Config::dumpShaders()); - LOG_INFO(Config, "GPU vblankFrequency: {}", Config::vblankFreq()); + LOG_INFO(Config, "GPU shouldDumpShaders: {}", EmulatorSettings::GetInstance()->IsDumpShaders()); + LOG_INFO(Config, "GPU vblankFrequency: {}", + EmulatorSettings::GetInstance()->GetVblankFrequency()); LOG_INFO(Config, "GPU shouldCopyGPUBuffers: {}", EmulatorSettings::GetInstance()->IsCopyGpuBuffers()); LOG_INFO(Config, "Vulkan gpuId: {}", EmulatorSettings::GetInstance()->GetGpuId()); diff --git a/src/shader_recompiler/frontend/translate/translate.cpp b/src/shader_recompiler/frontend/translate/translate.cpp index 3aa70e2ec..ceba93e19 100644 --- a/src/shader_recompiler/frontend/translate/translate.cpp +++ b/src/shader_recompiler/frontend/translate/translate.cpp @@ -1,9 +1,10 @@ -// 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/config.h" #include "common/io_file.h" #include "common/path_util.h" +#include "core/emulator_settings.h" #include "shader_recompiler/frontend/decode.h" #include "shader_recompiler/frontend/fetch_shader.h" #include "shader_recompiler/frontend/translate/translate.h" @@ -552,7 +553,7 @@ void Translator::EmitFetch(const GcnInst& inst) { const auto fetch_data = ParseFetchShader(info); ASSERT(fetch_data.has_value()); - if (Config::dumpShaders()) { + if (EmulatorSettings::GetInstance()->IsDumpShaders()) { using namespace Common::FS; const auto dump_dir = GetUserPath(PathType::ShaderDir) / "dumps"; if (!std::filesystem::exists(dump_dir)) { diff --git a/src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp b/src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp index e1f9f2c5a..afbc5f65c 100644 --- a/src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp +++ b/src/shader_recompiler/ir/passes/flatten_extended_userdata_pass.cpp @@ -1,5 +1,4 @@ - -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -11,6 +10,7 @@ #include "common/logging/log.h" #include "common/path_util.h" #include "common/signal_context.h" +#include "core/emulator_settings.h" #include "core/signals.h" #include "shader_recompiler/info.h" #include "shader_recompiler/ir/breadth_first_search.h" @@ -229,7 +229,7 @@ static void GenerateSrtProgram(Info& info, PassInfo& pass_info) { info.srt_info.walker_func_size = c.getCurr() - reinterpret_cast(info.srt_info.walker_func); - if (Config::dumpShaders()) { + if (EmulatorSettings::GetInstance()->IsDumpShaders()) { DumpSrtProgram(info, reinterpret_cast(info.srt_info.walker_func), info.srt_info.walker_func_size); } diff --git a/src/shader_recompiler/ir/program.cpp b/src/shader_recompiler/ir/program.cpp index 1d03ea9ab..9a535fc39 100644 --- a/src/shader_recompiler/ir/program.cpp +++ b/src/shader_recompiler/ir/program.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -9,6 +10,7 @@ #include "common/config.h" #include "common/io_file.h" #include "common/path_util.h" +#include "core/emulator_settings.h" #include "shader_recompiler/ir/basic_block.h" #include "shader_recompiler/ir/program.h" #include "shader_recompiler/ir/value.h" @@ -18,7 +20,7 @@ namespace Shader::IR { void DumpProgram(const Program& program, const Info& info, const std::string& type) { using namespace Common::FS; - if (!Config::dumpShaders()) { + if (!EmulatorSettings::GetInstance()->IsDumpShaders()) { return; } diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 6c724c4a2..a9ea0d422 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -544,7 +544,7 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim vk::ShaderModule module; auto patch = GetShaderPatch(info.pgm_hash, info.stage, perm_idx, "spv"); - const bool is_patched = patch && Config::patchShaders(); + const bool is_patched = patch && EmulatorSettings::GetInstance()->IsPatchShaders(); if (is_patched) { LOG_INFO(Loader, "Loaded patch for {} shader {:#x}", info.stage, info.pgm_hash); module = CompileSPV(*patch, instance.GetDevice()); @@ -649,7 +649,7 @@ std::string PipelineCache::GetShaderName(Shader::Stage stage, u64 hash, void PipelineCache::DumpShader(std::span code, u64 hash, Shader::Stage stage, size_t perm_idx, std::string_view ext) { - if (!Config::dumpShaders()) { + if (!EmulatorSettings::GetInstance()->IsDumpShaders()) { return; }