From 039b1451593aba903dfaf49d2bad88ffd56bac19 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 28 Nov 2025 15:11:41 +0200 Subject: [PATCH] more settings --- src/common/config.cpp | 23 ------------------- src/common/config.h | 4 ---- src/core/emulator_settings.cpp | 2 +- src/core/emulator_settings.h | 13 ++++++++--- src/emulator.cpp | 2 +- src/main.cpp | 2 +- src/sdl_window.cpp | 3 ++- .../renderer_vulkan/vk_presenter.cpp | 3 ++- 8 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 32084cea0..1533fa374 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -160,7 +160,6 @@ static ConfigEntry directMemoryAccessEnabled(false); static ConfigEntry shouldDumpShaders(false); static ConfigEntry shouldPatchShaders(false); static ConfigEntry vblankFrequency(60); -static ConfigEntry isFullscreen(false); static ConfigEntry fullscreenMode("Windowed"); static ConfigEntry presentMode("Mailbox"); static ConfigEntry isHDRAllowed(false); @@ -169,7 +168,6 @@ static ConfigEntry rcasEnabled(true); static ConfigEntry rcasAttenuation(250); // Vulkan -static ConfigEntry gpuId(-1); static ConfigEntry vkValidation(false); static ConfigEntry vkValidationCore(true); static ConfigEntry vkValidationSync(false); @@ -270,10 +268,6 @@ void setVolumeSlider(int volumeValue, bool is_game_specific) { volumeSlider.set(volumeValue, is_game_specific); } -bool getIsFullscreen() { - return isFullscreen.get(); -} - string getFullscreenMode() { return fullscreenMode.get(); } @@ -318,9 +312,6 @@ u32 getInternalScreenHeight() { return internalScreenHeight.get(); } -s32 getGpuId() { - return gpuId.get(); -} string getUserName() { return userName.get(); @@ -425,10 +416,6 @@ void setVkGuestMarkersEnabled(bool enable, bool is_game_specific) { vkGuestMarkers.set(enable, is_game_specific); } -void setGpuId(s32 selectedGpuId, bool is_game_specific) { - gpuId.set(selectedGpuId, is_game_specific); -} - void setWindowWidth(u32 width, bool is_game_specific) { windowWidth.set(width, is_game_specific); } @@ -501,10 +488,6 @@ void setVblankFreq(u32 value, bool is_game_specific) { vblankFrequency.set(value, is_game_specific); } -void setIsFullscreen(bool enable, bool is_game_specific) { - isFullscreen.set(enable, is_game_specific); -} - void setFullscreenMode(string mode, bool is_game_specific) { fullscreenMode.set(mode, is_game_specific); } @@ -682,7 +665,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); - isFullscreen.setFromToml(gpu, "Fullscreen", is_game_specific); fullscreenMode.setFromToml(gpu, "FullscreenMode", is_game_specific); presentMode.setFromToml(gpu, "presentMode", is_game_specific); isHDRAllowed.setFromToml(gpu, "allowHDR", is_game_specific); @@ -694,7 +676,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { if (data.contains("Vulkan")) { const toml::value& vk = data.at("Vulkan"); - gpuId.setFromToml(vk, "gpuId", is_game_specific); vkValidation.setFromToml(vk, "validation", is_game_specific); vkValidationCore.setFromToml(vk, "validation_core", is_game_specific); vkValidationSync.setFromToml(vk, "validation_sync", is_game_specific); @@ -832,7 +813,6 @@ void save(const std::filesystem::path& path, bool 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); - isFullscreen.setTomlValue(data, "GPU", "Fullscreen", 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); @@ -841,7 +821,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { rcasAttenuation.setTomlValue(data, "GPU", "rcasAttenuation", is_game_specific); directMemoryAccessEnabled.setTomlValue(data, "GPU", "directMemoryAccess", is_game_specific); - gpuId.setTomlValue(data, "Vulkan", "gpuId", is_game_specific); vkValidation.setTomlValue(data, "Vulkan", "validation", is_game_specific); vkValidationSync.setTomlValue(data, "Vulkan", "validation_sync", is_game_specific); vkValidationCore.setTomlValue(data, "Vulkan", "validation_core", is_game_specific); @@ -943,7 +922,6 @@ void setDefaultValues(bool is_game_specific) { shouldCopyGPUBuffers.set(false, is_game_specific); shouldDumpShaders.set(false, is_game_specific); vblankFrequency.set(60, is_game_specific); - isFullscreen.set(false, is_game_specific); fullscreenMode.set("Windowed", is_game_specific); presentMode.set("Mailbox", is_game_specific); isHDRAllowed.set(false, is_game_specific); @@ -952,7 +930,6 @@ void setDefaultValues(bool is_game_specific) { rcasAttenuation.set(250, is_game_specific); // GS - Vulkan - gpuId.set(-1, is_game_specific); vkValidation.set(false, is_game_specific); vkValidationCore.set(true, is_game_specific); vkValidationSync.set(false, is_game_specific); diff --git a/src/common/config.h b/src/common/config.h index ab29c5bd4..032570cd5 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -33,8 +33,6 @@ int getVolumeSlider(); void setVolumeSlider(int volumeValue, bool is_game_specific = false); std::string getTrophyKey(); void setTrophyKey(std::string key); -bool getIsFullscreen(); -void setIsFullscreen(bool enable, bool is_game_specific = false); std::string getFullscreenMode(); void setFullscreenMode(std::string mode, bool is_game_specific = false); std::string getPresentMode(); @@ -47,8 +45,6 @@ u32 getInternalScreenWidth(); u32 getInternalScreenHeight(); void setInternalScreenWidth(u32 width); void setInternalScreenHeight(u32 height); -s32 getGpuId(); -void setGpuId(s32 selectedGpuId, bool is_game_specific = false); bool allowHDR(); void setAllowHDR(bool enable, bool is_game_specific = false); bool nullGpu(); diff --git a/src/core/emulator_settings.cpp b/src/core/emulator_settings.cpp index 29f1b2b09..603b89c79 100644 --- a/src/core/emulator_settings.cpp +++ b/src/core/emulator_settings.cpp @@ -348,7 +348,7 @@ bool EmulatorSettings::Load(const std::string& serial) { } } -void EmulatorSettings::setDefaultValues() { +void EmulatorSettings::SetDefaultValues() { m_general = GeneralSettings{}; m_debug = DebugSettings{}; m_input = InputSettings{}; diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index b5a3bbde0..ee1bd48de 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -233,12 +233,15 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(GPUSettings, window_width, window_height, int // ------------------------------- struct VulkanSettings { Setting gpu_id{-1}; + Setting full_screen{false}; // TODO std::vector GetOverrideableFields() const { - return std::vector{}; + return std::vector{ + make_override("gpu_id", &VulkanSettings::gpu_id), + make_override("full_screen", &VulkanSettings::full_screen)}; } }; -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(VulkanSettings, gpu_id) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(VulkanSettings, gpu_id,full_screen) // ------------------------------- // User settings // ------------------------------- @@ -258,7 +261,7 @@ public: bool Save(const std::string& serial = "") const; bool Load(const std::string& serial = ""); - void setDefaultValues(); + void SetDefaultValues(); // general accessors bool AddGameInstallDir(const std::filesystem::path& dir, bool enabled = true); @@ -344,6 +347,10 @@ public: SETTING_FORWARD_BOOL(m_debug, DebugDump, debug_dump) SETTING_FORWARD_BOOL(m_debug, ShaderDump, shader_dump) + // Vulkan settings + SETTING_FORWARD(m_vulkan, GpuId, gpu_id) + SETTING_FORWARD_BOOL(m_vulkan, FullScreen, full_screen) + #undef SETTING_FORWARD #undef SETTING_FORWARD_BOOL }; diff --git a/src/emulator.cpp b/src/emulator.cpp index 963a2387c..6a35c4364 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -216,7 +216,7 @@ void Emulator::Run(std::filesystem::path file, std::vector args, LOG_INFO(Config, "GPU shouldDumpShaders: {}", Config::dumpShaders()); LOG_INFO(Config, "GPU vblankFrequency: {}", Config::vblankFreq()); LOG_INFO(Config, "GPU shouldCopyGPUBuffers: {}", Config::copyGPUCmdBuffers()); - LOG_INFO(Config, "Vulkan gpuId: {}", Config::getGpuId()); + LOG_INFO(Config, "Vulkan gpuId: {}", EmulatorSettings::GetInstance()->GetGpuId()); LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled()); LOG_INFO(Config, "Vulkan vkValidationCore: {}", Config::vkValidationCoreEnabled()); LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled()); diff --git a/src/main.cpp b/src/main.cpp index cdc2687d9..67854d5a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) { exit(1); } // Set fullscreen mode without saving it to config file - Config::setIsFullscreen(is_fullscreen); + EmulatorSettings::GetInstance()->SetFullScreen(is_fullscreen); }}, {"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, {"--add-game-folder", diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 449defdd1..7287651a4 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -12,6 +12,7 @@ #include "common/elf_info.h" #include "core/debug_state.h" #include "core/devtools/layer.h" +#include "core/emulator_settings.h" #include "core/libraries/kernel/time.h" #include "core/libraries/pad/pad.h" #include "imgui/renderer/imgui_core.h" @@ -317,7 +318,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_ SDL_SetWindowFullscreenMode( window, Config::getFullscreenMode() == "Fullscreen" ? displayMode : NULL); } - SDL_SetWindowFullscreen(window, Config::getIsFullscreen()); + SDL_SetWindowFullscreen(window, EmulatorSettings::GetInstance()->IsFullScreen()); SDL_InitSubSystem(SDL_INIT_GAMEPAD); controller->SetEngine(std::make_unique()); diff --git a/src/video_core/renderer_vulkan/vk_presenter.cpp b/src/video_core/renderer_vulkan/vk_presenter.cpp index 1694d137f..b8c458917 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.cpp +++ b/src/video_core/renderer_vulkan/vk_presenter.cpp @@ -7,6 +7,7 @@ #include "common/singleton.h" #include "core/debug_state.h" #include "core/devtools/layer.h" +#include "core/emulator_settings.h" #include "core/libraries/system/systemservice.h" #include "imgui/renderer/imgui_core.h" #include "imgui/renderer/imgui_impl_vulkan.h" @@ -104,7 +105,7 @@ static vk::Rect2D FitImage(s32 frame_width, s32 frame_height, s32 swapchain_widt Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_) : window{window_}, liverpool{liverpool_}, - instance{window, Config::getGpuId(), Config::vkValidationEnabled(), + instance{window, EmulatorSettings::GetInstance()->GetGpuId(), Config::vkValidationEnabled(), Config::getVkCrashDiagnosticEnabled()}, draw_scheduler{instance}, present_scheduler{instance}, flip_scheduler{instance}, swapchain{instance, window},