From 0103643c844905c493ca3f421c69ae3c60ee252d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 30 May 2023 16:09:56 +0000 Subject: [PATCH] Update gz-gui to use new message generation pipeline Signed-off-by: Michael Carroll --- CMakeLists.txt | 12 ++++ include/gz/gui/CMakeLists.txt | 5 +- src/CMakeLists.txt | 1 + src/plugins/CMakeLists.txt | 3 +- src/plugins/camera_tracking/CameraTracking.cc | 2 + src/plugins/minimal_scene/MinimalScene.cc | 60 ++++++++++--------- src/plugins/point_cloud/PointCloud.cc | 1 + test/integration/CMakeLists.txt | 1 + 8 files changed, 54 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b17a1996..386ae577b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,18 @@ set(GZ_RENDERING_VER ${gz-rendering8_VERSION_MAJOR}) gz_find_package(gz-msgs10 REQUIRED) set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR}) +# Get the gz-msgs installed messages and generate a library from them +gz_msgs_get_installed_messages( + MESSAGES_PATH_VARIABLE MSGS_PATH + MESSAGES_PROTOS_VARIABLE MSGS_PROTOS) + +gz_msgs_generate_messages( + TARGET gz_msgs_gen + PROTO_PACKAGE "gz.msgs" + MSGS_PATH ${MSGS_PATH} + MSGS_PROTOS ${MSGS_PROTOS}) + + # Find if command is available. This is used to enable tests. # Note that CLI files are installed regardless of whether the dependency is # available during build time diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index b3842959e..dec815c06 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -55,7 +55,6 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC gz-common${GZ_COMMON_VER}::events gz-math${GZ_MATH_VER}::gz-math${GZ_MATH_VER} - gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER} gz-plugin${GZ_PLUGIN_VER}::loader gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} ${Qt5Core_LIBRARIES} @@ -64,7 +63,9 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} ${Qt5QuickControls2_LIBRARIES} ${Qt5Widgets_LIBRARIES} TINYXML2::TINYXML2 + PRIVATE + gz_msgs_gen + ) gz_install_all_headers() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ef0d9928..d45bcdd35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,6 +51,7 @@ gz_build_tests(TYPE UNIT gz-common${GZ_COMMON_VER}::events gz-math${GZ_MATH_VER}::gz-math${GZ_MATH_VER} TINYXML2::TINYXML2 + gz_msgs_gen TEST_LIST gtest_targets ) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index ff282d6b9..8def76c13 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -76,7 +76,7 @@ function(gz_gui_add_plugin plugin_name) SOURCES ${gz_gui_add_plugin_SOURCES} QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} - PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register gz_msgs_gen ) if(gz_gui_add_plugin_TEST_SOURCES) @@ -87,6 +87,7 @@ function(gz_gui_add_plugin plugin_name) ${GZ-GUI_LIBRARIES} TINYXML2::TINYXML2 ${plugin_name} + gz_msgs_gen INCLUDE_DIRS # Used to make internal source file headers visible to the unit tests ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 17931b93d..32c18a150 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -18,6 +18,8 @@ #include #include +#include +#include #include #include diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index ab7e11d24..ee679b7ab 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -52,10 +52,16 @@ #include "gz/gui/Helpers.hh" #include "gz/gui/MainWindow.hh" -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) -# include +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && GZ_RENDERING_HAVE_VULKAN +#define GZ_GUI_HAVE_VULKAN 1 +#else +#define GZ_GUI_HAVE_VULKAN 0 #endif +#if GZ_GUI_HAVE_VULKAN +# include +#endif // GZ_GUI_HAVE_VULKAN + Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*) /// \brief Private data class for GzRenderer @@ -584,7 +590,7 @@ rendering::CameraPtr GzRenderer::Camera() return this->dataPtr->camera; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if GZ_GUI_HAVE_VULKAN ///////////////////////////////////////////////// /// \brief fillQtInstanceExtensionsToOgre /// Extract Vulkan Instance extension information to be sent to OgreNext @@ -592,7 +598,7 @@ rendering::CameraPtr GzRenderer::Camera() /// \param[out] externalInstance Data to be sent to OgreNext static void fillQtInstanceExtensionsToOgre( const QVulkanInstance *inst, - rendering::GzVulkanExternalInstance &externalInstance) + gz::rendering::GzVulkanExternalInstance &externalInstance) { { QByteArrayList extensions = inst->extensions(); @@ -657,7 +663,7 @@ static void fillQtDeviceExtensionsToOgre( extProp.extensionName[VK_MAX_EXTENSION_NAME_SIZE - 1u] = 0; } } -#endif +#endif // GZ_GUI_HAVE_VULKAN ///////////////////////////////////////////////// std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) @@ -677,7 +683,7 @@ 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 GZ_GUI_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. @@ -715,7 +721,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rhiParams["external_device"] = std::to_string(reinterpret_cast(&externalDevice)); } -#endif +#endif // GZ_GUI_HAVE_VULKAN engine = rendering::engine(this->engineName, this->dataPtr->rhiParams); } @@ -805,11 +811,11 @@ 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 GZ_GUI_HAVE_VULKAN this->dataPtr->rhi = std::make_unique(); #else this->dataPtr->rhi = std::make_unique(); -#endif +#endif // GZ_GUI_HAVE_VULKAN } #ifdef __APPLE__ else if (_graphicsAPI == rendering::GraphicsAPI::METAL) @@ -969,22 +975,22 @@ 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 GZ_GUI_HAVE_VULKAN // Use fallback (GPU -> CPU -> GPU) || _graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif +#endif // GZ_GUI_HAVE_VULKAN ) { 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 GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating render thread interface for Vulkan" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } -#endif +#endif // GZ_GUI_HAVE_VULKAN #ifdef __APPLE__ else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { @@ -1008,32 +1014,30 @@ 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) - _camera -#endif - ) : + rendering::CameraPtr &_camera) : renderSync(_renderSync), window(_window) { +#if !GZ_GUI_HAVE_VULKAN + (void) _camera; +#endif if (_graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if GZ_GUI_HAVE_VULKAN // Use fallback (GPU -> CPU -> GPU) || _graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif +#endif // GZ_GUI_HAVE_VULKAN ) { 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 GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating texture node render interface for Vulkan" << std::endl; this->rhi = std::make_unique(_window, _camera); } -#else -#endif +#endif // GZ_GUI_HAVE_VULKAN #ifdef __APPLE__ else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { @@ -1133,10 +1137,10 @@ 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 GZ_GUI_HAVE_VULKAN // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif +#endif // GZ_GUI_HAVE_VULKAN ) { this->dataPtr->renderThread->SetSurface(new QOffscreenSurface()); @@ -1152,10 +1156,10 @@ void RenderWindowItem::Ready() } if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if GZ_GUI_HAVE_VULKAN // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif +#endif // GZ_GUI_HAVE_VULKAN ) { // Move context to the render thread @@ -1200,7 +1204,7 @@ 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 GZ_GUI_HAVE_VULKAN // Use fallback (GPU -> CPU -> GPU) || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN #endif diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index f5a27cbf8..21383f0e6 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -16,6 +16,7 @@ */ #include "gz/msgs/pointcloud_packed.pb.h" +#include "gz/msgs/marker.pb.h" #include #include diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 55170ef0c..aca5196a8 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -10,4 +10,5 @@ gz_build_tests( gz-plugin${GZ_PLUGIN_VER}::loader gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} Qt5::Test + gz_msgs_gen )