From babae24a2a77708eae0a13d4c86a4f34dbdc5393 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 16 Oct 2023 22:38:00 +0000 Subject: [PATCH 1/2] add check for GZ_RENDERING_HAVE_VULKAN Signed-off-by: Ian Chen --- src/plugins/minimal_scene/MinimalScene.cc | 38 +++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 0ef8895dc..ff8882ea0 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -52,8 +51,10 @@ #include "gz/gui/Helpers.hh" #include "gz/gui/MainWindow.hh" -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) # include +# include #endif Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*) @@ -584,7 +585,8 @@ rendering::CameraPtr GzRenderer::Camera() return this->dataPtr->camera; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) ///////////////////////////////////////////////// /// \brief fillQtInstanceExtensionsToOgre /// Extract Vulkan Instance extension information to be sent to OgreNext @@ -677,7 +679,8 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rhiParams["winID"] = std::to_string(quickWindow->winId()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // externalInstance & externalDevice MUST be declared at this scope // because we save their stack addresses into this->dataPtr->rhiParams // and must be alive until rendering::engine() returns. @@ -805,7 +808,8 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) { gzdbg << "Creating gz-rendering interface for Vulkan" << std::endl; this->dataPtr->rhiParams["vulkan"] = "1"; -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) this->dataPtr->rhi = std::make_unique(); #else this->dataPtr->rhi = std::make_unique(); @@ -973,7 +977,8 @@ void RenderThread::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) // Create the render interface if (_graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // Use fallback (GPU -> CPU -> GPU) || _graphicsAPI == rendering::GraphicsAPI::VULKAN #endif @@ -982,7 +987,8 @@ void RenderThread::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) gzdbg << "Creating render thread interface for OpenGL" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating render thread interface for Vulkan" << std::endl; @@ -1013,7 +1019,8 @@ std::string RenderThread::Initialize() TextureNode::TextureNode(QQuickWindow *_window, RenderSync &_renderSync, const rendering::GraphicsAPI &_graphicsAPI, rendering::CameraPtr & -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) _camera #endif ) : @@ -1021,7 +1028,8 @@ TextureNode::TextureNode(QQuickWindow *_window, RenderSync &_renderSync, window(_window) { if (_graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // Use fallback (GPU -> CPU -> GPU) || _graphicsAPI == rendering::GraphicsAPI::VULKAN #endif @@ -1030,7 +1038,8 @@ TextureNode::TextureNode(QQuickWindow *_window, RenderSync &_renderSync, gzdbg << "Creating texture node render interface for OpenGL" << std::endl; this->rhi = std::make_unique(_window); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating texture node render interface for Vulkan" << std::endl; @@ -1137,7 +1146,8 @@ void RenderWindowItem::StopRendering() void RenderWindowItem::Ready() { if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN #endif @@ -1156,7 +1166,8 @@ void RenderWindowItem::Ready() } if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN #endif @@ -1204,7 +1215,8 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node, this->dataPtr->graphicsAPI); if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ + defined(GZ_RENDERING_HAVE_VULKAN) // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN #endif From 99a8619428cd265817b08a837b0515f57ac4d47f Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 16 Oct 2023 23:18:10 +0000 Subject: [PATCH 2/2] add include Signed-off-by: Ian Chen --- src/plugins/minimal_scene/MinimalScene.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index ff8882ea0..17c0b9417 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include