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 <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
parent
12e51f6efa
commit
c38c4d32f4
|
@ -329,17 +329,6 @@ namespace dawn_native {
|
||||||
// Handle the defaulting of size required by WebGPU, even if in webgpu_cpp.h it is not
|
// 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
|
// possible to default the function argument (because there is the callback later in the
|
||||||
// argument list)
|
// 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)) {
|
if ((size == wgpu::kWholeMapSize) && (offset <= mSize)) {
|
||||||
size = mSize - offset;
|
size = mSize - offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
DAWN_INSTANTIATE_TEST(DeprecationTests,
|
||||||
D3D12Backend(),
|
D3D12Backend(),
|
||||||
MetalBackend(),
|
MetalBackend(),
|
||||||
|
|
|
@ -219,21 +219,13 @@ TEST_F(BufferValidationTest, MapAsync_OffsetSizeOOB) {
|
||||||
// Valid case: empty range at the end of the buffer is ok.
|
// Valid case: empty range at the end of the buffer is ok.
|
||||||
{
|
{
|
||||||
wgpu::Buffer buffer = CreateMapReadBuffer(8);
|
wgpu::Buffer buffer = CreateMapReadBuffer(8);
|
||||||
// Currently using size=0 will cause a deprecation warning, and result in default size.
|
buffer.MapAsync(wgpu::MapMode::Read, 8, 0, nullptr, nullptr);
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error case, offset is larger than the buffer size (even if size is 0).
|
// Error case, offset is larger than the buffer size (even if size is 0).
|
||||||
{
|
{
|
||||||
wgpu::Buffer buffer = CreateMapReadBuffer(12);
|
wgpu::Buffer buffer = CreateMapReadBuffer(12);
|
||||||
// Currently using size=0 will cause a deprecation warning, and result in default size.
|
AssertMapAsyncError(buffer, wgpu::MapMode::Read, 16, 0);
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error case, offset + size is larger than the buffer
|
// Error case, offset + size is larger than the buffer
|
||||||
|
|
Loading…
Reference in New Issue