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

Open
github-bot wants to merge 1 commit from github-bot/gh-495 into main AGit
Owner

@⁠Tarraga on GitHub · 2026-11-27 22:15 UTC · original
Tarraga:vibe/bvh-builder-pipelines-7636bf-pr → main · +201 −2 · 6 files · 1 commits · draft

Refs #496. A port of VIctory-macOS #485 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)
**@⁠Tarraga** on GitHub · 2026-11-27 22:15 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495) `Tarraga:vibe/bvh-builder-pipelines-7636bf-pr` → `main` · +201 −2 · 6 files · 1 commits · draft Refs #496. A port of VIctory-macOS #485 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)
XboxBvhBuilder.dll builds the ray-tracing structures with 52 compute programs
embedded in its image. Put off past the frame's budget for new pipelines like any
other, its dispatches were dropped during the world load (about 7,700 of them, 28
programs, in one run to the world), leaving the structures partly built for the run.

Its pipelines are now known by their bytecode in the DLL's image
(pipeline::note_title_dll), made at their first dispatch however long it takes
(group counts and thread counts), and if one cannot be made every builder
dispatch is dropped from then on. A port of VIctory-macOS #481.

Test: bvh_tests::the_bvh_builders_pipelines_are_made_past_the_frames_budget_or_held_back_together
(fails without the change: the builder's pipeline is not made once the frame's budget is spent).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 22:17:28 +00:00
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 02:00 UTC · original

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 #499'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 #422 #470 #424 #413 #452 #437 #499 #501 on 86cefd22 (a local integration build, plus the pass-trace fix from #513):

  • World corpus: 302 shaders newly translated and 1 regression (see #437).
  • 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.
**@⁠Olima34** on GitHub · 2026-11-28 02:00 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495#issuecomment-7232065916) 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 #499'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 #422 #470 #424 #413 #452 #437 #499 #501 on 86cefd22 (a local integration build, plus the pass-trace fix from #513): - **World corpus:** 302 shaders newly translated and 1 regression (see #437). - **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.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 17:19 UTC · original · approved these changes

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 #485, refs #496. 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.

**@⁠AnastasisKon** on GitHub · 2026-11-28 17:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/495#pullrequestreview-6099269060) · **approved these changes** 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 #485, refs #496. 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 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/499/head:github-bot/gh-495'
git switch 'github-bot/gh-495'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-495'
git switch 'github-bot/gh-495'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-495'
git switch 'github-bot/gh-495'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-495'
git switch 'main'
git merge --squash 'github-bot/gh-495'
git switch 'main'
git merge --ff-only 'github-bot/gh-495'
git switch 'main'
git merge 'github-bot/gh-495'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.