From 06dbbf803318bd46f70ec3d762715beb8805a017 Mon Sep 17 00:00:00 2001 From: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Date: Sat, 2 Aug 2025 02:20:00 +0200 Subject: [PATCH] [fence_manager]: Try to simplify and improve early fence release --- src/video_core/fence_manager.h | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index 1a9fdde4ab..e9324185e9 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h @@ -76,27 +76,16 @@ public: void SignalFence(std::function&& func) { bool delay_fence = Settings::IsGPULevelHigh(); - #ifdef __ANDROID__ - if (!delay_fence && !Settings::values.early_release_fences.GetValue()) { - TryReleasePendingFences(); - } - #else + if constexpr (!can_async_check) { TryReleasePendingFences(); } - #endif const bool should_flush = ShouldFlush(); CommitAsyncFlushes(); TFence new_fence = CreateFence(!should_flush); - #ifdef __ANDROID__ - if (delay_fence && !Settings::values.early_release_fences.GetValue()) { - guard.lock(); - } - #else if constexpr (can_async_check) { guard.lock(); } - #endif if (delay_fence) { uncommitted_operations.emplace_back(std::move(func)); } @@ -109,17 +98,10 @@ public: if (should_flush) { rasterizer.FlushCommands(); } - #ifdef __ANDROID__ - if (delay_fence && !Settings::values.early_release_fences.GetValue()) { - guard.unlock(); - cv.notify_all(); - } - #else if constexpr (can_async_check) { guard.unlock(); cv.notify_all(); } - #endif rasterizer.InvalidateGPUCache(); } @@ -193,10 +175,18 @@ private: void TryReleasePendingFences() { while (!fences.empty()) { TFence& current_fence = fences.front(); - if (ShouldWait() && !IsFenceSignaled(current_fence)) { + + const bool should_wait = ShouldWait() && !IsFenceSignaled(current_fence); +#ifdef __ANDROID__ + const bool allow_early_release = Settings::values.early_release_fences.GetValue(); +#else + const bool allow_early_release = false; +#endif + + if (should_wait) { if constexpr (force_wait) { WaitFence(current_fence); - } else { + } else if (!allow_early_release) { return; } }