diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-17 12:07:40 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-21 16:19:19 +0100 |
commit | d7f795626dc2d1691df4fa91d174654510a81ef4 (patch) | |
tree | 6ab5b0063d1aad7a5488750a5822cb0ee7682c40 | |
parent | 11df026ea199c71b1e24c36dc0a6b7468288ce98 (diff) |
rhi: widgets: Try sw adapter if D3D11 init fails
create() for D3D11 performs a smoke test with creating a vertex shader
to ensure the created graphics device is actually usable for Qt's
purposes. When this fails, create() returns false. Qt Quick
automatically retries with the PreferSoftwareRenderer flag which
causes picking up the WARP device ("Microsoft Basic Render Driver").
Synchronize this behavior to the QRhi-based backing store so that
widget apps using QQuickWidget (or anything running QT_WIDGETS_RHI=1)
get this same behavior out of the box.
Pick-to: 6.5 6.4
Change-Id: Idff795401dbed8ba465102d075808010d421d34e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/gui/painting/qbackingstorerhisupport.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/painting/qbackingstorerhisupport.cpp b/src/gui/painting/qbackingstorerhisupport.cpp index 42d5a9d505..05329d61c5 100644 --- a/src/gui/painting/qbackingstorerhisupport.cpp +++ b/src/gui/painting/qbackingstorerhisupport.cpp @@ -85,6 +85,12 @@ bool QBackingStoreRhiSupport::create() QRhiD3D11InitParams params; params.enableDebugLayer = m_config.isDebugLayerEnabled(); rhi = QRhi::create(QRhi::D3D11, ¶ms, flags); + if (!rhi && !flags.testFlag(QRhi::PreferSoftwareRenderer)) { + qCDebug(lcQpaBackingStore, "Failed to create a D3D device with default settings; " + "attempting to get a software rasterizer backed device instead"); + flags |= QRhi::PreferSoftwareRenderer; + rhi = QRhi::create(QRhi::D3D11, ¶ms, flags); + } } else if (m_config.api() == QPlatformBackingStoreRhiConfig::D3D12) { QRhiD3D12InitParams params; params.enableDebugLayer = m_config.isDebugLayerEnabled(); |