Skip to content

WIP Vulkan Experiments and OGRE 3.0 #943

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
98 changes: 5 additions & 93 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,84 +79,13 @@ if (OpenGL_FOUND)
set(HAVE_OPENGL TRUE)
endif()

#--------------------------------------
# Find OGRE
list(APPEND gz_ogre_components "RTShaderSystem" "Terrain" "Overlay" "Paging")

gz_find_package(GzOGRE VERSION 1.9.0
COMPONENTS ${gz_ogre_components}
REQUIRED_BY ogre
PRIVATE_FOR ogre)

# Ogre versions greater than 1.9.x are not officialy supported.
# Display a warning for the users on this setup unless they provide
# USE_UNOFFICIAL_OGRE_VERSIONS flag
if (NOT USE_UNOFFICIAL_OGRE_VERSIONS)
if (OGRE_VERSION VERSION_GREATER_EQUAL 1.10.0)
GZ_BUILD_WARNING("Ogre 1.x versions greater than 1.9 are not officially supported."
"The software might compile and even work but support from upstream"
"could be reduced to accepting patches for newer versions")
endif()
endif()
#find_package(ogre_vendor REQUIRED)
#set(GZ_RENDERING_HAVE_OGRE TRUE)

if (OGRE_FOUND)
# find boost - mainly needed on macOS and also by the terrain component
find_package(Boost)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
find_package(ogre_next_vendor REQUIRED)
set(GZ_RENDERING_HAVE_OGRE2 TRUE)
set(GZ_RENDERING_HAVE_VULKAN TRUE)

set(GZ_RENDERING_HAVE_OGRE TRUE)
endif()

#--------------------------------------
# Find OGRE2: first try to find OGRE2 built with PlanarReflections support and
# fallback to look for OGRE2 without it. Both seems to works for gz-rendering.
# See https://github.com/gazebosim/gz-rendering/issues/597
gz_find_package(GzOGRE2 VERSION 2.3.1
COMPONENTS HlmsPbs HlmsUnlit Overlay PlanarReflections
PRIVATE_FOR ogre2
QUIET)

if ("${OGRE2-PlanarReflections}" STREQUAL "OGRE2-PlanarReflections-NOTFOUND")
message(STATUS "PlanarReflections component was not found. Try looking without it:")
gz_find_package(GzOGRE2 VERSION 2.3.1
COMPONENTS HlmsPbs HlmsUnlit Overlay
REQUIRED_BY ogre2
PRIVATE_FOR ogre2)
endif()

if (OGRE2_FOUND)
set(GZ_RENDERING_HAVE_OGRE2 TRUE)
endif()

#--------------------------------------
# Find Vulkan
# ogre-next 2.3 is built with vulkan support on Jammy
# Make sure we have vulkan headers, e.g. vulkan/vulkan_core.h
if (UNIX AND NOT APPLE)
# check if ogre-next vulkan headers are installed
find_path(ogre_vulkan_INCLUDE "RenderSystems/Vulkan/OgreVulkanDevice.h"
HINTS ${OGRE2_INCLUDE_DIRS})

# if not installed, ogre-next is likely built on platform without vulkan
# support, e.g. Focal
if (NOT ogre_vulkan_INCLUDE)
message(STATUS "Skipping vulkan support for component [ogre2]")
else()
find_path(vulkan_INCLUDE vulkan/vulkan_core.h)
if(NOT vulkan_INCLUDE)
message(STATUS "Looking for vulkan header (vulkan/vulkan_core.h) - not found")
gz_build_warning("Skipping component [ogre2]: Missing vulkan headers.\n")
# Create a variable to indicate that we need to skip the component
set(INTERNAL_SKIP_ogre2 true)
set(GZ_RENDERING_HAVE_OGRE2 FALSE)
else()
message(STATUS "Looking for vulkan header (vulkan/vulkan_core.h) - found")
set(GZ_RENDERING_HAVE_VULKAN TRUE)
endif()
endif()
endif()

