Skip to content
Merged
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
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ cc_library(
"@gz-common//events",
"@gz-common//geospatial",
"@gz-common//graphics",
"@gz-common//profiler",
"@gz-math",
"@gz-plugin//:loader",
"@gz-utils//:ImplPtr",
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ gz_configure_project(VERSION_SUFFIX pre1)
#============================================================================
option(USE_UNOFFICIAL_OGRE_VERSIONS "Accept unsupported Ogre versions in the build" OFF)

option(ENABLE_PROFILER "Enable Gazebo Profiler" FALSE)

if(ENABLE_PROFILER)
add_definitions("-DGZ_PROFILER_ENABLE=1")
else()
add_definitions("-DGZ_PROFILER_ENABLE=0")
endif()

#============================================================================
# Search for project-specific dependencies
#============================================================================
Expand All @@ -35,7 +43,7 @@ gz_find_package(gz-math REQUIRED COMPONENTS eigen3)
#--------------------------------------
# Find gz-common
gz_find_package(gz-common REQUIRED
COMPONENTS graphics events geospatial)
COMPONENTS graphics events profiler geospatial)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're adding a dependency on a component in gz-common here so just want to check if this can be backported to a release branch? @scpeters or @j-rivero

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we usually avoid adding dependencies to stable releases

I see some examples of using OPTIONAL_COMPONENTS with find_package, and I also see that gz_find_package supports that argument, though I don't see it in use anywhere, but you should be able to change this instance to find_package if there are bugs in the gz_find_package implementation.

The main issue will be that you would have to wrap the #include <gz/common/Profiler.hh> statement in a separate header (such as ogre/src/GzCommonProfiler.hh and ogre2/src/GzCommonProfiler.hh) that also defines a no-op version of the GZ_PROFILE macro. It's possible but a bit of work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we chose to release it anyway, we would need to update the build dependencies in each gz-rendering release repo:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it. If we want to backport this, we can try adding it as an optional component as suggested.

If we chose to release it anyway, we would need to update the build dependencies in each gz-rendering release repo:

If I understand correctly, we don't necessarily need to release it with the profiler dependency. Currently we're just adding remotery profiling points and we expect that users can only do profiling from source build by setting the ENABLE_PROFILER flag to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe by default, it's compile-time dependency (need header for define definition)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, we don't necessarily need to release it with the profiler dependency. Currently we're just adding remotery profiling points and we expect that users can only do profiling from source build by setting the ENABLE_PROFILER flag to true.

I believe by default, it's compile-time dependency (need header for define definition)

ok, you're right. I think what I meant to say was that if we wanted to just add profiler as a required component that we would have to update the debian metadata in order for it to compile, but as you point out the profile points wouldn't be active; they would still need to build from source to use the profiling.

So yeah, I think OPTIONAL_COMPONENTS in backports is the way to go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Who should do backports? Bot or maintainers or I should prepare PRs to other branches?


#--------------------------------------
# Find gz-plugin
Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreCOMVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*
*/
#include <gz/common/Profiler.hh>

