D3D12: Fix crash from non-initialized adapter.

If the Adapter failed to create a D3D device, it would
attempt to access it on destruction causing the
process to crash.

Bug: dawn:460
Change-Id: I3f13043e8049cd71806ee54efa92c70e26561580
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61300
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
This commit is contained in:
Bryan Bernhart 2021-08-09 17:46:03 +00:00 committed by Dawn LUCI CQ
parent 167f67f3cb
commit c61a24b5fd
1 changed files with 5 additions and 0 deletions

View File

@ -193,6 +193,11 @@ namespace dawn_native { namespace d3d12 {
return;
}
// The device may not exist if this adapter failed to initialize.
if (mD3d12Device == nullptr) {
return;
}
// If the debug layer is not installed, return immediately to avoid crashing the process.
ComPtr<ID3D12InfoQueue> infoQueue;
if (FAILED(mD3d12Device.As(&infoQueue))) {