diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-07 21:10:26 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-11 08:43:01 +0200 |
commit | fb7bf5343a0329459c40fb0dd84ca268e7681226 (patch) | |
tree | e6084315db92688ac088aa8379c338fa27d7db8d /src/quick/scenegraph/qsgrhisupport.cpp | |
parent | 263bb4dd30346c0657f187069e64e04c4b4d56df (diff) |
Pre-check for Metal support to please our CI VMs
An attempt to have a temporary solution for not having Metal support in
the CI VMs. In order to run graphical Qt Quick autotests, we need to
decide upfront if we want to go with Metal or try something else.
Leaving the decision to the point of initializing the scenegraph (and
so creating the QRhi instance) is not acceptable as that is way too
late.
If this works out, we can add a private helper in gui that does a more
lightweight check directly via the Metal APIs. But for now, just create
a QRhi temporarily.
For qtbase autotests (like tst_qrhi) the problem does not apply because
those simply go through all QRhi backends and exercise all that succeed
to initialize, skipping the failing ones. But a real application, and so
Qt Quick, does not work like that.
Task-number: QTBUG-84067
Change-Id: I52f31871eb72c8d57bc604391963f0d022a3321c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index c523bff702..fe3b626077 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -225,6 +225,24 @@ void QSGRhiSupport::adjustToPlatformQuirks() m_rhiBackend = QRhi::OpenGLES2; } } +#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS) + + // ### For now just create a throwaway QRhi instance. This will be replaced + // by a more lightweight way, once a helper function is added gui/rhi. + + // A macOS VM may not have Metal support at all. We have to decide at this + // point, it will be too late afterwards, and the only way is to see if + // MTLCreateSystemDefaultDevice succeeds. + if (m_rhiBackend == QRhi::Metal) { + QRhiMetalInitParams rhiParams; + QRhi *tempRhi = QRhi::create(m_rhiBackend, &rhiParams, {}); + if (!tempRhi) { + m_rhiBackend = QRhi::OpenGLES2; + qCDebug(QSG_LOG_INFO, "Metal does not seem to be supported. Falling back to OpenGL."); + } else { + delete tempRhi; + } + } #endif } |