Skip to main content
gamedev.net
🔒 Locked

Unreasonable frame times in XNA

Started by japro 2 replies 1.9k views
Original Post
japro
japro
So I figured I'd look into XNA/C# to widen my horizon. Now everything went smoothly until I changed the resolution of my Program. At the time I was only displaying 3 sprites and it went all choppy. Full screen on the other hand seems ok'ish again. Even an "empty" program has bad performance. I just checked that by creating a XNA project and inserting:

graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;
graphics.IsFullScreen = false;
graphics.ApplyChanges();

this.IsFixedTimeStep = false;

into the Initialize function and

System.Console.WriteLine(gameTime.ElapsedGameTime.TotalMilliseconds);

into the Update function.
This outputs wildly varying times in the range 20-50ms.
Hardware shouldn't be an issue since a i5-580m and a GTX260m should be plenty.

Not changing resolution or going fullscreen gives ok performance. Weirdly it still seems to be vsynced even with IsFixedTimestep = false.
DJTN
DJTN
I'm not well versed in XNA but I would first narrow down if the frame rate influx was GPU or CPU related. I'd also make sure the video card drivers were up to date and then I would use PIX to profile the application. The profile should give you a better idea of where the problem is occuring and when.

Also, does this influx happen in the release configuration or only in debug? I've had framerate drops in debug mode and then the release build was fine.
Hazard_X
Hazard_X

Weirdly it still seems to be vsynced even with IsFixedTimestep = false.


I'm not sure what the issue may be in general, but i can help you with this one. IsFixedTimestep is not VSync. It just guarantees that the Update Function is called 60 times per second, independent of framerate, even if you get less rendered frames.
To turn off VSync add this line to your code:

graphics.SynchronizeWithVerticalRetrace = false;


With both IsFixedTimestep and SynchronizeWithVerticalRetrace turned off you should get very high FPS.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.