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 <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Natasha Lee 2020-01-31 19:26:49 +00:00 committed by Commit Bot service account
parent f44a809f9a
commit 2dd9ed0776
2 changed files with 10 additions and 0 deletions

View File

@ -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())))) {

View File

@ -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);