From 8121b3992123678ed31560da766b64b11be1177a 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. Change-Id: Ie4ba22ff9f2a2f6882dd2d5e3063c4e6701fa95c Reviewed-by: Andy Nichols (cherry picked from commit 35dd681f2ba00e7196e59309d76f920ad8807205) Reviewed-by: Qt Cherry-pick Bot --- 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 44fff83675f..603ada99d71 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; @@ -273,7 +275,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); @@ -391,6 +392,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 24f3f792dde..8a14755c9a1 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; @@ -282,7 +284,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);