d3d12: keep replaced views for the records a title copied #393

Merged
MathiewMay merged 2 commits from upstream-pr/393 into main 2026-11-28 16:55:02 +00:00
MathiewMay commented 2026-11-28 09:58:07 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T09:58:07Z.


Stacked on #391. The first commit is #391's; this PR adds the second, "d3d12: keep replaced views for the records a title copied". I'll rebase it once #391 is merged.

Summary

On console a descriptor copy holds the descriptor's bytes, so a title can reuse a CPU heap slot as soon as it has copied from it. ProjectScarlett writes a descriptor into a CPU heap of 3,128 slots, copies its 32 bytes into its shader-visible heap, and writes the next descriptor into the same slot. Here the copied bytes are a record naming the slot and the version written there. Once the slot was written again, the record named a view that no longer existed. A root table could not resolve it, and neither could the index map's refresh from #391, which counts it stale and leaves the slot's old view.

  • descriptor_paging/history.rs (new): before the API replaces views in a heap of such records, the views about to be replaced are copied into a ring of 65,536 host descriptors, indexed by version. This happens for a descriptor write (Write::new) and for a descriptor copy into the heap (copy_host_range).
  • Arena::resolve_inline: versions are unique across the device, so a record whose version is no longer the slot's resolves to its kept view, while fewer than 65,536 views have been replaced since. Root tables and the index map both resolve through it.
  • The ring is one CPU-only descriptor heap per device, made with the first heap of such records. Its views keep the same tracking as a heap slot's (imported, placed and scene views). If it cannot be made, records resolve as before.

In ProjectScarlett, with traces I kept out of this branch, the refresh counted 16,661 stale records in 84 s without this change and 2,848 in 165 s with it, about 12 times fewer per second. The copies a submission reaches lag about 12,500 versions behind their slot. Some still go stale: they lag further, and I have not checked whether that is past the ring.

In game I tested this on an older main together with other fixes of mine, not on this branch alone; with all my fixes a 30-minute run had no fault.

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 still needs to run them.

New Lanes scenario bindless-raw-copy-reused (gates lanes-bindless-raw-copy-reused-wide and -constrained, in the lanes-bindless-compute suite). It is #391's bindless-raw-copy, except that the title writes another view into the CPU heap slot it copied from before it submits. The copy must keep the view it was given. With #391 alone both gates fail:

lanes-selftest FAIL bindless-raw-copy-reused: the program stored through the view the slot held before the copy

GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (--backend proton).

Commands run and their results:

python build.py, with #391's runtime/d3d12/src
python tuxbox.py verify --only lanes-bindless-compute --backend proton --adapter 1002:7550
  14 PASS, 2 FAIL: lanes-bindless-raw-copy-reused-wide, lanes-bindless-raw-copy-reused-constrained (above)

python build.py, with the change
python tuxbox.py verify --only guest-frame --only present --only lanes --only lanes-selftest
    --only lanes-shader-cache --only lanes-raster-tables --only lanes-compute-root
    --only lanes-compute-root-recovery --only lanes-compute-root-srv --only lanes-large-dispatch
    --only lanes-late-pipeline --only lanes-bindless-compute --only lanes-compute-heap-stride
    --only d3d12-exports --only d3d12-features --only d3d12-indirect --only d3d12-queries
    --only d3d12-queues --only d3d12-tables --only d3d12-heaps --only d3d12-placement
    --only d3d12-copy-resource --only d3d12-draw --only d3d12-stream --only d3d12-frame-events
    --only d3d12-guids --only d3d12-signatures --only d3d12-mesh --backend proton --adapter 1002:7550
  82 PASS, 0 FAIL (the four raw-copy gates included)

D3D12 regression controls, all 20 cases
  20 PASS, 0 FAIL

cargo xwin test --no-run --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --lib, the test executable run under Proton
  225 passed, 0 failed

python tuxbox.py check --no-gpu
  passed   Build the shader compiler, Python tests, Shader compiler tests, DXBC tests,
           XG layout tests, Storage codec tests, D3D12 Windows typecheck

