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

Open
github-bot wants to merge 18 commits from github-bot/gh-3063 into main AGit
Owner

@⁠HQasper on GitHub · 2026-11-29 19:52 UTC · original
HQasper:pr/bvh-rehydration-hitches → main · +208 −7 · 7 files · 18 commits · open

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 (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, 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 in emit/lower/tests.rs, and the cache key in victory-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 translate too). 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, in apps/victory/src/play.rs and scripts/play-foxhound.ps1.

How it was tested

  • GPU and profile: RTX 5090 (driver 621.24), Ryzen 9 9950X3D, Series X, 1440p (VICTORY_NATIVE_SIZE=2560x1440 because of #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 55d06914): 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.

    Before (both switches off) After (both on)
    fps in play 27.4 (26.4 / 28.4) 31.4 (29.9 / 32.8)
    1 % low in play 9.9 (12.3 / 7.6) fps 14.6 (13.1 / 16.1) fps
    Frames over 50 ms in play 498 (572 / 423) 96 (139 / 53)
    Frames over 100 ms in play 46 (3 / 88) 4 (6 / 1)
    fps on the way in 23.1 (21.1 / 25.2) 23.5 (22.9 / 24.1)
    Frames over 100 ms on the way in 30 (42 / 19) 36 (28 / 45)
    Longest frame on the way in 637 (512 / 761) ms 230 (244 / 216) ms

    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):

    • the two rehydration programs: 200 ms → 32 ms with the limit → 25.5 ms with both switches
    • the frame: 221 ms → 51.5 ms, the same picture
    • a limit of 256 changed nothing, and 64 left 59 ms
  • 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 55d06914 itself gives 2,165 passed, 4 failed, 78 ignored. Its 4 failures are three bcpack::tests::oracle_parity_* tests and xtask's repository_passes_policy, which flags upstream's own victory-loader/src/heap_sites/frame_users.rs.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1370 (its first section measures these two programs as over half the card's frame with ray tracing on; its hitches have another cause, a copy-at-its-place wait), #2108 (skips page faults for unread BVH nodes, a different problem), #2148 (restart of deferred builder pipelines). Nothing covers the rehydration loops or the builder's coherence. If #2722 (launcher parity guard) lands first, the launcher commit goes into both play.rs and play-foxhound.ps1 as its guard expects.

Written with Claude Code (Claude Opus 5.5); measured on my PC; reviewed by me.

🤖 Generated with Claude Code

**@⁠HQasper** on GitHub · 2026-11-29 19:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063) `HQasper:pr/bvh-rehydration-hitches` → `main` · +208 −7 · 7 files · 18 commits · open 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 (`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, 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 in `emit/lower/tests.rs`, and the cache key in `victory-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 translate` too). 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, in `apps/victory/src/play.rs` and `scripts/play-foxhound.ps1`. ## How it was tested - **GPU and profile:** RTX 5090 (driver 621.24), Ryzen 9 9950X3D, Series X, 1440p (`VICTORY_NATIVE_SIZE=2560x1440` because of #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 55d06914): 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. | | Before (both switches off) | After (both on) | |---|---|---| | fps in play | 27.4 (26.4 / 28.4) | 31.4 (29.9 / 32.8) | | 1 % low in play | 9.9 (12.3 / 7.6) fps | 14.6 (13.1 / 16.1) fps | | Frames over 50 ms in play | 498 (572 / 423) | 96 (139 / 53) | | Frames over 100 ms in play | 46 (3 / 88) | 4 (6 / 1) | | fps on the way in | 23.1 (21.1 / 25.2) | 23.5 (22.9 / 24.1) | | Frames over 100 ms on the way in | 30 (42 / 19) | 36 (28 / 45) | | Longest frame on the way in | 637 (512 / 761) ms | 230 (244 / 216) ms | 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): - the two rehydration programs: 200 ms → 32 ms with the limit → 25.5 ms with both switches - the frame: 221 ms → 51.5 ms, the same picture - a limit of 256 changed nothing, and 64 left 59 ms - **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 55d06914 itself gives 2,165 passed, 4 failed, 78 ignored. Its 4 failures are three `bcpack::tests::oracle_parity_*` tests and `xtask`'s `repository_passes_policy`, which flags upstream's own `victory-loader/src/heap_sites/frame_users.rs`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1370 (its first section measures these two programs as over half the card's frame with ray tracing on; its hitches have another cause, a copy-at-its-place wait), #2108 (skips page faults for unread BVH nodes, a different problem), #2148 (restart of deferred builder pipelines). Nothing covers the rehydration loops or the builder's coherence. If #2722 (launcher parity guard) lands first, the launcher commit goes into both `play.rs` and `play-foxhound.ps1` as its guard expects. --- Written with Claude Code (Claude Opus 5.5); measured on my PC; reviewed by me. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:53:15 +00:00
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-30 12:03 UTC · original

We ran a test of this PR with ray tracing on (VICTORY_BVH_BUILDER=1), on a 12 GB card, on current main (41adb551 with this PR merged, head 0fb92720). The log confirmed the switch: "VICTORY_BVH_COHERENT_GLC: the structure builder's memory views are coherent only where it asks".

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):

on the GPU (ms/frame) main at that point fps main at that point
round 1, run 1 82.6 148.4 5.6 4.3
round 1, run 2 96.7 164.5 4.7 3.8
round 2, run 1 85.2 101.9 5.5 4.8
round 2, run 2 177.3 109.5 3.8 4.8
round 2, run 3 79.7 102.9 5.7 5.1
round 2, run 4 178.4 93.2 3.6 5.5
mean difference −3.4 ms +4.1 %

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:

  • Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (driver 621.40, DXGI budget 11,175 MB), 64 GB RAM, Windows 11;
  • Series X, 1440p with DLAA (DLSS at native resolution), frame generation off, ray tracing on;
  • the PR merged locally onto main 41adb551, against 41adb551 itself, each with a preload made with these settings;
  • a warm-up run per build, then two rounds (2 PR runs among 3 main runs, then 4 among 4, ABBA), 150 s each, every run from the same save, restored before each run;
  • medians of the 5 s host lines on the light-view seconds after the first 20 s, each run compared with main's runs of its round interpolated in time;
  • picture check: a burst of 80 frames at the end of each run plus a capture at 120 s, looked at frame by frame.

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-11-30 12:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7277889378) We ran a test of this PR with ray tracing on (`VICTORY_BVH_BUILDER=1`), on a 12 GB card, on current main (41adb551 with this PR merged, head 0fb92720). The log confirmed the switch: "VICTORY_BVH_COHERENT_GLC: the structure builder's memory views are coherent only where it asks". **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): | | on the GPU (ms/frame) | main at that point | fps | main at that point | |---|---|---|---|---| | round 1, run 1 | 82.6 | 148.4 | 5.6 | 4.3 | | round 1, run 2 | 96.7 | 164.5 | 4.7 | 3.8 | | round 2, run 1 | 85.2 | 101.9 | 5.5 | 4.8 | | round 2, run 2 | 177.3 | 109.5 | 3.8 | 4.8 | | round 2, run 3 | 79.7 | 102.9 | 5.7 | 5.1 | | round 2, run 4 | 178.4 | 93.2 | 3.6 | 5.5 | | **mean difference** | **−3.4 ms** | | **+4.1 %** | | 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:** - Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (driver 621.40, DXGI budget 11,175 MB), 64 GB RAM, Windows 11; - Series X, 1440p with DLAA (DLSS at native resolution), frame generation off, ray tracing on; - the PR merged locally onto main 41adb551, against 41adb551 itself, each with a preload made with these settings; - a warm-up run per build, then two rounds (2 PR runs among 3 main runs, then 4 among 4, ABBA), 150 s each, every run from the same save, restored before each run; - medians of the 5 s host lines on the light-view seconds after the first 20 s, each run compared with main's runs of its round interpolated in time; - picture check: a burst of 80 frames at the end of each run plus a capture at 120 s, looked at frame by frame. 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 <[email protected]>
Conflicts: shader_cache.rs (both key lists kept), emit/mod.rs (note_program and the
program loop limit), emit/lower.rs (the trip count and the program's own limit);
upstream renamed scripts/play-foxhound.ps1 to play-nvidia.ps1, so the two launcher
defaults move there.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The tree is the same as the merge of upstream main alone.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
Owner

@⁠HQasper on GitHub · 2026-11-30 16:53 UTC · original

Thanks for the thorough test, and for running the extra rounds after the first two looked too good.

Speed. I agree with your reading. The gain measured here (RTX 5090) is in the loading frames. With ray tracing on, a 12 GB card that is GPU-bound at 4–6 fps and spilling into system memory won't show it, and main's own spread (75–184 ms) is larger than the mean difference you measured (−3.4 ms). So "no difference we can measure on this card" is a fair result and doesn't contradict ours.

The dark ladder. This is the part we can't rule out, so thank you for flagging it. What the cap does: the two rehydration programs (caa78b8ca62bc3d6, 28918b7150a7aad5) go round a node's children as many times as the top byte of its header says. A real node has at most 4 children, and those programs' other loops run at most 24 rounds. The lanes past a structure's last node read that byte from whatever lies after it, which is why they ran up to 255 rounds. Capping at 32 therefore should only cut rounds that read junk. That is a reading of the code, not a proof, and I haven't read the shaders' loop bounds to confirm that nothing needs more than 32. One dark picture in seven runs, and none in 11 other runs, is also not enough to pin it on the cap. The other change in this PR, VICTORY_BVH_COHERENT_GLC=1, is a second possible cause.

If you still have the setup, the check that would settle it is the 120 s scene with VICTORY_SHADER_LOOP_LIMIT_OF unset against the same scene with it set. If you can see it again, tell us whether it comes with the cap, with VICTORY_BVH_COHERENT_GLC, or with neither. Both switches can be turned off separately in the launcher defaults.

**@⁠HQasper** on GitHub · 2026-11-30 16:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7285396211) Thanks for the thorough test, and for running the extra rounds after the first two looked too good. Speed. I agree with your reading. The gain measured here (RTX 5090) is in the loading frames. With ray tracing on, a 12 GB card that is GPU-bound at 4–6 fps and spilling into system memory won't show it, and main's own spread (75–184 ms) is larger than the mean difference you measured (−3.4 ms). So "no difference we can measure on this card" is a fair result and doesn't contradict ours. The dark ladder. This is the part we can't rule out, so thank you for flagging it. What the cap does: the two rehydration programs (caa78b8ca62bc3d6, 28918b7150a7aad5) go round a node's children as many times as the top byte of its header says. A real node has at most 4 children, and those programs' other loops run at most 24 rounds. The lanes past a structure's last node read that byte from whatever lies after it, which is why they ran up to 255 rounds. Capping at 32 therefore should only cut rounds that read junk. That is a reading of the code, not a proof, and I haven't read the shaders' loop bounds to confirm that nothing needs more than 32. One dark picture in seven runs, and none in 11 other runs, is also not enough to pin it on the cap. The other change in this PR, VICTORY_BVH_COHERENT_GLC=1, is a second possible cause. If you still have the setup, the check that would settle it is the 120 s scene with VICTORY_SHADER_LOOP_LIMIT_OF unset against the same scene with it set. If you can see it again, tell us whether it comes with the cap, with VICTORY_BVH_COHERENT_GLC, or with neither. Both switches can be turned off separately in the launcher defaults.
Author
Owner

@⁠KruIN689 on GitHub · 2026-11-30 20:37 UTC · original

Test of #3063 and #3067 together on a 16 GB card, as a third datapoint beside the RTX 5090 and the 12 GB card above.

Setup. RTX 5080 16 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB, Windows 11. Series X, 1440p, DLSS Quality, software ray tracing (VICTORY_BVH_BUILDER=1), with VICTORY_BVH_INVERTED_MISS=1, VICTORY_BVH_COHERENT_GLC=1 and VICTORY_SHADER_LOOP_LIMIT_OF=caa78b8ca62bc3d6:32,28918b7150a7aad5:32. Both PRs were cherry-picked onto our fork of main 829188e9 + fixes. Same save, standing still, alternating runs of 3.5 min.

run build fps frames over 50 ms per 1,000 longest
1 with both 5.0 345 4,854 ms (new cache keys: shaders made again)
2 without 15.7 566 770 ms
3 with both 22.9 153 411 ms
4 without 25.0 88 109 ms
5 with both 12.0 458 610 ms
6 without 14.6 256 474 ms
7 with both 28.9 27 108 ms
8 without 20.8 348 359 ms
  • Noisy. The first runs of a session are slow with either build while structures are built and shaders made, so take only the late pairs. In the last pair, the PRs gave +39 % fps and 13× fewer frames over 50 ms. Means over runs 3–8: 21.3 vs 20.1 fps.
  • Picture: no defects seen in captured frames.
  • Where the card's time goes with them (diagnostics GPU timing): with software RT, 5 ray-walking compute programs take ~12.5 ms of the card's frame, the biggest 5.1 ms. DLSS Balanced and Performance keep the card 100 % busy as well (19–31 fps), because that cost doesn't scale with resolution.
  • Since then: with hardware RT (#3706) on the same PC, roaming reaches the high 20s to ~30 fps. So these two PRs matter most for cards without DXR 1.1 or with HW RT off.
  • Not tested: a fixed scene; driving with software RT.

We have carried both PRs in our fork since 2026-11-30 with these defaults, with no problems reported.

(Measured and written with Claude Code, for KruIN689.)

**@⁠KruIN689** on GitHub · 2026-11-30 20:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7291214721) Test of #3063 and #3067 together on a 16 GB card, as a third datapoint beside the RTX 5090 and the 12 GB card above. **Setup.** RTX 5080 16 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB, Windows 11. Series X, 1440p, DLSS Quality, software ray tracing (`VICTORY_BVH_BUILDER=1`), with `VICTORY_BVH_INVERTED_MISS=1`, `VICTORY_BVH_COHERENT_GLC=1` and `VICTORY_SHADER_LOOP_LIMIT_OF=caa78b8ca62bc3d6:32,28918b7150a7aad5:32`. Both PRs were cherry-picked onto our fork of main 829188e9 + fixes. Same save, standing still, alternating runs of 3.5 min. | run | build | fps | frames over 50 ms per 1,000 | longest | |---|---|---:|---:|---:| | 1 | with both | 5.0 | 345 | 4,854 ms (new cache keys: shaders made again) | | 2 | without | 15.7 | 566 | 770 ms | | 3 | with both | 22.9 | 153 | 411 ms | | 4 | without | 25.0 | 88 | 109 ms | | 5 | with both | 12.0 | 458 | 610 ms | | 6 | without | 14.6 | 256 | 474 ms | | 7 | with both | **28.9** | **27** | 108 ms | | 8 | without | 20.8 | 348 | 359 ms | - **Noisy.** The first runs of a session are slow with either build while structures are built and shaders made, so take only the late pairs. In the last pair, the PRs gave +39 % fps and 13× fewer frames over 50 ms. Means over runs 3–8: 21.3 vs 20.1 fps. - **Picture:** no defects seen in captured frames. - **Where the card's time goes with them** (diagnostics GPU timing): with software RT, 5 ray-walking compute programs take ~12.5 ms of the card's frame, the biggest 5.1 ms. DLSS Balanced and Performance keep the card 100 % busy as well (19–31 fps), because that cost doesn't scale with resolution. - **Since then:** with hardware RT (#3706) on the same PC, roaming reaches the high 20s to ~30 fps. So these two PRs matter most for cards without DXR 1.1 or with HW RT off. - **Not tested:** a fixed scene; driving with software RT. We have carried both PRs in our fork since 2026-11-30 with these defaults, with no problems reported. (Measured and written with Claude Code, for KruIN689.)
Conflicts in play.rs (stale-shader clearing) and xmem.rs (port_on) took upstream's
side; scripts/play-nvidia.ps1 keeps this PR's BVH launcher defaults, which
apps/victory/src/play.rs also carries.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GQWmXZJ5QxY42JzyPynkL6
Author
Owner

@⁠upipibi on GitHub · 2026-12-01 04:55 UTC · original

On the dark ladder: one possible way in for VICTORY_BVH_COHERENT_GLC=1. past_wave_cache doesn't count two ways a GFX10 program asks to see what other groups wrote. Code and synthetic tests only, head a5a8c1ef; I can't look at the title's programs, so this needs a recount on your side.

The two ways.

  1. An acquire done by invalidating. LLVM's GFX10 memory model (AMDGPUUsage, "AMDHSA Memory Model Code Sequences GFX10-GFX11") makes an agent-scope acquire, a fence or the acquire of an atomic, as s_waitcnt …; buffer_gl1_inv; buffer_gl0_inv. The loads after it are plain: no glc, no dlc. A refit where the last child to arrive builds the parent is that shape: an atomic, the invalidates, then plain loads of the children's boxes. past_wave_cache leaves atomics out on purpose and doesn't look at the invalidates, so such a program gets a plain view under the switch. The invalidates are then dropped in lowering ("The host has no console buffer cache to invalidate", lower.rs:13564 on main), so nothing makes the other groups' writes visible on the card.
  2. A scalar load with glc. s_load_dword* from title memory goes through memory() and memory_view (lower.rs:4041), so it shares the program's view. Fields::Smem carries cache.glc/dlc, but past_wave_cache only looks at Buffer and Flat.

Shown with your test's pattern. I encoded buffer_atomic_add … glc, buffer_gl1_inv, buffer_gl0_inv, buffer_load_dword, and separately s_load_dword s4, s[2:3], 0x0 glc. ir::build decodes them as those instructions, with glc=true on the atomic and on the scalar load, and past_wave_cache returns false for both programs.

A widening that counts them. With it, emit::lower::tests gives 32 passed, 0 failed, yours included:

        // An acquire on GFX10 invalidates the wave's caches and then loads
        // plainly (LLVM's GFX10 memory model); a scalar load asks with glc too.
        let invalidate = matches!(n, "buffer_gl0_inv" | "buffer_gl1_inv" | "s_gl1_inv" | "s_dcache_inv");
        let scalar = n.starts_with("s_load") || n.starts_with("s_buffer_load");
        let cache = match &i.fields {
            Fields::Buffer { cache, .. } | Fields::Flat { cache, .. } | Fields::Smem { cache, .. } => Some(cache),
            _ => None,
        };
        invalidate || ((access || scalar) && cache.is_some_and(|c| c.glc || c.dlc))
The test
#[test]
fn an_acquire_by_invalidating_and_a_scalar_glc_load_are_past_the_wave_cache() {
    use super::past_wave_cache;
    let built = |words: &[u32]| {
        let code: Vec<u8> = words.iter().chain(&[S_ENDPGM]).flat_map(|w| w.to_le_bytes()).collect();
        past_wave_cache(&ir::build(&code, false, 32).expect("ir::build"))
    };
    // buffer_atomic_add (returning), buffer_gl1_inv, buffer_gl0_inv, then a plain buffer_load_dword
    assert!(built(&[0xE0C8_5030, 0x8002_1114, 0xE1C8_0000, 0, 0xE1C4_0000, 0, 0xE030_1030, 0x8002_1114]));
    // s_load_dword s4, s[2:3], 0x0 glc
    assert!(built(&[0xF401_0101, 0xFA00_0000]));
}

What it would settle. You counted 3 of the builder's 52 programs with glc/dlc. If a count with the widened check still gives 3, this isn't the way in, and the loop limit is the one left to look at for the ladder. If it gives more, those programs read other groups' writes through a plain view now. Keeping them coherent would cost part of the gain but keep the picture.

Tested with the help of Claude Code (Claude Opus 5.5).

**@⁠upipibi** on GitHub · 2026-12-01 04:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7301244135) On the dark ladder: one possible way in for `VICTORY_BVH_COHERENT_GLC=1`. **`past_wave_cache` doesn't count two ways a GFX10 program asks to see what other groups wrote.** Code and synthetic tests only, head a5a8c1ef; I can't look at the title's programs, so this needs a recount on your side. **The two ways.** 1. **An acquire done by invalidating.** LLVM's GFX10 memory model ([AMDGPUUsage, "AMDHSA Memory Model Code Sequences GFX10-GFX11"](https://llvm.org/docs/AMDGPUUsage.html#amdgpu-amdhsa-memory-model-code-sequences-gfx10-gfx11-table)) makes an agent-scope acquire, a fence or the acquire of an atomic, as `s_waitcnt …; buffer_gl1_inv; buffer_gl0_inv`. The loads after it are plain: no `glc`, no `dlc`. A refit where the last child to arrive builds the parent is that shape: an atomic, the invalidates, then plain loads of the children's boxes. `past_wave_cache` leaves atomics out on purpose and doesn't look at the invalidates, so such a program gets a plain view under the switch. The invalidates are then dropped in lowering ("The host has no console buffer cache to invalidate", `lower.rs:13564` on `main`), so nothing makes the other groups' writes visible on the card. 2. **A scalar load with `glc`.** `s_load_dword*` from title memory goes through `memory()` and `memory_view` (`lower.rs:4041`), so it shares the program's view. `Fields::Smem` carries `cache.glc`/`dlc`, but `past_wave_cache` only looks at `Buffer` and `Flat`. **Shown with your test's pattern.** I encoded `buffer_atomic_add … glc`, `buffer_gl1_inv`, `buffer_gl0_inv`, `buffer_load_dword`, and separately `s_load_dword s4, s[2:3], 0x0 glc`. `ir::build` decodes them as those instructions, with `glc=true` on the atomic and on the scalar load, and `past_wave_cache` returns `false` for both programs. A widening that counts them. With it, `emit::lower::tests` gives 32 passed, 0 failed, yours included: ```rust // An acquire on GFX10 invalidates the wave's caches and then loads // plainly (LLVM's GFX10 memory model); a scalar load asks with glc too. let invalidate = matches!(n, "buffer_gl0_inv" | "buffer_gl1_inv" | "s_gl1_inv" | "s_dcache_inv"); let scalar = n.starts_with("s_load") || n.starts_with("s_buffer_load"); let cache = match &i.fields { Fields::Buffer { cache, .. } | Fields::Flat { cache, .. } | Fields::Smem { cache, .. } => Some(cache), _ => None, }; invalidate || ((access || scalar) && cache.is_some_and(|c| c.glc || c.dlc)) ``` <details><summary>The test</summary> ```rust #[test] fn an_acquire_by_invalidating_and_a_scalar_glc_load_are_past_the_wave_cache() { use super::past_wave_cache; let built = |words: &[u32]| { let code: Vec<u8> = words.iter().chain(&[S_ENDPGM]).flat_map(|w| w.to_le_bytes()).collect(); past_wave_cache(&ir::build(&code, false, 32).expect("ir::build")) }; // buffer_atomic_add (returning), buffer_gl1_inv, buffer_gl0_inv, then a plain buffer_load_dword assert!(built(&[0xE0C8_5030, 0x8002_1114, 0xE1C8_0000, 0, 0xE1C4_0000, 0, 0xE030_1030, 0x8002_1114])); // s_load_dword s4, s[2:3], 0x0 glc assert!(built(&[0xF401_0101, 0xFA00_0000])); } ``` </details> **What it would settle.** You counted 3 of the builder's 52 programs with `glc`/`dlc`. If a count with the widened check still gives 3, this isn't the way in, and the loop limit is the one left to look at for the ladder. If it gives more, those programs read other groups' writes through a plain view now. Keeping them coherent would cost part of the gain but keep the picture. *Tested with the help of Claude Code (Claude Opus 5.5).*
On GFX10 an agent-scope acquire is an atomic, buffer_gl1_inv, buffer_gl0_inv, then plain
loads, and a scalar load can carry glc. Neither made a program ask for a coherent builder
view under VICTORY_BVH_COHERENT_GLC=1, and lowering drops the invalidates. Found and
written by upipibi in the review of #3063; the test fails without the change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3063/head:github-bot/gh-3063'
git switch 'github-bot/gh-3063'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3063'
git switch 'github-bot/gh-3063'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3063'
git switch 'github-bot/gh-3063'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3063'
git switch 'main'
git merge --squash 'github-bot/gh-3063'
git switch 'main'
git merge --ff-only 'github-bot/gh-3063'
git switch 'main'
git merge 'github-bot/gh-3063'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3063
No description provided.