d3d12: pin guest-memory BLAS storage per TLAS and normalize prebuild geometry #455

Merged
DrArroway merged 1 commit from upstream-pr/455 into main 2026-11-29 12:00:38 +00:00
DrArroway commented 2026-11-29 07:45:03 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T07:45:03Z.


Summary

Contributes toward #403 (scoped cleanly around what is already merged in #409/#428 and open in #436, #442, #443, and #445):

  1. TLAS-pinned BLAS storage lifetime & fence-backed retirement

    • Tracks active private/relocated AS resources in Mappings.resources alongside Mappings.addresses, and binds a snapshot (tlas_deps) to each live non-empty TLAS build (Instances).
    • Propagates tlas_deps across Copy (CLONE / COMPACT), clears it on overwrite/release (publish_release, Native, cooked Input), and removes stale entries on Registration::drop, with full MappingSubmission rollback support.
    • Adds queue_trace::pending_fences() and a dedicated RetirementQueue (device/blas/lifetime.rs) so superseded private AS storages and TLAS dependency snapshots remain alive until all pending queue fences recorded at retirement time complete.
  2. Prebuild-after-translation, Xbox vertex format normalization & vertex_bytes

    • Translates non-TLAS geometry inputs (guest_addresses::geometry) before calling GetRaytracingAccelerationStructurePrebuildInfo in build_raytracing::translate, so host prebuild sizing sees decoded formats (R32_UINT, R32G32B32_FLOAT) and index-expanded VertexCount.
    • Normalizes Xbox meshlet index format 53 (to R32_UINT, clamping VertexCount to 1 << 16) and packed R32G32_FLOAT vertex format (to R32G32B32_FLOAT, stride 12) in device::ray_build::prebuild.
    • Adds explicit 12-byte and 16-byte vertex format widths in guest_addresses::vertex_bytes (DXGI_FORMAT_R32G32B32_{FLOAT,UINT,SINT} and DXGI_FORMAT_R32G32B32A32_{FLOAT,UINT,SINT}).

Tested

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: NVIDIA GPU checks and native Windows still need to be run.

GPU, driver and backend:

  • AMD Radeon RX 6900 XT (1002:73bf), Mesa RADV 26.3.1, GE-Proton11-14 (Linux 7.3.6)
  • AMD Raphael Radeon 610M (1002:164e), Mesa RADV 26.3.1, GE-Proton11-14 (Linux 7.3.6)

Added coverage:

  • Unit tests: normalize_prebuild_geometry_converts_xbox_formats_only (runtime/d3d12/src/tests/device/ray_build.rs), tlas_dependencies_replace_retire_and_roll_back and tlas_dependencies_copy_and_roll_back (runtime/d3d12/src/tests/device/blas/guest_memory.rs).
  • Lanes ray-tracing-guest-memory (examples/lanes/selftest.cpp): verifies a live TLAS still hits an evicted guest-memory BLAS after destroying the overwriting queue/allocator and reopening the earlier build list, then observes it as inactive once the scene is rebuilt.

Commands run and their results:

tuxbox.py check --backend proton --proton <GE-Proton11-14> --prefix <prefix> --windows-dxc <dxc-windows> --adapter 1002:73bf
  All 11 check steps passed: 114/114 Lanes & fixtures (0 skipped, 0 failed), 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI test suites.

tuxbox.py check --backend proton --proton <GE-Proton11-14> --prefix <prefix> --windows-dxc <dxc-windows> --adapter 1002:164e
  All 11 check steps passed: 113/113 Lanes & fixtures (0 skipped, 0 failed), 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI test suites.

tuxbox-d3d12 --lib (under GE-Proton11-14, 1002:73bf)
  346 passed, 0 failed, 8 ignored (*_cost / *_probe / watched_refresh_with_xmem).

