Fix timeline semaphore wait criteria
If VK_SEMAPHORE_WAIT_ANY_BIT is set, the current behavior is to avoid
waiting and the semaphore's current value is exactly the value waited
for.
If VK_SEMAPHORE_WAIT_ANY_BIT is not set but there is a non-infinte
timeout, the current behavior is to call wait_until with the criterion
that the counter reaches the exact value waited for.
In both cases, larger values should also be accepted.
Change-Id: I8e447501cc1d09d2071c95398663ec06b444106d
Bug: b/265933001
Tests: dEQP-VK.synchronization.basic.timeline_semaphore.*
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/70648
Presubmit-Ready: Shahbaz Youssefi <syoussefi@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@google.com>
Tested-by: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/src/Vulkan/VkDevice.cpp b/src/Vulkan/VkDevice.cpp
index b2470ea..b438f2e 100644
--- a/src/Vulkan/VkDevice.cpp
+++ b/src/Vulkan/VkDevice.cpp
@@ -280,7 +280,7 @@
TimelineSemaphore *semaphore = DynamicCast<TimelineSemaphore>(pWaitInfo->pSemaphores[i]);
uint64_t waitValue = pWaitInfo->pValues[i];
- if(semaphore->getCounterValue() == waitValue)
+ if(semaphore->getCounterValue() >= waitValue)
{
return VK_SUCCESS;
}
diff --git a/src/Vulkan/VkTimelineSemaphore.hpp b/src/Vulkan/VkTimelineSemaphore.hpp
index 55c3f45..d5fec6e 100644
--- a/src/Vulkan/VkTimelineSemaphore.hpp
+++ b/src/Vulkan/VkTimelineSemaphore.hpp
@@ -154,7 +154,7 @@
const std::chrono::time_point<Clock, Duration> timeout)
{
marl::lock lock(mutex);
- if(!cv.wait_until(lock, timeout, [&]() { return counter == value; }))
+ if(!cv.wait_until(lock, timeout, [&]() { return counter >= value; }))
{
return VK_TIMEOUT;
}