From 312d8736ae0df55c9f33e4eb5c00e4cd77e1c33f Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Mon, 6 Apr 2026 17:03:35 +1000 Subject: Add refactored VK_NV_low_latency2 impl, (fixes many threading issues) --- src/layer.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/layer.cc') diff --git a/src/layer.cc b/src/layer.cc index 335ebf3..471d2fb 100644 --- a/src/layer.cc +++ b/src/layer.cc @@ -21,6 +21,8 @@ #include "layer_context.hh" #include "queue_context.hh" #include "strategies/anti_lag/device_strategy.hh" +#include "strategies/low_latency2/device_strategy.hh" +#include "strategies/low_latency2/queue_strategy.hh" #include "timestamp_pool.hh" namespace low_latency { @@ -775,8 +777,10 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR( return result; } - assert(pCreateInfo); - context->strategy->notify_create_swapchain(*pSwapchain, *pCreateInfo); + if (context->was_capability_requested) { + assert(pCreateInfo); + context->strategy->notify_create_swapchain(*pSwapchain, *pCreateInfo); + } return VK_SUCCESS; } @@ -788,7 +792,9 @@ DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, context->vtable.DestroySwapchainKHR(device, swapchain, pAllocator); - context->strategy->notify_destroy_swapchain(swapchain); + if (context->was_capability_requested) { + context->strategy->notify_destroy_swapchain(swapchain); + } } static VKAPI_ATTR void VKAPI_CALL @@ -809,6 +815,12 @@ VkResult LatencySleepNV(VkDevice device, const auto context = layer_context.get_context(device); assert(pSleepInfo); + // call device strategy notify semaphore, no problem :) + const auto strategy = + dynamic_cast(context->strategy.get()); + assert(strategy); + strategy->notify_latency_sleep_nv(swapchain, *pSleepInfo); + return VK_SUCCESS; } @@ -817,9 +829,12 @@ void QueueNotifyOutOfBandNV( [[maybe_unused]] const VkOutOfBandQueueTypeInfoNV* pQueueTypeInfo) { // Kind of interesting how you can't turn it back on once it's turned off. - // Also I really have no idea why pQueueTypeInfo's VkOutOfBandQueueTypeNV - // enum even exists (I guess we will find out later when nothing works). const auto context = layer_context.get_context(queue); + + const auto strategy = + dynamic_cast(context->strategy.get()); + assert(strategy); + strategy->notify_out_of_band(); } VkResult SetLatencySleepModeNV( @@ -827,6 +842,12 @@ VkResult SetLatencySleepModeNV( [[maybe_unused]] const VkLatencySleepModeInfoNV* pSleepModeInfo) { const auto context = layer_context.get_context(device); + const auto strategy = + dynamic_cast(context->strategy.get()); + assert(strategy); + + strategy->notify_latency_sleep_mode(swapchain, pSleepModeInfo); + return VK_SUCCESS; } -- cgit v1.2.3