diff options
Diffstat (limited to 'src/strategies/low_latency2')
| -rw-r--r-- | src/strategies/low_latency2/swapchain_monitor.cc | 3 | ||||
| -rw-r--r-- | src/strategies/low_latency2/swapchain_monitor.hh | 2 |
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{}; |
