add wait on fence without flush
authorjoshualitt <joshualitt@chromium.org>
Wed, 20 Jan 2016 18:54:58 +0000 (10:54 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 20 Jan 2016 18:54:58 +0000 (10:54 -0800)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1610183002

Review URL: https://codereview.chromium.org/1610183002

include/private/SkGpuFenceSync.h
src/gpu/gl/SkGLContext.cpp
src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp

index b78398f..72fd241 100644 (file)
@@ -20,7 +20,7 @@ typedef void* SkPlatformGpuFence;
 class SkGpuFenceSync {
 public:
     virtual SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const = 0;
-    virtual bool flushAndWaitFence(SkPlatformGpuFence) const = 0;
+    virtual bool waitFence(SkPlatformGpuFence, bool flush) const = 0;
     virtual void deleteFence(SkPlatformGpuFence) const = 0;
 
     virtual ~SkGpuFenceSync() {}
index ad119ae..9f373d6 100644 (file)
@@ -14,7 +14,7 @@ public:
     static GLFenceSync* CreateIfSupported(const SkGLContext*);
 
     SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override;
-    bool flushAndWaitFence(SkPlatformGpuFence fence) const override;
+    bool waitFence(SkPlatformGpuFence fence, bool flush) const override;
     void deleteFence(SkPlatformGpuFence fence) const override;
 
 private:
@@ -85,7 +85,7 @@ void SkGLContext::swapBuffers() {
     }
 
     if (fFrameFences[fCurrentFenceIdx]) {
-        if (!fFenceSync->flushAndWaitFence(fFrameFences[fCurrentFenceIdx])) {
+        if (!fFenceSync->waitFence(fFrameFences[fCurrentFenceIdx], true)) {
             SkDebugf("WARNING: Wait failed for fence sync. Timings might not be accurate.\n");
         }
         fFenceSync->deleteFence(fFrameFences[fCurrentFenceIdx]);
@@ -143,9 +143,9 @@ SkPlatformGpuFence SkGLContext::GLFenceSync::insertFence() const {
     return fGLFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
 }
 
-bool SkGLContext::GLFenceSync::flushAndWaitFence(SkPlatformGpuFence fence) const {
+bool SkGLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const {
     GLsync glsync = static_cast<GLsync>(fence);
-    return GL_WAIT_FAILED != fGLClientWaitSync(glsync, GL_SYNC_FLUSH_COMMANDS_BIT, -1);
+    return GL_WAIT_FAILED != fGLClientWaitSync(glsync, flush ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, -1);
 }
 
 void SkGLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const {
index 821e040..bf93973 100644 (file)
@@ -24,7 +24,7 @@ public:
     static SkEGLFenceSync* CreateIfSupported(EGLDisplay);
 
     SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override;
-    bool flushAndWaitFence(SkPlatformGpuFence fence) const override;
+    bool waitFence(SkPlatformGpuFence fence, bool flush) const override;
     void deleteFence(SkPlatformGpuFence fence) const override;
 
 private:
@@ -302,12 +302,13 @@ SkPlatformGpuFence SkEGLFenceSync::insertFence() const {
     return eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr);
 }
 
-bool SkEGLFenceSync::flushAndWaitFence(SkPlatformGpuFence platformFence) const {
+bool SkEGLFenceSync::waitFence(SkPlatformGpuFence platformFence, bool flush) const {
     EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence);
-    return EGL_CONDITION_SATISFIED_KHR == eglClientWaitSyncKHR(fDisplay,
-                                                               eglsync,
-                                                               EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
-                                                               EGL_FOREVER_KHR);
+    return EGL_CONDITION_SATISFIED_KHR ==
+            eglClientWaitSyncKHR(fDisplay,
+                                 eglsync,
+                                 flush ? EGL_SYNC_FLUSH_COMMANDS_BIT_KHR : 0,
+                                 EGL_FOREVER_KHR);
 }
 
 void SkEGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const {