Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gz-gui to use new message generation pipeline #541

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions include/gz/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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()

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/camera_tracking/CameraTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <mutex>
#include <string>

#include <gz/msgs/boolean.pb.h>
#include <gz/msgs/gui_camera.pb.h>
#include <gz/msgs/stringmsg.pb.h>

#include <gz/common/Console.hh>
Expand Down
60 changes: 32 additions & 28 deletions src/plugins/minimal_scene/MinimalScene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QVulkanInstance>
#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 <QVulkanInstance>
#endif // GZ_GUI_HAVE_VULKAN

Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*)

/// \brief Private data class for GzRenderer
Expand Down Expand Up @@ -584,15 +590,15 @@ 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
/// \param[in] inst Qt's Vulkan Instance to extract
/// \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();
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -715,7 +721,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi)
this->dataPtr->rhiParams["external_device"] =
std::to_string(reinterpret_cast<uintptr_t>(&externalDevice));
}
#endif
#endif // GZ_GUI_HAVE_VULKAN

engine = rendering::engine(this->engineName, this->dataPtr->rhiParams);
}
Expand Down Expand Up @@ -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<GzCameraTextureRhiVulkan>();
#else
this->dataPtr->rhi = std::make_unique<GzCameraTextureRhiOpenGL>();
#endif
#endif // GZ_GUI_HAVE_VULKAN
}
#ifdef __APPLE__
else if (_graphicsAPI == rendering::GraphicsAPI::METAL)
Expand Down Expand Up @@ -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<RenderThreadRhiOpenGL>(&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<RenderThreadRhiVulkan>(&this->gzRenderer);
}
#endif
#endif // GZ_GUI_HAVE_VULKAN
#ifdef __APPLE__
else if (_graphicsAPI == rendering::GraphicsAPI::METAL)
{
Expand All @@ -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<TextureNodeRhiOpenGL>(_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<TextureNodeRhiVulkan>(_window, _camera);
}
#else
#endif
#endif // GZ_GUI_HAVE_VULKAN
#ifdef __APPLE__
else if (_graphicsAPI == rendering::GraphicsAPI::METAL)
{
Expand Down Expand Up @@ -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());
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/plugins/point_cloud/PointCloud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "gz/msgs/pointcloud_packed.pb.h"
#include "gz/msgs/marker.pb.h"

#include <algorithm>
#include <limits>
Expand Down
1 change: 1 addition & 0 deletions test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)