Jump to content
  • Advertisement
Sign in to follow this  
japro

Unreasonable frame times in XNA

This topic is 2506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Thank you. It seems the issue mostly exists in the case of vsync + nonfullscreen. I guess there is some sort of aliasing issue.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!