Page 1 of 1

Strange framerate fluctation with a specific mesh

Posted: Tue Apr 26, 2011 12:07 pm
by Gorbstein
Hi,

Ran into a bug in my game this week which has had me tearing my hair out.

I enable vsync to keep everything at a steady 60fps. However suddenly my delta time between frames started fluctuating, making the game jerky and unplayable. I started removing parts of my game right to the bare bones where all I had was a standard irrlicht render loop displaying some meshes, and still had the problem.

I tracked it down to a specific mesh file and I don't know why it specifically would cause a problem.

So if I load and display 100 scenenodes with the fighter mesh from Psionic's webpage : http://www.psionic3d.co.uk/?page_id=25 I get big spikes in my deltatime between frames. I logged them like this:

Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.029
Deltatime 0.009
Deltatime 0.009
Deltatime 0.018
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.029
Deltatime 0.009
Deltatime 0.01
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017

The mesh has ~900 tris in 1 group, 1 texture.

If I change one line in my code to replace the mesh filename with another, an asteroid containing 2000 tris, I get a rock steady 60fps.

Deltatime 0.016
Deltatime 0.017
Deltatime 0.017
Deltatime 0.017
Deltatime 0.016
Deltatime 0.016
Deltatime 0.018
Deltatime 0.016
Deltatime 0.018
Deltatime 0.016
Deltatime 0.016
Deltatime 0.018
Deltatime 0.016
Deltatime 0.016
Deltatime 0.017
Deltatime 0.016

Any idea why this would be?

D

Posted: Tue Apr 26, 2011 1:41 pm
by Gorbstein
Hmm even if I use Psionic's Jeep model (2000 tris), I get a solid 60fps. Switch back to his fighter and the juddering is back.

Tried disabling hardware mapping, turned off lighting, converted the .3ds to an .ms3d, changed the texture.. still the same!

Weird!!

D

Posted: Tue Apr 26, 2011 3:02 pm
by greenya
On my ati, when i use vsync, i have 1.6k fps with d3d8, 56 fps with d3d9 and 57 fps with opengl.

Posted: Tue Apr 26, 2011 6:14 pm
by Gorbstein
Its not so much a framerate problem as a consistency problem. It's as if this particular model is causing a stall in the pipeline somewhere every so often.

I can turn vsync off and get avg. 1000FPS, but even then I can still see the stuttering when I use this model.

The reason it's a problem is when I run the game on lower specced machines which run at about 40fps without vsync. Then there's very obvious juddering. Without this model, it still runs at 40ps but it runs smoothly.

Would be useful to know what causes it so I can avoid it.

Posted: Tue Apr 26, 2011 7:14 pm
by greenya
I don't know the reason why this happens. In my apps i just avoid sticking to fps.

Posted: Tue Apr 26, 2011 9:06 pm
by CuteAlien
Maybe output the number of rendered polygons as well to see if those numbers do also fluctuate (with getPrimitiveCountDrawn from the driver). I did run the model on Linux but couldn't reproduce this or see anything special so far.

Posted: Wed Apr 27, 2011 8:22 am
by Gorbstein
Good point about the tri count. It doesn't seem to show anything though, the change in tris is not significant when the pause occurs.

I'm suspecting a driver problem, although I'm sure this happens on my laptop too.. will double check.

Frame 1233:Primitives drawn : 14434, Delta Time : 0.018
Frame 1234:Primitives drawn : 14478, Delta Time : 0.015
Frame 1235:Primitives drawn : 14518, Delta Time : 0.032
Frame 1236:Primitives drawn : 14476, Delta Time : 0.008
Frame 1237:Primitives drawn : 14478, Delta Time : 0.011
Frame 1238:Primitives drawn : 14470, Delta Time : 0.017

Frame 1564:Primitives drawn : 12252, Delta Time : 0.017
Frame 1565:Primitives drawn : 12258, Delta Time : 0.016
Frame 1566:Primitives drawn : 12260, Delta Time : 0.017
Frame 1567:Primitives drawn : 12546, Delta Time : 0.018
Frame 1568:Primitives drawn : 12568, Delta Time : 0.016
Frame 1569:Primitives drawn : 12508, Delta Time : 0.07
Frame 1570:Primitives drawn : 12508, Delta Time : 0.012
Frame 1571:Primitives drawn : 12538, Delta Time : 0.013
Frame 1572:Primitives drawn : 12516, Delta Time : 0.011