diff options
author | Mike Krus <mike.krus@kdab.com> | 2021-03-16 09:47:38 +0000 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2021-03-22 10:00:22 +0100 |
commit | 9a473a3c9b246f4895ae73d7060745b8b199a6c5 (patch) | |
tree | 0ab43b532afdea78f1f8e25223d80711d01508f2 | |
parent | a536039d102f911677e5efec03cc6f3d701aceac (diff) | |
download | qt3d-9a473a3c9b246f4895ae73d7060745b8b199a6c5.tar.gz |
Fix detection of Vulkan
When Qt is built to enable Vulkan support, it is given the path to
the Vulkan header source. This then enables the vulkan feature.
Qt3D used this feature to decide if it could use Vulkan directly or
not, however, since it is now built separately, it has no idea where
to find the headers, so QVulkanInstance is not properly defined.
This caused an issue when using official installers of Qt since
those are configured to support Vulkan.
So we now do a separate config check to find Vulkan for Qt3D.
When building Qt3D, you need to make sure if can find Vulkan (the same
way you configure Qt itself)
Pick-to: 6.1
Task-number: QTBUG-90243
Change-Id: Ia05381597b4974d7b0914706ea2f607341dccacc
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/extras/defaults/qt3dwindow.cpp | 4 | ||||
-rw-r--r-- | src/plugins/renderers/configure.cmake | 17 | ||||
-rw-r--r-- | src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp | 4 | ||||
-rw-r--r-- | src/render/configure.cmake | 10 | ||||
-rw-r--r-- | src/render/surfaces/vulkaninstance.cpp | 2 | ||||
-rw-r--r-- | src/render/surfaces/vulkaninstance_p.h | 3 | ||||
-rw-r--r-- | tests/manual/rhi/simple-rhi-cpp/main.cpp | 3 |
7 files changed, 17 insertions, 26 deletions
diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp index e233aee42..2798fab17 100644 --- a/src/extras/defaults/qt3dwindow.cpp +++ b/src/extras/defaults/qt3dwindow.cpp @@ -67,7 +67,7 @@ #include <QEvent> -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) #include <QVulkanInstance> #endif @@ -319,7 +319,7 @@ void setupWindowSurface(QWindow *window, Qt3DRender::API api) noexcept qputenv("QSG_RHI_BACKEND", "metal"); window->setSurfaceType(QSurface::MetalSurface); break; -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) case Qt3DRender::API::Vulkan: { qputenv("QSG_RHI_BACKEND", "vulkan"); diff --git a/src/plugins/renderers/configure.cmake b/src/plugins/renderers/configure.cmake index 49d8a8d04..5d2fbcde5 100644 --- a/src/plugins/renderers/configure.cmake +++ b/src/plugins/renderers/configure.cmake @@ -11,20 +11,3 @@ #### Features - -qt_feature("qt3d_opengl_renderer" PRIVATE - SECTION "Qt 3D Renderers" - LABEL "OpenGL Renderer" - PURPOSE "Build the OpenGL renderer" -) - -qt_feature("qt3d_rhi_renderer" PRIVATE - SECTION "Qt 3D Renderers" - LABEL "RHI Renderer" - PURPOSE "Build the RHI renderer" -) - -qt_configure_add_summary_section(NAME "Qt3D Renderers") -qt_configure_add_summary_entry(ARGS "qt3d_opengl_renderer") -qt_configure_add_summary_entry(ARGS "qt3d_rhi_renderer") -qt_configure_end_summary_section() # end of "Qt3D" section diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp index bfa743b77..7614b45fb 100644 --- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp +++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp @@ -89,7 +89,7 @@ #include <QtGui/private/qrhigles2_p.h> #endif -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) #include <QtGui/private/qrhivulkan_p.h> #endif #include <bitset> @@ -578,7 +578,7 @@ void SubmissionContext::initialize() QRhi::Flags rhiFlags = QRhi::EnableDebugMarkers; -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) if (requestedApi == Qt3DRender::API::Vulkan) { QRhiVulkanInitParams params; params.inst = &Qt3DRender::staticVulkanInstance(); diff --git a/src/render/configure.cmake b/src/render/configure.cmake index 35d733808..b1f604d22 100644 --- a/src/render/configure.cmake +++ b/src/render/configure.cmake @@ -6,7 +6,7 @@ #### Libraries - +find_package(Vulkan) #### Tests @@ -23,8 +23,14 @@ qt_feature("qt3d-rhi-renderer" PRIVATE SECTION "Qt 3D Renderers" LABEL "RHI Renderer" PURPOSE "Use the RHI renderer" - AUTODETECT OFF ) +qt_feature("qt3d-vulkan" PUBLIC + LABEL "Vulkan" + CONDITION Vulkan_FOUND AND QT_FEATURE_qt3d_rhi_renderer +) +qt_configure_add_summary_section(NAME "Qt 3D APIs") +qt_configure_add_summary_entry(ARGS "qt3d-vulkan") +qt_configure_end_summary_section() # end of "Qt 3D APIs" section qt_configure_add_summary_section(NAME "Qt 3D Renderers") qt_configure_add_summary_entry(ARGS "qt3d-opengl-renderer") qt_configure_add_summary_entry(ARGS "qt3d-rhi-renderer") diff --git a/src/render/surfaces/vulkaninstance.cpp b/src/render/surfaces/vulkaninstance.cpp index a8de2fce8..24b1d55fa 100644 --- a/src/render/surfaces/vulkaninstance.cpp +++ b/src/render/surfaces/vulkaninstance.cpp @@ -39,7 +39,7 @@ #include "vulkaninstance_p.h" -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) #include <QVulkanInstance> diff --git a/src/render/surfaces/vulkaninstance_p.h b/src/render/surfaces/vulkaninstance_p.h index 67f52af6a..5d6203cfd 100644 --- a/src/render/surfaces/vulkaninstance_p.h +++ b/src/render/surfaces/vulkaninstance_p.h @@ -52,11 +52,12 @@ // #include <QtGui/qtguiglobal.h> +#include <Qt3DRender/qt3drender-config.h> #include <Qt3DRender/private/qt3drender_global_p.h> QT_BEGIN_NAMESPACE -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) class QVulkanInstance; namespace Qt3DRender { Q_3DRENDERSHARED_PRIVATE_EXPORT diff --git a/tests/manual/rhi/simple-rhi-cpp/main.cpp b/tests/manual/rhi/simple-rhi-cpp/main.cpp index f839012f2..021b72ef6 100644 --- a/tests/manual/rhi/simple-rhi-cpp/main.cpp +++ b/tests/manual/rhi/simple-rhi-cpp/main.cpp @@ -95,6 +95,7 @@ #include <Qt3DRender/QMaterial> #include <Qt3DRender/QTexture> #include <qmath.h> +#include <Qt3DRender/qt3drender-config.h> static const constexpr auto vertex_shader = R"_(#version 450 @@ -247,7 +248,7 @@ int main(int argc, char* argv[]) if (argv[1] == QByteArrayLiteral("--d3d11")) api = Qt3DRender::API::DirectX; #endif -#if QT_CONFIG(vulkan) +#if QT_CONFIG(qt3d_vulkan) if (argv[1] == QByteArrayLiteral("--vulkan")) api = Qt3DRender::API::Vulkan; #endif |