Implement new formula for requiredBytesInCopy

Changed upstream in:
- https://github.com/gpuweb/gpuweb/pull/1014
- https://github.com/gpuweb/gpuweb/pull/1130

Note that in some of the cases where width==0 || height==0 || depth==0,
this increases the number of linear data bytes required for a copy.
Since this is a corner case, no deprecation logic is added.

Removes a duplicated copy of this logic in TestUtils.cpp.

Bug: dawn:520
Change-Id: I3b3d079c6ef316df7d95ba5c349bf8de4646fa4d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30741
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Kai Ninomiya
2020-10-23 21:21:33 +00:00
committed by Commit Bot service account
parent ca5aa235da
commit c9d0b492d5
10 changed files with 157 additions and 87 deletions

View File

@@ -923,6 +923,34 @@ TEST_F(CopyCommandTest_T2B, Success) {
}
}
// Edge cases around requiredBytesInCopy computation for empty copies
TEST_F(CopyCommandTest_T2B, Empty) {
wgpu::Texture source =
Create2DTexture(16, 16, 1, 2, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureUsage::CopySrc);
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(0, wgpu::BufferUsage::CopyDst), 0, 256, 4, {0, 0, 0});
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(0, wgpu::BufferUsage::CopyDst), 0, 256, 4, {4, 0, 0});
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(0, wgpu::BufferUsage::CopyDst), 0, 256, 4, {4, 4, 0});
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(1024, wgpu::BufferUsage::CopyDst), 0, 256, 4, {4, 0, 2});
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0},
CreateBuffer(1023, wgpu::BufferUsage::CopyDst), 0, 256, 4, {4, 0, 2});
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(1792, wgpu::BufferUsage::CopyDst), 0, 256, 4, {0, 4, 2});
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0},
CreateBuffer(1791, wgpu::BufferUsage::CopyDst), 0, 256, 4, {0, 4, 2});
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0},
CreateBuffer(1024, wgpu::BufferUsage::CopyDst), 0, 256, 4, {0, 0, 2});
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0},
CreateBuffer(1023, wgpu::BufferUsage::CopyDst), 0, 256, 4, {0, 0, 2});
}
// Test OOB conditions on the texture
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);