From 3249ad6deff70eadf998faaac04bd2be5b6674f6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 24 Apr 2020 17:30:56 +0200 Subject: Make no-opengl builds succeed with Vulkan or Metal Amends c83ca003248a21e368ebfbf799ef9580e0f4e6ac. In Qt 5.x we do not support using Qt Quick with the QRhi-based rendering path in -no-opengl builds. (such builds default to the software backend in fact) This is due to structural difficulties, such as QSGDefaultRenderContext (the .cpp) being tied to direct OpenGL. This will only get solved properly in Qt 6 when the direct OpenGL code path gets removed. However, compilation should not break in -no-opengl builds, regardless of which other conditions (QT_CONFIG(vulkan), Q_OS_MACOS, etc.) evaluate to true. The original patch missed the case when we have Vulkan enabled or we are on macOS or iOS (which implies enabling the Metal code path). This is now corrected by extending the scope of the condition. Change-Id: I0e87d8b033aed8fdfaca826bcd32596a532380a7 Reviewed-by: Volker Hilsheimer Reviewed-by: Inho Lee --- src/quick/scenegraph/qsgrhisupport.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 2bf70ddec6..f25bbe2d26 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -389,12 +389,13 @@ static const void *qsgrhi_mtl_rifResource(QSGRendererInterface::Resource res, co const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, const QSGDefaultRenderContext *rc) { +// ### This condition is a temporary workaround to allow compilation +// with -no-opengl, but Vulkan or Metal enabled, to succeed. Full +// support for RHI-capable -no-opengl builds will be available in +// Qt 6 once the direct OpenGL code path gets removed. #if QT_CONFIG(opengl) + QRhi *rhi = rc->rhi(); -#else - Q_UNUSED(rc) - QRhi *rhi = nullptr; -#endif if (res == QSGRendererInterface::RhiResource || !rhi) return rhi; @@ -431,6 +432,12 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, default: return nullptr; } + +#else + Q_UNUSED(res); + Q_UNUSED(rc); + return nullptr; +#endif } int QSGRhiSupport::chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi) -- cgit v1.2.3