From 35dd681f2ba00e7196e59309d76f920ad8807205 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 25 Mar 2025 10:42:44 +0100 Subject: [PATCH] rhi: d3d11: Add activeAdapter null check ...to match 6.8 that has this added as part of a backport. The D3D12 backend has this already. Still, move the resetting of the variable to the outer scope in that one too, to cover both code paths. Pick-to: 6.9 Change-Id: Ie4ba22ff9f2a2f6882dd2d5e3063c4e6701fa95c Reviewed-by: Andy Nichols --- src/gui/rhi/qrhid3d11.cpp | 7 ++++++- src/gui/rhi/qrhid3d12.cpp | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index b79a1b9b8a9..912ebb06f04 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -240,6 +240,8 @@ bool QRhiD3D11::create(QRhi::Flags flags) if (maxFrameLatency == 0) qCDebug(QRHI_LOG_INFO, "Disabling FRAME_LATENCY_WAITABLE_OBJECT usage"); + activeAdapter = nullptr; + if (!importedDeviceAndContext) { IDXGIAdapter1 *adapter; int requestedAdapterIndex = -1; @@ -276,7 +278,6 @@ bool QRhiD3D11::create(QRhi::Flags flags) } } - activeAdapter = nullptr; for (int adapterIndex = 0; dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) { DXGI_ADAPTER_DESC1 desc; adapter->GetDesc1(&desc); @@ -394,6 +395,10 @@ bool QRhiD3D11::create(QRhi::Flags flags) } dxgiDev->Release(); } + if (!activeAdapter) { + qWarning("Failed to query adapter from imported device"); + return false; + } qCDebug(QRHI_LOG_INFO, "Using imported device %p", dev); } diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index d605693bad8..3d9ec3d43ec 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -249,6 +249,8 @@ bool QRhiD3D12::create(QRhi::Flags flags) } } + activeAdapter = nullptr; + if (!importedDevice) { IDXGIAdapter1 *adapter; int requestedAdapterIndex = -1; @@ -285,7 +287,6 @@ bool QRhiD3D12::create(QRhi::Flags flags) } } - activeAdapter = nullptr; for (int adapterIndex = 0; dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) { DXGI_ADAPTER_DESC1 desc; adapter->GetDesc1(&desc);