Display.update becomes very slow

Started by CodeBunny, April 25, 2011, 11:59:32

Previous topic - Next topic

CodeBunny

Ordinarily, calling Display.update() on my system takes 0.6-0.9 milliseconds. However, occasionally it starts spiking up, sometimes taking as much as 60 milliseconds. The weird thing is, my actual rendering is taking a fairly constant time, usually on the order of 8 milliseconds, so basically all the slowdown is coming from Display.update().

So... does anyone know what could cause this? Some preliminary testing seems to show that it is related to what I've been rendering - if I don't add any of the enemies in my game, it doesn't seem to occur. However, I'm stuck after that.

CodeBunny

Apparently it takes even longer than 60 ms. I've had it going on 200 milliseconds to update the Display.

Has this ever happened before, to anyone?

Fool Running

The time to render is, I'm assuming, the time it takes your code to call the OpenGL methods? If that is the case then there is something you should know:
Calling OpenGL methods just puts the calls into a queue of sorts in the display driver that the GPU reads from to know what to do next. Display.update() waits until the GPU has finished with the queue. What this means is that the problem is actually, indeed, in what you are rendering. For some reason (I guess when the enemies come on screen), the GPU sometimes has trouble with it.

If you're using shaders, I would check the ones on the enemies to make sure there isn't some code that might cause some problems. Otherwise, make sure that the enemies don't set some state that you forget to turn off for the other rendering that might cause it to slow down.

Hope that helps. ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D