From 59289c6fcd79e52a4395451f61851661c417dbb3 Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Sun, 12 Apr 2026 18:45:49 +1000 Subject: LowLatency2: Check semaphore value before signalling --- src/strategies/low_latency2/semaphore_signal.cc | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/strategies/low_latency2/semaphore_signal.cc (limited to 'src/strategies/low_latency2/semaphore_signal.cc') diff --git a/src/strategies/low_latency2/semaphore_signal.cc b/src/strategies/low_latency2/semaphore_signal.cc new file mode 100644 index 0000000..9597b71 --- /dev/null +++ b/src/strategies/low_latency2/semaphore_signal.cc @@ -0,0 +1,31 @@ +#include "semaphore_signal.hh" + +#include "helper.hh" + +namespace low_latency { + +SemaphoreSignal::SemaphoreSignal(const VkSemaphore& semaphore, + const std::uint64_t& value) + : semaphore(semaphore), value(value) {} + +SemaphoreSignal::~SemaphoreSignal() {} + +void SemaphoreSignal::signal(const DeviceContext& device) const { + + auto current = std::uint64_t{}; + THROW_NOT_VKSUCCESS(device.vtable.GetSemaphoreCounterValue( + device.device, this->semaphore, ¤t)); + + // Don't signal if it has already been signalled. + if (current >= this->value) { + return; + } + + const auto ssi = + VkSemaphoreSignalInfo{.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO, + .semaphore = this->semaphore, + .value = this->value}; + THROW_NOT_VKSUCCESS(device.vtable.SignalSemaphore(device.device, &ssi)); +} + +} // namespace low_latency \ No newline at end of file -- cgit v1.2.3