Native ray tracing fixes ready to pull: size bound, early builder pipelines, fewer write-watch copies #385

Open
opened 2026-11-27 00:58:53 +00:00 by github-bot · 1 comment
Owner

@⁠notquiteog on GitHub · 2026-11-26 23:12 UTC · original

Four fixes for the native ray tracing (the structure builder, VICTORY_BVH_BUILDER=1) are ready for you as a branch. A pull request isn't possible because this repo isn't in GitHub's fork network with ours.

Not tested on an AMD card. The numbers below were measured on an RTX card, so the gains on an RDNA card may differ.

Each fix has its own switch. All of them are on whenever the builder is on, and none of them does anything while it is off. Your builder default does not change: it stays opt-in (VICTORY_BVH_BUILDER=1).

1. Compacted-size bound (VICTORY_BVH_SIZES_BOUND, =0 turns it off)

The title reads a new structure's compacted size a frame or two after the builder's GetBVHCompactedSize program was recorded, and it does so without a fence. With VICTORY_THIN the list is translated and sent by our own threads, so the slot still held another structure's size. The compacting copy then wrote over its neighbours. VICTORY_BVH_SIZES_WAIT did not help because it blocks our sending thread, not the title's.

The fix:

  • The main image's imports of GetRaytracingAccelerationStructurePrebuildInfo and BuildRaytracingAccelerationStructureBatched2X go through a new victory-hle module, modules/bvh.rs.
  • The prebuild answer (ResultDataMaxSizeInBytes, which is never smaller than the compacted size) is recorded for each build.
  • When the size program is translated, its slot gets that upper bound at once.
  • When the card's real size lands, a bottom-of-pipe write (Written::SizeLanded) puts the latest bound back if an earlier asking of the same slot lands after it.

The new code is in crates/victory-gpu/src/bvhsize.rs (it has unit tests).

Measured on an RTX card with the builder on: card time per frame went from 19 ms to 9 ms.

2. Builder pipelines early (VICTORY_BVH_BUILDER_EARLY, =0 turns it off)

The builder's first dispatch made its 53 pipelines one after another on its own thread. With a cold driver cache that took about a second each, so the title's main thread waited past its 30 s watchdog, and the title crashed with a store to address 0. Now each builder pipeline is queued for the pipeline workers when the title creates it, and all of them are promoted at the first dispatch, so they are made in parallel (make::soon).

3. The push (VICTORY_BVH_PUSH, =0 turns it off), in memory.rs

Every list that read title memory by address used to refresh the whole directory (128 MB) and every arena (64 MB each) through GetWriteWatch. Only memory.rs writes those, so it now puts the dwords that changed into the copies' CPU side as it writes them, and they go up with the next submission.

Measured on an RTX card, this saves about 7 ms a frame on the submitting thread with rays on: GetWriteWatch went from 8.6 to 4.3 ms a frame.

4. One reading of the builder switch, and the ambient stand-in

  • victory_shader::bvh_builder_on() is now the single place that reads VICTORY_BVH_BUILDER, so the builder rule and the size bounds cannot disagree. It still means =1.
  • ambient::on() asks a new pipeline::builder_whole() instead of builder_runs(). The new check makes nothing, so the probes' resolve on a recording thread never waits for the builder's pipelines, and the stand-in turns itself off once the builder has run whole.

Offered separately, not in the branch

Our fork now turns ray tracing on by default: the builder runs unless VICTORY_BVH_BUILDER=0. After these fixes it ran whole on an RTX card, with no black, NaN or pink pixels. That is our fork's policy, so the branch does not change your default. If you want it, it is a one-line change to builder_setting in crates/victory-shader/src/lib.rs.

How it was tested

On the branch (off a-publier 4eb6cfdf9), on Windows:

  • cargo build --locked: OK, no warnings.
  • cargo test --locked -p victory-gpu --lib: 401 passed, 0 failed, 34 ignored.
  • cargo test --locked -p victory-shader --lib: 304 passed, 0 failed, 4 ignored.

