aboutsummaryrefslogtreecommitdiff
path: root/src/layer.cc
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2026-03-31 13:17:09 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2026-03-31 13:17:09 +1100
commitdf2933fd9c0ea2a99e89a6837123dfdf8b549d4a (patch)
tree42a5c73fc3735636efbe1eb7bf16adccd9aee664 /src/layer.cc
parent89f4c0f59a90b1a4447d171bd09235126561af91 (diff)
Split monitoring strategy between Reflex and AL2
Diffstat (limited to 'src/layer.cc')
-rw-r--r--src/layer.cc33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/layer.cc b/src/layer.cc
index bc988f0..cf9f56e 100644
--- a/src/layer.cc
+++ b/src/layer.cc
@@ -20,6 +20,7 @@
#include "instance_context.hh"
#include "layer_context.hh"
#include "queue_context.hh"
+#include "swapchain_monitor.hh"
#include "timestamp_pool.hh"
namespace low_latency {
@@ -754,8 +755,17 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR(
was_low_latency_requested = slci->latencyModeEnable;
}
- const auto [_, did_emplace] = context->swapchain_monitors.try_emplace(
- *pSwapchain, *context, was_low_latency_requested);
+ auto insertion = [&]() -> std::unique_ptr<SwapchainMonitor> {
+ if (!layer_context.should_expose_reflex) {
+ return std::make_unique<AntiLagSwapchainMonitor>(
+ *context, was_low_latency_requested);
+ }
+ return std::make_unique<ReflexSwapchainMonitor>(
+ *context, was_low_latency_requested);
+ }();
+ const auto did_emplace = context->swapchain_monitors
+ .try_emplace(*pSwapchain, std::move(insertion))
+ .second;
assert(did_emplace);
return VK_SUCCESS;
@@ -801,7 +811,13 @@ AntiLagUpdateAMD(VkDevice device, const VkAntiLagDataAMD* pData) {
// and made sure that at least that one completed. I think it's more robust
// to make sure they all complete.
for (auto& iter : context->swapchain_monitors) {
- iter.second.wait_until();
+
+ // All swapchains should be of type AntiLagSwapchainMonitor here.
+ const auto ptr =
+ dynamic_cast<AntiLagSwapchainMonitor*>(iter.second.get());
+ assert(ptr);
+
+ ptr->await_submissions();
}
}
@@ -813,16 +829,19 @@ VkResult LatencySleepNV(VkDevice device, VkSwapchainKHR swapchain,
// We're associating an application-provided timeline semaphore + value with
// a swapchain that says 'signal me when we should move past input'.
- auto& swapchain_monitor = [&]() -> auto& {
+ auto swapchain_monitor_ptr = [&]() -> auto {
const auto iter = context->swapchain_monitors.find(swapchain);
assert(iter != std::end(context->swapchain_monitors));
- return iter->second;
+ const auto ptr =
+ dynamic_cast<ReflexSwapchainMonitor*>(iter->second.get());
+ assert(ptr);
+ return ptr;
}();
// Tell our swapchain monitor that if they want us to proceed they should
// signal this semaphore.
- swapchain_monitor.notify_semaphore(pSleepInfo->signalSemaphore,
- pSleepInfo->value);
+ swapchain_monitor_ptr->notify_semaphore(pSleepInfo->signalSemaphore,
+ pSleepInfo->value);
return VK_SUCCESS;
}