From c38c4d32f405c9b07dab4060f3e8ec955c4d0767 Mon Sep 17 00:00:00 2001 From: Zhaoming Jiang Date: Mon, 15 Nov 2021 08:08:35 +0000 Subject: [PATCH] Remove deprecated zero default size of buffer mapAsync In this patch the deprecated usage of size=0 as default size is removed. Using size=0 in buffer.mapAsync now result in a zero size mapping, instead of the default size. Bug: dawn:1159 Change-Id: Ie8badc5eb7440980d0df3d3d27867e710e77f44b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67743 Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya Commit-Queue: Zhaoming Jiang --- src/dawn_native/Buffer.cpp | 11 -------- src/tests/end2end/DeprecatedAPITests.cpp | 26 ------------------- .../validation/BufferValidationTests.cpp | 12 ++------- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 6e4415c908..10673207a6 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp @@ -329,17 +329,6 @@ namespace dawn_native { // Handle the defaulting of size required by WebGPU, even if in webgpu_cpp.h it is not // possible to default the function argument (because there is the callback later in the // argument list) - if (size == 0) { - // Using 0 to indicating default size is deprecated. - // Temporarily treat 0 as undefined for size, and give a warning - // TODO(dawn:1058): Remove this if block - size = wgpu::kWholeMapSize; - GetDevice()->EmitDeprecationWarning( - "Using size=0 to indicate default mapping size for mapAsync " - "is deprecated. In the future it will result in a zero-size mapping. " - "Use `undefined` (wgpu::kWholeMapSize) or just omit the parameter instead."); - } - if ((size == wgpu::kWholeMapSize) && (offset <= mSize)) { size = mSize - offset; } diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp index 097185ed54..68beae9f38 100644 --- a/src/tests/end2end/DeprecatedAPITests.cpp +++ b/src/tests/end2end/DeprecatedAPITests.cpp @@ -71,32 +71,6 @@ TEST_P(DeprecationTests, SetBufferWithZeroSizeAsDefault) { } } -// Test that using size=0 to indicate default size in mapAsync of buffer is -// deprecated. -TEST_P(DeprecationTests, BufferMapAsyncWithZeroSizeAsDefault) { - wgpu::BufferDescriptor bufferDesc; - bufferDesc.size = 128; - bufferDesc.usage = wgpu::BufferUsage::MapWrite; - - { - // Control case, use wgpu::kWholeMapSize to indicate default size. - wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc); - - buffer.MapAsync(wgpu::MapMode::Write, 0, wgpu::kWholeMapSize, nullptr, nullptr); - - WaitForAllOperations(); - } - - { - // Deprecated case, use 0 to indicate default size will cause deprecated warning. - wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc); - - EXPECT_DEPRECATION_WARNING(buffer.MapAsync(wgpu::MapMode::Write, 0, 0, nullptr, nullptr)); - - WaitForAllOperations(); - } -} - DAWN_INSTANTIATE_TEST(DeprecationTests, D3D12Backend(), MetalBackend(), diff --git a/src/tests/unittests/validation/BufferValidationTests.cpp b/src/tests/unittests/validation/BufferValidationTests.cpp index ff5b00afc9..7651b90978 100644 --- a/src/tests/unittests/validation/BufferValidationTests.cpp +++ b/src/tests/unittests/validation/BufferValidationTests.cpp @@ -219,21 +219,13 @@ TEST_F(BufferValidationTest, MapAsync_OffsetSizeOOB) { // Valid case: empty range at the end of the buffer is ok. { wgpu::Buffer buffer = CreateMapReadBuffer(8); - // Currently using size=0 will cause a deprecation warning, and result in default size. - // After the deprecation is finished, size=0 will result in a mapping with zero size - // exactly. - // TODO(dawn:1058): Remove the deprecation warning expection after the removal. - EXPECT_DEPRECATION_WARNING(buffer.MapAsync(wgpu::MapMode::Read, 8, 0, nullptr, nullptr)); + buffer.MapAsync(wgpu::MapMode::Read, 8, 0, nullptr, nullptr); } // Error case, offset is larger than the buffer size (even if size is 0). { wgpu::Buffer buffer = CreateMapReadBuffer(12); - // Currently using size=0 will cause a deprecation warning, and result in default size. - // After the deprecation is finished, size=0 will result in a mapping with zero size - // exactly. - // TODO(dawn:1058): Remove the deprecation warning expection after the removal. - EXPECT_DEPRECATION_WARNING(AssertMapAsyncError(buffer, wgpu::MapMode::Read, 16, 0)); + AssertMapAsyncError(buffer, wgpu::MapMode::Read, 16, 0); } // Error case, offset + size is larger than the buffer