Skip to content

Commit

Permalink
Main: introduce OgreGpuEventScope macro
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Jul 28, 2024
1 parent 97f52d7 commit 80ebd27
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions OgreMain/src/OgreCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ namespace Ogre {
//-----------------------------------------------------------------------
void Camera::_renderScene(Viewport *vp)
{
OgreProfileBeginGPUEvent(getName());
OgreGpuEventScope(getName());

//update the pixel display ratio
if (mProjType == Ogre::PT_PERSPECTIVE)
Expand Down Expand Up @@ -502,7 +502,6 @@ namespace Ogre {
{
i->cameraPostRenderScene(this);
}
OgreProfileEndGPUEvent(getName());
}
//---------------------------------------------------------------------
void Camera::addListener(Listener* l)
Expand Down
3 changes: 1 addition & 2 deletions OgreMain/src/OgreRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ namespace Ogre {
//-----------------------------------------------------------------------
void RenderTarget::update(bool swap)
{
OgreProfileBeginGPUEvent(getName());
OgreGpuEventScope(mName);
// call implementation
updateImpl();

Expand All @@ -539,6 +539,5 @@ namespace Ogre {
// Swap buffers
swapBuffers();
}
OgreProfileEndGPUEvent(getName());
}
}
8 changes: 3 additions & 5 deletions OgreMain/src/OgreSceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,8 @@ void SceneManager::SceneMgrQueuedRenderableVisitor::visit(const Pass* p, Rendera

// Set pass, store the actual one used
mUsedPass = targetSceneMgr->_setPass(p);
OgreProfileBeginGPUEvent(mUsedPass->getParent()->getParent()->getName());

OgreGpuEventScope(mUsedPass->getParent()->getParent()->getName());

SubMesh* lastsm = 0;
RenderableList instances;
Expand Down Expand Up @@ -1369,8 +1370,6 @@ void SceneManager::SceneMgrQueuedRenderableVisitor::visit(const Pass* p, Rendera

if (!instances.empty())
targetSceneMgr->renderInstancedObject(instances, mUsedPass, scissoring, autoLights, manualLightList);

OgreProfileEndGPUEvent(mUsedPass->getParent()->getParent()->getName());
}
//-----------------------------------------------------------------------
void SceneManager::SceneMgrQueuedRenderableVisitor::visit(RenderablePass* rp)
Expand All @@ -1386,10 +1385,9 @@ void SceneManager::SceneMgrQueuedRenderableVisitor::visit(RenderablePass* rp)
if (targetSceneMgr->validateRenderableForRendering(rp->pass, rp->renderable))
{
mUsedPass = targetSceneMgr->_setPass(rp->pass);
OgreProfileBeginGPUEvent(mUsedPass->getParent()->getParent()->getName());
OgreGpuEventScope(mUsedPass->getParent()->getParent()->getName());
targetSceneMgr->renderSingleObject(rp->renderable, mUsedPass, scissoring,
autoLights, manualLightList);
OgreProfileEndGPUEvent(mUsedPass->getParent()->getParent()->getName());
}
}
//-----------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions OgreMain/src/OgreStableHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,22 @@ extern "C" {
#define OGRE_SERIALIZER_VALIDATE_CHUNKSIZE OGRE_DEBUG_MODE
#endif

#if OGRE_PROFILING == 1
#define OgreGpuEventScope(name) GpuEventScope _gpuEventScope(name)
#else
#define OgreGpuEventScope(name)
#endif

namespace Ogre
{
void logMaterialNotFound(const String& name, const String& groupName, const String& destType, const String& destName,
LogMessageLevel lml = LML_CRITICAL);

struct GpuEventScope
{
GpuEventScope(const String& name) { Root::getSingleton().getRenderSystem()->beginProfileEvent(name); }
~GpuEventScope() { Root::getSingleton().getRenderSystem()->endProfileEvent(); }
};
}

#endif

0 comments on commit 80ebd27

Please sign in to comment.