Jump to content
  • Advertisement
Sign in to follow this  
skjinedmjeet

Timing: Hugely frustrating.

This topic is 4843 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

Here's my problem: I'm using QueryPerformanceCounter for timing, and my game does run perfectly framerate independant on a wide variety of systems. Now, the problem is, if I just let the game synchronize to vsync, it runs perfectly smoothly. When using QPC to base timing off of, it runs fine most of the time, but every once in a while, a frame appears to "catch" and then rendering seems to jump ahead a couple of frames. I've experienced the same problem with SDL_GetTicks() and Allegro timers. It's not noticable when I only have a few objects on screen, but when I've got multiple parallaxing backgrounds, it becomes super noticable. Edit: I've just noticed that if I change, in task manager, the priority class to "high" the problem becomes infrequent, borderlining on completely unnoticable - is there a way to force this?

Share this post


Link to post
Share on other sites
Advertisement
AMD Athlon XP 64 3000. I'd be tempted to chalk it up to a processor specific phenomena, except that most games run perfectly on this system.

I logged the delta values (time difference between frames) and noticed this happening:


1.04413
0.958865
1.00033
1.0008
1.00097
1.00231
1.00012
1.0008
1.00057
1.00107
1.00127
1.00124
2.00219 <---- very high value
1.0005
1.00087
1.00109
1.00732
0.995054
1.00065
1.00084
1.00209
1.00028


It happens every now and then, and it seems to directly correlate to my problem.

Share this post


Link to post
Share on other sites
It sounds like your game is getting swapped out so other processes may run a bit, in a noticibly coarse grain - suggesting (to me) that your game is eating up a lot of the CPU. Assuming this is all true, adding the occasional (by which I mean, single, within the body of the game loop) sleep(0) statement or similar may help (e.g. swap out if other processes have a need to execute - note that sleep(0) may be a no-op depending on the exact function called, this is API dependant stuff).

It's not guaranteed to work, but the theory is if other processes get a chance to run more often, chances are they'll have less work to do once they get that chance. It's worth a try, anyways. Chances are this would harm preformance when the user is running (as in, actually running, eating up CPU, not just idling in the background using pagefile space) enough other programs.

All this said, the fact that your example shows a spike to nearly exactly 2.0 (not 1.9 or 2.1) seems a bit fishy, prehaps you've got a bug in your logic code or drivers? Just throwing out suggestions.

Also, since you mention process priorities, I should mention SetPriorityClass. I wouldn't recommend it, but if you want to go down that path, there's information on this functino in The MSDN

HTH

Share this post


Link to post
Share on other sites
This sounds like another process is taking too long. Certain things seem to do this on certain patforms. I'm developing on Debian linux and for me i notice that web pages open that have any kind of flash/java business on them (like those silly animated flash adverts) will chunkify the framerate. I also notice it when i have my System Monitor open, which monitors active processes (including the game and itself). Ironically, it throws in it's own "hiccup" every 3-4 seconds or so.

I suggest closing every other non-critical application open on your system and seeing if that helps first.

Share this post


Link to post
Share on other sites
sleep(0); has definitely helped a bit, it still chunks every once in a while, but if I turn off other applications it seems to do okay. Thanks for the help, dudes!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!