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