Skip to content

Commit

Permalink
style fixes and change cameraPassCountPerGpuFlush to 0
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jul 19, 2021
1 parent b7d7d63 commit 7ef48f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions include/ignition/rendering/Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,9 @@ namespace ignition
///
/// \code
/// scene->PreRender();
/// for( auto& camera in cameras )
/// for (auto &camera in cameras)
/// camera->Render();
/// for( auto& camera in cameras )
/// for (auto &camera in cameras)
/// camera->PostRender();
/// scene->PostRender();
/// \endcode
Expand Down
42 changes: 22 additions & 20 deletions ogre2/src/Ogre2Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ignition::rendering::Ogre2ScenePrivate
public: uint32_t currNumCameraPasses = 0u;

/// \brief Flag to indicate if we should flush GPU very often (per camera)
public: uint8_t cameraPassCountPerGpuFlush = 6u;
public: uint8_t cameraPassCountPerGpuFlush = 0u;

/// \brief Name of shadow compositor node
public: const std::string kShadowNodeName = "PbsMaterialsShadowNode";
Expand Down Expand Up @@ -191,12 +191,12 @@ void Ogre2Scene::PreRender()
}
}

UpdateShadowNode();
this->UpdateShadowNode();
}

BaseScene::PreRender();

if (!LegacyAutoGpuFlush())
if (!this->LegacyAutoGpuFlush())
{
auto engine = Ogre2RenderEngine::Instance();
engine->OgreRoot()->_fireFrameStarted();
Expand Down Expand Up @@ -224,16 +224,18 @@ void Ogre2Scene::PostRender()
}
else
{
if (dataPtr->currNumCameraPasses > 0u)
FlushGpuCommandsAndStartNewFrame(0u, true);
if (this->dataPtr->currNumCameraPasses > 0u)
{
this->FlushGpuCommandsAndStartNewFrame(0u, true);
}
else
{
// Every camera already calls FlushGpuCommandsAndStartNewFrame(false)
// right after rendering. So likely commands are already flushed.
//
// If we're here then we are only missing to perform the last step of
// FlushGpuCommandsAndStartNewFrame in order to start a new frame
EndFrame();
this->EndFrame();
}
}
}
Expand All @@ -250,8 +252,8 @@ void Ogre2Scene::StartForcedRender()
//////////////////////////////////////////////////
void Ogre2Scene::EndForcedRender()
{
dataPtr->currNumCameraPasses = 0;
FlushGpuCommandsOnly();
this->dataPtr->currNumCameraPasses = 0u;
this->FlushGpuCommandsOnly();

if (this->LegacyAutoGpuFlush() || !this->dataPtr->frameUpdateStarted)
{
Expand Down Expand Up @@ -279,27 +281,27 @@ void Ogre2Scene::StartRendering()
}
else
{
IGN_ASSERT( this->dataPtr->frameUpdateStarted == true,
"Started rendering without first calling Scene::PreRender. "
"See Scene::SetCameraPassCountPerGpuFlush for details");
IGN_ASSERT(this->dataPtr->frameUpdateStarted == true,
"Started rendering without first calling Scene::PreRender. "
"See Scene::SetCameraPassCountPerGpuFlush for details");
}
}

//////////////////////////////////////////////////
void Ogre2Scene::FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses,
bool _startNewFrame)
{
dataPtr->currNumCameraPasses += _numPasses;
this->dataPtr->currNumCameraPasses += _numPasses;

if (dataPtr->currNumCameraPasses >= dataPtr->cameraPassCountPerGpuFlush ||
_startNewFrame)
if (this->dataPtr->currNumCameraPasses >= dataPtr->cameraPassCountPerGpuFlush
|| _startNewFrame)
{
dataPtr->currNumCameraPasses = 0;
FlushGpuCommandsOnly();
this->dataPtr->currNumCameraPasses = 0u;
this->FlushGpuCommandsOnly();

// Legacy mode requires to do EndFrame here every time
if (dataPtr->cameraPassCountPerGpuFlush == 0u || _startNewFrame)
EndFrame();
this->EndFrame();
}
}

Expand Down Expand Up @@ -341,8 +343,8 @@ void Ogre2Scene::EndFrame()
auto itor = ogreRoot->getSceneManagerIterator();
while (itor.hasMoreElements())
{
Ogre::SceneManager *sceneManager = itor.getNext();
sceneManager->clearFrameData();
Ogre::SceneManager *sceneManager = itor.getNext();
sceneManager->clearFrameData();
}

ogreRoot->_fireFrameEnded();
Expand Down Expand Up @@ -1158,7 +1160,7 @@ void Ogre2Scene::CreateContext()

// See ogre doxygen documentation regarding culling methods.
// In some cases you may still want to use single thread.
// if( numThreads > 1 )
// if (numThreads > 1)
// threadedCullingMethod = Ogre::INSTANCING_CULLING_THREADED;
// Create the SceneManager, in this case a generic one
this->ogreSceneManager = root->createSceneManager(Ogre::ST_GENERIC,
Expand Down

0 comments on commit 7ef48f3

Please sign in to comment.