Frames shown as soon as presented, underwater shader back, warm-up restart only with frame generation
- Swap chain: DXGI's tearing support where the system has it, so a focused window (independent flip) no longer waits for each refresh, about 2 fps more in front. VICTORY_TEARING=0 turns it off; a refused present of that kind falls back to presenting at the next refresh for the rest of the run, and is logged. - Shaders: a program that has no wave32 lowering with the loop step on (VICTORY_LOOPS_WAVE) is translated again without it, so the water compute shader 926c46bab3b86bd6 runs again (black or missing water underwater, #539, #570). - The first start of a new exe restarts by itself only when DLSS frame generation is ready or on; without it a first run plays at full speed. - F1: turning frame generation on in a run started without it says "RESTART REQUIRED TO ENABLE FRAME GENERATION". Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b4e1b08245
commit
8fc22547c8
4 files changed
+127
-4
No files matched your search
@@ -9638,6 +9638,41 @@ struct Presenter {
|
||||
notice: panel::Notice,
|
||||
/// The F1 settings menu.
|
||||
menu: menu::Menu,
|
||||
/// The swap chain lets a frame be shown at once ([`tearing`]): its flags, kept for
|
||||
/// ResizeBuffers, which may not change them.
|
||||
tearing: bool,
|
||||
/// Presents ask for that; off for the rest of the run once one such present is refused.
|
||||
presents_tearing: bool,
|
||||
/// A refused present was logged.
|
||||
present_refused: bool,
|
||||
}
|
||||
|
||||
/// Whether the swap chain lets a frame be shown as soon as it is presented, not at the screen's
|
||||
/// next refresh (`DXGI_FEATURE_PRESENT_ALLOW_TEARING`; `VICTORY_TEARING=0`: not). Without it a
|
||||
/// window in front, which Windows then shows without its compositor ("independent flip"), had
|
||||
/// each frame wait for a refresh with two buffers: frame times rounded up to whole refreshes,
|
||||
/// about 2 fps fewer than the same window behind another (2026-11-28). On a G-SYNC or FreeSync
|
||||
/// screen nothing tears; on others a frame may.
|
||||
fn tearing(factory: &IDXGIFactory2) -> bool {
|
||||
if std::env::var("VICTORY_TEARING").is_ok_and(|v| v.trim() == "0") {
|
||||
return false;
|
||||
}
|
||||
let Ok(factory) = factory.cast::<IDXGIFactory5>() else { return false };
|
||||
let mut allowed = windows::core::BOOL(0);
|
||||
// SAFETY: a BOOL-sized answer for this feature.
|
||||
let asked = unsafe {
|
||||
factory.CheckFeatureSupport(
|
||||
DXGI_FEATURE_PRESENT_ALLOW_TEARING,
|
||||
(&raw mut allowed).cast(),
|
||||
size_of_val(&allowed) as u32,
|
||||
)
|
||||
};
|
||||
asked.is_ok() && allowed.as_bool()
|
||||
}
|
||||
|
||||
/// The swap chain's flags for [`tearing`].
|
||||
fn chain_flags(tearing: bool) -> DXGI_SWAP_CHAIN_FLAG {
|
||||
if tearing { DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING } else { DXGI_SWAP_CHAIN_FLAG(0) }
|
||||
}
|
||||
|
||||
/// The frame rate, shown in the window's caption every second and logged
|
||||
@@ -10240,7 +10275,7 @@ impl Host {
|
||||
// SAFETY: no back buffer is held; every submission was waited for.
|
||||
let resized = unsafe {
|
||||
p.swap_chain
|
||||
.ResizeBuffers(BUFFERS, width, height, format, DXGI_SWAP_CHAIN_FLAG(0))
|
||||
.ResizeBuffers(BUFFERS, width, height, format, chain_flags(p.tearing))
|
||||
};
|
||||
match resized {
|
||||
Ok(()) => {
|
||||
@@ -10478,7 +10513,17 @@ impl Host {
|
||||
},
|
||||
);
|
||||
let called = crate::streamline::present_called(&presenting);
|
||||
let _ = p.swap_chain.Present(0, DXGI_PRESENT(0));
|
||||
let shown = p.swap_chain.Present(0, if p.presents_tearing { DXGI_PRESENT_ALLOW_TEARING } else { DXGI_PRESENT(0) });
|
||||
if shown.is_err() && p.presents_tearing {
|
||||
// A white window on an RTX 5070 at 1440p (2026-11-28): presents that may tear
|
||||
// were not shown. The rest of the run presents at the next refresh.
|
||||
tracing::warn!(code = %shown, frame, "a present shown at once was refused; presenting at the next refresh for the rest of the run");
|
||||
p.presents_tearing = false;
|
||||
let _ = p.swap_chain.Present(0, DXGI_PRESENT(0));
|
||||
} else if shown.is_err() && !p.present_refused {
|
||||
p.present_refused = true;
|
||||
tracing::warn!(code = %shown, frame, "a present was refused (logged once)");
|
||||
}
|
||||
crate::streamline::present_returned(called);
|
||||
crate::streamline::present_ends(presenting);
|
||||
showing.next("the frame meter");
|
||||
@@ -10515,6 +10560,8 @@ impl Host {
|
||||
// SAFETY: plain object creation for our window.
|
||||
unsafe {
|
||||
let factory: IDXGIFactory2 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0))?;
|
||||
let tearing = tearing(&factory);
|
||||
tracing::info!(tearing, "swap chain: frames shown as soon as presented (VICTORY_TEARING=0: at the next refresh)");
|
||||
let desc = DXGI_SWAP_CHAIN_DESC1 {
|
||||
Width: width,
|
||||
Height: height,
|
||||
@@ -10526,6 +10573,7 @@ impl Host {
|
||||
BufferUsage: DXGI_USAGE_RENDER_TARGET_OUTPUT,
|
||||
BufferCount: BUFFERS,
|
||||
SwapEffect: DXGI_SWAP_EFFECT_FLIP_DISCARD,
|
||||
Flags: chain_flags(tearing).0 as u32,
|
||||
..Default::default()
|
||||
};
|
||||
// FSR 3 frame generation (where DLSS Frame Generation does not
|
||||
@@ -10576,6 +10624,9 @@ impl Host {
|
||||
panel: panel::Panel::new(),
|
||||
notice: panel::Notice::new(),
|
||||
menu: menu::Menu::new(),
|
||||
tearing,
|
||||
presents_tearing: tearing,
|
||||
present_refused: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user