aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas James <nj3ahxac@gmail.com>2026-04-13 13:56:11 +1000
committerNicolas James <nj3ahxac@gmail.com>2026-04-13 13:56:11 +1000
commit458797a7a726d6f30be2acaea1761d489c31061a (patch)
tree0788fae8303322ce450c3bd6ddada34717d64f59
parent59289c6fcd79e52a4395451f61851661c417dbb3 (diff)
LowLatency2: Avoid fast path when monitor is workingHEADmain
-rw-r--r--src/strategies/low_latency2/swapchain_monitor.cc3
-rw-r--r--src/strategies/low_latency2/swapchain_monitor.hh2
2 files changed, 5 insertions, 0 deletions
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 <vulkan/vulkan.h>
+#include <atomic>
#include <chrono>
#include <condition_variable>
#include <memory>
@@ -34,6 +35,7 @@ class SwapchainMonitor final {
std::mutex mutex{};
std::chrono::microseconds present_delay{};
bool was_low_latency_requested{};
+ std::atomic<bool> is_monitor_processing{};
AtomicTimePoint last_signal_time{};
std::condition_variable_any cv{};