aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgrhisupport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp18
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
}