vulkan: use a marl::Event in the VkSemaphore implementation.
Bug: 140421726
Change-Id: I375d937c92d1e88d30720cb0deca52c079fab134
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39249
Tested-by: David Turner <digit@google.com>
Kokoro-Presubmit: David Turner <digit@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Vulkan/VkSemaphore.cpp b/src/Vulkan/VkSemaphore.cpp
index f4b9062..31eb5fd 100644
--- a/src/Vulkan/VkSemaphore.cpp
+++ b/src/Vulkan/VkSemaphore.cpp
@@ -93,7 +93,7 @@
}
else
{
- waitInternal();
+ internal.wait();
}
}
@@ -107,26 +107,7 @@
}
else
{
- signalInternal();
- }
-}
-
-void Semaphore::waitInternal()
-{
- // Wait on the marl condition variable only.
- std::unique_lock<std::mutex> lock(mutex);
- condition.wait(lock, [this] { return this->signaled; });
- signaled = false; // Vulkan requires resetting after waiting.
-}
-
-void Semaphore::signalInternal()
-{
- // Signal the marl condition variable only.
- std::unique_lock<std::mutex> lock(mutex);
- if(!signaled)
- {
- signaled = true;
- condition.notify_one();
+ internal.signal();
}
}
diff --git a/src/Vulkan/VkSemaphore.hpp b/src/Vulkan/VkSemaphore.hpp
index 18ebc71..54004d8 100644
--- a/src/Vulkan/VkSemaphore.hpp
+++ b/src/Vulkan/VkSemaphore.hpp
@@ -18,7 +18,7 @@
#include "VkConfig.h"
#include "VkObject.hpp"
-#include "marl/conditionvariable.h"
+#include "marl/event.h"
#include <mutex>
#if VK_USE_PLATFORM_FUCHSIA
@@ -58,17 +58,12 @@
class External;
private:
- void waitInternal();
- void signalInternal();
-
void allocateExternal();
void deallocateExternal();
const VkAllocationCallbacks *allocator = nullptr;
+ marl::Event internal;
std::mutex mutex;
- marl::ConditionVariable condition;
- bool signaled = false;
-
External *external = nullptr;
bool temporaryImport = false;
};