video: do not engage Scanline Sync under Sync to Exact Content Framerate

Reported as a regression: G-Sync on with Scanline Sync also on had
worked before this series and now tears and loses A/V sync.

It worked before because Scanline Sync did nothing - it latched itself
off within two seconds of starting, so leaving it enabled alongside
G-Sync was harmless. c9260c895d made it work, and under VRR a working
scanline sync is wrong by construction. The display holds in blanking
until a frame arrives and only then scans it out. "Wait until the beam
reaches line N" therefore waits for a scan that starts when we present;
the phase lock closes on our own output rate and reports it as the
display period. Every frame is delayed, nothing is synchronised.

There is no software-visible signal that VRR is active. Sync to Exact
Content Framerate is the setting a user enables for VRR, and the
RUNLOOP_STATE_MENU throttle already treats it and Scanline Sync as
alternatives, so it is the proxy: when it is set, Scanline Sync clears
its target and does not engage. That restores the pre-series behaviour
for that configuration exactly.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-09-02 05:14:05 +02:00
1 parent 47b6955013
commit 985debc1a4
1 file changed
+21
+21
View File
@@ -6505,6 +6505,27 @@ VIDEO_NOINLINE static void video_driver_scanline_before_frame(video_driver_state
(void)frame_time_target;
(void)core_run_time;
/* Not under variable refresh.
*
* Scanline Sync assumes a display that scans on a fixed period, so
* that "wait until the beam reaches line N" names a moment. Under
* VRR the display holds in blanking until a frame arrives and only
* then scans it out, so the scan this waits for starts when we
* present - the lock closes on our own output rate and calls it the
* display period. That is not a sync, it is a delay on every frame,
* and with G-Sync on it showed as tearing and broken A/V sync where
* the old inert implementation had done nothing and been harmless.
*
* There is no software-visible "VRR is active" signal. Sync to
* Exact Content Framerate is the setting a user turns on for VRR,
* and the RUNLOOP_STATE_MENU throttle already treats it and this as
* alternatives, so it is the proxy. */
if (config_get_ptr()->bools.vrr_runloop_enable)
{
video_st->scanline[SCANLINE_NEXT] = 0;
return;
}
/* Lock on first use. Calibration measures the line count, the period
* and the residual bias together, because a mode change moves all
* three. */