ProjectScarlett 1.0.2.1 (offline, 3840x2160, 1002:73bf, tested with #441 applied for the unrelated root-SRV draw fault)
  545.6s, 24+ consecutive 3D world frames, live AS churn (998/173 MiB reclaimed down to 921/100 MiB), 0 GPUVM faults, 0 VK_ERROR_DEVICE_LOST (exited on an unrelated title CPU access violation).
<!-- greyfinch-sync:brcly/TuxBox:issue:5548737222 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/455). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T07:45:03Z. --- ## Summary Contributes toward #403 (scoped cleanly around what is already merged in #409/#428 and open in #436, #442, #443, and #445): 1. **TLAS-pinned BLAS storage lifetime & fence-backed retirement** - Tracks active private/relocated AS resources in `Mappings.resources` alongside `Mappings.addresses`, and binds a snapshot (`tlas_deps`) to each live non-empty TLAS build (`Instances`). - Propagates `tlas_deps` across `Copy` (`CLONE` / `COMPACT`), clears it on overwrite/release (`publish_release`, `Native`, cooked `Input`), and removes stale entries on `Registration::drop`, with full `MappingSubmission` rollback support. - Adds `queue_trace::pending_fences()` and a dedicated `RetirementQueue` (`device/blas/lifetime.rs`) so superseded private AS storages and TLAS dependency snapshots remain alive until all pending queue fences recorded at retirement time complete. 2. **Prebuild-after-translation, Xbox vertex format normalization & `vertex_bytes`** - Translates non-TLAS geometry inputs (`guest_addresses::geometry`) before calling `GetRaytracingAccelerationStructurePrebuildInfo` in `build_raytracing::translate`, so host prebuild sizing sees decoded formats (`R32_UINT`, `R32G32B32_FLOAT`) and index-expanded `VertexCount`. - Normalizes Xbox meshlet index format `53` (to `R32_UINT`, clamping `VertexCount` to `1 << 16`) and packed `R32G32_FLOAT` vertex format (to `R32G32B32_FLOAT`, stride `12`) in `device::ray_build::prebuild`. - Adds explicit 12-byte and 16-byte vertex format widths in `guest_addresses::vertex_bytes` (`DXGI_FORMAT_R32G32B32_{FLOAT,UINT,SINT}` and `DXGI_FORMAT_R32G32B32A32_{FLOAT,UINT,SINT}`). ## Tested - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: **NVIDIA GPU checks and native Windows still need to be run.** GPU, driver and backend: - AMD Radeon RX 6900 XT (`1002:73bf`), Mesa RADV 26.3.1, GE-Proton11-14 (Linux 7.3.6) - AMD Raphael Radeon 610M (`1002:164e`), Mesa RADV 26.3.1, GE-Proton11-14 (Linux 7.3.6) Added coverage: - Unit tests: `normalize_prebuild_geometry_converts_xbox_formats_only` (`runtime/d3d12/src/tests/device/ray_build.rs`), `tlas_dependencies_replace_retire_and_roll_back` and `tlas_dependencies_copy_and_roll_back` (`runtime/d3d12/src/tests/device/blas/guest_memory.rs`). - Lanes `ray-tracing-guest-memory` (`examples/lanes/selftest.cpp`): verifies a live TLAS still hits an evicted guest-memory BLAS after destroying the overwriting queue/allocator and reopening the earlier build list, then observes it as inactive once the scene is rebuilt. Commands run and their results: ```text tuxbox.py check --backend proton --proton <GE-Proton11-14> --prefix <prefix> --windows-dxc <dxc-windows> --adapter 1002:73bf All 11 check steps passed: 114/114 Lanes & fixtures (0 skipped, 0 failed), 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI test suites. tuxbox.py check --backend proton --proton <GE-Proton11-14> --prefix <prefix> --windows-dxc <dxc-windows> --adapter 1002:164e All 11 check steps passed: 113/113 Lanes & fixtures (0 skipped, 0 failed), 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI test suites. tuxbox-d3d12 --lib (under GE-Proton11-14, 1002:73bf) 346 passed, 0 failed, 8 ignored (*_cost / *_probe / watched_refresh_with_xmem). ProjectScarlett 1.0.2.1 (offline, 3840x2160, 1002:73bf, tested with #441 applied for the unrelated root-SRV draw fault) 545.6s, 24+ consecutive 3D world frames, live AS churn (998/173 MiB reclaimed down to 921/100 MiB), 0 GPUVM faults, 0 VK_ERROR_DEVICE_LOST (exited on an unrelated title CPU access violation). ```
DrArroway commented 2026-11-29 09:44:00 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T09:44:00Z.


Rebased onto current main (75453953) at 361df2d4:

  • Integrated cleanly with #436, #442, #443, and #445:
    • publish_locked in runtime/d3d12/src/device/blas/guest_memory.rs now maintains both mappings.addresses and mappings.resources (removing mappings.resources when publish_refused sets 0).
    • Kept #445's in_place / updated_extent tests, #443's private_scratch, and #436's unbuilt / withdraw / Sizes::Zero paths alongside #455's TLAS-pinned storage lifetime and prebuild geometry normalization.
    • Updated ray_tracing_guest_memory in examples/lanes/selftest.cpp to preserve both the #436 unbuilt-copy checks and the TLAS-pinned survival check.

