aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-07-21 14:27:57 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-22 01:03:06 +0000
commitcd1416efbc7af6f115dbaa09dce48e075d1d96ca (patch)
tree3f4ddbc475a167107929da6f670b7832b97f2c93 /include
parent97d4cf0e7eb15340b1f513ff8cfba4e55ee3acf2 (diff)
Add support for semaphores to be inserted on GrContext flush
This also moves the logic of inserting semaphores down into GrDrawingManager and finishFlush on GrGpu. With it being on finishFlush, there should be no issues when the DrawingManager starts respecting the proxy passed in assuming it always calls finishFlush at the end (which it should). Bug: skia: Change-Id: I925c2a289dcbbb9159b9120878af1d34f21a2dc7 Reviewed-on: https://skia-review.googlesource.com/25641 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkSurface.h14
-rw-r--r--include/gpu/GrBackendSemaphore.h7
-rw-r--r--include/gpu/GrContext.h30
3 files changed, 45 insertions, 6 deletions
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 4a8d81205f..d977391442 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -18,6 +18,7 @@ class GrBackendRenderTarget;
class GrBackendSemaphore;
class GrContext;
class GrRenderTarget;
+enum class GrSemaphoresSubmitted;
/**
* SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
@@ -329,16 +330,21 @@ public:
* If it is not initialized, a new semaphore is created and the GrBackendSemaphore object
* is initialized with that semaphore.
*
+ * The client will own and be responsible for deleting the underlying semaphores that are stored
+ * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects
+ * themselves can be deleted as soon as this function returns.
+ *
* If the backend API is OpenGL only uninitialized GrBackendSemaphores are supported.
* If the backend API is Vulkan either initialized or unitialized semaphores are supported.
* If unitialized, the semaphores which are created will be valid for use only with the VkDevice
* with which they were created.
*
- * If this call returns false, the GPU backend will not have created or added any semaphores to
- * signal. Thus the array of semaphores will remain uninitialized. However, any pending surface
- * IO will still be flush.
+ * If this call returns GrSemaphoresSubmited::kNo, the GPU backend will not have created or
+ * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on
+ * any of the semaphores. However, any pending surface IO will still be flushed.
*/
- bool flushAndSignalSemaphores(int numSemaphores, GrBackendSemaphore* signalSemaphores);
+ GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
+ GrBackendSemaphore signalSemaphores[]);
/**
* Inserts a list of GPU semaphores that the current backend 3D API must wait on before
diff --git a/include/gpu/GrBackendSemaphore.h b/include/gpu/GrBackendSemaphore.h
index 5c41532cb9..cea3745270 100644
--- a/include/gpu/GrBackendSemaphore.h
+++ b/include/gpu/GrBackendSemaphore.h
@@ -16,6 +16,13 @@
#include "vk/GrVkTypes.h"
#endif
+// Enum used as return value when flush with semaphores so the client knows whether the
+// semaphores were submitted to GPU or not.
+enum class GrSemaphoresSubmitted {
+ kNo,
+ kYes,
+};
+
/**
* Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
*/
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index f48b8db710..46a9008b63 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -17,6 +17,7 @@
#include "../private/GrSingleOwner.h"
class GrAtlasGlyphCache;
+class GrBackendSemaphore;
struct GrContextOptions;
class GrContextPriv;
class GrContextThreadSafeProxy;
@@ -43,6 +44,8 @@ class SkTraceMemoryDump;
class SkImage;
class SkSurfaceProps;
+enum class GrSemaphoresSubmitted;
+
class SK_API GrContext : public SkRefCnt {
public:
/**
@@ -237,12 +240,35 @@ public:
// Misc.
/**
- * Call to ensure all drawing to the context has been issued to the
- * underlying 3D API.
+ * Call to ensure all drawing to the context has been issued to the underlying 3D API.
*/
void flush();
/**
+ * Call to ensure all drawing to the context has been issued to the underlying 3D API. After
+ * issuing all commands, numSemaphore semaphores will be signaled by the gpu. The client passes
+ * in an array of numSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's can
+ * be either initialized or not. If they are initialized, the backend uses the passed in
+ * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore
+ * object is initialized with that semaphore.
+ *
+ * The client will own and be responsible for deleting the underlying semaphores that are stored
+ * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects
+ * themselves can be deleted as soon as this function returns.
+ *
+ * If the backend API is OpenGL only uninitialized GrBackendSemaphores are supported.
+ * If the backend API is Vulkan either initialized or unitialized semaphores are supported.
+ * If unitialized, the semaphores which are created will be valid for use only with the VkDevice
+ * with which they were created.
+ *
+ * If this call returns GrSemaphoresSubmited::kNo, the GPU backend will not have created or
+ * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on
+ * any of the semaphores. However, any pending commands to the context will still be flushed.
+ */
+ GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
+ GrBackendSemaphore signalSemaphores[]);
+
+ /**
* An ID associated with this context, guaranteed to be unique.
*/
uint32_t uniqueID() { return fUniqueID; }