d3d12: do not copy a structure that title memory never held #436

Merged
NickStallman merged 1 commit from upstream-pr/436 into main 2026-11-29 08:58:18 +00:00
NickStallman commented 2026-11-29 02:30:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T02:30:45Z.


Summary

An acceleration structure in a title's own memory exists only in the private storage TuxBox gives it. When a copy's source there has no storage, main gets it wrong in two ways:

  • Destination without storage too: the title's raw addresses go to the host. It compacts whatever its own buffers hold at those addresses, or vkd3d-proton refuses the source as unknown.
  • Destination with storage: recording the copy fails the list at Close. Its labels are never written, and queues that wait for them stop.

What changes

  • Such a copy is not run. The destination's storage is withdrawn when the list is submitted, through the path #409 added, so a scene submitted later finds an inactive instance there.
  • A source that isn't one of TuxBox's structures, copied to title memory without storage, isn't run either. It wrote to a title address.
  • A size query of a structure without storage reports 0 instead of asking the host about the title's address.
  • Skipped copies are logged with both addresses (first 64, then powers of two).

What it doesn't do

  • It treats a symptom. In ProjectScarlett, most sources that had no storage did hold a valid structure earlier. Their storage was released because a later build's recorded size reached over them (it looks like an in-place update booked at the host's maximum size; a full build can't be excluded). Their copies are dropped, and their geometry is missing. That needs its own fix.
  • Whether a copy runs is decided at recording. A source that a list recorded later but submitted earlier would build is wrongly skipped.
  • "Title memory" means an existing pool. A copy from an allocation where nothing was ever built still goes through as before.
  • Size 0 is my choice: whether titles accept it isn't known.
  • Not shown to fix a device loss. See below.

Observed in ProjectScarlett (integration builds, RTX 5090)

  • Two runs lost the device with a compaction as the oldest unfinished command: its source was a title address vkd3d-proton logged as "Copy placing unknown AS" (one run's addresses matched that log exactly).
  • One run stopped after a list was rejected at Close by the second form; its label was never written and the queues were held.
  • With the fix in an integration build, ten runs: four skipped between 1 and 12 copies, six skipped none, and neither form was logged. Nine of the ten lost the device and one ended in a CPU crash, so this says nothing about how often it helps. One of them had a list rejected at Close with E_INVALIDARG; I haven't found why.

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-guest-memory now copies a never-built source over a built triangle, with compact and clone, then traces the scene and queries three sizes. It fails on main (28717263 with this PR's Lanes change only, AMD) and passes with the fix on both cards. It covers the second form (destination with storage). The first form could hang a GPU without the fix, so only the unit tests cover it.

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)

The checks ran on f271e4f9. The pushed commit has the same tree and only its message differs. A game was playing on the 5090 during part of the AMD check. Not run on Windows.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5546830785 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/436). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T02:30:45Z. --- ## Summary An acceleration structure in a title's own memory exists only in the private storage TuxBox gives it. When a copy's source there has no storage, `main` gets it wrong in two ways: - **Destination without storage too:** the title's raw addresses go to the host. It compacts whatever its own buffers hold at those addresses, or vkd3d-proton refuses the source as unknown. - **Destination with storage:** recording the copy fails the list at `Close`. Its labels are never written, and queues that wait for them stop. **What changes** - Such a copy is not run. The destination's storage is withdrawn when the list is submitted, through the path #409 added, so a scene submitted later finds an inactive instance there. - A source that isn't one of TuxBox's structures, copied to title memory without storage, isn't run either. It wrote to a title address. - A size query of a structure without storage reports 0 instead of asking the host about the title's address. - Skipped copies are logged with both addresses (first 64, then powers of two). ## What it doesn't do - **It treats a symptom.** In ProjectScarlett, most sources that had no storage did hold a valid structure earlier. Their storage was released because a later build's recorded size reached over them (it looks like an in-place update booked at the host's maximum size; a full build can't be excluded). Their copies are dropped, and **their geometry is missing**. That needs its own fix. - Whether a copy runs is decided at recording. A source that a list recorded later but submitted earlier would build is wrongly skipped. - "Title memory" means an existing pool. A copy from an allocation where nothing was ever built still goes through as before. - Size 0 is my choice: whether titles accept it isn't known. - Not shown to fix a device loss. See below. ## Observed in ProjectScarlett (integration builds, RTX 5090) - Two runs lost the device with a compaction as the oldest unfinished command: its source was a title address vkd3d-proton logged as "Copy placing unknown AS" (one run's addresses matched that log exactly). - One run stopped after a list was rejected at `Close` by the second form; its label was never written and the queues were held. - With the fix in an integration build, ten runs: four skipped between 1 and 12 copies, six skipped none, and neither form was logged. Nine of the ten lost the device and one ended in a CPU crash, so this says nothing about how often it helps. One of them had a list rejected at `Close` with `E_INVALIDARG`; I haven't found why. ## 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-guest-memory` now copies a never-built source over a built triangle, with compact and clone, then traces the scene and queries three sizes. It **fails on `main`** (28717263 with this PR's Lanes change only, AMD) and passes with the fix on both cards. It covers the second form (destination with storage). The first form could hang a GPU without the fix, so only the unit tests cover it. 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) ``` The checks ran on f271e4f9. The pushed commit has the same tree and only its message differs. A game was playing on the 5090 during part of the AMD check. Not run on Windows. 🤖 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!436
No description provided.