From 458797a7a726d6f30be2acaea1761d489c31061a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Mon, 13 Apr 2026 13:56:11 +1000 Subject: LowLatency2: Avoid fast path when monitor is working --- src/strategies/low_latency2/swapchain_monitor.cc | 3 +++ src/strategies/low_latency2/swapchain_monitor.hh | 2 ++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/strategies/low_latency2/swapchain_monitor.cc b/src/strategies/low_latency2/swapchain_monitor.cc index 0dcd1ce..088e9bd 100644 --- a/src/strategies/low_latency2/swapchain_monitor.cc +++ b/src/strategies/low_latency2/swapchain_monitor.cc @@ -45,6 +45,7 @@ void SwapchainMonitor::do_monitor(const std::stop_token stoken) { // Grab mutex protected present delay before we sleep - doesn't matter // if it's 'old'. const auto delay = this->present_delay; + this->is_monitor_processing.store(true, std::memory_order_relaxed); lock.unlock(); // Wait for work to complete. @@ -62,6 +63,7 @@ void SwapchainMonitor::do_monitor(const std::stop_token stoken) { } this->last_signal_time.set(std::chrono::steady_clock::now()); + this->is_monitor_processing.store(false, std::memory_order_relaxed); pending_signal.semaphore_signal.signal(this->device); } } @@ -81,6 +83,7 @@ void SwapchainMonitor::notify_semaphore( // we have no outstanding work. using namespace std::chrono; if (this->present_delay == 0us && + !this->is_monitor_processing.load(std::memory_order_relaxed) && std::ranges::all_of(this->pending_frame_spans, [](const auto& frame_span) { if (!frame_span) { diff --git a/src/strategies/low_latency2/swapchain_monitor.hh b/src/strategies/low_latency2/swapchain_monitor.hh index 5906ad1..211da4b 100644 --- a/src/strategies/low_latency2/swapchain_monitor.hh +++ b/src/strategies/low_latency2/swapchain_monitor.hh @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -34,6 +35,7 @@ class SwapchainMonitor final { std::mutex mutex{}; std::chrono::microseconds present_delay{}; bool was_low_latency_requested{}; + std::atomic is_monitor_processing{}; AtomicTimePoint last_signal_time{}; std::condition_variable_any cv{}; -- cgit v1.2.3