aboutsummaryrefslogtreecommitdiff
path: root/src/strategies/low_latency2/semaphore_signal.cc
diff options
context:
space:
mode:
authorNicolas James <nj3ahxac@gmail.com>2026-04-12 18:45:49 +1000
committerNicolas James <nj3ahxac@gmail.com>2026-04-12 18:45:49 +1000
commit59289c6fcd79e52a4395451f61851661c417dbb3 (patch)
treed3cb760880805c84ed29b2d5e9fcfa69015e1625 /src/strategies/low_latency2/semaphore_signal.cc
parent973532a7d28c2afbaaf0fe79efa9a5084d14e3aa (diff)
LowLatency2: Check semaphore value before signalling
Diffstat (limited to 'src/strategies/low_latency2/semaphore_signal.cc')
-rw-r--r--src/strategies/low_latency2/semaphore_signal.cc31
1 files changed, 31 insertions, 0 deletions
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, &current));
+
+ // 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