Skip to content

Commit ae33976

Browse files
committed
Fix inverted vsync latch from the implicit swapchain present interval
When rtx.enableVsync is in its default WaitingForImplicitSwapchain state, the vsync default is latched from the first swapchain's PresentationInterval with a truthiness check. In D3D9, D3DPRESENT_INTERVAL_IMMEDIATE (the only "present unsynchronized" request) is 0x80000000, i.e. nonzero, so a game explicitly asking for no vsync latches vsync On; D3DPRESENT_INTERVAL_DEFAULT (0), which presents synchronized, latches Off. The two most common values map backwards. A game requesting IMMEDIATE at device creation therefore runs capped to the display refresh with elevated present latency from boot. With DLFG enabled the cap silently clears on the first interpolated 3D frame (dispatchDLFG forces vsync off), which disguises the bug as affecting menus and loading screens only; with DLFG off it persists. The d3d9.presentInterval config cannot help because enableVsyncState overrides the present interval at Present time. Latch Off only for D3DPRESENT_INTERVAL_IMMEDIATE; DEFAULT, ONE and TWO through FOUR latch On, matching D3D9 presentation interval semantics. An explicit rtx.enableVsync user setting still takes precedence.
1 parent 7011b32 commit ae33976

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/d3d9/d3d9_swapchain.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,18 @@ namespace dxvk {
332332

333333
// NV-DXVK start: DLFG integration
334334
if (RtxOptions::enableVsync() == EnableVsync::WaitingForImplicitSwapchain) {
335-
// save the vsync state when the first swapchain is created, to act as the default
336-
RtxOptions::enableVsyncState = m_presentParams.PresentationInterval ? EnableVsync::On : EnableVsync::Off;
335+
// Save the vsync state when the first swapchain is created, to act as the default.
336+
// D3D9 semantics: D3DPRESENT_INTERVAL_IMMEDIATE (0x80000000) is the only
337+
// "present unsynchronized" request; DEFAULT (0), ONE (1) and TWO..FOUR all
338+
// present synchronized to vblank. A plain truthiness check reads IMMEDIATE
339+
// (nonzero) as vsync-On and DEFAULT (zero) as vsync-Off - both inverted -
340+
// which capped games that explicitly request IMMEDIATE at device creation
341+
// to the display refresh until something else flipped the state (e.g.
342+
// DLFG's force-vsync-off on the first interpolated 3D frame).
343+
RtxOptions::enableVsyncState =
344+
(m_presentParams.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE)
345+
? EnableVsync::Off
346+
: EnableVsync::On;
337347
}
338348
// NV-DXVK end
339349

0 commit comments

Comments
 (0)