diff options
author | 2017-06-15 15:25:38 -0400 | |
---|---|---|
committer | 2017-06-15 19:49:18 +0000 | |
commit | 66366c697853e906d961ae691e2bc5209cdcfa62 (patch) | |
tree | f90de7fef9bd094ded9f6497c0004876694cca61 /src/gpu/vk/GrVkGpu.cpp | |
parent | 000182881a65ef4b12ca3739d47c5e21e79ca919 (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 'src/gpu/vk/GrVkGpu.cpp')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index f76f06cfc0..b10e9ed59d 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -7,6 +7,7 @@ #include "GrVkGpu.h" +#include "GrBackendSemaphore.h" #include "GrBackendSurface.h" #include "GrContextOptions.h" #include "GrGeometryProcessor.h" @@ -191,6 +192,12 @@ void GrVkGpu::destroyResources() { } fSemaphoresToWaitOn.reset(); + for (int i = 0; i < fSemaphoresToSignal.count(); ++i) { + fSemaphoresToSignal[i]->unref(this); + } + fSemaphoresToSignal.reset(); + + fCopyManager.destroyResources(this); // must call this just before we destroy the command pool and VkDevice @@ -226,12 +233,16 @@ void GrVkGpu::disconnect(DisconnectType type) { for (int i = 0; i < fSemaphoresToWaitOn.count(); ++i) { fSemaphoresToWaitOn[i]->unrefAndAbandon(); } + for (int i = 0; i < fSemaphoresToSignal.count(); ++i) { + fSemaphoresToSignal[i]->unrefAndAbandon(); + } fCopyManager.abandonResources(); // must call this just before we destroy the command pool and VkDevice fResourceProvider.abandonResources(); } fSemaphoresToWaitOn.reset(); + fSemaphoresToSignal.reset(); #ifdef SK_ENABLE_VK_LAYERS fCallback = VK_NULL_HANDLE; #endif @@ -249,17 +260,20 @@ GrGpuCommandBuffer* GrVkGpu::createCommandBuffer( return new GrVkGpuCommandBuffer(this, colorInfo, stencilInfo); } -void GrVkGpu::submitCommandBuffer(SyncQueue sync, - const GrVkSemaphore::Resource* signalSemaphore) { +void GrVkGpu::submitCommandBuffer(SyncQueue sync) { SkASSERT(fCurrentCmdBuffer); fCurrentCmdBuffer->end(this); - fCurrentCmdBuffer->submitToQueue(this, fQueue, sync, signalSemaphore, fSemaphoresToWaitOn); + fCurrentCmdBuffer->submitToQueue(this, fQueue, sync, fSemaphoresToSignal, fSemaphoresToWaitOn); for (int i = 0; i < fSemaphoresToWaitOn.count(); ++i) { fSemaphoresToWaitOn[i]->unref(this); } fSemaphoresToWaitOn.reset(); + for (int i = 0; i < fSemaphoresToSignal.count(); ++i) { + fSemaphoresToSignal[i]->unref(this); + } + fSemaphoresToSignal.reset(); fResourceProvider.checkCommandBuffers(); @@ -1937,15 +1951,25 @@ void GrVkGpu::deleteFence(GrFence fence) const { VK_CALL(DestroyFence(this->device(), (VkFence)fence, nullptr)); } -sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrVkGpu::makeSemaphore() { - return GrVkSemaphore::Make(this); +sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrVkGpu::makeSemaphore(bool isOwned) { + return GrVkSemaphore::Make(this, isOwned); +} + +sk_sp<GrSemaphore> GrVkGpu::wrapBackendSemaphore(const GrBackendSemaphore& semaphore, + GrWrapOwnership ownership) { + return GrVkSemaphore::MakeWrapped(this, semaphore.vkSemaphore(), ownership); } -void GrVkGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool /*flush*/) { +void GrVkGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) { GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore.get()); - // We *always* flush, so ignore that parameter - this->submitCommandBuffer(kSkip_SyncQueue, vkSem->getResource()); + const GrVkSemaphore::Resource* resource = vkSem->getResource(); + resource->ref(); + fSemaphoresToSignal.push_back(resource); + + if (flush) { + this->submitCommandBuffer(kSkip_SyncQueue); + } } void GrVkGpu::waitSemaphore(sk_sp<GrSemaphore> semaphore) { |