stuttering problem

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

stuttering problem

Post by ghiboz »

hi all!
I have this problem with my project:
[youtube]ZdbMx-1A-00[/youtube]
as you see at 5" circa: you can see a big stuttering, and the fps doesn't are affected, the tri count is like freezed and after it restarts,
after seems that if I go back and remake the same route, the stuttering doesn't appear.

my situation is:

ogre 1.9 (from bitbucket) , I use

Code: Select all

startRendering();
but also using

Code: Select all

renderOneFrame();
the situation is the same.

I use all static geometries: I load a dotscene with DotSceneLoader class and after, when all the scene is loaded, I calculate the AABB box and I subdivide by100 units, after, ciclyng by all the entities loaded, I create a single staticgeometry for each 'cell grid'.
If the entity is more big than the cell grid, I create a staticgeometry apart.

last but not least, the 0,0,0 world position is just before the starting line.

another test that I done , before the build command, I made setRenderingDistance(10.0), but nothing is changed (seems that is not considered)

thanks again
xelon
Halfling
Posts: 91
Joined: Mon Jan 07, 2013 4:24 am
x 13

Re: stuttering problem

Post by xelon »

What physics library are you using?
Does the stuttering only happens when you move the vehicle? If yes, Are you doing any update calculations for every x distance the vehicle has traveled?
Edit: One thing I would suggest is to profile your application and see where the bottleneck is.
Ludoria now on Kickstarter! Ludoria is now on KickStarter! https://www.kickstarter.com/projects/17 ... g-rpg-game
Ludoria's official website http://www.Ludoria.com
On Facebook https://www.facebook.com/pages/Ludoria/644733108967479
On Twitter https://twitter.com/LudoriaGame
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

thanks xelon!
the physics is not possible, 'cause is into a completely different thread, if there's a physics problem, may be you loose a position, but the render stats still continue as usual.
thanks to @scrawl, I preloaded all the shaders (i'm using shiny) and the things goes better but the problem is still alive
maybe a mesh loading problem?
NotCamelCase
Greenskin
Posts: 140
Joined: Sun Feb 03, 2013 6:32 pm
x 8

Re: stuttering problem

Post by NotCamelCase »

Are you using Bullet Physics ? I'd observed a similar stuttering in debug builds especially from time to time but improved it by profiling as suggested and rearranging physics update functions though mine is single-threaded ATM.
Check out my projects: https://github.com/NotCamelCase
xelon
Halfling
Posts: 91
Joined: Mon Jan 07, 2013 4:24 am
x 13

Re: stuttering problem

Post by xelon »

One more thing to check is your mesh loading. Are you pre-loading all the meshes prior to the game start? loading meshes for the first time during the in-game state will cause a significant stuttering because they have to be loaded from the main thread.
Ludoria now on Kickstarter! Ludoria is now on KickStarter! https://www.kickstarter.com/projects/17 ... g-rpg-game
Ludoria's official website http://www.Ludoria.com
On Facebook https://www.facebook.com/pages/Ludoria/644733108967479
On Twitter https://twitter.com/LudoriaGame
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: stuttering problem

Post by areay »

Yes, I also think it's caused by on-the-fly mesh loading. When you reverse back to the scene after getting to the start line there is no stuttering.

Add this before you start rendering

Code: Select all

Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

thanks to all,
i've found the problem, but not the solution:
here is my flow:
* load all the resources:
* init the resources using Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

is not a mesh problem, but a texture problem: i've logged the frames that have a big time and here is the log:

05/12/2014 15:14:05,514 [ERROR] AppStateManager.cpp:90 Time too long!! > 20:249 @:0.96744

and looking the ogre log:

15:14:05: D3D9 : Loading 2D Texture, image name : 'parete_rocciosa_1_D.dds' with 8 mip map levels

if I change the texture to a very small texture, the stutter doesn't appear... but is not a solution!
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: stuttering problem

Post by syedhs »

What is the texture dimension?
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

the texture is 2048x2048, is DXT1 and is 2Mb.

I'm using shiny and, with the help of scrawl I've preloaded all the materials, but some strange stutter appears again... I'll try to log something again and I show you some news....
if someone have some idea... :)
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: stuttering problem

Post by amartin »

Drop the number of MipMap levels or pregenerate the LOD for a texture that large. Each mipmap level is another slightly less detailed copy of the texture so you are creating a lot of copies of a very large texture when you do actually load it. It's also important to know that there is a 2 stage resource loading. Loading the resource into the resource manager just makes it available for the system to use. It won't be fully loaded into graphics until it's actually assigned to something in the scene. From your log I don't think it's creating the mipmaps until the texture hits the scene but you might be able to force it earlier from either the by retrieving the texture or the material from the relevant managers though you'll have to look at the docs for that.
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

so: this is my material:

Code: Select all

