D3D12: Check for device lost after ID3D12Fence::GetCompletedValue

The D3D12 docs say it returns UINT64_MAX if the device was removed

Fixed: dawn:1051
Change-Id: Ide3731e9389bdb4a5a81c9f65aa9bcad1b049446
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60961
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2021-08-05 14:02:49 +00:00 committed by Dawn LUCI CQ
parent 213ac89edf
commit ae840d5e61

View File

@ -288,13 +288,21 @@ namespace dawn_native { namespace d3d12 {
}
ResultOrError<ExecutionSerial> 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<IUnknown> object) {