diff options
author | 2016-01-20 10:54:58 -0800 | |
---|---|---|
committer | 2016-01-20 10:54:58 -0800 | |
commit | 4e8f567fa3229133670864a06fe4df26f437d14e (patch) | |
tree | 45ec0b3d044acd8254b049b2529b3d87f792455c | |
parent | 76097f823598076a440ed9dc7fa6611583308002 (diff) |
add wait on fence without flush
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
-rw-r--r-- | include/private/SkGpuFenceSync.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/SkGLContext.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp | 13 |
3 files changed, 12 insertions, 11 deletions
diff --git a/include/private/SkGpuFenceSync.h b/include/private/SkGpuFenceSync.h index b78398fed8..72fd241078 100644 --- a/include/private/SkGpuFenceSync.h +++ b/include/private/SkGpuFenceSync.h @@ -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() {} diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContext.cpp index ad119aee6a..9f373d6d47 100644 --- a/src/gpu/gl/SkGLContext.cpp +++ b/src/gpu/gl/SkGLContext.cpp @@ -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 { diff --git a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp index 821e040261..bf939730ca 100644 --- a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp +++ b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp @@ -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 { |