Commit 0acac464 by David 'Digit' Turner Committed by David Turner

vulkan: use a marl::Event in the VkSemaphore implementation.

Bug: 140421726 Change-Id: I375d937c92d1e88d30720cb0deca52c079fab134 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39249Tested-by: 's avatarDavid Turner <digit@google.com> Kokoro-Presubmit: David Turner <digit@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 43e33165
...@@ -93,7 +93,7 @@ void Semaphore::wait() ...@@ -93,7 +93,7 @@ void Semaphore::wait()
} }
else else
{ {
waitInternal(); internal.wait();
} }
} }
...@@ -107,26 +107,7 @@ void Semaphore::signal() ...@@ -107,26 +107,7 @@ void Semaphore::signal()
} }
else else
{ {
signalInternal(); internal.signal();
}
}
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();
} }
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "VkConfig.h" #include "VkConfig.h"
#include "VkObject.hpp" #include "VkObject.hpp"
#include "marl/conditionvariable.h" #include "marl/event.h"
#include <mutex> #include <mutex>
#if VK_USE_PLATFORM_FUCHSIA #if VK_USE_PLATFORM_FUCHSIA
...@@ -58,17 +58,12 @@ public: ...@@ -58,17 +58,12 @@ public:
class External; class External;
private: private:
void waitInternal();
void signalInternal();
void allocateExternal(); void allocateExternal();
void deallocateExternal(); void deallocateExternal();
const VkAllocationCallbacks *allocator = nullptr; const VkAllocationCallbacks *allocator = nullptr;
marl::Event internal;
std::mutex mutex; std::mutex mutex;
marl::ConditionVariable condition;
bool signaled = false;
External *external = nullptr; External *external = nullptr;
bool temporaryImport = false; bool temporaryImport = false;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment