diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp index 6cbcb4022a..a110a5fd38 100644 --- a/src/dawn/native/Buffer.cpp +++ b/src/dawn/native/Buffer.cpp @@ -131,11 +131,9 @@ MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* "Buffer is mapped at creation but its size (%u) is not a multiple of 4.", descriptor->size); - if (descriptor->size > device->GetLimits().v1.maxBufferSize) { - DAWN_TRY(DAWN_MAKE_DEPRECATION_ERROR( - device, "Buffer size (%u) exceeds the max buffer size limit (%u).", descriptor->size, - device->GetLimits().v1.maxBufferSize)); - } + DAWN_INVALID_IF(descriptor->size > device->GetLimits().v1.maxBufferSize, + "Buffer size (%u) exceeds the max buffer size limit (%u).", descriptor->size, + device->GetLimits().v1.maxBufferSize); return {}; } diff --git a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp index 09f07b50e0..0dead5225b 100644 --- a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp @@ -96,6 +96,29 @@ TEST_F(BufferValidationTest, CreationSuccess) { } } +// Test case where creation should succeed +TEST_F(BufferValidationTest, CreationMaxBufferSize) { + // Success when at limit + { + wgpu::BufferDescriptor descriptor; + descriptor.size = GetSupportedLimits().limits.maxBufferSize; + descriptor.usage = wgpu::BufferUsage::Uniform; + + device.CreateBuffer(&descriptor); + } + // Error once it is pass the (default) limit on the device. (Note that MaxLimitTests tests at + // max possible limit given the adapters.) + { + wgpu::BufferDescriptor descriptor; + ASSERT_TRUE(GetSupportedLimits().limits.maxBufferSize < + std::numeric_limits::max()); + descriptor.size = GetSupportedLimits().limits.maxBufferSize + 1; + descriptor.usage = wgpu::BufferUsage::Uniform; + + ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor)); + } +} + // Test restriction on usages must not be None (0) TEST_F(BufferValidationTest, CreationMapUsageNotZero) { // Zero (None) usage is an error diff --git a/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp b/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp index 029144d998..e283c14361 100644 --- a/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp +++ b/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp @@ -120,22 +120,6 @@ TEST_P(DeprecationTests, Dispatch) { pass.End(); } -// Test that creating a buffer with size exceeding the maximum buffer size limit should emits a -// warning. (dawn:1525) -TEST_P(DeprecationTests, MaxBufferSizeValidation) { - wgpu::BufferDescriptor descriptor; - descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; - - descriptor.size = 256; - device.CreateBuffer(&descriptor); - - descriptor.size = GetSupportedLimits().limits.maxBufferSize; - device.CreateBuffer(&descriptor); - - descriptor.size = GetSupportedLimits().limits.maxBufferSize + 1; - EXPECT_DEPRECATION_ERROR_OR_WARNING(device.CreateBuffer(&descriptor)); -} - INSTANTIATE_TEST_SUITE_P(DeprecatedAPITest, DeprecationTests, testing::Values(true, false),