CGBJ's renderer, DLSS, an F1 settings menu, frame generation, ray tracing switch

The default of scripts\play-nvidia.ps1 changes: the game renders its own
720p and DLSS takes it to 1080p (Series S), in place of the half render
scale and the title's upscaler. -Resolution still reaches the older path.

- Renderer: codec-d/cool_fox f4b48ad (GPL-3.0) with this fork's NVIDIA
  fixes on top (residency.rs, stretch.rs, the ffx upscale dispatch).
- DLSS for the title's upscale, from avatarmanz/VIctory-7900XTX pull
  request 203 (feature `dlss`, VICTORY_UPSCALE=dlss), with
  VICTORY_DLSS_PRESET and a live sharpness setting.
- F1 settings menu in the game (host/menu.rs): saved to
  victory-settings.txt, applied by the launcher at the next start,
  "save and restart" from the menu. F3: the panel, now with the
  generated frame rate beside the real one.
- DLSS frame generation through NVIDIA Streamline (streamline.rs, fg.rs),
  2x to 6x, the amount changed while playing. Constants and the depth and
  motion vector tags are handed over at each present.
- VICTORY_FPS_CAP: the title's own 30 frames a second can be lifted
  (60, 120, none), live from the menu.
- Real ray tracing as an option (-RayTracing, VICTORY_BVH_BUILDER=1): on
  this renderer the structure builder runs on NVIDIA. Frame generation is
  left off with it: the two together run at about 0.1 fps, cause not found.
- VICTORY_HEAP_RECHECK_EVERY: textures picked by index looked at again
  for the whole run (a test against the posterized look).
- Get-NVIDIA-DLSS.cmd / scripts\get-nvidia-sdks.ps1: fetch the few NVIDIA
  files DLSS and frame generation need (about 70 MB) from NVIDIA's GitHub
  into nvidia-sdk\ (git-ignored). They are NVIDIA's, under NVIDIA's
  licences, and are not part of this repository. Without them the picture
  is stretched and there is no frame generation.
- scripts\build-nvidia.ps1; the launcher builds the layer when it is not
  built, and again with DLSS once those files are there.

Measured on an RTX 5070 (Series S, DLSS, opening rooms): about 15-17 fps
without ray tracing, 13-15 with it, before generated frames. What is known
to be wrong is in the README's new section.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
trustno1-coderandClaude Fable 5.2 committed 2026-11-26 17:56:14 -08:00
1 parent 9e7ab9d9a2
commit 63957271cd
55 files changed
+8030 -1313

No files matched your search

