Repository navigation
Ray tracing: the BVH rehydration programs stop at 32 rounds and the builder's memory is coherent only where it asks (+15 % fps in play with ray tracing) - #3063
Conversation
…re asked The structure builder's views of title memory were all globally coherent (87eb9f2: a refit climbs from children to parents), and a coherent view is not kept in the card's first-level cache. Of the builder's 52 programs only 3 load or store with glc or dlc (93be497e, 5552dac6, ffd93c8a: 26-48 such loads each); the console's compiler sets them where other groups write what a program reads. With the switch, the other 49 get plain views. Measured on a recorded loading frame (victory replay, RTX, ray tracing on): the two BVH rehydration programs, 1,627 one-group dispatches, went from 200 to 151 ms, the frame from 221 to 163 ms, the same picture. Off unless set; on, the shader cache keys on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VICTORY_SHADER_LOOP_LIMIT_OF=<hash>:<limit>,... (any build): the programs named by the 16 hex digits a run's log names a shader by (the start of the BLAKE3 hash of the container) have that loop limit in place of their stage's. The shader cache keys those programs apart; the others keep their entries. `victory translate` applies it too. Root cause of the loading hitches with ray tracing on NVIDIA: the BVH rehydration programs (caa78b8ca62bc3d6 Box16Rehydration, 28918b7150a7aad5 Box32Rehydration) go round a node's children as many times as the top byte of its header says. A group is 64 nodes of one structure; most structures are smaller, and the lanes past the last node read that byte from whatever lies after the hierarchy, up to 255 rounds. What those lanes write goes to unused node slots of the group's page and to LDS above their own; the lanes before them do not read it. A real node has at most 4 children (the title's loop indexes a 4-entry array) and the programs' other loops go round at most 24 times, so a limit of 32 cuts only those lanes. On the console a round is a few instructions; translated it is about 3,000 IR instructions with two memory lookups per access. Recorded loading frame (victory replay, RTX, ray tracing on), 1,627 one-group dispatches: at 32 the two programs took 32 ms instead of 200; with VICTORY_BVH_COHERENT_GLC=1 too, 25.5 ms, the frame 51.5 ms instead of 221, the same picture. A limit of 256 changed nothing, 64 left 59 ms; VICTORY_SHADER_OPT=0, no barriers and the other wave64 switches changed nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut by default VICTORY_BVH_COHERENT_GLC=1 and VICTORY_SHADER_LOOP_LIMIT_OF= caa78b8ca62bc3d6:32,28918b7150a7aad5:32 by default (launcher and play-foxhound.ps1). ABBA on an RTX with ray tracing, DLSS Quality (release 9975300, warmed for both), 60-120 s after the first frame (the opening cutscene and the way into the world): frames over 100 ms 47 / 28 -> 10 / 9, over 50 ms 326 / 217 -> 167 / 167, longest 571 / 270 -> 184 / 172 ms, 20.3 / 23.8 -> 24.6 / 24.7 fps. Start-up and steady play alike (30.0 / 31.5 vs 29.7 / 30.8 fps), 0 crashes. Captures of the cutscene and the first 75 s in the world, aligned on the cutscene's flash: the same pictures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Carried ahead of upstream, each behind its own switch or strictly local: - trustno1-coder#3379 the commit floor scales to the PC's RAM, so a 16 GB PC still admits driver compiles (without it every PSO compile is put off, and the scene draws nothing); - trustno1-coder#3398 a draw's wait ends when the memory guard puts the compile off, so a drawing thread does not sit 500 ms at the commit limit; - trustno1-coder#3065 the ambient depth table is bound by the resolve only, and frame generation is asked again once DLSS-G allows more frames; - trustno1-coder#3067 the ray test misses inverted boxes, as the console's does (VICTORY_BVH_MISS; the authors measure +57 % with ray tracing); - trustno1-coder#3063 the BVH rehydration stops at 32 rounds and the builder's memory is coherent only where it asks (VICTORY_BVH_REHYDRATE_MAX, VICTORY_BVH_COHERENT_GLC; the authors measure +15 %); - trustno1-coder#3406 VRAM is checked before the first streamed textures are allocated; - trustno1-coder#3128 sampled texture eviction is on by default through 10 GB of VRAM; - trustno1-coder#3413 the relay fence context survives a GPU device loss. Left for a hand rebase, because they sit in the paths our parallel submit and DLSS work rewrote: trustno1-coder#1978 (keep the DLSS frame generation inputs through presentation) and trustno1-coder#3411 (the RTX 5060 Ti bundle).
Carried ahead of upstream, each behind its own switch or strictly local: - trustno1-coder#3379 the commit floor scales to the PC's RAM, so a 16 GB PC still admits driver compiles (without it every PSO compile is put off, and the scene draws nothing); - trustno1-coder#3398 a draw's wait ends when the memory guard puts the compile off, so a drawing thread does not sit 500 ms at the commit limit; - trustno1-coder#3065 the ambient depth table is bound by the resolve only, and frame generation is asked again once DLSS-G allows more frames; - trustno1-coder#3067 the ray test misses inverted boxes, as the console's does (VICTORY_BVH_MISS; the authors measure +57 % with ray tracing); - trustno1-coder#3063 the BVH rehydration stops at 32 rounds and the builder's memory is coherent only where it asks (VICTORY_BVH_REHYDRATE_MAX, VICTORY_BVH_COHERENT_GLC; the authors measure +15 %); - trustno1-coder#3406 VRAM is checked before the first streamed textures are allocated; - trustno1-coder#3128 sampled texture eviction is on by default through 10 GB of VRAM; - trustno1-coder#3413 the relay fence context survives a GPU device loss. Left for a hand rebase, because they sit in the paths our parallel submit and DLSS work rewrote: trustno1-coder#1978 (keep the DLSS frame generation inputs through presentation) and trustno1-coder#3411 (the RTX 5060 Ti bundle).
…oop limit, coherent builder memory), conflicts resolved by keeping both sides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
We ran a test of this PR with ray tracing on ( No difference we can measure on this card. With ray tracing on, the card is the limit here: about 4 to 6 fps, the GPU busy 98 to 100 % of the time, and the host's "on the GPU" time is 75 to 185 ms a frame on main, against 4 to 8 ms with ray tracing off. Our first two runs looked like a big gain, so we ran four more: Light-view seconds only (the idle camera's lighter views, about 7,500 draws a frame):
Four of the six runs had less GPU time than main and two had much more, and main's own seven runs ranged from 75.5 to 184.3 ms on the GPU. Shared memory was 10.4 to 11.3 GB in the last 100 s of every run, with this PR or without it (8.5 to 9.0 GB with ray tracing off), so on a 12 GB card part of the ray-tracing data probably lives in system memory. That may explain the spread, and why the gain you measured on an RTX 5090 does not show here. Picture, one case to look at: in this PR's warm-up run (its first run after the preload), from about 120 s to the end, a metal ladder and the character next to it went dark, as if in shadow, where every other run shows them lit. A glass door behind them showed a sharp, bright reflection with a black vertical band, where it shows a faint one otherwise. We did not see it again in this PR's six other runs, nor in eight main runs or three runs of #3067 with ray tracing on. So it happened once in seven runs of this PR. We do not know whether it came from this PR or from that run being the first after the preload. Since the rehydration programs now stop at 32 rounds, could a structure that needs more rounds keep stale geometry and cast a wrong shadow? Setup:
AI Assisted |
Conflicts in emit/mod.rs (translate: keep note_program and the per-program loop limit), emit/lower.rs (loop_cap: upstream's own-trip-count floor, then the per-program override) and shader_cache.rs (both sets of keyed switches). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Related to #1370.
What it changes
With ray tracing on, the title's BVH rehydration programs take a large share of the card's frame on NVIDIA, in play and not only while loading (#1370 measures these two programs as over half of it). Two causes, each behind a switch, and the launcher turns both on.
The rehydration programs' loops. The rehydration programs (
caa78b8ca62bc3d6Box16Rehydration,28918b7150a7aad5Box32Rehydration) go round a node's children as many times as the top byte of its header says. A group is 64 nodes of one structure, and most structures are smaller. The lanes past the last node read that byte from whatever lies after the hierarchy, and go round up to 255 times. What they write lands in unused node slots of the group's page and in LDS above their own; the lanes before them never read it. A real node has at most 4 children, and the programs' other loops go round at most 24 times, so a limit of 32 cuts only those lanes. On the console a round costs a few instructions; translated it is about 3,000 IR instructions with two memory lookups per access.The builder's coherence. The builder's views of title memory were all globally coherent (87eb9f2: a refit climbs from children to parents), and a coherent view is not kept in the card's first-level cache. Of the builder's 52 programs only 3 load or store with glc or dlc (93be497e, 5552dac6, ffd93c8a). The console's compiler sets those bits where other groups write what a program reads, so the other 49 can have plain views.
What is in it:
Shaders: VICTORY_BVH_COHERENT_GLC=1 …:emit/lower.rs,emit/mod.rs, a unit test inemit/lower/tests.rs, and the cache key invictory-gpu/src/shader_cache.rs.Shaders: VICTORY_SHADER_LOOP_LIMIT_OF=<hash>:<limit>,…: named programs get a loop limit of their own (any build,victory translatetoo). Each such program has its own cache entry (the variant's key plus the limit), and every other program keeps its entry.Launcher: …: both switches on by default, inapps/victory/src/play.rsandscripts/play-foxhound.ps1.How it was tested
GPU and profile: RTX 5090 (driver 621.24), Ryzen 9 9950X3D, Series X, 1440p (
VICTORY_NATIVE_SIZE=2560x1440because of v2026.11.29.01 is unable to start #2141), DLSS Quality, ray tracing on with the launcher's other ray-tracing defaults (inverted-box miss, walk loops at 512), frame generation off.In game, on 829188e (the same code as 55d0691): eight runs of 6 minutes from the same save, in the order b r i t t i r b (b: the launcher's ray-tracing defaults all on; r, i, t: PR 1, 2 or 3 off), with shaders and pipelines made beforehand for each variant. The world is reached about 45 s after the first frame. "Way in" is its first 60 s, "play" the next 180 s. Each cell is the mean of two runs, with the two runs' values in brackets. 0 GPU removals and 0 crashes in all eight runs.
On the first base this was measured on (d4b5d51), the gain was in loading: 60-120 s after the first frame, frames over 100 ms went from 47 / 28 to 10 / 9, and play was unchanged. On this base that window shows no difference (16 frames over 100 ms either way), and the gain is in play instead. The card is busy 91-95 % of the time without the switches and 88 % with them. The two switches were not measured apart here.
Recorded loading frame (
victory replay, base d4b5d51, 1,627 one-group dispatches):Pictures (base d4b5d51): captures of the opening cutscene and the first 75 s in the world, aligned on the cutscene's flash, show the same pictures with and without the switches.
Wave sizes: 32-lane host (the rehydration programs are wave64 programs lowered for it).
cargo test(cargo test --workspace --locked --no-fail-fast -- --test-threads=4, 2026-11-29): 4 failed, the same 4 as upstream (below).victory-hle's test binary stopped once with an access violation in its media tests, so the run counted 1,744 passed and 73 ignored. Run alone three times, that binary passed in full each time (423 passed, 5 ignored), as it did three times on upstream. Upstream main 55d0691 itself gives 2,165 passed, 4 failed, 78 ignored. Its 4 failures are threebcpack::tests::oracle_parity_*tests andxtask'srepository_passes_policy, which flags upstream's ownvictory-loader/src/heap_sites/frame_users.rs.Checked for overlap
play.rsandplay-foxhound.ps1as its guard expects.Written with Claude Code (Claude Opus 5.5); measured on my PC; reviewed by me.
🤖 Generated with Claude Code