From 2dd9ed07760d58db3f7163529af28b07c811583e Mon Sep 17 00:00:00 2001 From: Natasha Lee Date: Fri, 31 Jan 2020 19:26:49 +0000 Subject: [PATCH] Handle Device Lost for Command Encoder Finish Bug: dawn:68 Change-Id: I3449cdd9e69f3ae44a30f113fd88bd2fce2c94d7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15602 Commit-Queue: Kai Ninomiya Reviewed-by: Austin Eng Reviewed-by: Rafael Cintron Reviewed-by: Kai Ninomiya --- src/dawn_native/CommandEncoder.cpp | 1 + src/tests/end2end/DeviceLostTests.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) 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