From 973532a7d28c2afbaaf0fe79efa9a5084d14e3aa Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Sat, 11 Apr 2026 11:23:12 +1000 Subject: Don't discard signal semaphore on missing swapchain monitor without signalling it first --- src/layer.cc | 2 +- src/strategies/low_latency2/device_strategy.cc | 9 +++++++++ src/strategies/low_latency2/swapchain_monitor.cc | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/layer.cc b/src/layer.cc index e94fe54..54ad8d7 100644 --- a/src/layer.cc +++ b/src/layer.cc @@ -275,7 +275,7 @@ DestroyDevice(VkDevice device, const VkAllocationCallbacks* allocator) { const auto key = layer_context.get_key(device); const auto iter = layer_context.contexts.find(key); assert(iter != std::end(layer_context.contexts)); - auto context = dynamic_pointer_cast(iter->second); + auto context = std::dynamic_pointer_cast(iter->second); // Remove all owned queues from our global context pool. for (const auto& [queue, _] : context->queues) { diff --git a/src/strategies/low_latency2/device_strategy.cc b/src/strategies/low_latency2/device_strategy.cc index fa44468..f82098d 100644 --- a/src/strategies/low_latency2/device_strategy.cc +++ b/src/strategies/low_latency2/device_strategy.cc @@ -4,6 +4,7 @@ #include "helper.hh" #include +#include namespace low_latency { @@ -113,6 +114,14 @@ void LowLatency2DeviceStrategy::notify_latency_sleep_nv( const auto iter = this->swapchain_monitors.find(swapchain); if (iter == std::end(this->swapchain_monitors)) { + // If we can't find the swapchain we have to signal the semaphore + // anyway. We must *never* discard these semaphores without signalling + // them first. + const auto ssi = VkSemaphoreSignalInfo{ + .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO, + .semaphore = info.signalSemaphore, + .value = info.value}; + THROW_NOT_VKSUCCESS(device.vtable.SignalSemaphore(device.device, &ssi)); return; } iter->second.notify_semaphore(info.signalSemaphore, info.value); diff --git a/src/strategies/low_latency2/swapchain_monitor.cc b/src/strategies/low_latency2/swapchain_monitor.cc index 5d384f8..6f55dd6 100644 --- a/src/strategies/low_latency2/swapchain_monitor.cc +++ b/src/strategies/low_latency2/swapchain_monitor.cc @@ -102,6 +102,7 @@ void SwapchainMonitor::notify_semaphore(const VkSemaphore& timeline_semaphore, } return frame_span->has_completed(); })) { + wakeup_semaphore.signal(this->device); this->pending_frame_spans.clear(); return; -- cgit v1.2.3