Make use of VkSemaphores thread safe assuming use of the same VkQueue.
This allows us to re-enable support for multiple GrContexts in
GrBackendTextureImageGenerator.
Bug: skia:
Change-Id: Ifd6ac1ad81cdfbd1fd986467d8beb359399d6588
Reviewed-on: https://skia-review.googlesource.com/98340
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkSemaphore.cpp b/src/gpu/vk/GrVkSemaphore.cpp
index 38946f4..4a23c43 100644
--- a/src/gpu/vk/GrVkSemaphore.cpp
+++ b/src/gpu/vk/GrVkSemaphore.cpp
@@ -16,6 +16,8 @@
#undef CreateSemaphore
#endif
+SkMutex GrVkSemaphore::Resource::gMutex;
+
sk_sp<GrVkSemaphore> GrVkSemaphore::Make(const GrVkGpu* gpu, bool isOwned) {
VkSemaphoreCreateInfo createInfo;
memset(&createInfo, 0, sizeof(VkSemaphoreCreateInfo));
@@ -26,22 +28,26 @@
GR_VK_CALL_ERRCHECK(gpu->vkInterface(),
CreateSemaphore(gpu->device(), &createInfo, nullptr, &semaphore));
- return sk_sp<GrVkSemaphore>(new GrVkSemaphore(gpu, semaphore, isOwned));
+ return sk_sp<GrVkSemaphore>(new GrVkSemaphore(gpu, semaphore, false, false, isOwned));
}
sk_sp<GrVkSemaphore> GrVkSemaphore::MakeWrapped(const GrVkGpu* gpu,
VkSemaphore semaphore,
+ WrapType wrapType,
GrWrapOwnership ownership) {
if (VK_NULL_HANDLE == semaphore) {
return nullptr;
}
- return sk_sp<GrVkSemaphore>(new GrVkSemaphore(gpu, semaphore,
+ bool prohibitSignal = WrapType::kWillWait == wrapType;
+ bool prohibitWait = WrapType::kWillSignal == wrapType;
+ return sk_sp<GrVkSemaphore>(new GrVkSemaphore(gpu, semaphore, prohibitSignal, prohibitWait,
kBorrow_GrWrapOwnership != ownership));
}
-GrVkSemaphore::GrVkSemaphore(const GrVkGpu* gpu, VkSemaphore semaphore, bool isOwned)
+GrVkSemaphore::GrVkSemaphore(const GrVkGpu* gpu, VkSemaphore semaphore, bool prohibitSignal,
+ bool prohibitWait, bool isOwned)
: INHERITED(gpu) {
- fResource = new Resource(semaphore, isOwned);
+ fResource = new Resource(semaphore, prohibitSignal, prohibitWait, isOwned);
}
GrVkSemaphore::~GrVkSemaphore() {