mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Change rowsPerImage units from texels to blocks
Spec change: https://github.com/gpuweb/gpuweb/pull/958 Bug: dawn:520 Change-Id: I05c4792a2832d12cd68877f2b1b99cdf9ef26925 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29981 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
51af1b428f
commit
d1bca09f4a
@@ -1833,27 +1833,31 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, BytesPerRow) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests to verify that rowsPerImage must be a multiple of the compressed texture block height in
|
||||
// buffer-to-texture or texture-to-buffer copies with compressed texture formats.
|
||||
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageHeight) {
|
||||
// rowsPerImage must be >= heightInBlocks.
|
||||
TEST_F(CopyCommandTest_CompressedTextureFormats, RowsPerImage) {
|
||||
wgpu::Buffer buffer =
|
||||
CreateBuffer(512, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
|
||||
CreateBuffer(1024, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
|
||||
|
||||
for (wgpu::TextureFormat bcFormat : utils::kBCFormats) {
|
||||
wgpu::Texture texture = Create2DTexture(bcFormat);
|
||||
|
||||
// Valid usages of rowsPerImage in B2T and T2B copies with compressed texture formats.
|
||||
{
|
||||
constexpr uint32_t kValidImageHeight = 8;
|
||||
TestBothTBCopies(utils::Expectation::Success, buffer, 0, 256, kValidImageHeight,
|
||||
texture, 0, {0, 0, 0}, {4, 4, 1});
|
||||
constexpr uint32_t kValidRowsPerImage = 5;
|
||||
TestBothTBCopies(utils::Expectation::Success, buffer, 0, 256, kValidRowsPerImage,
|
||||
texture, 0, {0, 0, 0}, {4, 16, 1});
|
||||
}
|
||||
{
|
||||
constexpr uint32_t kValidRowsPerImage = 4;
|
||||
TestBothTBCopies(utils::Expectation::Success, buffer, 0, 256, kValidRowsPerImage,
|
||||
texture, 0, {0, 0, 0}, {4, 16, 1});
|
||||
}
|
||||
|
||||
// Failures on invalid rowsPerImage.
|
||||
// rowsPerImage is smaller than height.
|
||||
{
|
||||
constexpr uint32_t kInvalidImageHeight = 3;
|
||||
TestBothTBCopies(utils::Expectation::Failure, buffer, 0, 256, kInvalidImageHeight,
|
||||
texture, 0, {0, 0, 0}, {4, 4, 1});
|
||||
constexpr uint32_t kInvalidRowsPerImage = 3;
|
||||
TestBothTBCopies(utils::Expectation::Failure, buffer, 0, 256, kInvalidRowsPerImage,
|
||||
texture, 0, {0, 0, 0}, {4, 20, 1});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1996,31 +2000,15 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, CopyToMultipleArrayLayers) {
|
||||
12, 16, 1, 20, bcFormat, wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc);
|
||||
|
||||
// Copy to all array layers
|
||||
TestBothTBCopiesExactBufferSize(256, 16, texture, bcFormat, {0, 0, 0}, {12, 16, 20});
|
||||
TestBothTBCopiesExactBufferSize(256, 4, texture, bcFormat, {0, 0, 0}, {12, 16, 20});
|
||||
|
||||
// Copy to the highest array layer
|
||||
TestBothTBCopiesExactBufferSize(256, 16, texture, bcFormat, {0, 0, 19}, {12, 16, 1});
|
||||
TestBothTBCopiesExactBufferSize(256, 4, texture, bcFormat, {0, 0, 19}, {12, 16, 1});
|
||||
|
||||
// Copy to array layers in the middle
|
||||
TestBothTBCopiesExactBufferSize(256, 16, texture, bcFormat, {0, 0, 1}, {12, 16, 18});
|
||||
TestBothTBCopiesExactBufferSize(256, 4, texture, bcFormat, {0, 0, 1}, {12, 16, 18});
|
||||
|
||||
// Copy touching the texture corners with a non-packed rowsPerImage
|
||||
TestBothTBCopiesExactBufferSize(256, 24, texture, bcFormat, {4, 4, 4}, {8, 12, 16});
|
||||
|
||||
// rowsPerImage needs to be a multiple of blockHeight
|
||||
{
|
||||
wgpu::Buffer source =
|
||||
CreateBuffer(8192, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
|
||||
TestBothTBCopies(utils::Expectation::Failure, source, 0, 256, 6, texture, 0, {0, 0, 0},
|
||||
{4, 4, 1});
|
||||
}
|
||||
|
||||
// rowsPerImage must be a multiple of blockHeight even with an empty copy
|
||||
{
|
||||
wgpu::Buffer source =
|
||||
CreateBuffer(0, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
|
||||
TestBothTBCopies(utils::Expectation::Failure, source, 0, 256, 2, texture, 0, {0, 0, 0},
|
||||
{0, 0, 0});
|
||||
}
|
||||
TestBothTBCopiesExactBufferSize(256, 6, texture, bcFormat, {4, 4, 4}, {8, 12, 16});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,28 +619,28 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests to verify that rowsPerImage must be a multiple of the compressed texture block height
|
||||
// rowsPerImage must be >= heightInBlocks.
|
||||
TEST_F(WriteTextureTest_CompressedTextureFormats, RowsPerImage) {
|
||||
for (wgpu::TextureFormat bcFormat : utils::kBCFormats) {
|
||||
wgpu::Texture texture = Create2DTexture(bcFormat);
|
||||
|
||||
// Valid usages of rowsPerImage in WriteTexture with compressed texture formats.
|
||||
{
|
||||
constexpr uint32_t kValidRowsPerImage = 8;
|
||||
TestWriteTexture(512, 0, 256, kValidRowsPerImage, texture, 0, {0, 0, 0}, {4, 4, 1});
|
||||
constexpr uint32_t kValidRowsPerImage = 5;
|
||||
TestWriteTexture(1024, 0, 256, kValidRowsPerImage, texture, 0, {0, 0, 0},
|
||||
{4, 16, 1});
|
||||
}
|
||||
|
||||
// 4 is the exact limit for rowsPerImage here.
|
||||
{
|
||||
constexpr uint32_t kValidRowsPerImage = 4;
|
||||
TestWriteTexture(512, 0, 256, kValidRowsPerImage, texture, 0, {0, 0, 0}, {4, 4, 1});
|
||||
TestWriteTexture(1024, 0, 256, kValidRowsPerImage, texture, 0, {0, 0, 0},
|
||||
{4, 16, 1});
|
||||
}
|
||||
|
||||
// Failure on invalid rowsPerImage.
|
||||
{
|
||||
constexpr uint32_t kInvalidRowsPerImage = 2;
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(512, 0, 256, kInvalidRowsPerImage, texture, 0,
|
||||
{0, 0, 0}, {4, 4, 1}));
|
||||
constexpr uint32_t kInvalidRowsPerImage = 3;
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(1024, 0, 256, kInvalidRowsPerImage, texture, 0,
|
||||
{0, 0, 0}, {4, 16, 1}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -731,23 +731,16 @@ namespace {
|
||||
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc);
|
||||
|
||||
// Write to all array layers
|
||||
TestWriteTextureExactDataSize(256, 16, texture, bcFormat, {0, 0, 0}, {12, 16, 20});
|
||||
TestWriteTextureExactDataSize(256, 4, texture, bcFormat, {0, 0, 0}, {12, 16, 20});
|
||||
|
||||
// Write to the highest array layer
|
||||
TestWriteTextureExactDataSize(256, 16, texture, bcFormat, {0, 0, 19}, {12, 16, 1});
|
||||
TestWriteTextureExactDataSize(256, 4, texture, bcFormat, {0, 0, 19}, {12, 16, 1});
|
||||
|
||||
// Write to array layers in the middle
|
||||
TestWriteTextureExactDataSize(256, 16, texture, bcFormat, {0, 0, 1}, {12, 16, 18});
|
||||
TestWriteTextureExactDataSize(256, 4, texture, bcFormat, {0, 0, 1}, {12, 16, 18});
|
||||
|
||||
// Write touching the texture corners with a non-packed rowsPerImage
|
||||
TestWriteTextureExactDataSize(256, 24, texture, bcFormat, {4, 4, 4}, {8, 12, 16});
|
||||
|
||||
// rowsPerImage needs to be a multiple of blockHeight
|
||||
ASSERT_DEVICE_ERROR(
|
||||
TestWriteTexture(8192, 0, 256, 6, texture, 0, {0, 0, 0}, {4, 4, 1}));
|
||||
|
||||
// rowsPerImage must be a multiple of blockHeight even with an empty write
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(0, 0, 256, 2, texture, 0, {0, 0, 0}, {0, 0, 0}));
|
||||
TestWriteTextureExactDataSize(256, 6, texture, bcFormat, {4, 4, 4}, {8, 12, 16});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user