From 76e1e41cc7bf4292e6a37e9c8751f51a4c118224 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 11 Oct 2019 11:29:46 +0000 Subject: [PATCH] Vulkan: Proper error handling for submission. BUG=dawn:19 Change-Id: I457a7d3f95a9f486b6d7dbf5fe1885758362d504 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12021 Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya Commit-Queue: Corentin Wallez --- src/dawn_native/vulkan/DeviceVk.cpp | 17 ++++++++--------- src/dawn_native/vulkan/DeviceVk.h | 2 +- src/dawn_native/vulkan/QueueVk.cpp | 3 ++- src/dawn_native/vulkan/SwapChainVk.cpp | 2 +- src/dawn_native/vulkan/TextureVk.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index f950661f7d..b6e49b7c6c 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -222,7 +222,7 @@ namespace dawn_native { namespace vulkan { mDeleter->Tick(mCompletedSerial); if (mPendingCommands.pool != VK_NULL_HANDLE) { - SubmitPendingCommands(); + DAWN_TRY(SubmitPendingCommands()); } else if (mCompletedSerial == mLastSubmittedSerial) { // If there's no GPU work in flight we still need to artificially increment the serial // so that CPU operations waiting on GPU completion can know they don't have to wait. @@ -294,14 +294,13 @@ namespace dawn_native { namespace vulkan { return &mRecordingContext; } - void Device::SubmitPendingCommands() { + MaybeError Device::SubmitPendingCommands() { if (mPendingCommands.pool == VK_NULL_HANDLE) { - return; + return {}; } - if (fn.EndCommandBuffer(mPendingCommands.commandBuffer) != VK_SUCCESS) { - ASSERT(false); - } + DAWN_TRY(CheckVkSuccess(fn.EndCommandBuffer(mPendingCommands.commandBuffer), + "vkEndCommandBuffer")); std::vector dstStageMasks(mRecordingContext.waitSemaphores.size(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); @@ -320,9 +319,7 @@ namespace dawn_native { namespace vulkan { submitInfo.pSignalSemaphores = mRecordingContext.signalSemaphores.data(); VkFence fence = GetUnusedFence(); - if (fn.QueueSubmit(mQueue, 1, &submitInfo, fence) != VK_SUCCESS) { - ASSERT(false); - } + DAWN_TRY(CheckVkSuccess(fn.QueueSubmit(mQueue, 1, &submitInfo, fence), "vkQueueSubmit")); mLastSubmittedSerial++; mCommandsInFlight.Enqueue(mPendingCommands, mLastSubmittedSerial); @@ -338,6 +335,8 @@ namespace dawn_native { namespace vulkan { } mRecordingContext = CommandRecordingContext(); + + return {}; } ResultOrError Device::CreateDevice(VkPhysicalDevice physicalDevice) { diff --git a/src/dawn_native/vulkan/DeviceVk.h b/src/dawn_native/vulkan/DeviceVk.h index f4e728874c..bef3278fcf 100644 --- a/src/dawn_native/vulkan/DeviceVk.h +++ b/src/dawn_native/vulkan/DeviceVk.h @@ -67,7 +67,7 @@ namespace dawn_native { namespace vulkan { VkCommandBuffer GetPendingCommandBuffer(); CommandRecordingContext* GetPendingRecordingContext(); Serial GetPendingCommandSerial() const override; - void SubmitPendingCommands(); + MaybeError SubmitPendingCommands(); TextureBase* CreateTextureWrappingVulkanImage( const ExternalImageDescriptor* descriptor, diff --git a/src/dawn_native/vulkan/QueueVk.cpp b/src/dawn_native/vulkan/QueueVk.cpp index 379eb07fd4..558927c52a 100644 --- a/src/dawn_native/vulkan/QueueVk.cpp +++ b/src/dawn_native/vulkan/QueueVk.cpp @@ -38,7 +38,8 @@ namespace dawn_native { namespace vulkan { DAWN_TRY(ToBackend(commands[i])->RecordCommands(recordingContext)); } - device->SubmitPendingCommands(); + DAWN_TRY(device->SubmitPendingCommands()); + return {}; } diff --git a/src/dawn_native/vulkan/SwapChainVk.cpp b/src/dawn_native/vulkan/SwapChainVk.cpp index d1eafc9cf1..b465bd0a38 100644 --- a/src/dawn_native/vulkan/SwapChainVk.cpp +++ b/src/dawn_native/vulkan/SwapChainVk.cpp @@ -59,7 +59,7 @@ namespace dawn_native { namespace vulkan { CommandRecordingContext* recordingContext = device->GetPendingRecordingContext(); ToBackend(texture)->TransitionUsageNow(recordingContext, mTextureUsage); - device->SubmitPendingCommands(); + DAWN_TRY(device->SubmitPendingCommands()); return {}; } diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 9ff1dd0fbe..0cd4d053ca 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -562,7 +562,7 @@ namespace dawn_native { namespace vulkan { // Queue submit to signal we are done with the texture device->GetPendingRecordingContext()->signalSemaphores.push_back(mSignalSemaphore); - device->SubmitPendingCommands(); + DAWN_TRY(device->SubmitPendingCommands()); // Write out the signal semaphore *outSignalSemaphore = mSignalSemaphore;