diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp index fd3502d343..628b48e941 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.cpp +++ b/src/dawn_native/d3d12/DeviceD3D12.cpp @@ -288,13 +288,21 @@ namespace dawn_native { namespace d3d12 { } ResultOrError Device::CheckAndUpdateCompletedSerials() { - ExecutionSerial completeSerial = ExecutionSerial(mFence->GetCompletedValue()); + ExecutionSerial completedSerial = ExecutionSerial(mFence->GetCompletedValue()); + if (DAWN_UNLIKELY(completedSerial == ExecutionSerial(UINT64_MAX))) { + // GetCompletedValue returns UINT64_MAX if the device was removed. + // Try to query the failure reason. + DAWN_TRY(CheckHRESULT(mD3d12Device->GetDeviceRemovedReason(), + "ID3D12Device::GetDeviceRemovedReason")); + // Otherwise, return a generic device lost error. + return DAWN_DEVICE_LOST_ERROR("Device lost"); + } - if (completeSerial <= GetCompletedCommandSerial()) { + if (completedSerial <= GetCompletedCommandSerial()) { return ExecutionSerial(0); } - return completeSerial; + return completedSerial; } void Device::ReferenceUntilUnused(ComPtr object) {