D3D12: Prevent crash due to missing debug layer
Destroying the adapter without the debug layer installed
would crash the process upon access of the debug filters.
Bug: dawn:460
Change-Id: I04819c5136af780fd3b981857bd87d69d4abc9c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45560
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/d3d12/AdapterD3D12.cpp b/src/dawn_native/d3d12/AdapterD3D12.cpp
index 0fe3714..1455d12 100644
--- a/src/dawn_native/d3d12/AdapterD3D12.cpp
+++ b/src/dawn_native/d3d12/AdapterD3D12.cpp
@@ -191,8 +191,13 @@
if (!GetInstance()->IsBackendValidationEnabled()) {
return;
}
+
+ // If the debug layer is not installed, return immediately to avoid crashing the process.
ComPtr<ID3D12InfoQueue> infoQueue;
- ASSERT_SUCCESS(mD3d12Device.As(&infoQueue));
+ if (FAILED(mD3d12Device.As(&infoQueue))) {
+ return;
+ }
+
infoQueue->PopRetrievalFilter();
infoQueue->PopStorageFilter();
}