diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-04-04 15:53:19 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-04-04 15:56:38 +1100 |
| commit | 87f3efd5e9071db5c4fbdf71632657f5ee1723ee (patch) | |
| tree | 72b9e96fe45baa353ef7725d5d163c466d53c1d2 /src | |
| parent | 172b0b653b5e229d1daa8bbe69ad2d7e5fe249d1 (diff) | |
Ensure swapchain monitor signals outstanding semaphores on shutdown
Diffstat (limited to 'src')
| -rw-r--r-- | src/swapchain_monitor.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/swapchain_monitor.cc b/src/swapchain_monitor.cc index 492e83e..de950a3 100644 --- a/src/swapchain_monitor.cc +++ b/src/swapchain_monitor.cc @@ -62,19 +62,26 @@ void ReflexSwapchainMonitor::do_monitor(const std::stop_token stoken) { this->cv.wait(lock, stoken, [&]() { return !this->semaphore_submissions.empty(); }); - if (stoken.stop_requested()) { - // Small chance an application might need outstanding semaphores - // to be signalled if it's closing to avoid a hang. + // No work implies stopped so break immediately. + if (this->semaphore_submissions.empty()) { break; } - // Grab the most recent semaphore we want to signal off the queue. + // Grab the most recent semaphore we want to signal off the queue and + // clear it. const auto semaphore_submission = std::move(this->semaphore_submissions.back()); this->semaphore_submissions.clear(); + // If we're stopping, signal the semaphore and don't worry about work + // actually completing. + if (stoken.stop_requested()) { + semaphore_submission.wakeup_semaphore.signal(this->device); + break; + } + + // Unlock, wait for work to finish, signal semaphore. lock.unlock(); - // Wait for work to finish and signal its associated semaphore. semaphore_submission.submissions->await_completed(); semaphore_submission.wakeup_semaphore.signal(this->device); } @@ -82,12 +89,10 @@ void ReflexSwapchainMonitor::do_monitor(const std::stop_token stoken) { void ReflexSwapchainMonitor::notify_semaphore( const VkSemaphore& timeline_semaphore, const std::uint64_t& value) { - auto lock = std::unique_lock{this->mutex}; const auto wakeup_semaphore = WakeupSemaphore{ .timeline_semaphore = timeline_semaphore, .value = value}; - if (!this->was_low_latency_requested || this->in_flight_submissions.empty()) { |
