Add wait function on GrContext to wait on semaphores.
This behaves like the SkSurface::wait call but is not tied to a specific
surface.
Change-Id: Ic572296e0f581204bf69a7178645d99e365c0692
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209648
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2f4a674..0517e4e 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -239,6 +239,21 @@
////////////////////////////////////////////////////////////////////////////////
+bool GrContext::wait(int numSemaphores, const GrBackendSemaphore waitSemaphores[]) {
+ if (!fGpu || fGpu->caps()->fenceSyncSupport()) {
+ return false;
+ }
+ for (int i = 0; i < numSemaphores; ++i) {
+ sk_sp<GrSemaphore> sema = fResourceProvider->wrapBackendSemaphore(
+ waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait,
+ kAdopt_GrWrapOwnership);
+ fGpu->waitSemaphore(std::move(sema));
+ }
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
GrSemaphoresSubmitted GrContext::flush(const GrFlushInfo& info) {
ASSERT_SINGLE_OWNER
if (this->abandoned()) {