From ac0f60c307c2227cc57eadb02f7056b174433b85 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 28 Mar 2022 18:47:02 +0000 Subject: [PATCH] Fix one APICreateBuffer use in CommandBufferVk. Bug: dawn:723 Change-Id: I48c1c2594ee8b86dfe11b5dcaedcdd8170868def Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/84765 Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez Reviewed-by: Loko Kung --- src/dawn/native/vulkan/CommandBufferVk.cpp | 16 +++++++++------- src/dawn/native/vulkan/CommandBufferVk.h | 8 ++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/dawn/native/vulkan/CommandBufferVk.cpp b/src/dawn/native/vulkan/CommandBufferVk.cpp index 8a40d30934..23125bd36c 100644 --- a/src/dawn/native/vulkan/CommandBufferVk.cpp +++ b/src/dawn/native/vulkan/CommandBufferVk.cpp @@ -444,7 +444,7 @@ namespace dawn::native::vulkan { : CommandBufferBase(encoder, descriptor) { } - void CommandBuffer::RecordCopyImageWithTemporaryBuffer( + MaybeError CommandBuffer::RecordCopyImageWithTemporaryBuffer( CommandRecordingContext* recordingContext, const TextureCopy& srcCopy, const TextureCopy& dstCopy, @@ -467,12 +467,12 @@ namespace dawn::native::vulkan { tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; Device* device = ToBackend(GetDevice()); - // TODO(dawn:723): change to not use AcquireRef for reentrant object creation. - Ref tempBuffer = - AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor))); + Ref tempBufferBase; + DAWN_TRY_ASSIGN(tempBufferBase, device->CreateBuffer(&tempBufferDescriptor)); + Buffer* tempBuffer = ToBackend(tempBufferBase.Get()); BufferCopy tempBufferCopy; - tempBufferCopy.buffer = tempBuffer.Get(); + tempBufferCopy.buffer = tempBuffer; tempBufferCopy.rowsPerImage = heightInBlocks; tempBufferCopy.offset = 0; tempBufferCopy.bytesPerRow = copySize.width / blockInfo.width * blockInfo.byteSize; @@ -500,6 +500,8 @@ namespace dawn::native::vulkan { &tempBufferToDstRegion); recordingContext->tempBuffers.emplace_back(tempBuffer); + + return {}; } MaybeError CommandBuffer::RecordCommands(CommandRecordingContext* recordingContext) { @@ -706,8 +708,8 @@ namespace dawn::native::vulkan { 1, ®ion); } } else { - RecordCopyImageWithTemporaryBuffer(recordingContext, src, dst, - copy->copySize); + DAWN_TRY(RecordCopyImageWithTemporaryBuffer(recordingContext, src, dst, + copy->copySize)); } break; diff --git a/src/dawn/native/vulkan/CommandBufferVk.h b/src/dawn/native/vulkan/CommandBufferVk.h index b0d1e9cab9..d329a41868 100644 --- a/src/dawn/native/vulkan/CommandBufferVk.h +++ b/src/dawn/native/vulkan/CommandBufferVk.h @@ -44,10 +44,10 @@ namespace dawn::native::vulkan { const ComputePassResourceUsage& resourceUsages); MaybeError RecordRenderPass(CommandRecordingContext* recordingContext, BeginRenderPassCmd* renderPass); - void RecordCopyImageWithTemporaryBuffer(CommandRecordingContext* recordingContext, - const TextureCopy& srcCopy, - const TextureCopy& dstCopy, - const Extent3D& copySize); + MaybeError RecordCopyImageWithTemporaryBuffer(CommandRecordingContext* recordingContext, + const TextureCopy& srcCopy, + const TextureCopy& dstCopy, + const Extent3D& copySize); }; } // namespace dawn::native::vulkan