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 <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
This commit is contained in:
Corentin Wallez 2022-03-28 18:47:02 +00:00 committed by Dawn LUCI CQ
parent 45b4893326
commit ac0f60c307
2 changed files with 13 additions and 11 deletions

View File

@ -444,7 +444,7 @@ namespace dawn::native::vulkan {
: CommandBufferBase(encoder, descriptor) { : CommandBufferBase(encoder, descriptor) {
} }
void CommandBuffer::RecordCopyImageWithTemporaryBuffer( MaybeError CommandBuffer::RecordCopyImageWithTemporaryBuffer(
CommandRecordingContext* recordingContext, CommandRecordingContext* recordingContext,
const TextureCopy& srcCopy, const TextureCopy& srcCopy,
const TextureCopy& dstCopy, const TextureCopy& dstCopy,
@ -467,12 +467,12 @@ namespace dawn::native::vulkan {
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
// TODO(dawn:723): change to not use AcquireRef for reentrant object creation. Ref<BufferBase> tempBufferBase;
Ref<Buffer> tempBuffer = DAWN_TRY_ASSIGN(tempBufferBase, device->CreateBuffer(&tempBufferDescriptor));
AcquireRef(ToBackend(device->APICreateBuffer(&tempBufferDescriptor))); Buffer* tempBuffer = ToBackend(tempBufferBase.Get());
BufferCopy tempBufferCopy; BufferCopy tempBufferCopy;
tempBufferCopy.buffer = tempBuffer.Get(); tempBufferCopy.buffer = tempBuffer;
tempBufferCopy.rowsPerImage = heightInBlocks; tempBufferCopy.rowsPerImage = heightInBlocks;
tempBufferCopy.offset = 0; tempBufferCopy.offset = 0;
tempBufferCopy.bytesPerRow = copySize.width / blockInfo.width * blockInfo.byteSize; tempBufferCopy.bytesPerRow = copySize.width / blockInfo.width * blockInfo.byteSize;
@ -500,6 +500,8 @@ namespace dawn::native::vulkan {
&tempBufferToDstRegion); &tempBufferToDstRegion);
recordingContext->tempBuffers.emplace_back(tempBuffer); recordingContext->tempBuffers.emplace_back(tempBuffer);
return {};
} }
MaybeError CommandBuffer::RecordCommands(CommandRecordingContext* recordingContext) { MaybeError CommandBuffer::RecordCommands(CommandRecordingContext* recordingContext) {
@ -706,8 +708,8 @@ namespace dawn::native::vulkan {
1, &region); 1, &region);
} }
} else { } else {
RecordCopyImageWithTemporaryBuffer(recordingContext, src, dst, DAWN_TRY(RecordCopyImageWithTemporaryBuffer(recordingContext, src, dst,
copy->copySize); copy->copySize));
} }
break; break;

View File

@ -44,10 +44,10 @@ namespace dawn::native::vulkan {
const ComputePassResourceUsage& resourceUsages); const ComputePassResourceUsage& resourceUsages);
MaybeError RecordRenderPass(CommandRecordingContext* recordingContext, MaybeError RecordRenderPass(CommandRecordingContext* recordingContext,
BeginRenderPassCmd* renderPass); BeginRenderPassCmd* renderPass);
void RecordCopyImageWithTemporaryBuffer(CommandRecordingContext* recordingContext, MaybeError RecordCopyImageWithTemporaryBuffer(CommandRecordingContext* recordingContext,
const TextureCopy& srcCopy, const TextureCopy& srcCopy,
const TextureCopy& dstCopy, const TextureCopy& dstCopy,
const Extent3D& copySize); const Extent3D& copySize);
}; };
} // namespace dawn::native::vulkan } // namespace dawn::native::vulkan