diff options
author | Greg Daniel <egdaniel@google.com> | 2018-01-09 13:55:33 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-09 19:22:27 +0000 |
commit | 17b7c054339dfa592571ebd92d2419949baca6f0 (patch) | |
tree | 2ecef7a4c9ccfb2edaf72dd5eb56b229ed29a2ca /src/gpu/gl | |
parent | e48eb337e1ff16bc0190a0562b01ea4cc9a84ccb (diff) |
Update GrSemaphore to allow it to only be used once for signaling and once for waiting.
This is required for Vulkan which doesn't allow a semaphore to be waited on by
multiple things at once or signaled from multiple places.
Bug: skia:
Change-Id: Iac0cb782a6662167c2cab1fd6a2c80378834a480
Reviewed-on: https://skia-review.googlesource.com/92601
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 17 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 9 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 7b66bcc8a1..fb82a54448 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4569,26 +4569,29 @@ sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrGLGpu::makeSemaphore(bool isOwned) { return GrGLSemaphore::Make(this, isOwned); } -sk_sp<GrSemaphore> GrGLGpu::wrapBackendSemaphore(const GrBackendSemaphore& semaphore, - GrWrapOwnership ownership) { +sk_sp<GrSemaphore> GrGLGpu::onWrapBackendSemaphore(const GrBackendSemaphore& semaphore, + GrWrapOwnership ownership) { SkASSERT(this->caps()->fenceSyncSupport()); return GrGLSemaphore::MakeWrapped(this, semaphore.glSync(), ownership); } -void GrGLGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) { +void GrGLGpu::onInsertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) { GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore.get()); - GrGLsync sync; - GL_CALL_RET(sync, FenceSync(GR_GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); - glSem->setSync(sync); + if (glSem) { + GrGLsync sync; + GL_CALL_RET(sync, FenceSync(GR_GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); + glSem->setSync(sync); + } if (flush) { GL_CALL(Flush()); } } -void GrGLGpu::waitSemaphore(sk_sp<GrSemaphore> semaphore) { +void GrGLGpu::onWaitSemaphore(sk_sp<GrSemaphore> semaphore) { GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore.get()); + SkASSERT(glSem); GL_CALL(WaitSync(glSem->sync(), 0, GR_GL_TIMEOUT_IGNORED)); } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 4559d38e4a..2087356f04 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -173,10 +173,6 @@ public: void deleteFence(GrFence) const override; sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned) override; - sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore, - GrWrapOwnership ownership) override; - void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override; - void waitSemaphore(sk_sp<GrSemaphore> semaphore) override; sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override; @@ -290,6 +286,11 @@ private: void onFinishFlush(bool insertedSemaphores) override; + void onInsertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override; + void onWaitSemaphore(sk_sp<GrSemaphore> semaphore) override; + sk_sp<GrSemaphore> onWrapBackendSemaphore(const GrBackendSemaphore& semaphore, + GrWrapOwnership ownership) override; + bool hasExtension(const char* ext) const { return fGLContext->hasExtension(ext); } bool copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, |