The D3D12 controls ran with the tool's own case table, staging and validate, but outside its Bubblewrap/xvfb-run sandbox, which stalls on this machine (it has no Xvfb).

Checks

No evidence JSON changes.

<!-- greyfinch-sync:brcly/TuxBox:issue:5538971912 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/393). Originally posted by [MathiewMay](https://github.com/MathiewMay) on 2026-11-28T09:58:07Z. --- **Stacked on #391.** The first commit is #391's; this PR adds the second, "d3d12: keep replaced views for the records a title copied". I'll rebase it once #391 is merged. ## Summary On console a descriptor copy holds the descriptor's bytes, so a title can reuse a CPU heap slot as soon as it has copied from it. ProjectScarlett writes a descriptor into a CPU heap of 3,128 slots, copies its 32 bytes into its shader-visible heap, and writes the next descriptor into the same slot. Here the copied bytes are a record naming the slot and the version written there. Once the slot was written again, the record named a view that no longer existed. A root table could not resolve it, and neither could the index map's refresh from #391, which counts it stale and leaves the slot's old view. - `descriptor_paging/history.rs` (new): before the API replaces views in a heap of such records, the views about to be replaced are copied into a ring of 65,536 host descriptors, indexed by version. This happens for a descriptor write (`Write::new`) and for a descriptor copy into the heap (`copy_host_range`). - `Arena::resolve_inline`: versions are unique across the device, so a record whose version is no longer the slot's resolves to its kept view, while fewer than 65,536 views have been replaced since. Root tables and the index map both resolve through it. - The ring is one CPU-only descriptor heap per device, made with the first heap of such records. Its views keep the same tracking as a heap slot's (imported, placed and scene views). If it cannot be made, records resolve as before. In ProjectScarlett, with traces I kept out of this branch, the refresh counted 16,661 stale records in 84 s without this change and 2,848 in 165 s with it, about 12 times fewer per second. The copies a submission reaches lag about 12,500 versions behind their slot. Some still go stale: they lag further, and I have not checked whether that is past the ring. In game I tested this on an older `main` together with other fixes of mine, not on this branch alone; with all my fixes a 30-minute run had no fault. ## 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 still needs to run them.** New Lanes scenario `bindless-raw-copy-reused` (gates `lanes-bindless-raw-copy-reused-wide` and `-constrained`, in the `lanes-bindless-compute` suite). It is #391's `bindless-raw-copy`, except that the title writes another view into the CPU heap slot it copied from before it submits. The copy must keep the view it was given. With #391 alone both gates fail: ```text lanes-selftest FAIL bindless-raw-copy-reused: the program stored through the view the slot held before the copy ``` GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (`--backend proton`). Commands run and their results: ```text python build.py, with #391's runtime/d3d12/src python tuxbox.py verify --only lanes-bindless-compute --backend proton --adapter 1002:7550 14 PASS, 2 FAIL: lanes-bindless-raw-copy-reused-wide, lanes-bindless-raw-copy-reused-constrained (above) python build.py, with the change python tuxbox.py verify --only guest-frame --only present --only lanes --only lanes-selftest --only lanes-shader-cache --only lanes-raster-tables --only lanes-compute-root --only lanes-compute-root-recovery --only lanes-compute-root-srv --only lanes-large-dispatch --only lanes-late-pipeline --only lanes-bindless-compute --only lanes-compute-heap-stride --only d3d12-exports --only d3d12-features --only d3d12-indirect --only d3d12-queries --only d3d12-queues --only d3d12-tables --only d3d12-heaps --only d3d12-placement --only d3d12-copy-resource --only d3d12-draw --only d3d12-stream --only d3d12-frame-events --only d3d12-guids --only d3d12-signatures --only d3d12-mesh --backend proton --adapter 1002:7550 82 PASS, 0 FAIL (the four raw-copy gates included) D3D12 regression controls, all 20 cases 20 PASS, 0 FAIL cargo xwin test --no-run --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --lib, the test executable run under Proton 225 passed, 0 failed python tuxbox.py check --no-gpu passed Build the shader compiler, Python tests, Shader compiler tests, DXBC tests, XG layout tests, Storage codec tests, D3D12 Windows typecheck ``` The D3D12 controls ran with the tool's own case table, staging and `validate`, but outside its Bubblewrap/`xvfb-run` sandbox, which stalls on this machine (it has no Xvfb). ## Checks No evidence JSON changes.
DrArroway commented 2026-11-28 15:28:10 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-28T15:28:10Z.


Tested in ProjectScarlett 1.0.2.1 on an AMD Radeon RX 6900 XT (1002:73bf, RADV NAVI21), Mesa 26.3.1, Linux 7.3.6, GE-Proton11-14 (--backend proton), warm shader caches.

  • Without #389 and #393 (main at 6f89916): Two runs both lost the device immediately on the first 3D world frame (radv: GPUVM fault, CLIENT_ID: TCP (0x8)).
  • With #393 (d9dfe887, including #391) stacked with #373, #389 and #398 on 6f89916: Rendered 13+ world frames over 7m 12s (2,105 frames total) with 0 GPUVM faults and 0 device losses (ending on a title CPU EXCEPTION_BREAKPOINT in resource loading). Two further world runs rebased onto e380da1 also entered the world cleanly with no copied-descriptor faults.

Also confirmed this rebases cleanly onto main after #395 and #399 (567bd04), needing only in_flight: Mutex::default(), pins: Mutex::default() added to the test Arena literal in runtime/d3d12/src/tests/device/descriptor_paging.rs.

<!-- greyfinch-sync:brcly/TuxBox:comment:7241489269 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/393#issuecomment-7241489269). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-28T15:28:10Z. --- Tested in ProjectScarlett 1.0.2.1 on an AMD Radeon RX 6900 XT (`1002:73bf`, RADV NAVI21), Mesa 26.3.1, Linux 7.3.6, GE-Proton11-14 (`--backend proton`), warm shader caches. - **Without #389 and #393 (`main` at `6f89916`):** Two runs both lost the device immediately on the first 3D world frame (`radv: GPUVM fault`, `CLIENT_ID: TCP (0x8)`). - **With #393 (`d9dfe887`, including #391) stacked with #373, #389 and #398 on `6f89916`:** Rendered `13+` world frames over 7m 12s (`2,105` frames total) with `0` GPUVM faults and `0` device losses (ending on a title CPU `EXCEPTION_BREAKPOINT` in resource loading). Two further world runs rebased onto `e380da1` also entered the world cleanly with no copied-descriptor faults. Also confirmed this rebases cleanly onto `main` after #395 and #399 (`567bd04`), needing only `in_flight: Mutex::default(), pins: Mutex::default()` added to the test `Arena` literal in `runtime/d3d12/src/tests/device/descriptor_paging.rs`.
MathiewMay commented 2026-11-28 16:19:44 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T16:19:44Z.


Thanks for testing, and for the rebase note.

Rebased onto 2af42c9 with that change: the test Arena literal gets in_flight and pins. The literal is in #391's commit, so the change is there. #391 is now 99d8569, and this branch is 0ae06f5 on top of it.

After the rebase, on an RX 9070 (RADV GFX1201, Mesa 26.2.7, GE-Proton11-14): 292 crate tests pass, the 39 lanes-selftest and lanes-bindless-compute gates pass (including the four raw-copy ones), and tuxbox.py check --no-gpu passes.

<!-- greyfinch-sync:brcly/TuxBox:comment:7242156962 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/393#issuecomment-7242156962). Originally posted by [MathiewMay](https://github.com/MathiewMay) on 2026-11-28T16:19:44Z. --- Thanks for testing, and for the rebase note. Rebased onto `2af42c9` with that change: the test `Arena` literal gets `in_flight` and `pins`. The literal is in #391's commit, so the change is there. #391 is now `99d8569`, and this branch is `0ae06f5` on top of it. After the rebase, on an RX 9070 (RADV GFX1201, Mesa 26.2.7, GE-Proton11-14): 292 crate tests pass, the 39 `lanes-selftest` and `lanes-bindless-compute` gates pass (including the four raw-copy ones), and `tuxbox.py check --no-gpu` passes.
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!393
No description provided.