aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-06-15 15:25:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-15 19:49:18 +0000
commit66366c697853e906d961ae691e2bc5209cdcfa62 (patch)
treef90de7fef9bd094ded9f6497c0004876694cca61 /include
parent000182881a65ef4b12ca3739d47c5e21e79ca919 (diff)
Add API for flushing surfaces with gpu semaphores
BUG=skia: Change-Id: Ia4bfef784cd5f2516ceccafce958be18a86f91d1 Reviewed-on: https://skia-review.googlesource.com/11488 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Forrest Reiling <freiling@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkSurface.h25
-rw-r--r--include/gpu/GrBackendSemaphore.h69
2 files changed, 94 insertions, 0 deletions
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index efa2428ccb..6fad21721e 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -15,6 +15,7 @@
class SkCanvas;
class SkPaint;
class GrBackendRenderTarget;
+class GrBackendSemaphore;
class GrContext;
class GrRenderTarget;
@@ -323,9 +324,33 @@ public:
/**
* Issue any pending surface IO to the current backend 3D API and resolve any surface MSAA.
+ *
+ * The flush calls below are the new preferred way to flush calls to a surface, and this call
+ * will eventually be removed.
*/
void prepareForExternalIO();
+ /**
+ * Issue any pending surface IO to the current backend 3D API
+ */
+ void flush();
+
+ /**
+ * Issue any pending surface IO to the current backend 3D API. After issuing all commands, we
+ * will issue numSemaphore semaphores for the gpu to signal. We will then fill in the array
+ * signalSemaphores with the info on the semaphores we submitted. The client is reposonsible for
+ * allocating enough space in signalSemaphores to handle numSemaphores of GrBackendSemaphores.
+ * The client will also take ownership of the returned underlying backend semaphores.
+ */
+ void flushAndSignalSemaphores(int numSemaphores, GrBackendSemaphore* signalSemaphores);
+
+ /**
+ * Inserts a list of GPU semaphores that the current backend 3D API must wait on before
+ * executing any more commands on the GPU for this surface. Skia will take ownership of the
+ * underlying semaphores and delete them once they have been signaled and waited on.
+ */
+ void wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
+
protected:
SkSurface(int width, int height, const SkSurfaceProps*);
SkSurface(const SkImageInfo&, const SkSurfaceProps*);
diff --git a/include/gpu/GrBackendSemaphore.h b/include/gpu/GrBackendSemaphore.h
new file mode 100644
index 0000000000..668f6bb1c9
--- /dev/null
+++ b/include/gpu/GrBackendSemaphore.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrBackendSemaphore_DEFINED
+#define GrBackendSemaphore_DEFINED
+
+#include "GrTypes.h"
+
+#include "gl/GrGLTypes.h"
+
+#ifdef SK_VULKAN
+#include "vk/GrVkTypes.h"
+#endif
+
+/**
+ * Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
+ */
+class GrBackendSemaphore {
+public:
+ // For convenience we just set the backend here to OpenGL. The GrBackendSemaphore cannot be used
+ // until either initGL or initVulkan are called which will set the appropriate GrBackend.
+ GrBackendSemaphore() : fBackend(kOpenGL_GrBackend), fGLSync(0), fIsInitialized(false) {}
+
+ void initGL(GrGLsync sync) {
+ fBackend = kOpenGL_GrBackend;
+ fGLSync = sync;
+ fIsInitialized = true;
+ }
+
+#ifdef SK_VULKAN
+ void initVulkan(VkSemaphore semaphore) {
+ fBackend = kVulkan_GrBackend;
+ fVkSemaphore = semaphore;
+ fIsInitialized = true;
+ }
+#endif
+
+ GrGLsync glSync() const {
+ if (!fIsInitialized || kOpenGL_GrBackend != fBackend) {
+ return 0;
+ }
+ return fGLSync;
+ }
+
+#ifdef SK_VULKAN
+ VkSemaphore vkSemaphore() const {
+ if (!fIsInitialized || kVulkan_GrBackend != fBackend) {
+ return VK_NULL_HANDLE;
+ }
+ return fVkSemaphore;
+ }
+#endif
+
+private:
+ GrBackend fBackend;
+ union {
+ GrGLsync fGLSync;
+#ifdef SK_VULKAN
+ VkSemaphore fVkSemaphore;
+#endif
+ };
+ bool fIsInitialized;
+};
+
+#endif