From 263bb4dd30346c0657f187069e64e04c4b4d56df Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 May 2020 20:41:14 +0200 Subject: Please the broken Win 7 CI by forcing OpenGL over D3D Not very interesting because Windows 7 is not supported in Qt 6, but as long as the CI for it is around, let's try to keep it functional. Task-number: QTBUG-84067 Change-Id: Ifae65355466ae6d372169974e6034b370b0e1328 Reviewed-by: Eirik Aavitsland --- src/quick/scenegraph/qsgrhisupport.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 2a49a0958d..c523bff702 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -51,6 +51,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE #if QT_CONFIG(vulkan) @@ -181,6 +183,14 @@ void QSGRhiSupport::applySettings() if (!m_enableRhi) return; + adjustToPlatformQuirks(); + + // At this point the RHI backend is fixed, it cannot be changed once we + // return from this function. This is because things like the QWindow + // (QQuickWindow) may depend on the graphics API as well (surfaceType + // f.ex.), and all that is based on what we report from here. So further + // adjustments are not possible (or, at minimum, not safe and portable). + // validation layers (Vulkan) or debug layer (D3D) m_debugLayer = uint(qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER")); @@ -203,6 +213,21 @@ void QSGRhiSupport::applySettings() qCDebug(QSG_LOG_INFO, "Prioritizing software renderers"); } +void QSGRhiSupport::adjustToPlatformQuirks() +{ +#if defined(Q_OS_WIN) + // Temporary Windows 7 workaround: no D3D. Just stick with OpenGL like Qt 5 + // would. Can be removed when Win 7 support is finally dropped from Qt 6. + // (but as long as we have a Win 7 CI, this is mandatory) + if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) { + if (m_rhiBackend == QRhi::D3D11) { + qCDebug(QSG_LOG_INFO, "D3D on Windows 7 is not supported. Trying OpenGL instead."); + m_rhiBackend = QRhi::OpenGLES2; + } + } +#endif +} + QSGRhiSupport *QSGRhiSupport::staticInst() { static QSGRhiSupport inst; -- cgit v1.2.3