# Plugin install dirs
set(GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR
Expand All @@ -166,23 +95,6 @@ set(GZ_RENDERING_ENGINE_INSTALL_DIR
${CMAKE_INSTALL_PREFIX}/${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR})


#--------------------------------------
# Find dependencies that we ignore for Visual Studio
if(NOT MSVC)
#--------------------------------------
# Find CUDA
find_package(CUDA)

#--------------------------------------
# Find OptiX
gz_find_package(OptiX VERSION 3.8.0
REQUIRED_BY optix
PRIVATE_FOR optix)

if (OptiX_FOUND AND CUDA_FOUND)
set(GZ_RENDERING_HAVE_OPTIX TRUE)
endif()
endif()

#####################################
# Define compile-time default variables
Expand Down
4 changes: 3 additions & 1 deletion examples/global_illumination/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(gz-rendering-global_illumination)

find_package(gz-rendering9)
find_package(gz-rendering9 REQUIRED)
find_package(gz-common6 REQUIRED)

include_directories(SYSTEM
${PROJECT_BINARY_DIR}
Expand All @@ -25,6 +26,7 @@ add_executable(global_illumination Main.cc Sdl2Window.cc)
target_link_libraries(global_illumination
${SDL2_LIBRARIES}
${GZ-RENDERING_LIBRARIES}
gz-common6::gz-common6
)

add_custom_command(TARGET global_illumination POST_BUILD
Expand Down
6 changes: 6 additions & 0 deletions examples/ogre2_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ int main(int _argc, char** _argv)
params["metal"] = "1";
}

if (engineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::VULKAN)
{
params["vulkan"] = "1";
}

CameraPtr camera = createCamera(engineName, params);
if (camera)
{
Expand Down
2 changes: 1 addition & 1 deletion include/gz/rendering/GpuRays.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace gz
public: virtual const float *Data() const = 0;

/// \brief Copy to the specified memory direction the gpu rays data.
public: virtual void Copy(float *_data) = 0;
public: virtual void CopyData(float *_data) = 0;

/// \brief Configure behaviour for data values outside of camera range
/// \param[in] _clamp True to clamp data to camera clip distances,
Expand Down
2 changes: 1 addition & 1 deletion include/gz/rendering/InertiaVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace gz
/// \brief Load the Inertia visual from its pose and scale
/// \param[in] _pose Pose of the Inertia visual
/// \param[in] _scale Scale factor of the box visual
public: virtual void Load(const gz::math::Pose3d &_pose,
public: virtual void LoadInertial(const gz::math::Pose3d &_pose,
const gz::math::Vector3d &_scale) = 0;

/// \brief Get the box visual
Expand Down
2 changes: 1 addition & 1 deletion include/gz/rendering/LensFlarePass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace gz

/// \brief Initializes the Lens Flare Pass with given scene
/// \param[in] _scene Pointer to scene
public: virtual void Init(ScenePtr _scene) = 0;
public: virtual void InitFromScene(ScenePtr _scene) = 0;

/// \brief Set the light that generates lens flare
/// \param[in] _light Pointer to light
Expand Down
4 changes: 2 additions & 2 deletions include/gz/rendering/ParticleEmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ namespace gz
/// \brief Get the material which all particles in the emitter will use.
/// \return The material pointer.
/// \sa SetMaterial
public: virtual MaterialPtr Material() const = 0;
public: virtual MaterialPtr ParticleMaterial() const = 0;

/// \brief Sets the material which all particles in the emitter will use.
/// \param[in] _material The material pointer.
/// \sa Material
public: virtual void SetMaterial(const MaterialPtr &_material) = 0;
public: virtual void SetParticleMaterial(const MaterialPtr &_material) = 0;

/// \brief Get the minimum velocity each particle is emitted (m/s).
/// \return Minimum velocity.
Expand Down
4 changes: 2 additions & 2 deletions include/gz/rendering/RenderPass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace gz
: public virtual Object
{
/// \brief Destructor
public: virtual ~RenderPass();
public: ~RenderPass() override;

/// \brief Set to enable or disable the render pass
/// \param[in] _enabled True to enable the render pass, false to disable.
Expand All @@ -49,7 +49,7 @@ namespace gz
/// Object::PreRender but with the added bonus that it has access
/// to the camera that is about to render
/// \param[in] _camera Camera that is about to render
public: virtual void PreRender(const CameraPtr &_camera) = 0;
public: virtual void CameraPreRender(const CameraPtr &_camera) = 0;

/// \brief WideAngleCamera renders to 6 faces; then stitches all 6
/// into a final "fish-eye" lens result.
Expand Down
3 changes: 3 additions & 0 deletions include/gz/rendering/RenderPassSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace gz
/// \brief A factory interface for creating render passes
class GZ_RENDERING_VISIBLE RenderPassFactory
{
/// \brief Destructor
public: virtual ~RenderPassFactory();

/// \brief Instantiate new render pass
/// \return New render pass
public: virtual RenderPass *New() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/gz/rendering/RenderTarget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace gz
/// Object::PreRender but with the added bonus that it has access
/// to the camera that is about to render
/// \param[in] _camera Camera that is about to render
public: virtual void PreRender(const CameraPtr &_camera) = 0;
public: virtual void CameraPreRender(const CameraPtr &_camera) = 0;

/// \brief Add a render pass to the render target
/// \param[in] _pass New render pass to add
Expand Down
2 changes: 1 addition & 1 deletion include/gz/rendering/base/BaseCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ namespace gz
{
CameraPtr camera =
std::dynamic_pointer_cast<Camera>(this->shared_from_this());
this->RenderTarget()->PreRender(camera);
this->RenderTarget()->CameraPreRender(camera);
}

// camera following
Expand Down
4 changes: 2 additions & 2 deletions include/gz/rendering/base/BaseGpuRays.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace gz
public: virtual const float *Data() const override;

// Documentation inherited.
public: virtual void Copy(float *_data) override;
public: virtual void CopyData(float *_data) override;

// Documentation inherited.
public: virtual void SetClamp(bool _enable) override;
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace gz

//////////////////////////////////////////////////
template <class T>
void BaseGpuRays<T>::Copy(float *_dataDest)
void BaseGpuRays<T>::CopyData(float *_dataDest)
{
// Unused
(void)_dataDest;
Expand Down
6 changes: 3 additions & 3 deletions include/gz/rendering/base/BaseInertiaVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace gz
const gz::math::Inertiald &_inertial) override;

// Documentation inherited.
public: virtual void Load(const gz::math::Pose3d &,
public: virtual void LoadInertial(const gz::math::Pose3d &,
const gz::math::Vector3d &) override;

// Documentation inherited
Expand Down Expand Up @@ -108,13 +108,13 @@ namespace gz
else
{
// Apply additional rotation by boxRot
this->Load(gz::math::Pose3d(xyz, q * boxRot), boxScale);
this->LoadInertial(gz::math::Pose3d(xyz, q * boxRot), boxScale);
}
}

//////////////////////////////////////////////////
template <class T>
void BaseInertiaVisual<T>::Load(const gz::math::Pose3d &,
void BaseInertiaVisual<T>::LoadInertial(const gz::math::Pose3d &,
const gz::math::Vector3d &)
{
// no op
Expand Down
8 changes: 4 additions & 4 deletions include/gz/rendering/base/BaseParticleEmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ namespace gz
public: virtual void SetLifetime(double _lifetime) override;

// Documentation inherited.
public: virtual MaterialPtr Material() const override;
public: virtual MaterialPtr ParticleMaterial() const override;

// Documentation inherited.
public: virtual void SetMaterial(const MaterialPtr &_material) override;
public: virtual void SetParticleMaterial(const MaterialPtr &_material) override;

// Documentation inherited.
public: virtual double MinVelocity() const override;
Expand Down Expand Up @@ -334,14 +334,14 @@ namespace gz

//////////////////////////////////////////////////
template <class T>
MaterialPtr BaseParticleEmitter<T>::Material() const
MaterialPtr BaseParticleEmitter<T>::ParticleMaterial() const
{
return this->material;
}

/////////////////////////////////////////////////
template <class T>
void BaseParticleEmitter<T>::SetMaterial(const MaterialPtr &_material)
void BaseParticleEmitter<T>::SetParticleMaterial(const MaterialPtr &_material)
{
this->material = _material;
}
Expand Down
4 changes: 2 additions & 2 deletions include/gz/rendering/base/BaseRenderPass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace gz
public: virtual bool IsEnabled() const override;

// Documentation inherited
public: void PreRender(const CameraPtr &_camera) override;
public: void CameraPreRender(const CameraPtr &_camera) override;

// Documentation inherited
public: void SetWideAngleCameraAfterStitching(bool _afterStitching)
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace gz

//////////////////////////////////////////////////
template <class T>
void BaseRenderPass<T>::PreRender(const CameraPtr &/*_camera*/)
void BaseRenderPass<T>::CameraPreRender(const CameraPtr &/*_camera*/)
{
T *thisT = this;
thisT->PreRender(); // NOT the same as doing T::PreRender
Expand Down
6 changes: 3 additions & 3 deletions include/gz/rendering/base/BaseRenderTarget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace gz
public: virtual ~BaseRenderTarget();

// Documentation inherited.
public: virtual void PreRender(const CameraPtr &_camera) override;
public: virtual void CameraPreRender(const CameraPtr &_camera) override;

// Documentation inherited.
public: virtual void PreRender() override;
Expand Down Expand Up @@ -165,11 +165,11 @@ namespace gz

//////////////////////////////////////////////////
template <class T>
void BaseRenderTarget<T>::PreRender(const CameraPtr &_camera)
void BaseRenderTarget<T>::CameraPreRender(const CameraPtr &_camera)
{
this->PreRender();
for (auto &pass : this->renderPasses)
pass->PreRender(_camera);
pass->CameraPreRender(_camera);
}

//////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions include/gz/rendering/base/SceneExt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ namespace gz
{
/// \brief Constructor
/// \param[in] _scene Pointer to scene
public: SceneExt(Scene *_scene)
public: explicit SceneExt(Scene *_scene)
{
this->scene = _scene;
}

/// \brief Destructor
public: ~SceneExt() = default;
public: virtual ~SceneExt() = default;

/// \brief Generic create function
/// \param[in] _type Type of object to create
Expand Down
6 changes: 3 additions & 3 deletions ogre/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ target_link_libraries(${ogre_target}
${gz-common${GZ_COMMON_VER}_LIBRARIES}
PRIVATE
gz-plugin${GZ_PLUGIN_VER}::register
${OPENGL_LIBRARIES}
GzOGRE::GzOGRE
)
ogre_vendor::OgreMain
ogre_vendor::Paging
)

# Build the unit tests
gz_build_tests(TYPE UNIT
Expand Down
2 changes: 1 addition & 1 deletion ogre2/include/gz/rendering/ogre2/Ogre2GpuRays.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace gz
public: virtual const float *Data() const override;

// Documentation inherited.
public: virtual void Copy(float *_data) override;
public: virtual void CopyData(float *_data) override;

// Documentation inherited.
public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame(
Expand Down
2 changes: 1 addition & 1 deletion ogre2/include/gz/rendering/ogre2/Ogre2InertiaVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace gz
/// \brief Load the Inertia visual from its pose and scale
/// \param[in] _pose Pose of the Inertia visual
/// \param[in] _scale Scale factor of the box visual
public: void Load(const gz::math::Pose3d &_pose,
public: void LoadInertial(const gz::math::Pose3d &_pose,
const gz::math::Vector3d &_scale) override;

/// \brief Get the box visual
Expand Down
Loading