From 4edcf3ddb8a79095cc527d671bcbee0d318c7293 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 May 2020 20:28:27 +0200 Subject: [PATCH] rhi: d3d11: Handle DXGI_ERROR_SDK_COMPONENT_MISSING gracefully MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Requesting the debug layer is not something that succeeds at run time if the corresponding SDK component is not present. Handle it gracefully: simply retry D3D11CreateDevice without the debug device flag. Relevant also for the Qt CI's Windows 10 VMs. Task-number: QTBUG-84067 Change-Id: Ia7b2562917ec11ce04a75c052527bf526d1fe81b Reviewed-by: Christian Strømme --- src/gui/rhi/qrhid3d11.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 05ee415502..2f7974944c 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -264,6 +264,15 @@ bool QRhiD3D11::create(QRhi::Flags flags) HRESULT hr = D3D11CreateDevice(adapterToUse, D3D_DRIVER_TYPE_UNKNOWN, nullptr, devFlags, nullptr, 0, D3D11_SDK_VERSION, &dev, &featureLevel, &ctx); + // We cannot assume that D3D11_CREATE_DEVICE_DEBUG is always available. Retry without it, if needed. + if (hr == DXGI_ERROR_SDK_COMPONENT_MISSING && debugLayer) { + qCDebug(QRHI_LOG_INFO, "Debug layer was requested but is not available. " + "Attempting to create D3D11 device without it."); + devFlags &= ~D3D11_CREATE_DEVICE_DEBUG; + hr = D3D11CreateDevice(adapterToUse, D3D_DRIVER_TYPE_UNKNOWN, nullptr, devFlags, + nullptr, 0, D3D11_SDK_VERSION, + &dev, &featureLevel, &ctx); + } adapterToUse->Release(); if (FAILED(hr)) { qWarning("Failed to create D3D11 device and context: %s", qPrintable(comErrorMessage(hr)));