My xna game is running at about 70-90fps and it looks laggy at this fps. I'm using fraps to record the fps and I have a 120hz monitor, over 120hz looks fine but I can't understand why it feels like it's lagging so much at high fps :/.

  • 4
    \$\begingroup\$ We're really going to need more than this information. I can only say that the XNA apps I've made that run at < 100fps still don't look laggy on my machine. \$\endgroup\$ – Roy T. May 7 '12 at 15:29
  • \$\begingroup\$ Explain lag. Does it look choppy (I'd insist that anything north of 50fps or so probably doesn't look choppy, unless you're getting occasional hiccups). If the lag is in the perceived response time (time from the player providing an input to the time it's reflected on screen) I'd believe you, but this wouldn't have much to do with framerate (not at those rates.) \$\endgroup\$ – notlesh May 7 '12 at 15:54
  • \$\begingroup\$ Yes it can look very choppy. I just realized that if I put fixed time step on at 60fps it looks a lot smoother, but without it on I get around 80-90 and it looks very choppy and laggy :/. \$\endgroup\$ – Levi H May 7 '12 at 15:58
  • \$\begingroup\$ What time control would you use if not a constant 60 fps? \$\endgroup\$ – aaaaaaaaaaaa May 7 '12 at 16:04
  • 1
    \$\begingroup\$ And you can remove that accepted mark, we are not done util you understand the cause of the error. Simply finding a setting that solves the issue on your computer without knowing why is pretty much asking for it to resurface in another environment. \$\endgroup\$ – aaaaaaaaaaaa May 7 '12 at 16:55

I think you have some very inconsistent frame times. You can test this by printing out the frame times to a log (or similar) and measuring their jitter.

Edit: If you find that a small number of frames consume substantially more time than most, this is indicative of a performance problem. If this is the case, you need to use a profiler to help you understand where this problem is and fix it.

In general, the faster you try to draw your frames, the more your framerate can be affected by outside factors (such as the OS scheduling CPU time for other tasks, or a function in your game running unusually slow).

At 120 fps, you have 8.33 millis to have your frame drawn. As you are not hitting your 120 fps, it can be assumed that your game can't be run on that hardware at 120 fps, and that it will draw as fast as it can. This means that any extra load on the CPU will necessarily drag your framerate down. In other words, you have no built-in tolerance to fluctuations in CPU load.

I would suggest capping the framerate. If you really want to optimize around the minority of people who have the equipment to draw frames so frequently, allow them to change the max fps in your games's settings, or you can run some analysis on the framerate in your game itself to find an appropriate max.

Capping the framerate at a rate below which it can be drawn provides some "down time" for your game. This can absorb any of the fluctuations mentioned above without affecting your framerate. If you cap it at 60 fps, you have 16.66 millis to draw your frame. If you can draw the frame in 12, you have almost 5 millis for other things to happen without anyone noticing.

If it were me, I'd set it at 60 and be done with it.

  • \$\begingroup\$ Why 60 and not, say, 30? \$\endgroup\$ – ashes999 May 7 '12 at 17:40
  • 1
    \$\begingroup\$ If 60 is no sweat, why limit to 30? If 60 isn't doable, limiting to 30 might be appropriate. \$\endgroup\$ – notlesh May 7 '12 at 17:44
  • \$\begingroup\$ @Levi, see my edit. Don't use my advice to throw a blanket on an underlying problem. \$\endgroup\$ – notlesh May 7 '12 at 19:10
  • \$\begingroup\$ because human eyes cannot perceive much higher than 30, if even that, IIRC \$\endgroup\$ – ashes999 May 7 '12 at 19:11
  • 4
    \$\begingroup\$ @ashes999 That may be true in relation to film where each frame contains some motion blur that helps the brain 'fill in the gaps,' but I think the human eye/brain is much more sensitive when it comes to computer graphics, which essentially provide a rendering of an instantaneous state. Additionally, as framerate decreases, perceived response to input suffers as well. \$\endgroup\$ – notlesh May 7 '12 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.