d3d12: let an update in place take no more than the structure there #445

Merged
NickStallman merged 1 commit from upstream-pr/445 into main 2026-11-29 09:03:33 +00:00
NickStallman commented 2026-11-29 05:00:14 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T05:00:14Z.


Summary

A structure in title memory reserves the space its build or copy takes, and a new one releases the older ones it covers. An in-place update was booked at the host's size for a full build. A title updates a compacted copy where it lies and packs the next one right after it, inside that size, so each update released its neighbour. A scene then lost that neighbour's instances, and the neighbour's own update found no structure and was built in full, over the first one in turn.

An update in place now books what the structure at its address already reserves (the smaller of that and the host size). Updates into another address, or where no structure lies, and full builds are unchanged.

Why it's sound

An update where a structure lies can't take more than that structure reserves. A copy stays booked at the 256-byte minimum, as on main. A structure kept too long is one whose tail was overwritten beyond 256 bytes; a title naming it names overwritten memory on the console too, and a structure built there is published at its own address. The cost is storage held longer for copies the title has freed.

Evidence (ProjectScarlett, RTX 5090, integration builds that don't include this change)

  • In two runs with a diagnostic switch that keeps such neighbours, 20 were kept; all 20 were updates over an already booked copy, and all the neighbours were copies.
  • The spacing between packed structures repeats across runs for the same host size, which fits packing by compacted size.
  • Runs without the switch rebuilt up to 64 updates in full for lack of storage.

Not shown

  • That the title's updates write in place (source equals destination); the logs don't record it. If they don't, this does nothing.
  • That this causes or prevents any GPU loss.

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

Lanes: ray-tracing-packed-update is new. It fails on main (28717263 with this PR's Lanes change, AMD) and passes with the fix on both cards. It proves nothing on a driver where compaction saves no space.

Three unit tests are new; two fail when the rule is removed. The project's checks only typecheck the D3D12 crate, so these don't run in check.

GPU, driver and backend:

  • RTX 5090 (10de:2b85), NVIDIA 620.70.10
  • AMD Raphael iGPU (1002:13c0), Mesa RADV 26.0.8
  • both on GE-Proton11-14
python tuxbox.py check --no-gpu
  all 7 steps passed
python tuxbox.py check --adapter 10de:2b85 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64
  all steps passed
python tuxbox.py check --adapter 1002:13c0 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64
  all steps passed (guest-present-4k-splash skipped: this GPU presents to the test display through software)

Some of these ran while a game was loading its shaders on the 5090. Not run in the game with this change, or on Windows. #442 also edits blas.rs; whichever merges second needs a small rebase.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5547737339 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/445). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T05:00:14Z. --- ## Summary A structure in title memory reserves the space its build or copy takes, and a new one releases the older ones it covers. An in-place update was booked at the host's size for a full build. A title updates a compacted copy where it lies and packs the next one right after it, inside that size, so each update released its neighbour. A scene then lost that neighbour's instances, and the neighbour's own update found no structure and was built in full, over the first one in turn. An update in place now books what the structure at its address already reserves (the smaller of that and the host size). Updates into another address, or where no structure lies, and full builds are unchanged. ## Why it's sound An update where a structure lies can't take more than that structure reserves. A copy stays booked at the 256-byte minimum, as on `main`. A structure kept too long is one whose tail was overwritten beyond 256 bytes; a title naming it names overwritten memory on the console too, and a structure built there is published at its own address. The cost is storage held longer for copies the title has freed. ## Evidence (ProjectScarlett, RTX 5090, integration builds that don't include this change) - In two runs with a diagnostic switch that keeps such neighbours, 20 were kept; **all 20 were updates over an already booked copy, and all the neighbours were copies.** - The spacing between packed structures repeats across runs for the same host size, which fits packing by compacted size. - Runs without the switch rebuilt up to 64 updates in full for lack of storage. ## Not shown - That the title's updates write in place (source equals destination); the logs don't record it. If they don't, this does nothing. - That this causes or prevents any GPU loss. ## 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 - [x] Where the table calls for AMD and NVIDIA, they passed on both **Lanes:** `ray-tracing-packed-update` is new. It fails on `main` (28717263 with this PR's Lanes change, AMD) and passes with the fix on both cards. It proves nothing on a driver where compaction saves no space. Three unit tests are new; two fail when the rule is removed. The project's checks only typecheck the D3D12 crate, so these don't run in `check`. GPU, driver and backend: - RTX 5090 (10de:2b85), NVIDIA 620.70.10 - AMD Raphael iGPU (1002:13c0), Mesa RADV 26.0.8 - both on GE-Proton11-14 ```text python tuxbox.py check --no-gpu all 7 steps passed python tuxbox.py check --adapter 10de:2b85 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64 all steps passed python tuxbox.py check --adapter 1002:13c0 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64 all steps passed (guest-present-4k-splash skipped: this GPU presents to the test display through software) ``` Some of these ran while a game was loading its shaders on the 5090. Not run in the game with this change, or on Windows. #442 also edits `blas.rs`; whichever merges second needs a small rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!445
No description provided.