Skip to content

Ray tracing: builder within a wait budget, recycled ray pages; opt-in descriptor-slot, ray-walker and water switches; counters and bench script - #1046

Closed
ldanyyl wants to merge 12 commits into
trustno1-coder:mainfrom
ldanyyl:ray-tracing-fixes-and-switches
Closed

ldanyyl wants to merge 12 commits into
trustno1-coder:mainfrom
ldanyyl:ray-tracing-fixes-and-switches

Conversation

@ldanyyl

@ldanyyl ldanyyl commented Nov 28, 2026

Copy link
Copy Markdown

Fixes for the title's own ray tracing (VICTORY_BVH_BUILDER=1), new opt-in switches for the descriptor slots, ray walkers and water light, counters, and a benchmark script. With every new switch off, the default path is VIctory-NVIDIA's, except for counters and log lines; the two ray-tracing budgets only act with VICTORY_BVH_BUILDER=1.

Part of this is fxceless's work (credited with Co-authored-by on those commits).

Ray tracing (only with VICTORY_BVH_BUILDER=1)

  • Structure builder programs are made by the pipeline workers within a per-frame wait budget, instead of on the title's thread. Before this, a cold cache could hold the title's thread long enough for its own 30 s watchdog to end the run.
    • VICTORY_BVH_BUILDER_WAIT_MS, default 2000: on by default, against the switch rule, because the old path ends the run.
    • VICTORY_BVH_BUILDER_ON_THE_SPOT=1 restores the old behaviour.
  • Pages made for the ray programs are a recycled budget, not a limit for the whole run (memory.rs).

New switches, all off by default (on with =1)

Switch What it does
VICTORY_DYNAMIC_WAIT A draw that finds no free dynamic descriptor slot waits for the next landing without holding the submission lock (alt: on and off in turns, for A/B)
VICTORY_THIN_GATE A list's translation pauses while dynamic slots are short
VICTORY_TABLES_ONCE One copy of a descriptor table for every length, reused by the other stages of the list
VICTORY_MEMORY_NEAR Ray-walking shaders reuse an earlier load's look in the memory directory (in the shader cache key)
VICTORY_WATER_TILE_SLOTS On 32-lane hosts the water light's tile lists take a slot a lane, matched by program hash (in the shader cache key)

The documentation is in docs/fork-ray-tracing.md and in comments where each switch is read.

Counters and diagnostics

  • Ownerless views evicted, and lookups that found them gone.
  • Uploads served from the process heap; a failed upload pool reservation is logged.
  • Diagnostics builds only: draw time by what was recorded with it, windows of title memory, and F9 to save a frame together with every texture its passes wrote.

Benchmark

scripts/bench.ps1 is based on PR #617. It runs the diagnostics build unattended through victory play with chosen switches. It writes:

  • median fps, p99, and 1 % / 0.1 % low, from a new framelog: frame times line built from the frame meter's intervals;
  • GPU busy share, VRAM and memory samples;
  • a summary in markdown and json.

Options: -RayTracing, -Dlss, -FrameGen, -Switches, -Seconds, -Warmup, -CaptureEvery, -Compare.

Also

  • Clippy lints from toolchain 1.98 (is_multiple_of, checked_div, explicit precedence), with no change in behaviour.

Tests

On Windows (toolchain from rust-toolchain.toml):

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo test -p victory-gpu --lib --locked -- --test-threads=1: 465 passed
  • cargo test -p victory-shader --locked: 295 passed
  • cargo test -p victory --locked: passed
  • cargo xtask policy: ok

In game, on a Ryzen 5 9600X with 32 GB and an RTX 5060 Ti 16 GB: Series X profile, 2560x1440, DLSS and frame generation off, diagnostics build of this branch, 4-minute windows with scripts/bench.ps1.