#include "gz/rendering/ogre/OgreCOMVisual.hh"
#include "gz/rendering/ogre/OgreDynamicLines.hh"
Expand Down Expand Up @@ -49,6 +50,7 @@ OgreCOMVisual::~OgreCOMVisual()
//////////////////////////////////////////////////
void OgreCOMVisual::PreRender()
{
GZ_PROFILE("OgreCOMVisual::PreRender");
if (this->HasParent() && this->parentName.empty())
this->parentName = this->Parent()->Name();

Expand Down Expand Up @@ -78,6 +80,7 @@ Ogre::MovableObject *OgreCOMVisual::OgreObject() const
//////////////////////////////////////////////////
void OgreCOMVisual::CreateVisual()
{
GZ_PROFILE("OgreCOMVisual::CreateVisual");
if (!this->dataPtr->crossLines)
{
this->dataPtr->crossLines = std::shared_ptr<OgreDynamicLines>(
Expand Down
4 changes: 4 additions & 0 deletions ogre/src/OgreCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <gz/common/Profiler.hh>
#include "gz/rendering/InstallationDirectories.hh"
#include "gz/rendering/ogre/OgreCamera.hh"
#include "gz/rendering/ogre/OgreConversions.hh"
Expand Down Expand Up @@ -132,6 +133,7 @@ void OgreCamera::SetMaterial(const MaterialPtr &_material)
//////////////////////////////////////////////////
void OgreCamera::Render()
{
GZ_PROFILE("OgreCamera::Render");
this->renderTexture->Render();
}

Expand Down Expand Up @@ -217,6 +219,7 @@ void OgreCamera::DestroyRenderTexture()
//////////////////////////////////////////////////
unsigned int OgreCamera::RenderTextureGLId() const
{
GZ_PROFILE("OgreCamera::RenderTextureGLId");
if (!this->renderTexture)
return 0u;

Expand All @@ -240,6 +243,7 @@ void OgreCamera::SetSelectionBuffer()
VisualPtr OgreCamera::VisualAt(const math::Vector2i
&_mousePos)
{
GZ_PROFILE("OgreCamera::VisualAt");
VisualPtr result;

if (!this->selectionBuffer)
Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreCapsule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <gz/common/Mesh.hh>
#include <gz/common/MeshManager.hh>
#include <gz/common/Profiler.hh>

#include "gz/rendering/ogre/OgreCapsule.hh"
#include "gz/rendering/ogre/OgreMaterial.hh"
Expand Down Expand Up @@ -59,6 +60,7 @@ Ogre::MovableObject *OgreCapsule::OgreObject() const
//////////////////////////////////////////////////
void OgreCapsule::PreRender()
{
GZ_PROFILE("OgreCapsule::PreRender");
if (this->capsuleDirty)
{
this->Update();
Expand Down Expand Up @@ -91,6 +93,7 @@ void OgreCapsule::Destroy()
//////////////////////////////////////////////////
void OgreCapsule::Update()
{
GZ_PROFILE("OgreCapsule::Update");
common::MeshManager *meshMgr = common::MeshManager::Instance();
std::string capsuleMeshName = this->Name() + "_capsule_mesh"
+ "_" + std::to_string(this->radius)
Expand Down
8 changes: 8 additions & 0 deletions ogre/src/OgreDepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#endif
#include <windows.h>
#endif
#include <gz/common/Profiler.hh>

#include <gz/math/Helpers.hh>
#include <gz/math/Matrix4.hh>

Expand Down Expand Up @@ -196,6 +198,7 @@ void OgreDepthCamera::CreateCamera()
/////////////////////////////////////////////////
void OgreDepthCamera::CreatePointCloudTexture()
{
GZ_PROFILE("OgreDepthCamera::CreatePointCloudTexture");
if (this->dataPtr->pcdTexture || this->dataPtr->colorTexture)
return;

Expand Down Expand Up @@ -265,6 +268,7 @@ void OgreDepthCamera::DestroyPointCloudTexture()
/////////////////////////////////////////////////
void OgreDepthCamera::CreateDepthTexture()
{
GZ_PROFILE("OgreDepthCamera::CreateDepthTexture");
if (this->ogreCamera == nullptr)
{
gzerr << "Ogre camera cannot be created" << std::endl;
Expand Down Expand Up @@ -317,6 +321,7 @@ void OgreDepthCamera::SetProjectionMatrix(const math::Matrix4d &_matrix) {
//////////////////////////////////////////////////
void OgreDepthCamera::PreRender()
{
GZ_PROFILE("OgreDepthCamera::PreRender");
if (!this->depthTexture)
this->CreateDepthTexture();
if (!this->dataPtr->pcdTexture || !this->dataPtr->colorTexture)
Expand All @@ -326,6 +331,7 @@ void OgreDepthCamera::PreRender()
//////////////////////////////////////////////////
void OgreDepthCamera::Render()
{
GZ_PROFILE("OgreDepthCamera::Render");
Ogre::SceneManager *sceneMgr = this->scene->OgreSceneManager();
Ogre::ShadowTechnique shadowTech = sceneMgr->getShadowTechnique();

Expand Down Expand Up @@ -359,6 +365,7 @@ void OgreDepthCamera::UpdateRenderTarget(OgreRenderTexturePtr _target,
Ogre::Material *_material, const std::string &_matName)

{
GZ_PROFILE("OgreDepthCamera::UpdateRenderTarget");
Ogre::RenderTarget *target = _target->RenderTarget();
std::string matName = _matName;

Expand Down Expand Up @@ -429,6 +436,7 @@ void OgreDepthCamera::UpdateRenderTarget(OgreRenderTexturePtr _target,
//////////////////////////////////////////////////
void OgreDepthCamera::PostRender()
{
GZ_PROFILE("OgreDepthCamera::PostRender");
unsigned int width = this->ImageWidth();
unsigned int height = this->ImageHeight();
unsigned int len = width * height;
Expand Down
5 changes: 5 additions & 0 deletions ogre/src/OgreDistortionPass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


#include <gz/common/Console.hh>
#include <gz/common/Profiler.hh>

#include "gz/rendering/RenderPassSystem.hh"
#include "gz/rendering/ogre/OgreIncludes.hh"
Expand Down Expand Up @@ -122,6 +123,7 @@ OgreDistortionPass::~OgreDistortionPass()
//////////////////////////////////////////////////
void OgreDistortionPass::PreRender()
{
GZ_PROFILE("OgreDistortionPass::PreRender");
if (!this->dataPtr->distortionInstance)
return;
if (this->enabled != this->dataPtr->distortionInstance->getEnabled())
Expand All @@ -131,6 +133,7 @@ void OgreDistortionPass::PreRender()
//////////////////////////////////////////////////
void OgreDistortionPass::CreateRenderPass()
{
GZ_PROFILE("OgreDistortionPass::CreateRenderPass");
if (!this->ogreCamera[0])
{
gzerr << "No camera set for applying Distortion Pass" << std::endl;
Expand Down Expand Up @@ -470,6 +473,7 @@ gz::math::Vector2d OgreDistortionPass::Distort(
const gz::math::Vector2d &_center, double _k1, double _k2, double _k3,
double _p1, double _p2, unsigned int _width, double _f)
{
GZ_PROFILE("OgreDistortionPass::Distort");
// apply Brown's distortion model, see
// http://en.wikipedia.org/wiki/Distortion_%28optics%29#Software_correction

Expand Down Expand Up @@ -512,6 +516,7 @@ gz::math::Vector2d
//////////////////////////////////////////////////
void OgreDistortionPass::CalculateAndApplyDistortionScale()
{
GZ_PROFILE("OgreDistortionPass::CalculateAndApplyDistortionScale");
if (this->dataPtr->distortionMaterial.isNull())
return;

Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreDynamicLines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <gz/math/Color.hh>

#include "gz/common/Console.hh"
#include <gz/common/Profiler.hh>
#include "gz/rendering/ogre/OgreDynamicLines.hh"

using namespace gz;
Expand Down Expand Up @@ -129,6 +130,7 @@ void OgreDynamicLines::Clear()
/////////////////////////////////////////////////
void OgreDynamicLines::Update()
{
GZ_PROFILE("OgreDynamicLines::Update");
if (this->dataPtr->dirty && this->dataPtr->points.size() > 1)
this->FillHardwareBuffers();
}
Expand All @@ -146,6 +148,7 @@ void OgreDynamicLines::CreateVertexDeclaration()
/////////////////////////////////////////////////
void OgreDynamicLines::FillHardwareBuffers()
{
GZ_PROFILE("OgreDynamicLines::FillHardwareBuffers");
int size = this->dataPtr->points.size();
this->PrepareHardwareBuffers(size, 0);

Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreDynamicRenderable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/

#include "gz/common/Console.hh"
#include <gz/common/Profiler.hh>

#include "gz/rendering/ogre/OgreDynamicRenderable.hh"

using namespace gz;
Expand Down Expand Up @@ -139,6 +141,7 @@ MarkerType OgreDynamicRenderable::OperationType() const
void OgreDynamicRenderable::PrepareHardwareBuffers(size_t vertexCount,
size_t indexCount)
{
GZ_PROFILE("OgreDynamicRenderable::PrepareHardwareBuffers");
// Prepare vertex buffer
size_t newVertCapacity = this->vertexBufferCapacity;

Expand Down
3 changes: 3 additions & 0 deletions ogre/src/OgreGaussianNoisePass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


#include <gz/common/Console.hh>
#include <gz/common/Profiler.hh>

#include "gz/rendering/RenderPassSystem.hh"
#include "gz/rendering/ogre/OgreIncludes.hh"
Expand Down Expand Up @@ -105,6 +106,7 @@ OgreGaussianNoisePass::~OgreGaussianNoisePass()
//////////////////////////////////////////////////
void OgreGaussianNoisePass::PreRender()
{
GZ_PROFILE("OgreGaussianNoisePass::PreRender");
if (!this->gaussianNoiseInstance[0])
return;

Expand All @@ -121,6 +123,7 @@ void OgreGaussianNoisePass::PreRender()
//////////////////////////////////////////////////
void OgreGaussianNoisePass::CreateRenderPass()
{
GZ_PROFILE("OgreGaussianNoisePass::CreateRenderPass");
if (!this->ogreCamera[0])
{
gzerr << "No camera set for applying Gaussian Noise Pass" << std::endl;
Expand Down
11 changes: 11 additions & 0 deletions ogre/src/OgreGpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <gz/common/Mesh.hh>
#include <gz/common/SubMesh.hh>
#include <gz/common/Profiler.hh>

#include <gz/math/Color.hh>
#include <gz/math/Helpers.hh>
Expand Down Expand Up @@ -419,6 +420,7 @@ void OgreGpuRays::ConfigureCameras()
/////////////////////////////////////////////////////////
void OgreGpuRays::CreateGpuRaysTextures()
{
GZ_PROFILE("OgreGpuRays::CreateGpuRaysTextures");
this->ConfigureCameras();

this->CreateOrthoCam();
Expand Down Expand Up @@ -552,6 +554,7 @@ void OgreGpuRays::UpdateRenderTarget(Ogre::RenderTarget *_target,
Ogre::Material *_material, Ogre::Camera *_cam,
const bool _updateTex)
{
GZ_PROFILE("OgreGpuRays::UpdateRenderTarget");
Ogre::SceneManager *sceneMgr = this->scene->OgreSceneManager();
Ogre::RenderSystem *renderSys = sceneMgr->getDestinationRenderSystem();
// Get pointer to the material pass
Expand Down Expand Up @@ -620,6 +623,7 @@ void OgreGpuRays::UpdateRenderTarget(Ogre::RenderTarget *_target,
//////////////////////////////////////////////////
void OgreGpuRays::Render()
{
GZ_PROFILE("OgreGpuRays::Render");
Ogre::SceneManager *sceneMgr = this->scene->OgreSceneManager();

sceneMgr->_suppressRenderStateChanges(true);
Expand Down Expand Up @@ -663,13 +667,15 @@ void OgreGpuRays::Render()
//////////////////////////////////////////////////
void OgreGpuRays::PreRender()
{
GZ_PROFILE("OgreGpuRays::PreRender");
if (this->dataPtr->textureCount == 0)
this->CreateGpuRaysTextures();
}

//////////////////////////////////////////////////
void OgreGpuRays::PostRender()
{
GZ_PROFILE("OgreGpuRays::PostRender");
for (unsigned int i = 0; i < this->dataPtr->textureCount; ++i)
{
auto rt =
Expand Down Expand Up @@ -718,6 +724,7 @@ const float* OgreGpuRays::Data() const
//////////////////////////////////////////////////
void OgreGpuRays::Copy(float *_dataDest)
{
GZ_PROFILE("OgreGpuRays::Copy");
auto rt = this->dataPtr->secondPassTexture->getBuffer()->getRenderTarget();
const Ogre::Viewport *secondPassViewport = rt->getViewport(0);
unsigned int width = secondPassViewport->getActualWidth();
Expand All @@ -732,6 +739,7 @@ void OgreGpuRays::Copy(float *_dataDest)
/////////////////////////////////////////////////
void OgreGpuRays::CreateOrthoCam()
{
GZ_PROFILE("OgreGpuRays::CreateOrthoCam");
// create ogre camera object
Ogre::SceneManager *ogreSceneManager;
ogreSceneManager = this->scene->OgreSceneManager();
Expand Down Expand Up @@ -812,6 +820,7 @@ void OgreGpuRays::SetRangeCount(
/////////////////////////////////////////////////
void OgreGpuRays::CreateMesh()
{
GZ_PROFILE("OgreGpuRays::CreateMesh");
std::string meshName = this->Name() + "_undistortion_mesh";

common::Mesh *mesh = new common::Mesh();
Expand Down Expand Up @@ -925,6 +934,7 @@ void OgreGpuRays::CreateMesh()
/////////////////////////////////////////////////
void OgreGpuRays::CreateCanvas()
{
GZ_PROFILE("OgreGpuRays::CreateCanvas");
this->CreateMesh();

this->dataPtr->visual = this->scene->CreateVisual(
Expand Down Expand Up @@ -962,6 +972,7 @@ void OgreGpuRays::notifyRenderSingleObject(Ogre::Renderable *_rend,
const Ogre::Pass* /*pass*/, const Ogre::AutoParamDataSource* /*source*/,
const Ogre::LightList* /*lights*/, bool /*supp*/)
{
GZ_PROFILE("OgreGpuRays::notifyRenderSingleObject");
// TODO(anyone): this function sets the retro for each obj
// but currently just sets it to 0

Expand Down
2 changes: 2 additions & 0 deletions ogre/src/OgreGrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include <gz/common/Console.hh>
#include <gz/common/Profiler.hh>

#include "gz/rendering/ogre/OgreGrid.hh"
#include "gz/rendering/ogre/OgreMaterial.hh"
Expand Down Expand Up @@ -47,6 +48,7 @@ OgreGrid::~OgreGrid()
//////////////////////////////////////////////////
void OgreGrid::PreRender()
{
GZ_PROFILE("OgreGrid::PreRender");
if (this->gridDirty)
{
this->Create();
Expand Down
Loading
Loading