Skip to content

Commit 115a179

Browse files
authored
Merge pull request #1077 from gazebosim/merge_9_main_20241004
Merge 9 -> main
2 parents ecd9f75 + efb4bf5 commit 115a179

File tree

17 files changed

+303
-42
lines changed

17 files changed

+303
-42
lines changed

.github/workflows/windows.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Windows
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
build:
7+
name: Window CI
8+
env:
9+
PACKAGE: gz-rendering9
10+
runs-on: windows-latest
11+
steps:
12+
- name: setup-pixi
13+
uses: prefix-dev/[email protected]
14+
with:
15+
run-install: false
16+
17+
- name: Install build tools
18+
run: |
19+
pixi init
20+
pixi add vcstool colcon-common-extensions pkgconfig
21+
- name: Setup pixi env variables
22+
shell: bash
23+
run: |
24+
eval "$(pixi shell-hook)"
25+
echo CMAKE_PREFIX_PATH=$CONDA_PREFIX/Library >> $GITHUB_ENV
26+
- name: Install base dependencies
27+
run: |
28+
# List adapted from https://github.com/gazebo-tooling/release-tools/blob/f89ac8cafc646260598eb8eb6d94be8093bdc9f7/jenkins-scripts/lib/windows_env_vars.bat#L22
29+
pixi add assimp dlfcn-win32 eigen ffmpeg freeimage gdal gflags ogre ogre-next spdlog tinyxml2
30+
- name: Clone source dependencies
31+
run: |
32+
mkdir src
33+
cd src
34+
pixi run vcs import --input https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/${env:PACKAGE}.yaml
35+
36+
- uses: actions/checkout@v4
37+
with:
38+
path: src/gz-rendering
39+
40+
- name: Build Dependencies
41+
run: |
42+
pixi run colcon build --merge-install --cmake-args -G"Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF --event-handlers console_direct+ --packages-up-to ${env:PACKAGE}
43+
44+
- name: Build Package
45+
run: pixi run colcon build --merge-install --cmake-args -G"Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DSKIP_ogre=ON --event-handlers console_direct+ --packages-select ${env:PACKAGE}
46+
47+
- name: Test
48+
run: pixi run colcon test --merge-install --event-handlers console_direct+ --packages-select ${env:PACKAGE}

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ set(GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR
154154
set(GZ_RENDERING_ENGINE_INSTALL_DIR
155155
${CMAKE_INSTALL_PREFIX}/${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR})
156156

157+
#--------------------------------------
158+
# Find DL if doing relocatable installation
159+
if (GZ_ENABLE_RELOCATABLE_INSTALL)
160+
gz_find_package(DL REQUIRED)
161+
endif()
157162

158163
#--------------------------------------
159164
# Find dependencies that we ignore for Visual Studio

Changelog.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,36 @@
22

33
### Gazebo Rendering 9.X
44

5-
### Gazebo Rendering 9.0.0 (2024-09-XX)
5+
### Gazebo Rendering 9.0.0 (2024-09-25)
6+
7+
1. **Baseline:** this includes all changes from 8.2.0 and earlier.
8+
9+
1. Update code for loading normal and albedo maps from image data
10+
* [Pull request #1068](https://github.com/gazebosim/gz-rendering/pull/1068)
11+
12+
1. examples/depth_camera: Fixed windows usage
13+
* [Pull request #1060](https://github.com/gazebosim/gz-rendering/pull/1060)
14+
15+
1. examples/heightmap: Fixed Windows build
16+
* [Pull request #1062](https://github.com/gazebosim/gz-rendering/pull/1062)
17+
18+
1. Add Github Action for Windows and fix build
19+
* [Pull request #1049](https://github.com/gazebosim/gz-rendering/pull/1049)
20+
21+
1. Miscellaneous documentation fixes
22+
* [Pull request #1051](https://github.com/gazebosim/gz-rendering/pull/1051)
23+
* [Pull request #1053](https://github.com/gazebosim/gz-rendering/pull/1053)
24+
* [Pull request #1054](https://github.com/gazebosim/gz-rendering/pull/1054)
25+
* [Pull request #1055](https://github.com/gazebosim/gz-rendering/pull/1055)
26+
* [Pull request #1061](https://github.com/gazebosim/gz-rendering/pull/1061)
27+
* [Pull request #1064](https://github.com/gazebosim/gz-rendering/pull/1064)
28+
* [Pull request #1069](https://github.com/gazebosim/gz-rendering/pull/1069)
29+
30+
1. Update badges to point to gz-rendering9 branch
31+
* [Pull request #1044](https://github.com/gazebosim/gz-rendering/pull/1044)
32+
33+
1. Ionic Changelog
34+
* [Pull request #1042](https://github.com/gazebosim/gz-rendering/pull/1042)
635

736
1. Remove gl preference in cmake
837
* [Pull request #1041](https://github.com/gazebosim/gz-rendering/pull/1041)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Build | Status
1111
-- | --
12-
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/branch/main)
12+
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/main)
1313
Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-noble-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-noble-amd64)
1414
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64)
1515
Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-main-win)](https://build.osrfoundation.org/job/gz_rendering-main-win)
@@ -31,9 +31,9 @@ of libraries designed to rapidly develop robot applications.
3131

3232
[Folder Structure](#folder-structure)
3333

34-
[Code of Conduct](#code-of-conduct)
34+
[Contributing](#contributing)
3535

36-
[Contributing](#code-of-contributing)
36+
[Code of Conduct](#code-of-conduct)
3737

3838
[Versioning](#versioning)
3939

@@ -80,8 +80,8 @@ Rendering engine plugin implementation code is stored in their own folders
8080

8181
# Contributing
8282

83-
Please see
84-
[CONTRIBUTING.md](https://gazebosim.org/docs/all/contributing).
83+
Please see the
84+
[contribution guide](https://gazebosim.org/docs/all/contributing).
8585

8686
# Code of Conduct
8787

examples/depth_camera/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ if (NOT APPLE)
2020
link_directories(${GLEW_LIBRARY_DIRS})
2121
endif()
2222

23-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
23+
if(NOT WIN32)
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
25+
endif()
2426

2527
configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)
2628

examples/depth_camera/Main.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@
3838
using namespace gz;
3939
using namespace rendering;
4040

41+
#if not defined(_WIN32)
4142
const std::string RESOURCE_PATH =
4243
common::joinPaths(std::string(PROJECT_BINARY_PATH), "media");
44+
#else
45+
const std::string RESOURCE_PATH =
46+
common::joinPaths(std::string(PROJECT_BINARY_PATH), "..", "media");
47+
#endif
4348

4449
void buildScene(ScenePtr _scene)
4550
{

examples/heightmap/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ if (NOT APPLE)
2020
link_directories(${GLEW_LIBRARY_DIRS})
2121
endif()
2222

23-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
23+
if(NOT MSVC)
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
25+
endif()
2426

2527
configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)
2628

examples/heightmap/Main.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <GL/glew.h>
2323
#include <GL/gl.h>
2424
#include <GL/glut.h>
25+
#else
26+
#include <GL/glut.h>
2527
#endif
2628

2729
#include <iostream>
@@ -39,8 +41,13 @@
3941
using namespace gz;
4042
using namespace rendering;
4143

44+
#if not defined(_WIN32)
4245
const std::string RESOURCE_PATH =
4346
common::joinPaths(std::string(PROJECT_BINARY_PATH), "media");
47+
#else
48+
const std::string RESOURCE_PATH =
49+
common::joinPaths(std::string(PROJECT_BINARY_PATH), "..", "media");
50+
#endif
4451

4552
//////////////////////////////////////////////////
4653
void createImageHeightmaps(const ScenePtr _scene, VisualPtr _root)

examples/lux_core_engine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
33
set(GZ_PLUGIN_VER 2)
44
set(GZ_COMMON_VER 5)
55

6-
find_package(gz-rendering7 REQUIRED)
6+
find_package(gz-rendering9 REQUIRED)
77
find_package(gz-plugin3 REQUIRED COMPONENTS all)
88

99
if (NOT DEFINED ENV{LUXCORE_SDK_PATH})

ogre2/src/Ogre2Material.cc

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*
1616
*/
1717

18+
#include <cstddef>
19+
1820
// Note this include is placed in the src file because
1921
// otherwise ogre produces compile errors
2022
#ifdef _MSC_VER
@@ -31,6 +33,8 @@
3133
#include <OgreMaterialManager.h>
3234
#include <OgrePixelFormatGpuUtils.h>
3335
#include <OgreTechnique.h>
36+
#include <OgreTextureBox.h>
37+
#include <OgreTextureFilters.h>
3438
#include <OgreTextureGpuManager.h>
3539
#include <Vao/OgreVaoManager.h>
3640
#ifdef _MSC_VER
@@ -130,6 +134,23 @@ class gz::rendering::Ogre2MaterialPrivate
130134
return "invalid";
131135
}
132136
}
137+
138+
/// \brief Prepare for normal mapping by converting to two-component
139+
/// normalized signed 8-bit format
140+
/// \param[in] _texture Normal map texture
141+
/// \param[in/out] _image Normal map image data
142+
public: void PrepareForNormalMapping(Ogre::TextureGpu *_texture,
143+
Ogre::Image2 &_image);
144+
145+
/// \brief Allocate mimaps for the texture. This should be done when the
146+
/// texture's residency status is still OnStorage.
147+
/// \param[in] _texture Input texture to allocate mimaps
148+
public: void AllocateMipmaps(Ogre::TextureGpu *_texture);
149+
150+
/// \brief Generate mimaps for the texture. This should be done when the
151+
/// texture's residency status is Resident.
152+
/// \param[in] _texture Input texture to generate mimpas
153+
public: void GenerateMipmaps(Ogre::TextureGpu *_texture);
133154
};
134155

135156
using namespace gz;
@@ -1220,6 +1241,8 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
12201241
root->getRenderSystem()->getTextureGpuManager();
12211242

12221243
// create the gpu texture
1244+
Ogre::uint32 filters = Ogre::TextureFilter::TypeGenerateDefaultMipmaps;
1245+
filters |= this->ogreDatablock->suggestFiltersForType(_type);
12231246
Ogre::uint32 textureFlags = 0;
12241247
textureFlags |= Ogre::TextureFlags::AutomaticBatching;
12251248
Ogre::TextureGpu *texture = textureMgr->createOrRetrieveTexture(
@@ -1228,7 +1251,7 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
12281251
textureFlags | Ogre::TextureFlags::ManualTexture,
12291252
Ogre::TextureTypes::Type2D,
12301253
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
1231-
0u);
1254+
filters);
12321255

12331256
// Has to be loaded
12341257
if (texture->getWidth() == 0)
@@ -1241,13 +1264,31 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
12411264
texture->setTextureType(Ogre::TextureTypes::Type2D);
12421265
texture->setNumMipmaps(1u);
12431266
texture->setResolution(_img->Width(), _img->Height());
1244-
texture->scheduleTransitionTo(Ogre::GpuResidency::Resident);
1245-
texture->waitForData();
12461267

1247-
// upload raw color image data to gpu texture
12481268
Ogre::Image2 img;
12491269
img.loadDynamicImage(&data[0], false, texture);
1270+
1271+
// Replicates the steps that ogre does when it loads a texture map from
1272+
// file. For normal maps, it is first converted to a two component signed
1273+
// 8 bit format. Albedo and normal maps will have mipmaps generated.
1274+
// \todo(iche033) See if there is a way to reuse these functions
1275+
// from ogre-next without copying the code here.
1276+
1277+
// Normal maps - convert to two component signed 8 bit format:
1278+
// Ogre::PFG_RG8_SNORM format
1279+
if (_type == Ogre::PBSM_NORMAL)
1280+
this->dataPtr->PrepareForNormalMapping(texture, img);
1281+
1282+
if (_type == Ogre::PBSM_DIFFUSE || _type == Ogre::PBSM_NORMAL)
1283+
this->dataPtr->AllocateMipmaps(texture);
1284+
1285+
// Upload raw color image data to gpu texture
1286+
texture->scheduleTransitionTo(Ogre::GpuResidency::Resident);
1287+
texture->waitForData();
12501288
img.uploadTo(texture, 0, 0);
1289+
1290+
if (_type == Ogre::PBSM_DIFFUSE || _type == Ogre::PBSM_NORMAL)
1291+
this->dataPtr->GenerateMipmaps(texture);
12511292
}
12521293

12531294
// Now assign it to the material
@@ -1563,3 +1604,89 @@ ShaderParamsPtr Ogre2Material::FragmentShaderParams()
15631604
{
15641605
return this->dataPtr->fragmentShaderParams;
15651606
}
1607+
1608+
//////////////////////////////////////////////////
1609+
void Ogre2MaterialPrivate::PrepareForNormalMapping(Ogre::TextureGpu *_texture,
1610+
Ogre::Image2 &_image)
1611+
{
1612+
// code adpated from PrepareForNormalMapping::_executeStreaming function in
1613+
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
1614+
const Ogre::uint8 numMipmaps = _image.getNumMipmaps();
1615+
const Ogre::PixelFormatGpu dstFormat = Ogre::PFG_RG8_SNORM;
1616+
const Ogre::uint32 rowAlignment = 4u;
1617+
const size_t dstSizeBytes = Ogre::PixelFormatGpuUtils::calculateSizeBytes(
1618+
_image.getWidth(),
1619+
_image.getHeight(),
1620+
_image.getDepth(),
1621+
_image.getNumSlices(),
1622+
dstFormat, numMipmaps,
1623+
rowAlignment );
1624+
void *imgData = OGRE_MALLOC_SIMD( dstSizeBytes, Ogre::MEMCATEGORY_RESOURCE);
1625+
for (Ogre::uint8 mip = 0; mip < numMipmaps; ++mip)
1626+
{
1627+
Ogre::TextureBox srcBox = _image.getData( mip );
1628+
const Ogre::uint32 width = srcBox.width;
1629+
const Ogre::uint32 height = srcBox.height;
1630+
1631+
Ogre::TextureBox dstBox = srcBox;
1632+
dstBox.bytesPerPixel =
1633+
Ogre::PixelFormatGpuUtils::getBytesPerPixel(dstFormat);
1634+
dstBox.bytesPerRow =
1635+
Ogre::PixelFormatGpuUtils::getSizeBytes(
1636+
width, 1u, 1u, 1u, dstFormat, 4u);
1637+
dstBox.bytesPerImage =
1638+
Ogre::PixelFormatGpuUtils::getSizeBytes(width, height, 1u, 1u,
1639+
dstFormat, 4u);
1640+
dstBox.data = Ogre::PixelFormatGpuUtils::advancePointerToMip(
1641+
imgData, width, height, srcBox.depth, srcBox.numSlices, mip, dstFormat);
1642+
1643+
Ogre::PixelFormatGpuUtils::convertForNormalMapping(
1644+
srcBox, _image.getPixelFormat(),
1645+
dstBox, dstFormat);
1646+
}
1647+
_image.loadDynamicImage(imgData, _image.getWidth(), _image.getHeight(),
1648+
_image.getDepthOrSlices(), _image.getTextureType(), dstFormat, false,
1649+
numMipmaps);
1650+
_texture->setPixelFormat(dstFormat);
1651+
}
1652+
1653+
//////////////////////////////////////////////////
1654+
void Ogre2MaterialPrivate::AllocateMipmaps(Ogre::TextureGpu *_texture)
1655+
{
1656+
// code adpated from GenerateHwMipmaps::_executeStreaming function in
1657+
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
1658+
Ogre::uint8 maxMipmaps = Ogre::PixelFormatGpuUtils::getMaxMipmapCount(
1659+
_texture->getWidth(),
1660+
_texture->getHeight(),
1661+
_texture->getDepth() );
1662+
_texture->setNumMipmaps(maxMipmaps);
1663+
}
1664+
1665+
//////////////////////////////////////////////////
1666+
void Ogre2MaterialPrivate::GenerateMipmaps(Ogre::TextureGpu *_texture)
1667+
{
1668+
// code adpated from GenerateHwMipmaps::_executeSerial function in
1669+
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
1670+
Ogre::TextureGpuManager *textureManager = _texture->getTextureManager();
1671+
Ogre::TextureGpu *tempTexture = textureManager->createTexture(
1672+
"___tempMipmapTexture",
1673+
Ogre::GpuPageOutStrategy::Discard,
1674+
Ogre::TextureFlags::RenderToTexture |
1675+
Ogre::TextureFlags::AllowAutomipmaps |
1676+
Ogre::TextureFlags::DiscardableContent,
1677+
_texture->getTextureType());
1678+
tempTexture->copyParametersFrom(_texture);
1679+
tempTexture->unsafeScheduleTransitionTo(Ogre::GpuResidency::Resident);
1680+
Ogre::TextureBox box = _texture->getEmptyBox(0);
1681+
_texture->copyTo(tempTexture, box, 0, box, 0);
1682+
tempTexture->_autogenerateMipmaps();
1683+
1684+
Ogre::uint8 mipmaps = _texture->getNumMipmaps();
1685+
for (size_t i = 1u; i < mipmaps; ++i)
1686+
{
1687+
box = _texture->getEmptyBox( i );
1688+
tempTexture->copyTo(_texture, box, i, box, i);
1689+
}
1690+
textureManager->destroyTexture(tempTexture);
1691+
tempTexture = 0;
1692+
}

0 commit comments

Comments
 (0)