diff --git a/src/common/config.cpp b/src/common/config.cpp index 1533fa374..3831236cb 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -152,7 +152,6 @@ static ConfigEntry windowWidth(1280); static ConfigEntry windowHeight(720); static ConfigEntry internalScreenWidth(1280); static ConfigEntry internalScreenHeight(720); -static ConfigEntry isNullGpu(false); static ConfigEntry shouldCopyGPUBuffers(false); static ConfigEntry readbacksEnabled(false); static ConfigEntry readbackLinearImagesEnabled(false); @@ -160,8 +159,6 @@ static ConfigEntry directMemoryAccessEnabled(false); static ConfigEntry shouldDumpShaders(false); static ConfigEntry shouldPatchShaders(false); static ConfigEntry vblankFrequency(60); -static ConfigEntry fullscreenMode("Windowed"); -static ConfigEntry presentMode("Mailbox"); static ConfigEntry isHDRAllowed(false); static ConfigEntry fsrEnabled(false); static ConfigEntry rcasEnabled(true); @@ -179,7 +176,6 @@ static ConfigEntry rdocEnable(false); // Debug static ConfigEntry isFpsColor(true); -static ConfigEntry logEnabled(true); // GUI static std::vector settings_install_dirs = {}; @@ -239,10 +235,6 @@ int* GetControllerCustomColor() { return controllerCustomColorRGB; } -bool getLoggingEnabled() { - return logEnabled.get(); -} - void SetControllerCustomColor(int r, int b, int g) { controllerCustomColorRGB[0] = r; controllerCustomColorRGB[1] = b; @@ -268,14 +260,6 @@ void setVolumeSlider(int volumeValue, bool is_game_specific) { volumeSlider.set(volumeValue, is_game_specific); } -string getFullscreenMode() { - return fullscreenMode.get(); -} - -std::string getPresentMode() { - return presentMode.get(); -} - s16 getCursorState() { return cursorState.get(); } @@ -312,7 +296,6 @@ u32 getInternalScreenHeight() { return internalScreenHeight.get(); } - string getUserName() { return userName.get(); } @@ -329,10 +312,6 @@ bool getIsMotionControlsEnabled() { return isMotionControlsEnabled.get(); } -bool nullGpu() { - return isNullGpu.get(); -} - bool copyGPUCmdBuffers() { return shouldCopyGPUBuffers.get(); } @@ -365,10 +344,6 @@ bool fpsColor() { return isFpsColor.get(); } -bool isLoggingEnabled() { - return logEnabled.get(); -} - u32 vblankFreq() { if (vblankFrequency.get() < 60) { vblankFrequency = 60; @@ -432,14 +407,6 @@ void setInternalScreenHeight(u32 height) { internalScreenHeight.base_value = height; } -void setLoggingEnabled(bool enable, bool is_game_specific) { - logEnabled.set(enable, is_game_specific); -} - -void setNullGpu(bool enable, bool is_game_specific) { - isNullGpu.set(enable, is_game_specific); -} - void setAllowHDR(bool enable, bool is_game_specific) { isHDRAllowed.set(enable, is_game_specific); } @@ -488,14 +455,6 @@ void setVblankFreq(u32 value, bool is_game_specific) { vblankFrequency.set(value, is_game_specific); } -void setFullscreenMode(string mode, bool is_game_specific) { - fullscreenMode.set(mode, is_game_specific); -} - -void setPresentMode(std::string mode, bool is_game_specific) { - presentMode.set(mode, is_game_specific); -} - void setCursorState(s16 newCursorState, bool is_game_specific) { cursorState.set(newCursorState, is_game_specific); } @@ -657,7 +616,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { windowHeight.setFromToml(gpu, "screenHeight", is_game_specific); internalScreenWidth.setFromToml(gpu, "internalScreenWidth", is_game_specific); internalScreenHeight.setFromToml(gpu, "internalScreenHeight", is_game_specific); - isNullGpu.setFromToml(gpu, "nullGpu", is_game_specific); shouldCopyGPUBuffers.setFromToml(gpu, "copyGPUBuffers", is_game_specific); readbacksEnabled.setFromToml(gpu, "readbacks", is_game_specific); readbackLinearImagesEnabled.setFromToml(gpu, "readbackLinearImages", is_game_specific); @@ -665,8 +623,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { shouldDumpShaders.setFromToml(gpu, "dumpShaders", is_game_specific); shouldPatchShaders.setFromToml(gpu, "patchShaders", is_game_specific); vblankFrequency.setFromToml(gpu, "vblankFrequency", is_game_specific); - fullscreenMode.setFromToml(gpu, "FullscreenMode", is_game_specific); - presentMode.setFromToml(gpu, "presentMode", is_game_specific); isHDRAllowed.setFromToml(gpu, "allowHDR", is_game_specific); fsrEnabled.setFromToml(gpu, "fsrEnabled", is_game_specific); rcasEnabled.setFromToml(gpu, "rcasEnabled", is_game_specific); @@ -691,7 +647,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { const toml::value& debug = data.at("Debug"); isFpsColor.setFromToml(debug, "FPSColor", is_game_specific); - logEnabled.setFromToml(debug, "logEnabled", is_game_specific); current_version = toml::find_or(debug, "ConfigVersion", current_version); } @@ -807,14 +762,11 @@ void save(const std::filesystem::path& path, bool is_game_specific) { windowWidth.setTomlValue(data, "GPU", "screenWidth", is_game_specific); windowHeight.setTomlValue(data, "GPU", "screenHeight", is_game_specific); - isNullGpu.setTomlValue(data, "GPU", "nullGpu", is_game_specific); shouldCopyGPUBuffers.setTomlValue(data, "GPU", "copyGPUBuffers", is_game_specific); readbacksEnabled.setTomlValue(data, "GPU", "readbacks", is_game_specific); readbackLinearImagesEnabled.setTomlValue(data, "GPU", "readbackLinearImages", is_game_specific); shouldDumpShaders.setTomlValue(data, "GPU", "dumpShaders", is_game_specific); vblankFrequency.setTomlValue(data, "GPU", "vblankFrequency", is_game_specific); - fullscreenMode.setTomlValue(data, "GPU", "FullscreenMode", is_game_specific); - presentMode.setTomlValue(data, "GPU", "presentMode", is_game_specific); isHDRAllowed.setTomlValue(data, "GPU", "allowHDR", is_game_specific); fsrEnabled.setTomlValue(data, "GPU", "fsrEnabled", is_game_specific); rcasEnabled.setTomlValue(data, "GPU", "rcasEnabled", is_game_specific); @@ -830,8 +782,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { vkGuestMarkers.setTomlValue(data, "Vulkan", "guestMarkers", is_game_specific); rdocEnable.setTomlValue(data, "Vulkan", "rdocEnable", is_game_specific); - logEnabled.setTomlValue(data, "Debug", "logEnabled", is_game_specific); - m_language.setTomlValue(data, "Settings", "consoleLanguage", is_game_specific); if (!is_game_specific) { @@ -918,12 +868,9 @@ void setDefaultValues(bool is_game_specific) { // GS - GPU windowWidth.set(1280, is_game_specific); windowHeight.set(720, is_game_specific); - isNullGpu.set(false, is_game_specific); shouldCopyGPUBuffers.set(false, is_game_specific); shouldDumpShaders.set(false, is_game_specific); vblankFrequency.set(60, is_game_specific); - fullscreenMode.set("Windowed", is_game_specific); - presentMode.set("Mailbox", is_game_specific); isHDRAllowed.set(false, is_game_specific); fsrEnabled.set(true, is_game_specific); rcasEnabled.set(true, is_game_specific); @@ -939,9 +886,6 @@ void setDefaultValues(bool is_game_specific) { vkGuestMarkers.set(false, is_game_specific); rdocEnable.set(false, is_game_specific); - // GS - Debug - logEnabled.set(true, is_game_specific); - // GS - Settings m_language.set(1, is_game_specific); diff --git a/src/common/config.h b/src/common/config.h index 032570cd5..8133f86cf 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -33,10 +33,6 @@ int getVolumeSlider(); void setVolumeSlider(int volumeValue, bool is_game_specific = false); std::string getTrophyKey(); void setTrophyKey(std::string key); -std::string getFullscreenMode(); -void setFullscreenMode(std::string mode, bool is_game_specific = false); -std::string getPresentMode(); -void setPresentMode(std::string mode, bool is_game_specific = false); u32 getWindowWidth(); u32 getWindowHeight(); void setWindowWidth(u32 width, bool is_game_specific = false); @@ -47,8 +43,6 @@ void setInternalScreenWidth(u32 width); void setInternalScreenHeight(u32 height); bool allowHDR(); void setAllowHDR(bool enable, bool is_game_specific = false); -bool nullGpu(); -void setNullGpu(bool enable, bool is_game_specific = false); bool copyGPUCmdBuffers(); void setCopyGPUCmdBuffers(bool enable, bool is_game_specific = false); bool readbacks(); @@ -101,8 +95,6 @@ std::string getDefaultControllerID(); void setDefaultControllerID(std::string id); bool getBackgroundControllerInput(); void setBackgroundControllerInput(bool enable, bool is_game_specific = false); -bool getLoggingEnabled(); -void setLoggingEnabled(bool enable, bool is_game_specific = false); bool getFsrEnabled(); void setFsrEnabled(bool enable, bool is_game_specific = false); bool getRcasEnabled(); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 808df8599..fc9cdd00c 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -184,7 +184,8 @@ public: void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, const char* format, const fmt::format_args& args) { - if (!filter.CheckMessage(log_class, log_level) || !Config::getLoggingEnabled()) { + if (!filter.CheckMessage(log_class, log_level) || + !EmulatorSettings::GetInstance()->IsLogEnabled()) { return; } diff --git a/src/core/devtools/widget/shader_list.cpp b/src/core/devtools/widget/shader_list.cpp index 19f7a0308..0cfa6b9e9 100644 --- a/src/core/devtools/widget/shader_list.cpp +++ b/src/core/devtools/widget/shader_list.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index ee1bd48de..546a362fa 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -218,7 +218,10 @@ struct GPUSettings { Setting rcas_attenuation{250}; // TODO add overrides std::vector GetOverrideableFields() const { - return std::vector{}; + return std::vector{ + make_override("null_gpu", &GPUSettings::null_gpu), + make_override("full_screen", &GPUSettings::full_screen), + make_override("present_mode", &GPUSettings::present_mode)}; } }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(GPUSettings, window_width, window_height, internal_screen_width, @@ -241,7 +244,7 @@ struct VulkanSettings { make_override("full_screen", &VulkanSettings::full_screen)}; } }; -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(VulkanSettings, gpu_id,full_screen) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(VulkanSettings, gpu_id, full_screen) // ------------------------------- // User settings // ------------------------------- @@ -346,6 +349,12 @@ public: SETTING_FORWARD_BOOL(m_debug, SeparateLoggingEnabled, separate_logging_enabled) SETTING_FORWARD_BOOL(m_debug, DebugDump, debug_dump) SETTING_FORWARD_BOOL(m_debug, ShaderDump, shader_dump) + SETTING_FORWARD_BOOL(m_debug, LogEnabled, log_enabled) + + // GPU Settings + SETTING_FORWARD_BOOL(m_gpu, NullGPU, null_gpu) + SETTING_FORWARD(m_gpu, FullScreenMode, full_screen_mode) + SETTING_FORWARD(m_gpu, PresentMode, present_mode) // Vulkan settings SETTING_FORWARD(m_vulkan, GpuId, gpu_id) diff --git a/src/emulator.cpp b/src/emulator.cpp index 6a35c4364..3e62f6efb 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -209,7 +209,7 @@ void Emulator::Run(std::filesystem::path file, std::vector args, LOG_INFO(Config, "General isConnectedToNetwork: {}", EmulatorSettings::GetInstance()->IsConnectedToNetwork()); LOG_INFO(Config, "General isPsnSignedIn: {}", EmulatorSettings::GetInstance()->IsPSNSignedIn()); - LOG_INFO(Config, "GPU isNullGpu: {}", Config::nullGpu()); + LOG_INFO(Config, "GPU isNullGpu: {}", EmulatorSettings::GetInstance()->IsNullGPU()); LOG_INFO(Config, "GPU readbacks: {}", Config::readbacks()); LOG_INFO(Config, "GPU readbackLinearImages: {}", Config::readbackLinearImages()); LOG_INFO(Config, "GPU directMemoryAccess: {}", Config::directMemoryAccess()); diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 7287651a4..3959588c8 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "SDL3/SDL_events.h" @@ -315,8 +315,10 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_ error = true; } if (!error) { - SDL_SetWindowFullscreenMode( - window, Config::getFullscreenMode() == "Fullscreen" ? displayMode : NULL); + SDL_SetWindowFullscreenMode(window, EmulatorSettings::GetInstance()->GetFullScreenMode() == + "Fullscreen" + ? displayMode + : NULL); } SDL_SetWindowFullscreen(window, EmulatorSettings::GetInstance()->IsFullScreen()); diff --git a/src/video_core/renderer_vulkan/vk_presenter.cpp b/src/video_core/renderer_vulkan/vk_presenter.cpp index b8c458917..129cef6a2 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.cpp +++ b/src/video_core/renderer_vulkan/vk_presenter.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/config.h" @@ -578,7 +578,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) { ImGui::SetCursorPos(ImGui::GetCursorStartPos() + offset); ImGui::Image(game_texture, size); - if (Config::nullGpu()) { + if (EmulatorSettings::GetInstance()->IsNullGPU()) { Core::Devtools::Layer::DrawNullGpuNotice(); } } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 214d6d697..dab9c30cf 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/config.h" #include "common/debug.h" +#include "core/emulator_settings.h" #include "core/memory.h" #include "shader_recompiler/runtime_info.h" #include "video_core/amdgpu/liverpool.h" @@ -38,7 +39,7 @@ Rasterizer::Rasterizer(const Instance& instance_, Scheduler& scheduler_, texture_cache{instance, scheduler, liverpool_, buffer_cache, page_manager}, liverpool{liverpool_}, memory{Core::Memory::Instance()}, pipeline_cache{instance, scheduler, liverpool} { - if (!Config::nullGpu()) { + if (!EmulatorSettings::GetInstance()->IsNullGPU()) { liverpool->BindRasterizer(this); } memory->SetRasterizer(this); diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 4dd3bd502..3fc857bd9 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -6,6 +6,7 @@ #include "common/assert.h" #include "common/config.h" #include "common/logging/log.h" +#include "core/emulator_settings.h" #include "imgui/renderer/imgui_core.h" #include "sdl_window.h" #include "video_core/renderer_vulkan/vk_instance.h" @@ -199,7 +200,7 @@ void Swapchain::FindPresentMode() { return; } - const auto requested_mode = Config::getPresentMode(); + const auto requested_mode = EmulatorSettings::GetInstance()->GetPresentMode(); if (requested_mode == "Mailbox") { present_mode = vk::PresentModeKHR::eMailbox; } else if (requested_mode == "Fifo") { @@ -208,7 +209,7 @@ void Swapchain::FindPresentMode() { present_mode = vk::PresentModeKHR::eImmediate; } else { LOG_ERROR(Render_Vulkan, "Unknown present mode {}, defaulting to Mailbox.", - Config::getPresentMode()); + EmulatorSettings::GetInstance()->GetPresentMode()); present_mode = vk::PresentModeKHR::eMailbox; }