diff options
author | 2016-11-07 11:10:21 -0500 | |
---|---|---|
committer | 2016-11-07 16:51:34 +0000 | |
commit | 09557d7c0409ca1194d06d9dd9664fb5530c3f46 (patch) | |
tree | f8285d3ae30c00258d65a6f76ffc2e2472d280c8 /src | |
parent | 20b914b00eae64bdd9f5a8ff1ca2be6ebe61c2a3 (diff) |
Fix Vulkan command buffer assert on device lost
BUG=skia:5939
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4483
Change-Id: Id363c4d774095b1707adbe6c8ab537c6e5ecab6c
Reviewed-on: https://skia-review.googlesource.com/4483
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 8 | ||||
-rw-r--r-- | src/gpu/vk/GrVkResourceProvider.cpp | 6 | ||||
-rw-r--r-- | src/gpu/vk/GrVkResourceProvider.h | 4 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index f11193f245..b64d3ce1d0 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -166,12 +166,12 @@ GrVkGpu::~GrVkGpu() { // wait for all commands to finish fResourceProvider.checkCommandBuffers(); - SkDEBUGCODE(VkResult res = ) VK_CALL(QueueWaitIdle(fQueue)); + VkResult res = VK_CALL(QueueWaitIdle(fQueue)); // On windows, sometimes calls to QueueWaitIdle return before actually signalling the fences // on the command buffers even though they have completed. This causes an assert to fire when // destroying the command buffers. Currently this ony seems to happen on windows, so we add a - // sleep to make sure the fence singals. + // sleep to make sure the fence signals. #ifdef SK_DEBUG #if defined(SK_BUILD_FOR_WIN) Sleep(10); // In milliseconds @@ -187,8 +187,8 @@ GrVkGpu::~GrVkGpu() { fCopyManager.destroyResources(this); - // must call this just before we destroy the VkDevice - fResourceProvider.destroyResources(); + // must call this just before we destroy the command pool and VkDevice + fResourceProvider.destroyResources(VK_ERROR_DEVICE_LOST == res); VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp index ca4d52e9e6..5cde9bc6df 100644 --- a/src/gpu/vk/GrVkResourceProvider.cpp +++ b/src/gpu/vk/GrVkResourceProvider.cpp @@ -307,10 +307,10 @@ void GrVkResourceProvider::recycleStandardUniformBufferResource(const GrVkResour fAvailableUniformBufferResources.push_back(resource); } -void GrVkResourceProvider::destroyResources() { +void GrVkResourceProvider::destroyResources(bool deviceLost) { // release our active command buffers for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { - SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); + SkASSERT(deviceLost || fActiveCommandBuffers[i]->finished(fGpu)); SkASSERT(fActiveCommandBuffers[i]->unique()); fActiveCommandBuffers[i]->reset(fGpu); fActiveCommandBuffers[i]->unref(fGpu); @@ -318,7 +318,7 @@ void GrVkResourceProvider::destroyResources() { fActiveCommandBuffers.reset(); // release our available command buffers for (int i = 0; i < fAvailableCommandBuffers.count(); ++i) { - SkASSERT(fAvailableCommandBuffers[i]->finished(fGpu)); + SkASSERT(deviceLost || fAvailableCommandBuffers[i]->finished(fGpu)); SkASSERT(fAvailableCommandBuffers[i]->unique()); fAvailableCommandBuffers[i]->unref(fGpu); } diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h index 0c9397e706..99724a6a8b 100644 --- a/src/gpu/vk/GrVkResourceProvider.h +++ b/src/gpu/vk/GrVkResourceProvider.h @@ -148,7 +148,9 @@ public: // The assumption is that all queues are idle and all command buffers are finished. // For resource tracing to work properly, this should be called after unrefing all other // resource usages. - void destroyResources(); + // If deviceLost is true, then resources will not be checked to see if they've finished + // before deleting (see section 4.2.4 of the Vulkan spec). + void destroyResources(bool deviceLost); // Abandon any cached resources. To be used when the context/VkDevice is lost. // For resource tracing to work properly, this should be called after unrefing all other |