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:
trustno1-coderandClaude Opus 5.5 committed 2026-11-27 18:44:17 -08:00
1 parent b4e1b08245
commit 8fc22547c8
4 files changed
+127 -4

No files matched your search

+53 -2
View File
@@ -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,
})
}
}
+33
View File
@@ -102,6 +102,15 @@ const ABOUT_NO_DLSS: [&str; 3] = [
"DOWNLOADED FROM NVIDIA ON GITHUB AT THE NEXT START",
"(ABOUT 70 MB, ONCE). SAVE AND RESTART NOW DOES IT.",
];
/// Frame generation that this run did not start with: it is made ready only at a start with it
/// on (a start with it ready but off held some PCs at 14 fps, #515, #574), so turning it on takes
/// a restart; a run started with it on changes it, or turns it off, live.
const ABOUT_FRAMEGEN_RESTART: [&str; 3] = [
"RESTART REQUIRED TO ENABLE FRAME GENERATION: THIS RUN",
"STARTED WITHOUT IT. SAVE AND RESTART NOW TURNS IT ON.",
"AFTER THAT IT CHANGES, OR TURNS OFF, LIVE.",
];
const FRAMEGEN: &str = "VICTORY_MENU_FRAMEGEN";
/// The note after the first Enter on it: the second one does it.
const CONFIRM_PRELOAD: &str = "ENTER AGAIN: SAVE, CLOSE THE GAME AND PRELOAD";
/// The last line of the box: where this build comes from.
@@ -514,6 +523,10 @@ impl Menu {
&& std::env::var_os("VICTORY_STREAMLINE_DIR").is_none()
{
ABOUT_NO_DLSS
} else if ITEMS.get(self.at).is_some_and(|i| i.var == FRAMEGEN && !live(i))
&& !matches!(self.values[self.at].as_str(), "" | "0")
{
ABOUT_FRAMEGEN_RESTART
} else {
[""; 3]
};
@@ -558,6 +571,9 @@ impl Menu {
self.apply_live(i);
}
self.note.clear();
if item.var == FRAMEGEN && !live(item) && !matches!(self.values[i].as_str(), "" | "0") {
"RESTART REQUIRED TO ENABLE FRAME GENERATION".clone_into(&mut self.note);
}
}
/// A setting the build reads at each use: changed in this run's environment at once.
@@ -1041,6 +1057,23 @@ mod tests {
let lines = menu.lines();
assert!(lines[lines.len() - 5..lines.len() - 2].iter().all(String::is_empty));
assert_eq!(ITEMS.iter().filter(|i| i.var == MFG).count(), 1);
// Frame generation turned on in a run started without it (no Streamline in tests): a
// restart is required, and the menu says so; OFF needs no word.
for line in ABOUT_FRAMEGEN_RESTART {
assert!(line.len() <= COLUMNS as usize && line.bytes().all(|c| glyph(c) != glyph(b'#')), "{line}");
}
let fg = ITEMS.iter().position(|i| i.var == FRAMEGEN).expect("in the menu");
menu.at = fg;
menu.values[fg] = "0".to_owned();
menu.change(fg, 1);
assert_eq!(menu.values[fg], "2");
assert_eq!(menu.note, "RESTART REQUIRED TO ENABLE FRAME GENERATION");
let lines = menu.lines();
assert_eq!(&lines[lines.len() - 5..lines.len() - 2], ABOUT_FRAMEGEN_RESTART);
menu.change(fg, -1);
assert!(menu.note.is_empty());
let lines = menu.lines();
assert!(lines[lines.len() - 5..lines.len() - 2].iter().all(String::is_empty));
}
#[test]