Add wait function to GrVkSecondaryCBDrawContext for semaphores.
Bug: skia:
Change-Id: Icd4875fa8fa495f9ce02135bc0a8c37608ed09df
Reviewed-on: https://skia-review.googlesource.com/c/181661
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index a7e5e3f..83de36d 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -61,6 +61,11 @@
fDevice->flush();
}
+bool GrVkSecondaryCBDrawContext::wait(int numSemaphores,
+ const GrBackendSemaphore waitSemaphores[]) {
+ return fDevice->wait(numSemaphores, waitSemaphores);
+}
+
void GrVkSecondaryCBDrawContext::releaseResources() {
fCachedCanvas.reset();
fDevice.reset();
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.h b/src/gpu/vk/GrVkSecondaryCBDrawContext.h
index 6a47775..c6ea9f9 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.h
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.h
@@ -11,6 +11,7 @@
#include "SkTypes.h"
#include "SkRefCnt.h"
+class GrBackendSemaphore;
class GrContext;
struct GrVkDrawableInfo;
class SkCanvas;
@@ -67,6 +68,21 @@
// offscreen draws to the GPU.
void flush();
+ /** Inserts a list of GPU semaphores that Skia will have the driver wait on before executing
+ commands for this secondary CB. The wait semaphores will get added to the VkCommandBuffer
+ owned by this GrContext when flush() is called, and not the command buffer which the
+ Secondary CB is from. This will guarantee that the driver waits on the semaphores before
+ the secondary command buffer gets executed. Skia will take ownership of the underlying
+ semaphores and delete them once they have been signaled and waited on. If this call returns
+ false, then the GPU back-end will not wait on any passed in semaphores, and the client will
+ still own the semaphores.
+
+ @param numSemaphores size of waitSemaphores array
+ @param waitSemaphores array of semaphore containers
+ @return true if GPU is waiting on semaphores
+ */
+ bool wait(int numSemaphores, const GrBackendSemaphore waitSemaphores[]);
+
// This call will release all resources held by the draw context. The client must call
// releaseResources() before deleting the drawing context. However, the resources also include
// any Vulkan resources that were created and used for draws. Therefore the client must only