diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index 9a84237d7d..5185d1b64e 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -763,6 +763,7 @@ namespace dawn_native { // state of the encoding context. The internal state is set to finished, and subsequent // calls to encode commands will generate errors. if (device->ConsumedError(mEncodingContext.Finish()) || + device->ConsumedError(device->ValidateIsAlive()) || (device->IsValidationEnabled() && device->ConsumedError(ValidateFinish(mEncodingContext.GetIterator(), mEncodingContext.GetPassUsages())))) { diff --git a/src/tests/end2end/DeviceLostTests.cpp b/src/tests/end2end/DeviceLostTests.cpp index c5471f11d4..103d6f4613 100644 --- a/src/tests/end2end/DeviceLostTests.cpp +++ b/src/tests/end2end/DeviceLostTests.cpp @@ -357,4 +357,13 @@ TEST_P(DeviceLostTest, SetSubDataFails) { ASSERT_DEVICE_ERROR(buffer.SetSubData(0, sizeof(float), data.data())); } +// Test that Command Encoder Finish fails when device lost +TEST_P(DeviceLostTest, CommandEncoderFinishFails) { + wgpu::CommandBuffer commands; + wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); + + SetCallbackAndLoseForTesting(); + ASSERT_DEVICE_ERROR(encoder.Finish()); +} + DAWN_INSTANTIATE_TEST(DeviceLostTest, D3D12Backend, VulkanBackend); \ No newline at end of file