Skip to content

Commit

Permalink
rhi: d3d11: Handle DXGI_ERROR_SDK_COMPONENT_MISSING gracefully
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
alpqr committed May 12, 2020
1 parent 286d79d commit 4edcf3d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gui/rhi/qrhid3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit 4edcf3d

Please sign in to comment.