Run Median fps p99 frame time 1 % low Crashes / device loss
Ray tracing off (default) 17.6 126.9 ms 7.9 fps none
VICTORY_BVH_BUILDER=1 8.7 532.1 ms 1.9 fps none (the builder ran without tripping the title's watchdog)

These are single runs on one machine; the new switches were not A/B-measured on this base.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hw2UBhLdHXyf9znVoP6cYo

ldanyyl and others added 12 commits November 28, 2026 11:59
… gone

Two counters on the frame line, so a run shows how often a view no list owns
is evicted and how often a later lookup finds it gone. Counting only, no
change in behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reservation

Counting and logging only, no change in behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dget, not on the title's thread

- Per-material ray-tracing resolve programs are not waited for while they are
  being made (their dispatches are dropped at once), and they queue in a line
  of their own behind the pipelines draws ask for, with a quarter of the
  workers kept free.
- The builder's own programs are made by the workers, within a budget per
  frame (VICTORY_BVH_BUILDER_WAIT_MS, 2000 ms by default; 0: not at all). Not
  all made: the builder is off for that frame and tried again in the next.
  Without the wait, the title's watchdog ends a run on a cold cache.
  VICTORY_BVH_BUILDER_ON_THE_SPOT=1 keeps the old behaviour.
- A new log line names the pipeline a wait of 50 ms or more went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
… for the run

Pages of title memory made from the ray programs' fault notes were limited
for the whole run: once used up, every page touched after that read zeros for
good. They are now a budget of 512 MB held at a time. At the budget the oldest
page is given back (never in its first 128 frames, never one a list names); a
page that is still read leaves its note again and is made again first. A page
whose title memory is gone is dropped.

The log line "title memory by address" gains the counts of why a page got no
copy (the frame's limit, the budget, not the title's memory, no place).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
…lot waits for the next landing without the submission lock

Off by default: everything in the air is settled under the submission lock, as
before. On, the thread that translates the draw waits until a landing gave
slots back and takes them, while other submissions go on. With nothing in the
air and nothing being landed no slot can come back that way: then, and
without the relay, as before. A log line says what it did; two more log lines
count refused card-step submissions and the line's waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
…es through that look's view

In a program that walks the title's structures, a load by address of a page
an earlier load of the same program already looked up in the directory goes
through that look's view, and the second half of a 128-byte node through the
first half's. The same bytes are read either way; the looks are what costs.

VICTORY_MEMORY_NEAR=1 turns it on (off by default). The switch is part of the
shader cache key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
… length; diagnostics builds

Switches, all off by default:
- VICTORY_THIN_GATE=1: a list's translation pauses while dynamic descriptor
  slots are short, so the lists that are sent next keep theirs (a recording
  is held back at most 250 ms).
- VICTORY_TABLES_ONCE=1: a table a list reads to different lengths is copied
  once, as long as any stage reads it; the shorter readings use that copy.
- VICTORY_DYNAMIC_WAIT=alt: the wait of VICTORY_DYNAMIC_WAIT=1 on and off in
  turns of 20 s, to compare the two inside one run. With the switch set,
  slots also go back at the start of a landing, not after its read-backs.

Always on, counting or logging only: a counter line for slots taken and held.

Diagnostics builds: the card's time of draws by what was recorded with them
and by where their buffers lie, a census of windows of title memory, F9 to
save one frame with every texture its passes wrote, tile-mask words of a
dumped frame in the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
…ORY_WATER_TILE_SLOTS=1)

On a host of 32-lane waves, one compute program of the water light listed
tiles over each other: the console takes the slots for a whole 64-lane wave at
once, and the second host wave needs the first one's lane mask, exchanged
through group memory. The tiles that were overwritten got no light and the
water was dark there.

The program is changed in its own code before translation (known by its
container digest and a hash of its bytes; any other program is left as it is):
every lane adds 1 to the list's counter and its slot is what the counter held.
Slots are still each given once and the counters end the same.

VICTORY_WATER_TILE_SLOTS=1 turns it on; off by default. The switch is part of
the shader cache key. The test of the rewrite runs the byte rewrite itself.
After a change by xss3009 in a fork of VIctory-NVIDIA (69e7e00), written again
for this tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
…e descriptor slots line, no change in behaviour

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tracing, DLSS and frame generation; frame times on the frame log

- scripts/bench.ps1 starts the title through `victory play ... --set ...` and
  summarises the frame lines (median, 1 % low, draw bands), CPU, memory, GPU
  and video-memory samples, and compares earlier runs (-Compare). Options
  for ray tracing, DLSS, frame generation and the pipeline book. Run folders
  sit beside cache_dir, not in it.
- A video-memory sample over 1 TB (a counter that underflowed) is left out of
  the mean and the peak, and the summary says how many were.
- A comma inside a switch value ('A=1,2,3') stays in the value.
- host.rs: the Meter writes a frame-times line every 5 s (diagnostics builds),
  the lengths taken from the frame meter's intervals.
- capture.rs: a file named `now` in the capture folder saves the next frame,
  so a tool can look at the screen of a title running in the background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ater light tile lists

All off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s textures only with VICTORY_TABLES_ONCE=1

With the switch off the branch for a table another stage made is as in
VIctory-NVIDIA again (no texture_slot_tabled / mirror_after there), and
the longer copy's records are hashed again only in diagnostics builds or
with the switch on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hw2UBhLdHXyf9znVoP6cYo
@ballsimulation

Copy link
Copy Markdown
Contributor

@ldanyyl, thanks for scripts/bench.ps1. I've opened #1099 with your bench commit (7756cd9) on its own, so it can land without waiting for this PR's ray-tracing changes. The commit is unchanged and still yours as author. On top of it, #1099 adds -Route, a scripted walk that starts at the world's first frame (#1098).

I tried it on main 63b902fe from the free-roam save in #332. It worked unattended from the boot screens to the summary. Two runs loaded 6 s apart and still ended the route at the same spot.

If #1099 lands first, this PR can drop its copy of the script. If you'd rather keep it here, tell me and I'll close #1099.

@trustno1-coder

Copy link
Copy Markdown
Owner

Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants