Frame stutters on Entity add/creation.

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
Nickenstein79
Halfling
Posts: 50
Joined: Tue Sep 18, 2012 3:30 am
x 6

Frame stutters on Entity add/creation.

Post by Nickenstein79 »

Hi. :)

I've just gone through the nightmare of upgrading from stock Ogre_1_8(pre-baked SDK from about 2 years ago) & CEGUI_0_1_7, to using home-compiled Ogre_1_9/CEGUI_0_8_3 via the latest available mercurial repos.

It's been... emotional. ;) (I still need to rework all of my CEGUI xml-based data files into the new formats, and change a boat-load of gamecode, but that's another story.)

My reason for doing this is because I'm currently in a 'profiling & optimising & cleaning' phase with my game.
Basically, I'm spring-cleaning my entire codebase from the ground up before I add any new features.

The thing that has pushed me into the 'tidy-up' phase: Frame stuttering on adding entities to the scenegraph.

My game relies quite heavily on procedural mesh generation for the landscape. To mitigate the problems which that can cause I have shifted the mesh-gen into an asynchronous boost-thread. Finished meshes are then added to the scenegraph by the main thread during a FrameRenderingQueued event.

The problem is, I always get a frame stutter at this stage.

I get frame stutters even if I am only adding tiny meshes (about 300 verts), and even if I ensure that I only upload 1 tiny vert/index buffer to the GPU per frame.
(The stall is the same if I Lock>memcpy>Unlock OR use the Buffer->writeData method. With tiny meshes or HUGE meshes. The problem isn't the GPU upload.)

It seems that these stalls occur during (or shortly after) attaching the finished mesh to a scenenode, or when creating an instance/entity of the (already GPU resident) mesh.

I've noticed that the landscape demos for Ogre suffer from this exact same problem. I'm not using Ogre's landscape systems, but I have the same frame-stutter problem that they do.

So I was wondering if there are any known bottlenecks inside Ogre's scene management code that I should be looking at and tweaking?

Perhaps the adding of a new bounding box is triggering a huge (N ^ N) sort algorithm or something?

Any advice/tips/help would be hugely appreciated. :)