From 6d86c6f9bfe71d68191a7ed4beacf8745fc47af5 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:34:47 +0300 Subject: [PATCH] config: Add vblank divider option --- src/common/config.cpp | 7 +++++++ src/common/config.h | 1 + src/core/libraries/videoout/driver.cpp | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index a577b143a..6a7d25e8b 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -22,6 +22,7 @@ static bool isShowSplash = false; static bool isNullGpu = false; static bool shouldDumpShaders = false; static bool shouldDumpPM4 = false; +static u32 vblankDivider = 1; static bool vkValidation = false; static bool vkValidationSync = false; // Gui @@ -94,6 +95,10 @@ bool dumpPM4() { return shouldDumpPM4; } +u32 vblankDiv() { + return vblankDivider; +} + bool vkValidationEnabled() { return vkValidation; } @@ -237,6 +242,7 @@ void load(const std::filesystem::path& path) { isNullGpu = toml::find_or(gpu, "nullGpu", false); shouldDumpShaders = toml::find_or(gpu, "dumpShaders", false); shouldDumpPM4 = toml::find_or(gpu, "dumpPM4", false); + vblankDivider = toml::find_or(gpu, "vblankDivider", 1); } } if (data.contains("Vulkan")) { @@ -318,6 +324,7 @@ void save(const std::filesystem::path& path) { data["GPU"]["nullGpu"] = isNullGpu; data["GPU"]["dumpShaders"] = shouldDumpShaders; data["GPU"]["dumpPM4"] = shouldDumpPM4; + data["GPU"]["vblankDivider"] = vblankDivider; data["Vulkan"]["validation"] = vkValidation; data["Vulkan"]["validation_sync"] = vkValidationSync; data["Debug"]["DebugDump"] = isDebugDump; diff --git a/src/common/config.h b/src/common/config.h index 0a3b4905e..39c1c8485 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -26,6 +26,7 @@ bool showSplash(); bool nullGpu(); bool dumpShaders(); bool dumpPM4(); +u32 vblankDiv(); bool vkValidationEnabled(); bool vkValidationSyncEnabled(); diff --git a/src/core/libraries/videoout/driver.cpp b/src/core/libraries/videoout/driver.cpp index 0e832f728..cd96916ff 100644 --- a/src/core/libraries/videoout/driver.cpp +++ b/src/core/libraries/videoout/driver.cpp @@ -3,6 +3,7 @@ #include #include "common/assert.h" +#include "common/config.h" #include "common/debug.h" #include "common/thread.h" #include "core/libraries/error_codes.h" @@ -269,10 +270,11 @@ void VideoOutDriver::PresentThread(std::stop_token token) { return {}; }; + auto vblank_period = VblankPeriod / Config::vblankDiv(); auto delay = std::chrono::microseconds{0}; while (!token.stop_requested()) { // Sleep for most of the vblank duration. - std::this_thread::sleep_for(VblankPeriod - delay); + std::this_thread::sleep_for(vblank_period - delay); // Check if it's time to take a request. auto& vblank_status = main_port.vblank_status;