+113 -18
View File
@@ -122,7 +122,7 @@ pub use lower::{host_settings, set_host_max_wave, set_host_rdna};
pub use rect::rect_list_gs;
pub use shader::{
MEMORY_FAULTS, MEMORY_PAGES, MEMORY_READ_ONLY, ROOT_CBV_SPACE, SAMPLER_SPACE, SLOT_FAULTS, SLOT_MEMORY, SLOT_STRIDES,
SLOT_STRIDE_CONSTANT, SLOT_STRIDES_COUNT, USER_DATA_SPACE, VIEW_INTEGER, VIEW_SIGNED, VIEW_STRIDE_BITS, USER_DISPATCH_THREADS_X, USER_MEMORY_BASE, USER_ROOT_ADDRESS, USER_VIEW_ADDRESS, USER_VIEW_BIAS,
SLOT_STRIDE_CONSTANT, SLOT_STRIDES_COUNT, SLOT_TABLE_STRIDES, USER_DATA_SPACE, VIEW_INTEGER, VIEW_SIGNED, VIEW_STRIDE_BITS, USER_DISPATCH_THREADS_X, USER_MEMORY_BASE, USER_ROOT_ADDRESS, USER_VIEW_ADDRESS, USER_VIEW_BIAS,
constant_marks, raw_views, set_raw_views, set_view_heap_limit, view_heap_limit,
};
@@ -500,17 +500,45 @@ pub fn emit(
};
// The program in two other forms: without its early-outs, and
// without any branch that only skips code no lane is left for.
let form = |p: Option<ir::Program>| {
p.and_then(|p| {
let st = structure::structure(&p).ok()?;
let io = io::raise(&p, native).ok()?;
let res = resource::track(&p, &native.layout, native.stage, Some(&st)).ok()?;
Some((p, st, io, res))
})
let form = |label: &str, p: Option<ir::Program>| {
let Some(p) = p else {
if why {
eprintln!("WAVE64-FORM {label}: ir returned None");
}
return None;
};
let st = match structure::structure(&p) {
Ok(st) => st,
Err(e) => {
if why {
eprintln!("WAVE64-FORM {label}: structure failed: {e}");
}
return None;
}
};
let io = match io::raise(&p, native) {
Ok(io) => io,
Err(e) => {
if why {
eprintln!("WAVE64-FORM {label}: io::raise failed: {e}");
}
return None;
}
};
let res = match resource::track(&p, &native.layout, native.stage, Some(&st)) {
Ok(res) => res,
Err(e) => {
if why {
eprintln!("WAVE64-FORM {label}: resource::track failed: {e}");
}
return None;
}
};
Some((p, st, io, res))
};
let forms = [
("without early-outs", form(ir::without_early_outs(p))),
("without skips", form(ir::without_skips(p, false))),
("without early-outs", form("without early-outs", ir::without_early_outs(p))),
("without skips", form("without skips", ir::without_skips(p, false))),
];
for (name, f) in &forms {
if let Some((p, st, io, res)) = f {
@@ -526,7 +554,24 @@ pub fn emit(
// lost the card in a submission of two programs that had just moved to it
// (`ptfx_CS_lightAtlas_Sprite` and `_Trail`). The 32-lane programs' form below, which
// has no barrier, stays on.
let wide_on = std::env::var_os("VICTORY_WAVE_WIDE").is_some_and(|v| v == "1");
let wide_option = std::env::var_os("VICTORY_WAVE_WIDE");
// Both archived kernels use one logical wave per group and have
// validated wave32 PSOs on RTX. Explicit policy wins.
let scene_kernel = matches!(native.io, crate::native::StageIo::Cs(cs) if cs.threads.iter().product::<u32>() == 64)
&& matches!(
c.digest,
[0x58, 0x1d, 0xab, 0x2c, 0xd8, 0xbc, 0xf2, 0x2e, 0x5c, 0x96, 0x4b, 0x98, 0xe9, 0x03, 0x48, 0xd1]
| [0x24, 0x31, 0xbb, 0xe7, 0xdc, 0x15, 0x4a, 0xd7, 0x59, 0xd2, 0x0b, 0xc9, 0x54, 0x82, 0x9c, 0x1c]
);
let wide_on = wide_option.as_ref().map_or(scene_kernel, |v| v == "1");
// A single guest wave can iterate an active-lane loop until both host
// halves have finished. The precise latch and convergence conditions
// for the driver compute route are checked by widen().
let driver_loop = wide_option.is_none()
&& c.part(FourCC::DXIL).is_none()
&& c.part(FourCC::ACCC).is_some()
&& matches!(&original, Err(ShaderError::Unsupported { what, .. })
if *what == lower::DIVERGENT_MASK_EXCHANGE);
// exact first: each host wave on its own where that is exact (the idiom, every
// form; no barriers), then the other exact forms; then approximate
for exact in [true, false] {
@@ -537,7 +582,7 @@ pub fn emit(
// lane runs, where the two host waves can exchange.
// (`VICTORY_WAVE_DEEP_SKIPS=0` and `VICTORY_WAVE_WIDE=0` turn the two off.)
let deep_on = std::env::var_os("VICTORY_WAVE_DEEP_SKIPS").is_none_or(|v| v != "0");
let deep = if deep_on { form(ir::without_skips(p, true)) } else { None };
let deep = if deep_on { form("without skips, scalars followed", ir::without_skips(p, true)) } else { None };
if let Some((p, st, io, res)) = &deep {
let again = emit_program(c, native, p, st, io, res);
report("without skips, scalars followed", &again);
@@ -548,7 +593,7 @@ pub fn emit(
// Still stopped where not every lane runs: the per-lane branches around
// those places taken as the console takes them, by the whole wave at once
// ([`widen`]), at two group barriers per such branch.
if wide_on {
if wide_on || driver_loop {
let bases = [
deep.as_ref().map(|f| &f.0),
forms[1].1.as_ref().map(|f| &f.0),
@@ -556,7 +601,7 @@ pub fn emit(
Some(p),
];
if let Some(base) = bases.into_iter().flatten().next() {
let again = widen(c, native, base, why);
let again = widen(c, native, base, why, driver_loop);
report("wave-wide branches", &again);
if done(&again) {
return again.map(|(shader, _)| shader);
@@ -618,7 +663,7 @@ pub fn emit(
&& what == lower::LANE_MASK
&& std::env::var_os("VICTORY_WAVE_WIDE").is_none_or(|v| v != "0") =>
{
let again = widen(c, native, p, std::env::var_os("VICTORY_WAVE_WHY").is_some());
let again = widen(c, native, p, std::env::var_os("VICTORY_WAVE_WHY").is_some(), false);
match again {
Ok(_) => again,
Err(_) => emit_program(c, native, p, st, io, res),
@@ -626,7 +671,17 @@ pub fn emit(
}
other => other,
};
let original = original.map(|(shader, _)| shader);
let supported = |(shader, wave): (HostShader, Option<u32>)| {
if wave == Some(64) && lower::host_max_wave() == 32 {
Err(ShaderError::Unsupported {
offset: 0,
what: "no wave32 lowering for this wave64 program",
})
} else {
Ok(shader)
}
};
let original = original.and_then(supported);
// Retry unsupported programs only. Threading can separate an unknown
// register value from its apparent use on a mutually exclusive path.
if !matches!(original, Err(ShaderError::Unsupported { .. })) {
@@ -640,7 +695,7 @@ pub fn emit(
let st = structure::structure(&p)?;
let io = io::raise(&p, native)?;
let res = resource::track(&p, &native.layout, native.stage, Some(&st))?;
emit_program(c, native, &p, &st, &io, &res).map(|(shader, _)| shader)
emit_program(c, native, &p, &st, &io, &res).and_then(supported)
}
/// `p` (a console wave64 compute program on a host of 32-lane waves) with the per-lane
@@ -655,6 +710,7 @@ fn widen(
native: &NativeProgram,
p: &ir::Program,
why: bool,
active_loop_only: bool,
) -> Result<(HostShader, Option<u32>), ShaderError> {
const NOT: ShaderError = ShaderError::Unsupported {
offset: 0,
@@ -687,7 +743,22 @@ fn widen(
|| matches!(&r, Ok((_, Some(64)))) && !needs.is_empty();
if !stuck {
if why {
eprintln!("WAVE64-WIDE {} branches taken wave-wide", wide.len());
let order = ir::reverse_postorder(&p.blocks);
let mut rpo = vec![0usize; p.blocks.len()];
for (i, &b) in order.iter().enumerate() {
rpo[b] = i;
}
let mut sorted: Vec<usize> = wide.iter().copied().collect();
sorted.sort_unstable();
let desc: Vec<String> = sorted
.iter()
.map(|&b| {
let back = matches!(p.blocks[b].exit, ir::Exit::Branch { taken, not_taken } if rpo[taken] <= rpo[b] || rpo[not_taken] <= rpo[b]);
let nm = p.blocks[b].insts.last().map_or("?", |i| i.name());
format!("B{b}({nm}{})", if back { ",BACK" } else { "" })
})
.collect();
eprintln!("WAVE64-WIDE {} branches taken wave-wide: [{}]", wide.len(), desc.join(", "));
}
return r;
}
@@ -702,6 +773,30 @@ fn widen(
}
return r;
}
if active_loop_only {
// Only a single backward branch on the SCC just set by
// s_andn2_wrexec_b64. This instruction restricts EXEC to the
// unfinished lanes. The guest repeats the loop if *either*
// half still has work, while individual vector writes retain
// their EXEC predicates.
let [latch] = more.as_slice() else {
return r;
};
let block = &p.blocks[*latch];
let [.., update, branch] = block.insts.as_slice() else {
return r;
};
if !wide.is_empty()
|| update.name() != "s_andn2_wrexec_b64"
|| branch.name() != "s_cbranch_scc1"
|| !matches!(
block.exit,
ir::Exit::Branch { taken, not_taken } if taken <= *latch && not_taken > *latch
)
{
return r;
}
}
wide.extend(more);
}
}