diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 9ec821e040..3b2b750ffc 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp @@ -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"); } diff --git a/src/tests/unittests/validation/BufferValidationTests.cpp b/src/tests/unittests/validation/BufferValidationTests.cpp index 1c93b07ad9..d0179d699e 100644 --- a/src/tests/unittests/validation/BufferValidationTests.cpp +++ b/src/tests/unittests/validation/BufferValidationTests.cpp @@ -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()); } }