gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
774 stars 180 forks source link

WindowsWGL: use adaptive vsync when supported #2583

Closed Rosalie241 closed 3 years ago

Rosalie241 commented 3 years ago

From https://www.khronos.org/opengl/wiki/Swap_Interval:

if the renderer takes slightly longer than the v-blank intervals to render, say 18ms, then a different problem can result. It will effectively take two full v-blank intervals to display an image to the user, turning a 60fps program into a 30fps program.

I think this behavior is undesirable for end-users, so this patch makes WindowsWGL use adaptive vsync instead (when supported), which works in a different way:

Adaptive vsync enables v-blank synchronisation when the frame rate is higher than the sync rate, but disables synchronisation when the frame rate drops below the sync rate. Disabling the synchronisation on low frame rates prevents the common problem where the frame rate syncs to a integer fraction of the screen's refresh rate in a complex scene.

I personally feel like such behavior is more desirable, because before this patch, some users were complaining that sometimes their game would halve in speed for some time when vsync was enabled due to some slowdown (i.e vsync would force the game at 30 Hz instead of 60 Hz).

oddMLan commented 3 years ago

This might actually solve #1284 #1534, this part sounds suspicious

if the renderer takes slightly longer than the v-blank intervals to render, say 18ms, then a different problem can result. It will effectively take two full v-blank intervals to display an image to the user, turning a 60fps program into a 30fps program.

Because this is the effect it had on me while playing something like Mario Tennis using like 5x-6x resolution factor, the framerate would sometimes stutter/halve. I gotta try this later, see if it had any effect.