After a longer break from Ogre I restarted development of my game. While chasing bugs in my linux builds (which turned out to be Cg issues with the vp30/fp30 profiles) I upgraded ogre from 1.7.something to 1.8.tip. This broke something badly as it appears that the "render queues" are not cleared properly anymore (ie each new rendered frame adds new batches, overlays dont disappear when hidden but are still rendered with the old data, fps goes constantly down) Upgrading further to 1.9.tip didn't change the behaviour. I have not found anything in the porting notes, nor did google search turn up something useful so I cut out more and more of my game. But even doing a very basic test that just renders a skydome and an fps overlay with the default SM and render loop now exhibits that behaviour (self compiled ogre 1.9 on windows, packaged 1.8 and 1.9 releases on linux) so i suspect that is not a bug in ogre but that I am missing something obvious. (and the ogre demos in the windows build seem to work fine)
Anyone having a clue what could be wrong? I'm quite baffled and out of clues how to proceed next. Will try to clean up the test to work with the samples media files and make that available unless someone has an idea what is going on...
Odd problem with increasing batch count
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
Re: Odd problem with increasing batch count
Test files included:
Batch.h
Batch.cpp
OgreDebugPanel.overlay:
If I compile this under linux (packaged ogre 1.9) with
the program exihibits the described behaviour.
Thanks in advance
Batch.h
Code: Select all
#include <OGRE/Ogre.h>
#include <OGRE/Overlay/OgreOverlaySystem.h>
class BatchListener : public Ogre::FrameListener
{
public:
BatchListener( Ogre::RenderWindow * win );
~BatchListener();
bool frameEnded( Ogre::FrameEvent const & evt );
protected:
Ogre::RenderWindow * mWindow;
};
class BatchApplication
{
public:
BatchApplication( void );
~BatchApplication( void );
void go( void );
protected:
Ogre::Root * mRoot;
Ogre::RenderWindow * mWindow;
Ogre::SceneManager * mSceneMgr;
Ogre::OverlaySystem * mOverlaySystem;
Ogre::Camera * mCamera;
BatchListener * mFrameListener;
};
Code: Select all
#include "Batch.h"
BatchListener::BatchListener( Ogre::RenderWindow * win ) :
mWindow( win )
{
}
BatchListener::~BatchListener( void )
{
}
bool BatchListener::frameEnded( Ogre::FrameEvent const & evt )
{
static std::string currFps = "Current FPS: ";
static std::string avgFps = "Average FPS: ";
static std::string bestFps = "Best FPS: ";
static std::string worstFps = "Worst FPS: ";
static std::string tris = "Tri/Batch Count: ";
if ( Ogre::OverlayManager::getSingleton().getByName( "Core/DebugOverlay" )->isVisible() )
{
Ogre::RenderTarget::FrameStats const & stats = mWindow->getStatistics();
Ogre::OverlayElement * guiAvg = Ogre::OverlayManager::getSingleton().getOverlayElement( "Core/AverageFps" );
guiAvg->setCaption( avgFps + Ogre::StringConverter::toString( stats.avgFPS ) );
Ogre::OverlayElement * guiCurr = Ogre::OverlayManager::getSingleton().getOverlayElement( "Core/CurrFps" );
guiCurr->setCaption( currFps + Ogre::StringConverter::toString( stats.lastFPS ) );
Ogre::OverlayElement * guiBest = Ogre::OverlayManager::getSingleton().getOverlayElement( "Core/BestFps" );
guiBest->setCaption( bestFps + Ogre::StringConverter::toString( stats.bestFPS )
+ " " + Ogre::StringConverter::toString( stats.bestFrameTime ) + " ms" );
Ogre::OverlayElement * guiWorst = Ogre::OverlayManager::getSingleton().getOverlayElement( "Core/WorstFps" );
guiWorst->setCaption( worstFps + Ogre::StringConverter::toString( stats.worstFPS )
+ " " + Ogre::StringConverter::toString( stats.worstFrameTime ) + " ms" );
Ogre::OverlayElement * guiTris = Ogre::OverlayManager::getSingleton().getOverlayElement( "Core/NumTris" );
guiTris->setCaption( tris + Ogre::StringConverter::toString( stats.triangleCount ) + "/" + Ogre::StringConverter::toString( stats.batchCount ));
}
return true;
}
BatchApplication::BatchApplication( void ) :
mRoot( 0 ),
mWindow( 0 ),
mSceneMgr( 0 ),
mOverlaySystem( 0 ),
mCamera( 0 ),
mFrameListener( 0 )
{
}
BatchApplication::~BatchApplication( void )
{
}
void BatchApplication::go( void )
{
mRoot = new Ogre::Root( "plugins.cfg", "ogre.cfg", "Ogre.log" );
if( mRoot->showConfigDialog() )
{
mWindow = mRoot->initialise( true, "batch" );
}
else
{ return; }
mSceneMgr = new Ogre::DefaultSceneManager( "sm" );
mSceneMgr->_setDestinationRenderSystem( Ogre::Root::getSingleton().getRenderSystem() );
mOverlaySystem = new Ogre::OverlaySystem();
mSceneMgr->addRenderQueueListener( mOverlaySystem );
mCamera = mSceneMgr->createCamera( "cam" );
Ogre::Viewport * vp = mWindow->addViewport( mCamera );
vp->setBackgroundColour( Ogre::ColourValue::Black );
mCamera->setAspectRatio( Ogre::Real( vp->getActualWidth() ) / Ogre::Real( vp->getActualHeight() ) );
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load("resources.cfg");
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::Plane plane;
plane.d = 2000;
plane.normal = -Ogre::Vector3::UNIT_Y;
mSceneMgr->setSkyPlane( true, plane, "Examples/CloudySky", 500, 15, true, 0.1f, 10 ,10 );
mFrameListener= new BatchListener( mWindow );
mRoot->addFrameListener( mFrameListener );
Ogre::OverlayManager::getSingleton().getByName( "Core/DebugOverlay" )->show();
mRoot->startRendering();
}
int main( int argc, char * argv[] )
{
BatchApplication * app = 0;
try
{
app = new BatchApplication();
app->go();
delete app;
app = 0;
}
catch ( Ogre::Exception & e )
{
std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl;
}
return 0;
}
Code: Select all
// Ogre overlay scripts
Core/DebugOverlay
{
zorder 500
// Stats block
container BorderPanel(Core/StatPanel)
{
metrics_mode pixels
vert_align bottom
left 5
top -92
width 220
height 87
material Core/StatsBlockCenter
border_size 1 1 1 1
border_material Core/StatsBlockBorder
border_topleft_uv 0.0000 1.0000 0.0039 0.9961
border_top_uv 0.0039 1.0000 0.9961 0.9961
border_topright_uv 0.9961 1.0000 1.0000 0.9961
border_left_uv 0.0000 0.9961 0.0039 0.0039
border_right_uv 0.9961 0.9961 1.0000 0.0039
border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000
border_bottom_uv 0.0039 0.0039 0.9961 0.0000
border_bottomright_uv 0.9961 0.0039 1.0000 0.0000
container Panel(Core/BreakPanel)
{
metrics_mode pixels
left 5
top 22
width 210
height 1
material Core/StatsBreak
}
element TextArea(Core/CurrFps)
{
metrics_mode pixels
left 5
top 5
width 90
height 30
font_name SdkTrays/Caption
char_height 19
caption Current FPS:
colour_top 1 1 0.7
colour_bottom 1 1 0.7
}
element TextArea(Core/AverageFps)
{
metrics_mode pixels
left 5
top 25
width 90
height 30
font_name SdkTrays/Caption
char_height 16
caption AVERAGE FPS:
colour_top 0.5 0.7 0.5
colour_bottom 0.3 0.5 0.3
}
element TextArea(Core/WorstFps)
{
metrics_mode pixels
left 5
top 40
width 90
height 30
font_name SdkTrays/Caption
char_height 16
caption WORST FPS:
colour_top 0.5 0.7 0.5
colour_bottom 0.3 0.5 0.3
}
element TextArea(Core/BestFps)
{
metrics_mode pixels
left 5
top 55
width 90
height 30
font_name SdkTrays/Caption
char_height 16
caption BEST FPS:
colour_top 0.5 0.7 0.5
colour_bottom 0.3 0.5 0.3
}
element TextArea(Core/NumTris)
{
metrics_mode pixels
left 5
top 70
width 90
height 30
font_name SdkTrays/Caption
char_height 16
caption Triangle Count:
colour_top 0.5 0.7 0.5
colour_bottom 0.3 0.5 0.3
}
element TextArea(Core/DebugText)
{
metrics_mode pixels
left 230
top 70
width 200
height 30
font_name SdkTrays/Caption
char_height 16
colour_top 0.5 0.7 0.5
colour_bottom 0.3 0.5 0.3
}
}
}
Code: Select all
g++ Batch.cpp -I/usr/include/OGRE -lOgreMain -lboostystem -lOgreOverlay
Thanks in advance
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
Re: Odd problem with increasing batch count
Still haven't gotten anywhere ...
Since my program was working fine in this regard with ogre 1.7 I compiled the previously posted sample files in an old VM with packaged ogre 1.7.4 (commenting out the unneeded overlay system init) and it works as expected (staying rock solid at 10 rendered batches, stable framerates).
I looked through the 1.8 (first version to show the defect) porting notes twice and have not found anything that explains the changed behaviour. Using ogre supplied overlays, skyplanes, SM and render loop an error on my side could only be in the library setup that was adapted from old sample files and worked flawlessy for several ogre versions ....
I really could use a second set of eyes.
Since my program was working fine in this regard with ogre 1.7 I compiled the previously posted sample files in an old VM with packaged ogre 1.7.4 (commenting out the unneeded overlay system init) and it works as expected (staying rock solid at 10 rendered batches, stable framerates).
I looked through the 1.8 (first version to show the defect) porting notes twice and have not found anything that explains the changed behaviour. Using ogre supplied overlays, skyplanes, SM and render loop an error on my side could only be in the library setup that was adapted from old sample files and worked flawlessy for several ogre versions ....
I really could use a second set of eyes.
- c6burns
- Beholder
- Posts: 1512
- Joined: Fri Feb 22, 2013 4:44 am
- Location: Deep behind enemy lines
- x 138
Re: Odd problem with increasing batch count
Yes there are issues with this. My advice is to move to v1-9 head and start with the tutorial framework: http://www.ogre3d.org/tikiwiki/Ogre+Wik ... +Framework
I can tell you for sure that initializing Ogre the way it's done in the framework does not result in the issues you are experiencing. Whether this is due to the difference in the way root creates the scene manager, or the fact that it will use the octree scene manager and not the default one ... I can't say. But even if you just made this small change:
Your problem will likely dissappear.
I can tell you for sure that initializing Ogre the way it's done in the framework does not result in the issues you are experiencing. Whether this is due to the difference in the way root creates the scene manager, or the fact that it will use the octree scene manager and not the default one ... I can't say. But even if you just made this small change:
Code: Select all
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
//mSceneMgr->_setDestinationRenderSystem( Ogre::Root::getSingleton().getRenderSystem() );
-
- Greenskin
- Posts: 125
- Joined: Mon Oct 20, 2003 8:25 pm
Re: Odd problem with increasing batch count
Thanks for taking the time to look into it. Ironically I was just stopping by to tag the thread solved as I investigated this problem once more yesterday.
The problem was indeed the manual creation of the scene manager. When creating the scenemanager through Root ScenemanagerEnumerator keeps a list of all created SceneManagers around and Ogre uses an Iterator over this list to clear the render queues after each frame. Since there is no official way to add a manually created SM to this list I made the container in ScenemanagerEnumerator public and amended my setup/shutdown code.
The problem was indeed the manual creation of the scene manager. When creating the scenemanager through Root ScenemanagerEnumerator keeps a list of all created SceneManagers around and Ogre uses an Iterator over this list to clear the render queues after each frame. Since there is no official way to add a manually created SM to this list I made the container in ScenemanagerEnumerator public and amended my setup/shutdown code.