material parete_rocciosa_1
{
	parent grsDN
	ambient 1 1 1 1
	diffuse 1 1 1 1
	specular 0 0 0 0 25.5
	emissive 0 0 0 1
	diffuseMap textures/parete_rocciosa_1_D.dds
	normalMap textures/Parete_Rocciosa1_NM.dds
}
and I load all the meshes, after I preload all the materials with this code:

Code: Select all

	void Factory::preloadMaterials(const std::string& configuration)
	{
		for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it)
		{
			std::string matName  = it->second.getName();
			_ensureMaterial(matName, configuration);
			static_cast<sh::OgreMaterial*>(it->second.getMaterial())->getOgreMaterial()->load();
		}
		LOG(INFO) << "All materials preloaded for configuration " << configuration;
	}
and looking the log:

Code: Select all

11:19:34: D3D9 : Loading 2D Texture, image name : 'textures/parete_rocciosa_1_D.dds' with 8 mip map levels
11:19:39: D3D9 : Loading 2D Texture, image name : 'textures/Parete_Rocciosa1_NM.dds' with 8 mip map levels
11:19:40: [INFO ] All materials preloaded for configuration Default
and after there's some little stutter...
so when the log tells that the 2d texture is loaded means that ogre open the file and put it into the memory, but it uses only when the mesh is visible?
if I go back to my road and I remake the drive, the stutter doesn't appear... this seems to assume that the texture is used only when the mesh is visible is true...
I don't use the LOD, but imho doesn't fix the problem, 'cause when it loads the texture (big) some stutter may appears..

it's not possible force OGRE to use the textures when it starts?

thanks in advance :)
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: stuttering problem

Post by amartin »

I think the stutter is moving the 5mb worth of textures from memory to graphical memory. You have two large textures each with an additional 8 levels of detail there. They are managed by the texture manager so you can try iterating through that and loading them like you did the material manager. I'd also try turning off the mip maps for those two textures I'm not sure you want automatic down sampling on something with a normal map. If you are still stuck I'll have a look through some stuff when I have more time.
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

thanks amartin,
the problem is not only by these 2 textures, I have almost 200mb of textures..
I've checked that before and after the stutter:
MemoryBudget: 4294967295
MemoryUsage: 490007112
Stutter
MemoryBudget: 4294967295
MemoryUsage: 490007112

so, correctly the textures are all preloaded, but probabily are into the memory and not to graphical...
how can I send a texture to the graphical?
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: stuttering problem

Post by amartin »

Ok finally had some time to dig around in the code. There is a method on the resource class virtual void loadImpl(void).

Get the textures and call that on them that method will go through and create all the directX resources for them. If that doesn't work then I think you'll have to actually attach a profiler to your project and find out where the bottleneck is. There is a limit to what can be done by guessing and really profile it then fix is the proper way of solving your issue.
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2
Contact:

Re: stuttering problem

Post by ghiboz »

I've made another test:
the loadimpl I don't know how to use, 'cause is protected...

I've made this test: I create a staticgeometry depending by a grid, so if the grid compact all the meshes in one single geometry, the fps are low but I don't have stuttering, if I subdivide only in 2 meshes, when the second mesh is rendered, the stutter appear....

The last idea is to put the camera in an angle of the bbox of the scene, set the camera far distance that cover all the scene, to led a render just one frame of all the scene, and after go back to the classic visual...

any other ideas?

thanks
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: stuttering problem

Post by syedhs »

Yes of course when staticgeometry is divided into regions, it caused stutter because Ogre tries to build a second set of staticgeometry (second bucket I think). One solution is to set the region radius so that Ogre in the end, just generate one bucket. Or trim down those entities' triangles to a low enough count eg < 500 so that the build-up time is negligible.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: stuttering problem

Post by areay »

Getting back to your stuttering on load and forcing Ogre to actually send textures to the GPU.

I've heard of people doing things like overlaying a fullscreen loading screen as a GUI element then moving the camera around and rendering single frames. The frames aren't seen by the user due to the overlay but the GPU is doing real work anyway.

So your startup would look like this

1. Display the 'loading' overlay
2. Create your scene.
3. Set the camera to the starting position.
4. Render a single frame.
5. Rotate the camera 90 degrees around the y-axis.
6. Render a single frame.
7. Rotate the camera a further 90 degrees around the y-axis.
8. Render a single frame.
9. Rotate the camera a further 90 degrees around the y-axis.
10. Reset the camera.
11. Hide the 'loading' overlay
12. Go!

Doing this means that all the textures/models that the player can see at the start will be loaded in the GPU. This should mean less stuttering. You can of course move the camera around as well but you get the idea.

If there are 200MB of textures that get loaded only on some event then you'll need to create this event while in loading-mode to get that cached too.

Hope that helps.
Post Reply