Skip to content

Commit

Permalink
Improve build times by reducing included headers
Browse files Browse the repository at this point in the history
Ogre2Includes.hh is a very convenient header but it includes too many
Ogre headers, which heavily affects build times.

For certain .cc files compilation time was reduced by 1.2 seconds on an
i7 7700 @3.60Ghz

A full build was of ign-rendering5 went from 1m 57s to 1m 46s (I only
touched ogre2, not ogre; a full rebuild of ign-rendering5 includes
both).

This amounts to an 11 second improvement for a full build meaning a 9.4%
reduction (more if we consider ogre1 module is affecting measuring)

The solution is to simply include Ogre headers that are needed, instead
of relying on Ogre2Includes.hh; and make sure Ogre2Includes.hh is never
included in a *.hh file.

Signed-off-by: Matias N. Goldberg <[email protected]>
  • Loading branch information
darksylinc committed Apr 10, 2021
1 parent d6957d0 commit 85dd1b9
Show file tree
Hide file tree
Showing 36 changed files with 266 additions and 36 deletions.
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Capsule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "ignition/rendering/base/BaseCapsule.hh"
#include "ignition/rendering/ogre2/Ogre2Geometry.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace Ogre
{
Expand Down
13 changes: 12 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@

#include "ignition/rendering/config.hh"
#include "ignition/rendering/PixelFormat.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Export.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif

#include <OgreColourValue.h>
#include <OgreVector3.h>
#include <OgrePixelFormat.h>

#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace ignition
{
namespace rendering
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <string>

#include "ignition/rendering/base/BaseDepthCamera.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Sensor.hh"

#include "ignition/common/Event.hh"
Expand Down
14 changes: 13 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2DynamicRenderable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@
#include <vector>

#include "ignition/rendering/ogre2/Export.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"
#include "ignition/rendering/Marker.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreHlmsPso.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace Ogre
{
class MovableObject;
}

namespace ignition
{
namespace rendering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <memory>

#include "ignition/rendering/base/BaseGaussianNoisePass.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2RenderPass.hh"
#include "ignition/rendering/ogre2/Export.hh"

Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2GpuRays.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/base/BaseGpuRays.hh"
#include "ignition/rendering/ogre2/Export.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Grid.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <memory>
#include "ignition/rendering/base/BaseGrid.hh"
#include "ignition/rendering/ogre2/Ogre2Geometry.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace Ogre
{
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "ignition/rendering/base/BaseLidarVisual.hh"
#include "ignition/rendering/ogre2/Ogre2Visual.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace ignition
{
Expand Down
9 changes: 8 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@

#include "ignition/rendering/base/BaseLight.hh"
#include "ignition/rendering/ogre2/Ogre2Node.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreLight.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace Ogre
{
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2LightVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "ignition/rendering/base/BaseLightVisual.hh"
#include "ignition/rendering/ogre2/Ogre2Visual.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace Ogre
{
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Marker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <memory>
#include "ignition/rendering/base/BaseMarker.hh"
#include "ignition/rendering/ogre2/Ogre2Geometry.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace ignition
{
Expand Down
16 changes: 15 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@

#include "ignition/rendering/base/BaseMaterial.hh"
#include "ignition/rendering/ogre2/Ogre2Object.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <Hlms/Pbs/OgreHlmsPbsPrerequisites.h>
#include <OgreMaterial.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace Ogre
{
class HlmsPbsDatablock;
class HlmsUnlitDatablock;
} // namespace Ogre

namespace ignition
{
Expand Down
10 changes: 9 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
#include <ignition/math/Color.hh>
#include "ignition/rendering/config.hh"
#include "ignition/rendering/ogre2/Export.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreMaterial.h>
#include <OgreRenderTargetListener.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace ignition
{
namespace rendering
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2RayQuery.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <memory>

#include "ignition/rendering/base/BaseRayQuery.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Object.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"

Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2RenderPass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "ignition/rendering/base/BaseRenderPass.hh"
#include "ignition/rendering/ogre2/Export.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Object.hh"

namespace ignition
Expand Down
9 changes: 8 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2RenderTarget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@

#include "ignition/rendering/base/BaseRenderTypes.hh"
#include "ignition/rendering/base/BaseRenderTarget.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Object.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTargetMaterial.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <Compositor/OgreCompositorShadowNode.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace Ogre
{
class Camera;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@
#include <vector>

#include "ignition/rendering/config.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Export.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreRenderTargetListener.h>
#include <OgreMaterialManager.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace ignition
{
namespace rendering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "ignition/rendering/base/BaseThermalCamera.hh"
#include "ignition/rendering/ogre2/Export.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Sensor.hh"

#include "ignition/common/Event.hh"
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2WireBox.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <memory>
#include "ignition/rendering/base/BaseWireBox.hh"
#include "ignition/rendering/ogre2/Ogre2Geometry.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"

namespace Ogre
{
Expand Down
12 changes: 10 additions & 2 deletions ogre2/src/Ogre2Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

#include "ignition/rendering/ogre2/Ogre2Camera.hh"
#include "ignition/rendering/ogre2/Ogre2Conversions.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
// #include "ignition/rendering/ogre2/Ogre2Material.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"
#include "ignition/rendering/ogre2/Ogre2SelectionBuffer.hh"
#include "ignition/rendering/Utils.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreCamera.h>
#include <OgreItem.h>
#include <OgreSceneManager.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

/// \brief Private data for the Ogre2Camera class
class ignition::rendering::Ogre2CameraPrivate
{
Expand Down
8 changes: 8 additions & 0 deletions ogre2/src/Ogre2Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
*/
#include "ignition/rendering/ogre2/Ogre2Conversions.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreMatrix4.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

using namespace ignition;
using namespace rendering;

Expand Down
20 changes: 16 additions & 4 deletions ogre2/src/Ogre2DynamicRenderable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreItem.h>
#include <OgreMesh2.h>
#include <OgreMeshManager2.h>
#include <OgreSceneManager.h>
#include <OgreSubMesh2.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

/// \brief Private implementation
class ignition::rendering::Ogre2DynamicRenderablePrivate
{
Expand Down Expand Up @@ -131,8 +143,8 @@ void Ogre2DynamicRenderable::DestroyBuffer()
if (this->dataPtr->vbuffer)
delete [] this->dataPtr->vbuffer;

Ogre::Root *root = Ogre2RenderEngine::Instance()->OgreRoot();
Ogre::RenderSystem *renderSystem = root->getRenderSystem();
Ogre::RenderSystem *renderSystem =
this->dataPtr->sceneManager->getDestinationRenderSystem();
Ogre::VaoManager *vaoManager = renderSystem->getVaoManager();

if (!vaoManager)
Expand Down Expand Up @@ -187,8 +199,8 @@ void Ogre2DynamicRenderable::UpdateBuffer()
if (!this->dataPtr->dirty)
return;

Ogre::Root *root = Ogre2RenderEngine::Instance()->OgreRoot();
Ogre::RenderSystem *renderSystem = root->getRenderSystem();
Ogre::RenderSystem *renderSystem =
this->dataPtr->sceneManager->getDestinationRenderSystem();

Ogre::VaoManager *vaoManager = renderSystem->getVaoManager();
if (!vaoManager)
Expand Down
17 changes: 16 additions & 1 deletion ogre2/src/Ogre2GaussianNoisePass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@
#include <ignition/common/Console.hh>

#include "ignition/rendering/RenderPassSystem.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2GaussianNoisePass.hh"
#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <Compositor/OgreCompositorManager2.h>
#include <Compositor/OgreCompositorNodeDef.h>
#include <Compositor/Pass/PassQuad/OgreCompositorPassQuadDef.h>
#include <OgreMaterial.h>
#include <OgreMaterialManager.h>
#include <OgrePass.h>
#include <OgreRoot.h>
#include <OgreTechnique.h>
#include <OgreVector3.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

/// \brief Private data for the Ogre2GaussianNoisePass class
class ignition::rendering::Ogre2GaussianNoisePassPrivate
{
Expand Down
21 changes: 20 additions & 1 deletion ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "ignition/rendering/ogre2/Ogre2RenderEngine.hh"
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/ogre2/Ogre2Conversions.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2ParticleEmitter.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTarget.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"
Expand All @@ -36,6 +35,26 @@

#include "Ogre2ParticleNoiseListener.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <Compositor/OgreCompositorManager2.h>
#include <Compositor/OgreCompositorWorkspace.h>
#include <Compositor/Pass/PassClear/OgreCompositorPassClearDef.h>
#include <Compositor/Pass/PassQuad/OgreCompositorPassQuadDef.h>
#include <Compositor/Pass/PassScene/OgreCompositorPassSceneDef.h>
#include <OgreDepthBuffer.h>
#include <OgreHardwarePixelBuffer.h>
#include <OgreItem.h>
#include <OgreRenderTexture.h>
#include <OgreRoot.h>
#include <OgreSceneManager.h>
#include <OgreTechnique.h>
#include <OgreTextureManager.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

namespace ignition
{
namespace rendering
Expand Down
8 changes: 8 additions & 0 deletions ogre2/src/Ogre2LidarVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#include "ignition/rendering/ogre2/Ogre2Marker.hh"
#include "ignition/rendering/ogre2/Ogre2Geometry.hh"

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreSceneNode.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

class ignition::rendering::Ogre2LidarVisualPrivate
{
/// \brief Non Hitting DynamicLines Object to display
Expand Down
Loading

0 comments on commit 85dd1b9

Please sign in to comment.