gpu(native): the ray-tracing structure builder's pipelines are never put off, and held back together if one fails (#492) #495

Open
Tarraga wants to merge 1 commit from upstream-pr/495 into main
Tarraga commented 2026-11-27 22:15:22 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Tarraga on 2026-11-27T22:15:22Z.


Refs #492. A port of VIctory-macOS #481 to the native host.

What this changes

Problem

XboxBvhBuilder.dll, a title DLL that runs in our process, builds and refits the ray-tracing structures in title memory with 52 compute programs embedded in its image. The host put its pipelines off like any other once a frame had spent its budget for new pipelines (glue::pipe, glue::thread_pipe), and a put-off pipeline's dispatches are dropped. Its stages depend on each other, and many run only while a level streams in, so a dropped dispatch is never rebuilt.

Evidence

From one run to the world (M4 Pro, 48 GB, Series S, a cold cache, a working branch that carries main's pipeline budget): 28 of the 52 programs lost about 7,700 dispatches in the 77 s of the world load, and the log has "a dispatch of thread counts without a host compute pipeline" there. The structures stay partly built for the rest of the run. I have not run the game on this branch's tree, so I do not claim any change in the picture here; what is shown is that the dispatches are no longer dropped, by the test below.

Fix

  • pipeline::note_title_dll (called from the loader's note) records where XboxBvhBuilder.dll is mapped. A pipeline is the builder's if its bytecode lies in that image (pipeline::builder_pipeline).
  • The builder's pipelines are never put off: made at their first dispatch however long it takes (BUILDER_WAIT, 120 s), for group counts and for thread counts.
  • If one cannot be made, every dispatch of the builder is dropped from then on, logged once (a BVH builder pipeline is not made), so no stage runs on what a missing one never wrote.
  • Cost: the frames that first make them wait for the compiles (52 programs, most small). This is a host policy, not console behaviour.
  • No new switch; behaviour is the same for every other pipeline. docs/native-host.md has a section on it.

How it was tested

  • bvh_tests::the_bvh_builders_pipelines_are_made_past_the_frames_budget_or_held_back_together (victory-gpu, x86_64 with D3DMetal 4.0b3's converter via VICTORY_MSC_DYLIB). With the frame's budget spent on the test's thread: an ordinary pipeline is put off, the builder's pipeline is made (by group counts and by thread counts), one that cannot be made holds every builder pipeline back, and the hold can be undone.
    • Passes with the change.
    • Without the change (the builder check off) it fails: made at once: ShaderStats { pipelines: 0, cached: 0, put_off: 0, refused: [] }.
  • Windows clippy (x86_64-pc-windows-gnullvm): not run locally (no such target on this Mac); left to CI. Host clippy shows no warning on the changed lines.
  • Full victory-gpu suite (x86_64, VICTORY_MSC_DYLIB, release): 412 passed, 1 failed, 6 ignored. The one failure, list::tests::unordered_access_clears_have_the_same_slots_in_both_layouts (it compares function addresses in a release build), fails the same on main (b998bb65: 411 passed, 1 failed, 6 ignored).

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented (none added; two log lines)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5533792046 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495). Originally posted by [Tarraga](https://github.com/Tarraga) on 2026-11-27T22:15:22Z. --- Refs #492. A port of VIctory-macOS #481 to the native host. ## What this changes ### Problem `XboxBvhBuilder.dll`, a title DLL that runs in our process, builds and refits the ray-tracing structures in title memory with 52 compute programs embedded in its image. The host put its pipelines off like any other once a frame had spent its budget for new pipelines (`glue::pipe`, `glue::thread_pipe`), and a put-off pipeline's dispatches are dropped. Its stages depend on each other, and many run only while a level streams in, so a dropped dispatch is never rebuilt. ### Evidence From one run to the world (M4 Pro, 48 GB, Series S, a cold cache, a working branch that carries main's pipeline budget): 28 of the 52 programs lost about 7,700 dispatches in the 77 s of the world load, and the log has "a dispatch of thread counts without a host compute pipeline" there. The structures stay partly built for the rest of the run. I have not run the game on this branch's tree, so I do not claim any change in the picture here; what is shown is that the dispatches are no longer dropped, by the test below. ### Fix - `pipeline::note_title_dll` (called from the loader's `note`) records where `XboxBvhBuilder.dll` is mapped. A pipeline is the builder's if its bytecode lies in that image (`pipeline::builder_pipeline`). - The builder's pipelines are never put off: made at their first dispatch however long it takes (`BUILDER_WAIT`, 120 s), for group counts and for thread counts. - If one cannot be made, every dispatch of the builder is dropped from then on, logged once (`a BVH builder pipeline is not made`), so no stage runs on what a missing one never wrote. - Cost: the frames that first make them wait for the compiles (52 programs, most small). This is a host policy, not console behaviour. - No new switch; behaviour is the same for every other pipeline. docs/native-host.md has a section on it. ## How it was tested - `bvh_tests::the_bvh_builders_pipelines_are_made_past_the_frames_budget_or_held_back_together` (victory-gpu, x86_64 with D3DMetal 4.0b3's converter via `VICTORY_MSC_DYLIB`). With the frame's budget spent on the test's thread: an ordinary pipeline is put off, the builder's pipeline is made (by group counts and by thread counts), one that cannot be made holds every builder pipeline back, and the hold can be undone. - Passes with the change. - Without the change (the builder check off) it fails: `made at once: ShaderStats { pipelines: 0, cached: 0, put_off: 0, refused: [] }`. - [ ] Windows clippy (`x86_64-pc-windows-gnullvm`): not run locally (no such target on this Mac); left to CI. Host clippy shows no warning on the changed lines. - Full victory-gpu suite (x86_64, `VICTORY_MSC_DYLIB`, release): 412 passed, 1 failed, 6 ignored. The one failure, `list::tests::unordered_access_clears_have_the_same_slots_in_both_layouts` (it compares function addresses in a release build), fails the same on main (b998bb65: 411 passed, 1 failed, 6 ignored). ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added; two log lines)
Olima34 commented 2026-11-28 02:00:37 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T02:00:37Z.


Thanks for this PR! An offline check of 4684dc49:

Measured offline on main 86cefd22 with examples/sweep + tools/corpus/compare.sh, on our 21,600-shader world corpus. The PR alone was swept over the 10,319 world shaders that the combination below changes. "Passes/frame" is an estimate from four traced world frames of an earlier preview run: the dropped passes whose only refused shader this PR translates.

#495 alone: no translator output changes (0 newly translated, 0 changed, 0 regressions), as expected for a pipeline-scheduling change.

GPU errors and fps: I can't isolate #495's effect from the run below, because there was no matching run without it. In the combination run, there were no GPU errors and the world ran at about 1.4 fps.

In combination with #418 #466 #420 #409 #448 #433 #495 #497 on 86cefd22 (a local integration build, plus the pass-trace fix from #509):

  • World corpus: 302 shaders newly translated and 1 regression (see #433).
  • Windowed run (6 min): no GPU errors, and the GPU memory drained afterwards. About 1.4 fps in the world. 351 passes dropped per world frame, against 456 in an earlier census of the preview branch; these are different runs, so not a clean A/B.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232065916 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495#issuecomment-7232065916). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T02:00:37Z. --- Thanks for this PR! An offline check of 4684dc49: Measured offline on main 86cefd22 with `examples/sweep` + `tools/corpus/compare.sh`, on our 21,600-shader world corpus. The PR alone was swept over the 10,319 world shaders that the combination below changes. "Passes/frame" is an estimate from four traced world frames of an earlier preview run: the dropped passes whose only refused shader this PR translates. **#495 alone:** no translator output changes (0 newly translated, 0 changed, 0 regressions), as expected for a pipeline-scheduling change. **GPU errors and fps:** I can't isolate #495's effect from the run below, because there was no matching run without it. In the combination run, there were no GPU errors and the world ran at about 1.4 fps. **In combination** with #418 #466 #420 #409 #448 #433 #495 #497 on 86cefd22 (a local integration build, plus the pass-trace fix from #509): - **World corpus:** 302 shaders newly translated and 1 regression (see #433). - **Windowed run (6 min):** no GPU errors, and the GPU memory drained afterwards. About 1.4 fps in the world. 351 passes dropped per world frame, against 456 in an earlier census of the preview branch; these are different runs, so not a clean A/B.
AnastasisKon commented 2026-11-28 17:19:24 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T17:19:24Z.

Review: APPROVED


Read the diff: XboxBvhBuilder.dll's 52 embedded compute programs are now recognised as the ray-tracing structure builder's (pipeline.rs) and their pipelines are never put off for the frame budget, and are held back together when one fails — a port of the Windows-side #481, refs #492. Verified on the head 4684dc49: the new bvh_tests pass under the darwin target, the full victory-gpu darwin lib suite is green at --test-threads=4 (413 passed / 0 failed), and the workspace windows clippy with -D warnings is clean. Approving.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6099269060 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495#pullrequestreview-6099269060). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T17:19:24Z. **Review:** APPROVED --- Read the diff: `XboxBvhBuilder.dll`'s 52 embedded compute programs are now recognised as the ray-tracing structure builder's (pipeline.rs) and their pipelines are never put off for the frame budget, and are held back together when one fails — a port of the Windows-side #481, refs #492. Verified on the head 4684dc49: the new `bvh_tests` pass under the darwin target, the full `victory-gpu` darwin lib suite is green at `--test-threads=4` (413 passed / 0 failed), and the workspace windows clippy with `-D warnings` is clean. Approving.
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/495:upstream-pr/495'
git switch 'upstream-pr/495'

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/495'
git switch 'upstream-pr/495'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/495'
git switch 'upstream-pr/495'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/495'
git switch 'main'
git merge --squash 'upstream-pr/495'
git switch 'main'
git merge --ff-only 'upstream-pr/495'
git switch 'main'
git merge 'upstream-pr/495'
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
LakshanSivakumar/Native-Victory-macOS!495
No description provided.