Move zero-size copy skips from the frontend to the backend

Bug: chromium:1217741
Change-Id: Ib4884b5aa80124ed9da48262fcae11cf6d605034
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53883
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Austin Eng
2021-06-10 02:40:18 +00:00
committed by Dawn LUCI CQ
parent 5173a0236d
commit f8a0f82fad
6 changed files with 134 additions and 60 deletions

View File

@@ -226,6 +226,22 @@ TEST_F(CopyCommandTest_B2B, Success) {
}
}
// Test a successful B2B copy where the last external reference is dropped.
// This is a regression test for crbug.com/1217741 where submitting a command
// buffer with dropped resources when the copy size is 0 was a use-after-free.
TEST_F(CopyCommandTest_B2B, DroppedBuffer) {
wgpu::Buffer source = CreateBuffer(16, wgpu::BufferUsage::CopySrc);
wgpu::Buffer destination = CreateBuffer(16, wgpu::BufferUsage::CopyDst);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(source, 0, destination, 0, 0);
wgpu::CommandBuffer commandBuffer = encoder.Finish();
source = nullptr;
destination = nullptr;
device.GetQueue().Submit(1, &commandBuffer);
}
// Test B2B copies with OOB
TEST_F(CopyCommandTest_B2B, OutOfBounds) {
wgpu::Buffer source = CreateBuffer(16, wgpu::BufferUsage::CopySrc);