Re-verified on 361df2d4

  • AMD RX 6900 XT (1002:73bf, RADV NAVI21, Mesa 26.3.1, GE-Proton11-14): python tuxbox.py check — all 11 steps passed (117/117 Lanes & guest fixtures including all 7 ray-tracing-* selftests, 22/22 D3D12 regression controls, shader translator on GPU, and all CPU/CI suites).
  • AMD Raphael Radeon 610M (1002:164e, RADV, Mesa 26.3.1, GE-Proton11-14): python tuxbox.py check — all 11 steps passed (116/116 Lanes & guest fixtures, guest-present-4k-splash skipped on software display, 22/22 D3D12 regression controls, shader translator on GPU, and all CPU/CI suites).
  • Windows unit tests (tuxbox-d3d12 --lib via Proton): 357 passed; 0 failed; 8 ignored.
  • ProjectScarlett sanity run (1002:73bf, with #441 + #439 on top for the unrelated root-SRV fault and faster readbacks): 403.9s, 30 consecutive 3D world frames (7548 → 7578), live BLAS churn across 512+ pools (3,700 → 2,784 → 3,854 live allocations), 0 GPU faults / 0 VK_ERROR_DEVICE_LOST.
<!-- greyfinch-sync:brcly/TuxBox:comment:7253959092 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/455#issuecomment-7253959092). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T09:44:00Z. --- Rebased onto current `main` (`75453953`) at `361df2d4`: - Integrated cleanly with `#436`, `#442`, `#443`, and `#445`: - `publish_locked` in `runtime/d3d12/src/device/blas/guest_memory.rs` now maintains both `mappings.addresses` and `mappings.resources` (removing `mappings.resources` when `publish_refused` sets `0`). - Kept `#445`'s `in_place` / `updated_extent` tests, `#443`'s `private_scratch`, and `#436`'s `unbuilt` / `withdraw` / `Sizes::Zero` paths alongside `#455`'s TLAS-pinned storage lifetime and prebuild geometry normalization. - Updated `ray_tracing_guest_memory` in `examples/lanes/selftest.cpp` to preserve both the `#436` unbuilt-copy checks and the TLAS-pinned survival check. ### Re-verified on `361df2d4` - **AMD RX 6900 XT (`1002:73bf`, RADV NAVI21, Mesa 26.3.1, `GE-Proton11-14`):** `python tuxbox.py check` — all 11 steps passed (`117/117` Lanes & guest fixtures including all 7 `ray-tracing-*` selftests, `22/22` D3D12 regression controls, shader translator on GPU, and all CPU/CI suites). - **AMD Raphael Radeon 610M (`1002:164e`, RADV, Mesa 26.3.1, `GE-Proton11-14`):** `python tuxbox.py check` — all 11 steps passed (`116/116` Lanes & guest fixtures, `guest-present-4k-splash` skipped on software display, `22/22` D3D12 regression controls, shader translator on GPU, and all CPU/CI suites). - **Windows unit tests (`tuxbox-d3d12 --lib` via Proton):** `357 passed; 0 failed; 8 ignored`. - **ProjectScarlett sanity run (`1002:73bf`, with `#441` + `#439` on top for the unrelated root-SRV fault and faster readbacks):** `403.9s`, 30 consecutive 3D world frames (`7548` → `7578`), live BLAS churn across `512+` pools (`3,700` → `2,784` → `3,854` live allocations), `0` GPU faults / `0` `VK_ERROR_DEVICE_LOST`.
NickStallman commented 2026-11-29 09:49:37 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:49:37Z.


Thanks for rebasing it so quickly. Two things:

  • NVIDIA: I've queued a full tuxbox.py check of 361df2d4 on an RTX 5090. It comes after my own checks, and I'll post the result, pass or fail.
  • Overlap with my draft #461 (a refused build keeps its storage, so a copy of it still reaches the host). They conflict in guest_memory.rs and its tests. From reading 361df2d4, the same gap is in this branch, as on main: publish_refused removes the published address and resource but not the entry in targets, so unbuilt() still sees a source with storage. It's a small change next to yours: withdraw the storage there and let the recording list keep what comes back. If yours lands first I'll rebase #461 on it, so there's nothing for you to do. I haven't run either on a GPU together.
<!-- greyfinch-sync:brcly/TuxBox:comment:7254023289 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/455#issuecomment-7254023289). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T09:49:37Z. --- Thanks for rebasing it so quickly. Two things: - **NVIDIA:** I've queued a full `tuxbox.py check` of `361df2d4` on an RTX 5090. It comes after my own checks, and I'll post the result, pass or fail. - **Overlap with my draft #461** (a refused build keeps its storage, so a copy of it still reaches the host). They conflict in `guest_memory.rs` and its tests. From reading `361df2d4`, the same gap is in this branch, as on `main`: `publish_refused` removes the published address and resource but not the entry in `targets`, so `unbuilt()` still sees a source with storage. It's a small change next to yours: withdraw the storage there and let the recording list keep what comes back. If yours lands first I'll rebase #461 on it, so there's nothing for you to do. I haven't run either on a GPU together.
NickStallman commented 2026-11-29 11:35:56 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T11:35:56Z.


The NVIDIA full check of 361df2d4 is done: python tuxbox.py check on an RTX 5090 (620.70.10, GE-Proton11-14): 181 pass, 0 fail, including 7 ray-tracing selftests. This is a rerun with no game running, though small GPU shader tests of mine may have overlapped it; the first attempt was stopped by a game reaching its world.

<!-- greyfinch-sync:brcly/TuxBox:comment:7255220794 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/455#issuecomment-7255220794). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T11:35:56Z. --- The NVIDIA full check of `361df2d4` is done: `python tuxbox.py check` on an RTX 5090 (620.70.10, GE-Proton11-14): 181 pass, 0 fail, including 7 ray-tracing selftests. This is a rerun with no game running, though small GPU shader tests of mine may have overlapped it; the first attempt was stopped by a game reaching its world.
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
brcly/TuxBox!455
No description provided.