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
HQasper wants to merge 18 commits from upstream-pr/3063 into main
HQasper commented 2026-11-29 19:52:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by HQasper on 2026-11-29T19:52:40Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5554483704 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063). Originally posted by [HQasper](https://github.com/HQasper) on 2026-11-29T19:52:40Z. --- 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)
DoubleD17 commented 2026-11-30 12:03:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T12:03:44Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7277889378 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7277889378). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-30T12:03:44Z. --- 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
HQasper commented 2026-11-30 16:53:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by HQasper on 2026-11-30T16:53:44Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7285396211 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7285396211). Originally posted by [HQasper](https://github.com/HQasper) on 2026-11-30T16:53:44Z. --- 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.
KruIN689 commented 2026-11-30 20:37:19 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KruIN689 on 2026-11-30T20:37:19Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7291214721 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7291214721). Originally posted by [KruIN689](https://github.com/KruIN689) on 2026-11-30T20:37:19Z. --- 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.)
upipibi commented 2026-12-01 04:55:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by upipibi on 2026-12-01T04:55:39Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7301244135 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3063#issuecomment-7301244135). Originally posted by [upipibi](https://github.com/upipibi) on 2026-12-01T04:55:39Z. --- 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).*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3063:upstream-pr/3063'
git switch 'upstream-pr/3063'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3063'
git switch 'upstream-pr/3063'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3063'
git switch 'upstream-pr/3063'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3063'
git switch 'main'
git merge --squash 'upstream-pr/3063'
git switch 'main'
git merge --ff-only 'upstream-pr/3063'
git switch 'main'
git merge 'upstream-pr/3063'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

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