The measurements above come from runs of the original commits on notquiteog/victory-nvidia (RTX card, Series S profile, render scale 0.5, walking). This port was not run in the title, and not on an AMD card.

  • The first three commits are cherry-picked with -x from e8258c1bb, 3e423ed0a and df64c27d5. The script changes from df64c27d5 that turned rays on by default were left out.
  • The fourth is a hand-port of b463129c8 without its change of default.
  • docs/fork-ray-tracing.md lists the new switches.

🤖 Generated with Claude Code

**@⁠notquiteog** on GitHub · 2026-11-26 23:12 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/385) Four fixes for the native ray tracing (the structure builder, `VICTORY_BVH_BUILDER=1`) are ready for you as a branch. A pull request isn't possible because this repo isn't in GitHub's fork network with ours. - **Branch:** https://github.com/notquiteog/victory-nvidia/tree/pr/belobug-bvh-fixes (4 commits on top of your `a-publier` 4eb6cfdf9). - **To pull it:** `git fetch https://github.com/notquiteog/victory-nvidia pr/belobug-bvh-fixes`, then merge or cherry-pick `FETCH_HEAD`. **Not tested on an AMD card.** The numbers below were measured on an RTX card, so the gains on an RDNA card may differ. Each fix has its own switch. All of them are on whenever the builder is on, and none of them does anything while it is off. **Your builder default does not change: it stays opt-in (`VICTORY_BVH_BUILDER=1`).** ## 1. Compacted-size bound (`VICTORY_BVH_SIZES_BOUND`, `=0` turns it off) The title reads a new structure's compacted size a frame or two after the builder's `GetBVHCompactedSize` program was recorded, and it does so without a fence. With `VICTORY_THIN` the list is translated and sent by our own threads, so the slot still held another structure's size. The compacting copy then wrote over its neighbours. `VICTORY_BVH_SIZES_WAIT` did not help because it blocks our sending thread, not the title's. The fix: - The main image's imports of `GetRaytracingAccelerationStructurePrebuildInfo` and `BuildRaytracingAccelerationStructureBatched2X` go through a new `victory-hle` module, `modules/bvh.rs`. - The prebuild answer (`ResultDataMaxSizeInBytes`, which is never smaller than the compacted size) is recorded for each build. - When the size program is translated, its slot gets that upper bound at once. - When the card's real size lands, a bottom-of-pipe write (`Written::SizeLanded`) puts the latest bound back if an earlier asking of the same slot lands after it. The new code is in `crates/victory-gpu/src/bvhsize.rs` (it has unit tests). Measured on an RTX card with the builder on: card time per frame went from 19 ms to 9 ms. ## 2. Builder pipelines early (`VICTORY_BVH_BUILDER_EARLY`, `=0` turns it off) The builder's first dispatch made its 53 pipelines one after another on its own thread. With a cold driver cache that took about a second each, so the title's main thread waited past its 30 s watchdog, and the title crashed with a store to address 0. Now each builder pipeline is queued for the pipeline workers when the title creates it, and all of them are promoted at the first dispatch, so they are made in parallel (`make::soon`). ## 3. The push (`VICTORY_BVH_PUSH`, `=0` turns it off), in `memory.rs` Every list that read title memory by address used to refresh the whole directory (128 MB) and every arena (64 MB each) through `GetWriteWatch`. Only `memory.rs` writes those, so it now puts the dwords that changed into the copies' CPU side as it writes them, and they go up with the next submission. Measured on an RTX card, this saves about 7 ms a frame on the submitting thread with rays on: `GetWriteWatch` went from 8.6 to 4.3 ms a frame. ## 4. One reading of the builder switch, and the ambient stand-in - `victory_shader::bvh_builder_on()` is now the single place that reads `VICTORY_BVH_BUILDER`, so the builder rule and the size bounds cannot disagree. It still means `=1`. - `ambient::on()` asks a new `pipeline::builder_whole()` instead of `builder_runs()`. The new check makes nothing, so the probes' resolve on a recording thread never waits for the builder's pipelines, and the stand-in turns itself off once the builder has run whole. ## Offered separately, not in the branch Our fork now turns ray tracing on by default: the builder runs unless `VICTORY_BVH_BUILDER=0`. After these fixes it ran whole on an RTX card, with no black, NaN or pink pixels. That is our fork's policy, so the branch does not change your default. If you want it, it is a one-line change to `builder_setting` in `crates/victory-shader/src/lib.rs`. ## How it was tested On the branch (off `a-publier` 4eb6cfdf9), on Windows: - `cargo build --locked`: OK, no warnings. - `cargo test --locked -p victory-gpu --lib`: 401 passed, 0 failed, 34 ignored. - `cargo test --locked -p victory-shader --lib`: 304 passed, 0 failed, 4 ignored. The measurements above come from runs of the original commits on notquiteog/victory-nvidia (RTX card, Series S profile, render scale 0.5, walking). This port was not run in the title, and not on an AMD card. - The first three commits are cherry-picked with `-x` from e8258c1bb, 3e423ed0a and df64c27d5. The script changes from df64c27d5 that turned rays on by default were left out. - The fourth is a hand-port of b463129c8 without its change of default. - `docs/fork-ray-tracing.md` lists the new switches. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:53 +00:00
Author
Owner

