1
Graphics / Re: stuttering on some hardware, not others
« on: April 15, 2016, 06:26:49 am »
I know I'm digging up an old thread, but I figured I'd mention this for future readers.
I was timing each frame in my game, and they were consistently coming in under 0.5ms. Silky smooth. Every few seconds, I'd get a frame that was 30ms+. This baffled me. I profiled the various parts of my code, and there was no rhyme or reason to why different parts seemed to be randomly taking a long time all of a sudden.
It was the OS switching threads while the frame was in progress.
If you're seeing stuttering, try turning up the process priority. Be careful of course, as you don't want to negatively impact the usability of the machine by making everything else slow. And make sure that you have vsync or a frame limit enabled if you do this, so you don't chew through boundless CPU cycles at a high priority. But I found this change completely fixed the stuttering I was having.
I'm on Windows, and I added the following at the startup of my game:
...and this eliminated practically all of the stuttering. You'll need the Windows API available to you of course to get the above to compile. I still get stuttering when the game doesn't have focus, or when other CPU-intensive processes run. Those cases however are both to be expected, and are acceptable for a game in my opinion.
I was timing each frame in my game, and they were consistently coming in under 0.5ms. Silky smooth. Every few seconds, I'd get a frame that was 30ms+. This baffled me. I profiled the various parts of my code, and there was no rhyme or reason to why different parts seemed to be randomly taking a long time all of a sudden.
It was the OS switching threads while the frame was in progress.
If you're seeing stuttering, try turning up the process priority. Be careful of course, as you don't want to negatively impact the usability of the machine by making everything else slow. And make sure that you have vsync or a frame limit enabled if you do this, so you don't chew through boundless CPU cycles at a high priority. But I found this change completely fixed the stuttering I was having.
I'm on Windows, and I added the following at the startup of my game:
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
...and this eliminated practically all of the stuttering. You'll need the Windows API available to you of course to get the above to compile. I still get stuttering when the game doesn't have focus, or when other CPU-intensive processes run. Those cases however are both to be expected, and are acceptable for a game in my opinion.