From 80d12e3e88c6d58b00e0828b3cd9fb7489b6e7ba Mon Sep 17 00:00:00 2001 From: Filippo Tarpini Date: Thu, 8 Jun 2023 02:46:08 +0300 Subject: [PATCH] Video: Fix crash when getting the AA modes DX12 would often crash when starting and stopping the emulation many times, due to the device enumerator failing for some reason. Checking for success fixes it. --- Source/Core/VideoBackends/D3D12/DX12Context.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/D3D12/DX12Context.cpp b/Source/Core/VideoBackends/D3D12/DX12Context.cpp index 19a13f64b4..7b33ffe8d9 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Context.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Context.cpp @@ -48,7 +48,10 @@ std::vector DXContext::GetAAModes(u32 adapter_index) return {}; ComPtr adapter; - temp_dxgi_factory->EnumAdapters(adapter_index, &adapter); + HRESULT hr = temp_dxgi_factory->EnumAdapters(adapter_index, &adapter); + + if (!SUCCEEDED(hr)) + return {}; PFN_D3D12_CREATE_DEVICE d3d12_create_device; if (!temp_lib.Open("d3d12.dll") || @@ -57,8 +60,7 @@ std::vector DXContext::GetAAModes(u32 adapter_index) return {}; } - HRESULT hr = - d3d12_create_device(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&temp_device)); + hr = d3d12_create_device(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&temp_device)); if (!SUCCEEDED(hr)) return {}; }