@⁠gw1337x on GitHub · 2026-11-26 23:59 UTC · original · edited 2026-11-27 04:32 UTC

Tested the branch in the title on an AMD card: RX 7800 XT 16 GB (RDNA 3, driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, 48 GB page file, Windows 11 26200 (Memory Integrity off). Diagnostics builds (--profile diag --features diagnostics) of ff87d84 and its base 4eb6cfd, same boot.

Settings: scripts/play.ps1 settings plus VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile, VICTORY_BVH_BUILDER=1, the branch's switches at their defaults. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures from VICTORY_TIMELINE windows of 30 frames at 200 s and 240 s. Runs interleaved base, fix, fix, base.

Run Build median / steady fps 1 s samples < 15 fps frame card running card idle GetWriteWatch (all threads) peak commit
1 4eb6cfd 17.0 / 18.0 73 / 202 52.3-53.3 ms 39.4-40.8 ms 11.5-14.0 ms 6.7-8.8 ms 37.1 GB
2 ff87d84 16.0 / 17.0 80 / 199 57.8-59.4 ms 41.9-43.4 ms 15.9-16.0 ms 1.6 ms 37.0 GB
3 ff87d84 15.0 / 15.0 95 / 200 65.3-65.8 ms 48.8-49.8 ms 16.1-16.6 ms 1.6 ms 37.3 GB
4 4eb6cfd 14.0 / 14.0 139 / 198 70.1-71.7 ms 51.4-53.3 ms 18.4-18.7 ms 5.8-5.9 ms 37.3 GB

What showed:

  • Active, from the log: the import wrap reports wrapped=2, the builder ran with all 53 pipelines, and structure sizes (VICTORY_BVH_SIZES_BOUND) reports about 43-46 sizes asked with a bound per 10 s (5-19 without, 0-1 put back). I did not check a log line for the early pipeline queuing (fix 2).
  • VICTORY_BVH_PUSH works here: GetWriteWatch falls from 5.8-8.8 to 1.6 ms a frame.
  • No fps change on this card: interleaved, both builds average 16 fps steady. The card's own time per frame is 39-53 ms in both and rose run after run through the session whichever build ran. The timeline's critical path ("the chain back through all frames", 200 s and 240 s windows) is shared between the card running submissions (7.6-32.3 ms a frame) and one of the title's own threads outside our spans (11.4-44.8 ms a frame), in both builds; the submitting thread, where the push saves its time, is not a large part of it, so that saving does not reach the frame rate here. The card-time drop measured on RTX (19 to 9 ms) did not show on RDNA 3 in this scene.
  • With ray tracing off (VICTORY_BVH_BUILDER unset), the branch measured the same as its base: 28.4 vs 28.5 fps steady, GetWriteWatch 1.7 vs 1.7-2.1 ms a frame.

Caveats: two runs a side, one scene (a boat on open water), picture not compared; the card time drifted upward across the session, which the interleaving is meant to cancel.

**@⁠gw1337x** on GitHub · 2026-11-26 23:59 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/385#issuecomment-7206076286) · edited 2026-11-27 04:32 UTC Tested the branch in the title on an AMD card: RX 7800 XT 16 GB (RDNA 3, driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, 48 GB page file, Windows 11 26200 (Memory Integrity off). Diagnostics builds (`--profile diag --features diagnostics`) of `ff87d84` and its base `4eb6cfd`, same boot. Settings: `scripts/play.ps1` settings plus `VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1`, Series X profile, `VICTORY_BVH_BUILDER=1`, the branch's switches at their defaults. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures from `VICTORY_TIMELINE` windows of 30 frames at 200 s and 240 s. Runs interleaved base, fix, fix, base. | Run | Build | median / steady fps | 1 s samples < 15 fps | frame | card running | card idle | `GetWriteWatch` (all threads) | peak commit | |---|---|---|---|---|---|---|---|---| | 1 | `4eb6cfd` | 17.0 / 18.0 | 73 / 202 | 52.3-53.3 ms | 39.4-40.8 ms | 11.5-14.0 ms | 6.7-8.8 ms | 37.1 GB | | 2 | `ff87d84` | 16.0 / 17.0 | 80 / 199 | 57.8-59.4 ms | 41.9-43.4 ms | 15.9-16.0 ms | 1.6 ms | 37.0 GB | | 3 | `ff87d84` | 15.0 / 15.0 | 95 / 200 | 65.3-65.8 ms | 48.8-49.8 ms | 16.1-16.6 ms | 1.6 ms | 37.3 GB | | 4 | `4eb6cfd` | 14.0 / 14.0 | 139 / 198 | 70.1-71.7 ms | 51.4-53.3 ms | 18.4-18.7 ms | 5.8-5.9 ms | 37.3 GB | What showed: - Active, from the log: the import wrap reports `wrapped=2`, the builder ran with all 53 pipelines, and `structure sizes (VICTORY_BVH_SIZES_BOUND)` reports about 43-46 sizes asked with a bound per 10 s (5-19 without, 0-1 put back). I did not check a log line for the early pipeline queuing (fix 2). - `VICTORY_BVH_PUSH` works here: `GetWriteWatch` falls from 5.8-8.8 to 1.6 ms a frame. - No fps change on this card: interleaved, both builds average 16 fps steady. The card's own time per frame is 39-53 ms in both and rose run after run through the session whichever build ran. The timeline's critical path ("the chain back through all frames", 200 s and 240 s windows) is shared between the card running submissions (7.6-32.3 ms a frame) and one of the title's own threads outside our spans (11.4-44.8 ms a frame), in both builds; the submitting thread, where the push saves its time, is not a large part of it, so that saving does not reach the frame rate here. The card-time drop measured on RTX (19 to 9 ms) did not show on RDNA 3 in this scene. - With ray tracing off (`VICTORY_BVH_BUILDER` unset), the branch measured the same as its base: 28.4 vs 28.5 fps steady, `GetWriteWatch` 1.7 vs 1.7-2.1 ms a frame. Caveats: two runs a side, one scene (a boat on open water), picture not compared; the card time drifted upward across the session, which the interleaving is meant to cancel.
This discussion has been locked. Commenting is limited to contributors.
No description provided.