mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Adding validation for requiredBytesInCopy overflow
Also some uint32_t computations are now done on uint64_t. Bug: dawn:482 Change-Id: Ia0094e16999ec3a9fec193f27760e73cd14d289c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26540 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Tomek Ponitka <tommek@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
cbec3179ef
commit
11c0f579b1
@@ -793,6 +793,20 @@ TEST_F(CopyCommandTest_B2T, CopyToStencilAspect) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that CopyB2T throws an error when requiredBytesInCopy overflows uint64_t
|
||||
TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) {
|
||||
wgpu::Buffer source = CreateBuffer(10000, wgpu::BufferUsage::CopySrc);
|
||||
wgpu::Texture destination =
|
||||
Create2DTexture(1, 1, 1, 16, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureUsage::CopyDst);
|
||||
|
||||
// Success
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, (1 << 31), (1 << 31), destination, 0,
|
||||
{0, 0, 0}, {1, 1, 1});
|
||||
// Failure because bytesPerImage * (depth - 1) overflows
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, (1 << 31), (1 << 31), destination, 0,
|
||||
{0, 0, 0}, {1, 1, 16});
|
||||
}
|
||||
|
||||
class CopyCommandTest_T2B : public CopyCommandTest {};
|
||||
|
||||
// Test a successfull T2B copy
|
||||
@@ -1227,6 +1241,20 @@ TEST_F(CopyCommandTest_T2B, CopyFromStencilAspect) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that CopyT2B throws an error when requiredBytesInCopy overflows uint64_t
|
||||
TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) {
|
||||
wgpu::Buffer destination = CreateBuffer(10000, wgpu::BufferUsage::CopyDst);
|
||||
wgpu::Texture source =
|
||||
Create2DTexture(1, 1, 1, 16, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureUsage::CopySrc);
|
||||
|
||||
// Success
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, (1 << 31),
|
||||
(1 << 31), {1, 1, 1});
|
||||
// Failure because bytesPerImage * (depth - 1) overflows
|
||||
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, (1 << 31),
|
||||
(1 << 31), {1, 1, 16});
|
||||
}
|
||||
|
||||
class CopyCommandTest_T2T : public CopyCommandTest {};
|
||||
|
||||
TEST_F(CopyCommandTest_T2T, Success) {
|
||||
|
||||
@@ -334,6 +334,18 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that WriteTexture throws an error when requiredBytesInCopy overflows uint64_t
|
||||
TEST_F(QueueWriteTextureValidationTest, RequiredBytesInCopyOverflow) {
|
||||
wgpu::Texture destination = Create2DTexture({1, 1, 16}, 1, wgpu::TextureFormat::RGBA8Unorm,
|
||||
wgpu::TextureUsage::CopyDst);
|
||||
|
||||
// success because depth = 1.
|
||||
TestWriteTexture(10000, 0, (1 << 31), (1 << 31), destination, 0, {0, 0, 0}, {1, 1, 1});
|
||||
// failure because bytesPerImage * (depth - 1) overflows.
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(10000, 0, (1 << 31), (1 << 31), destination, 0,
|
||||
{0, 0, 0}, {1, 1, 16}));
|
||||
}
|
||||
|
||||
// Regression tests for a bug in the computation of texture data size in Dawn.
|
||||
TEST_F(QueueWriteTextureValidationTest, TextureWriteDataSizeLastRowComputation) {
|
||||
constexpr uint32_t kBytesPerRow = 256;
|
||||
|
||||
Reference in New Issue
Block a user