What's new

Auto frameskip

Exophase

Emulator Developer
I know a lot of people have done emulators here, so I was wondering if anyone has done auto-frameskip. I'd love to see some ideas for systems that work best.
 

blueshogun96

A lowdown dirty shame
I've never done auto frameskip, but this is the most logical way that I can think to do it. I'm guessing it's all a matter of the percentage of the current framerate (i.e. actual_framerate/target_framerate). So let's say you are running at 30fps and you want 60fps, since 30 if 50% of 60, try rendering only half of the frames you render every second. Or if you are getting 15 fps out of 60, that's 25%, so try rendering 1 out of every four frames. I haven't actually tried this, but I hope it helps you understand the concept. Also, if I'm wrong, please feel free to correct me. :)
 
OP
E

Exophase

Emulator Developer
I don't think that'll work well, because rendering the frames is not 100% of the computation time. However, I was thinking about it and this might work (I need to try it, should be easy):

Keep two time records, "virtual" time and "real" time. The former would be computed by adding the amount of time that a frame should take every frame. The latter would be computed by measurement. If the latter gets too far behind the former, stop rendering frames until it catches up (or a threshold is reached). Thoughts?
 

Slougi

New member
I'd say that if you notice you are running too slow, drop the fps, and check again if you are running too slow, readjust, etc.

If you can somehow compute or estimate the amount of computation time drawing takes, you could calculate how many frames to drop for the optimal speed.
 
OP
E

Exophase

Emulator Developer
There's a question of what to drop it to, but more importantly, you'd be constantly playing a game if seeing if you are running "just fast enough" - it's easy to drop too many frames and be fine.

The problem with computing how long drawing a frame takes is that often a frame is not drawn all at once, but in scanlines interleaved with emulating the CPU code. You can add up the time for every scanling but then the timing overhead starts getting more serious and you need a lot of precision.

I think that in the end it'll be better to have a method that agressively wants to render every frame and only drops them each on a one by one basis if it has to.
 

Garstyciuks

New member
I would make it to check if it is running too slow. If it is, then increase the frame skip by some amount. If it is still not good, increase more. If it is too fast, decrease the frame skip. I think that's the same that Slougi said.
 

Top