From c56553ae3dc1dffeafb5ba1b5cb10091201d02b7 Mon Sep 17 00:00:00 2001 From: Oliver Dawes Date: Tue, 6 Feb 2024 17:43:43 +0000 Subject: [PATCH] Initialize QRhiD3D12::activeAdapter for imported device path This commit makes it so the QRhiD3D12::activeAdapter is set when using an imported device. QD3D12MemoryAllocator::create would crash before as it would attempt to call IDXGIAdapter1::GetDesc1 on the passed uninitalized pointer. With this change using an imported device with the d3d12 rhi backend will no longer crash the application. Fixes: QTBUG-122007 Pick-to: 6.6 Change-Id: Iadc67fee0c7ee70ac904f66a523acd3b1a63e42b Reviewed-by: Laszlo Agocs (cherry picked from commit 95c20ffac3473f9188df363aebcb911589645806) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhid3d12.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 745e55d76e8..9fa5d345028 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -292,14 +292,20 @@ bool QRhiD3D12::create(QRhi::Flags flags) for (int adapterIndex = 0; dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) { DXGI_ADAPTER_DESC1 desc; adapter->GetDesc1(&desc); - adapter->Release(); if (desc.AdapterLuid.LowPart == adapterLuid.LowPart && desc.AdapterLuid.HighPart == adapterLuid.HighPart) { + activeAdapter = adapter; QRhiD3D::fillDriverInfo(&driverInfoStruct, desc); break; + } else { + adapter->Release(); } } + if (!activeAdapter) { + qWarning("No adapter"); + return false; + } qCDebug(QRHI_LOG_INFO, "Using imported device %p", dev); }