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>
This commit is contained in:
Laszlo Agocs 2023-03-17 12:07:40 +01:00
parent 11df026ea1
commit d7f795626d

View File

@ -85,6 +85,12 @@ bool QBackingStoreRhiSupport::create()
QRhiD3D11InitParams params;
params.enableDebugLayer = m_config.isDebugLayerEnabled();
rhi = QRhi::create(QRhi::D3D11, &params, 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, &params, flags);
}
} else if (m_config.api() == QPlatformBackingStoreRhiConfig::D3D12) {
QRhiD3D12InitParams params;
params.enableDebugLayer = m_config.isDebugLayerEnabled();