Buffer: Disallow unmapping when unmapped.
This is to match the upstream WebGPU spec. Bug: dawn:445 Change-Id: I4246487247fdba8d90a119c1970d6d4df3235835 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29361 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
3066cd3387
commit
c1cce0c57d
|
@ -492,10 +492,7 @@ namespace dawn_native {
|
|||
// even if it did not have a mappable usage.
|
||||
return {};
|
||||
case BufferState::Unmapped:
|
||||
if ((mUsage & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) == 0) {
|
||||
return DAWN_VALIDATION_ERROR("Buffer does not have map usage");
|
||||
}
|
||||
return {};
|
||||
return DAWN_VALIDATION_ERROR("Buffer is unmapped");
|
||||
case BufferState::Destroyed:
|
||||
return DAWN_VALIDATION_ERROR("Buffer is destroyed");
|
||||
}
|
||||
|
|
|
@ -604,21 +604,21 @@ TEST_F(BufferValidationTest, UnmapWithoutMapUsage) {
|
|||
TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
|
||||
{
|
||||
wgpu::Buffer buf = CreateMapReadBuffer(4);
|
||||
// Buffer starts unmapped. Unmap should succeed.
|
||||
buf.Unmap();
|
||||
// Buffer starts unmapped. Unmap should fail.
|
||||
ASSERT_DEVICE_ERROR(buf.Unmap());
|
||||
buf.MapAsync(wgpu::MapMode::Read, 0, 4, nullptr, nullptr);
|
||||
buf.Unmap();
|
||||
// Unmapping twice should succeed
|
||||
buf.Unmap();
|
||||
// Unmapping a second time should fail.
|
||||
ASSERT_DEVICE_ERROR(buf.Unmap());
|
||||
}
|
||||
{
|
||||
wgpu::Buffer buf = CreateMapWriteBuffer(4);
|
||||
// Buffer starts unmapped. Unmap should succeed.
|
||||
buf.Unmap();
|
||||
// Buffer starts unmapped. Unmap should fail.
|
||||
ASSERT_DEVICE_ERROR(buf.Unmap());
|
||||
buf.MapAsync(wgpu::MapMode::Write, 0, 4, nullptr, nullptr);
|
||||
// Unmapping twice should succeed
|
||||
buf.Unmap();
|
||||
buf.Unmap();
|
||||
// Unmapping a second time should fail.
|
||||
ASSERT_DEVICE_ERROR(buf.Unmap());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue