d3d12: publish reserved images with their batch instead of on access #672

Open
NickStallman wants to merge 1 commit from upstream-pr/672 into main
NickStallman commented 2026-12-03 09:02:56 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-03T09:02:56Z.


Summary

Lazy publication leaves a texture the GPU wrote unpublished until the title's CPU touches its pages. The access fault then copies the image back on a copy queue of the provider's own (#657) and waits for it. For reserved (tiled) images, that copy never completed. In ProjectScarlett runs on an RTX 5090, the first publication on access of a fully mapped 256x256 R32_FLOAT reserved image stayed at its fence's first value indefinitely, on a copy queue and on a compute queue alike. Empty submissions on the same kinds of queue completed in 2–6 ms. The title's thread waited in its access fault, work behind it piled up, and the copy engine faulted (Xid 32). The batch's own readback of reserved images, on the queue that wrote them, doesn't stall.

Reserved images are therefore no longer deferred: they are published with their batch, as without lazy publication. Committed images are deferred as before. TUXBOX_LAZY_PUBLICATION_RESERVED=1 defers reserved images too, for testing the original path (documented in docs/ENVIRONMENT.md).

Limits:

  • Why the copy of a reserved image never completes on a separate queue isn't known. This change avoids that path; it doesn't explain it.
  • The performance cost isn't measured. Reserved images that were deferred are now copied back after every batch that writes them.

Claimed on #533.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed: on NVIDIA, yes. On AMD, everything passed except three Lanes selftests that fail the same way on main 106120ca on this card (#656), see below
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: a unit test covers the default and the switch (reserved_images_are_published_with_their_batch_unless_the_switch_defers_them). There's no Lanes scenario that touches a reserved image's pages from the CPU after a GPU write yet.
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both ran. NVIDIA passed; AMD has only the three failures main also has (#656). A discrete AMD card hasn't run them.

GPU, driver and backend: RTX 5090 (10de:2b85, NVIDIA 620.70.10) and AMD Ryzen 9 9950X graphics, RDNA 2 (1002:13c0, RADV, Mesa 26.0.8), both through GE-Proton11-15. tuxbox.py check --changed 106120ca, which selects the lanes, lanes-*, d3d12-*, guest-frame and present suites and the D3D12 regression controls.

The Evidence: line tuxbox.py check prints last, one per card (it names the commit it tested; run it on this pull request's head):

Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run
Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU 1002:13c0: 15 passed, 1 failed, 0 not run

Commands run and their results:

python tuxbox.py check --no-gpu   # on a023d862: 13 passed, 0 failed
python tuxbox.py check --changed 106120ca --adapter 10de:2b85   # 16 passed, 0 failed
python tuxbox.py check --changed 106120ca --adapter 1002:13c0   # 15 passed, 1 failed (Lanes and fixtures):
  lanes-selftest FAIL queue-page-mappings: copy ordered GPU mapping failed: 0x80004001
  lanes-selftest FAIL queue-texture-boundary: map the texture tail failed: 0x80004001
  lanes-selftest FAIL ray-tracing-rehydrate: map physical pages for the GPU failed: 0x80004001
python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0   # on main 106120ca: the same three fail

A first attempt that ran the AMD and NVIDIA checks at the same time had scattered 30-second guest timeouts on both cards, in different suites each time. Run one at a time, the results are the ones above.

Game run. This change ran in ProjectScarlett only as part of a combined build, on an RTX 5090. On the older line, that build (this change plus other fixes) gave 3 of 3 clean 15-minute runs into gameplay. On current upstream the game still loses the GPU to a separate mesh-draw MMU fault (Xid 13), which this change doesn't address. It hasn't been run in the game on its own.

Checks

CI runs the code checks: the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU.

No evidence JSON changes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5623300393 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/672). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-03T09:02:56Z. --- ## Summary Lazy publication leaves a texture the GPU wrote unpublished until the title's CPU touches its pages. The access fault then copies the image back on a copy queue of the provider's own (#657) and waits for it. For reserved (tiled) images, that copy never completed. In ProjectScarlett runs on an RTX 5090, the first publication on access of a fully mapped 256x256 R32_FLOAT reserved image stayed at its fence's first value indefinitely, on a copy queue and on a compute queue alike. Empty submissions on the same kinds of queue completed in 2–6 ms. The title's thread waited in its access fault, work behind it piled up, and the copy engine faulted (Xid 32). The batch's own readback of reserved images, on the queue that wrote them, doesn't stall. Reserved images are therefore no longer deferred: they are published with their batch, as without lazy publication. Committed images are deferred as before. `TUXBOX_LAZY_PUBLICATION_RESERVED=1` defers reserved images too, for testing the original path (documented in `docs/ENVIRONMENT.md`). Limits: - Why the copy of a reserved image never completes on a separate queue isn't known. This change avoids that path; it doesn't explain it. - The performance cost isn't measured. Reserved images that were deferred are now copied back after every batch that writes them. Claimed on #533. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [ ] The checks relevant to this change passed: on NVIDIA, yes. On AMD, everything passed except three Lanes selftests that fail the same way on main `106120ca` on this card (#656), see below - [ ] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: a unit test covers the default and the switch (`reserved_images_are_published_with_their_batch_unless_the_switch_defers_them`). There's no Lanes scenario that touches a reserved image's pages from the CPU after a GPU write yet. - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both ran. NVIDIA passed; AMD has only the three failures main also has (#656). A discrete AMD card hasn't run them. GPU, driver and backend: RTX 5090 (`10de:2b85`, NVIDIA 620.70.10) and AMD Ryzen 9 9950X graphics, RDNA 2 (`1002:13c0`, RADV, Mesa 26.0.8), both through GE-Proton11-15. `tuxbox.py check --changed 106120ca`, which selects the `lanes`, `lanes-*`, `d3d12-*`, `guest-frame` and `present` suites and the D3D12 regression controls. The `Evidence:` line `tuxbox.py check` prints last, one per card (it names the commit it tested; run it on this pull request's head): ```text Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU 1002:13c0: 15 passed, 1 failed, 0 not run ``` Commands run and their results: ```text python tuxbox.py check --no-gpu # on a023d862: 13 passed, 0 failed python tuxbox.py check --changed 106120ca --adapter 10de:2b85 # 16 passed, 0 failed python tuxbox.py check --changed 106120ca --adapter 1002:13c0 # 15 passed, 1 failed (Lanes and fixtures): lanes-selftest FAIL queue-page-mappings: copy ordered GPU mapping failed: 0x80004001 lanes-selftest FAIL queue-texture-boundary: map the texture tail failed: 0x80004001 lanes-selftest FAIL ray-tracing-rehydrate: map physical pages for the GPU failed: 0x80004001 python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0 # on main 106120ca: the same three fail ``` A first attempt that ran the AMD and NVIDIA checks at the same time had scattered 30-second guest timeouts on both cards, in different suites each time. Run one at a time, the results are the ones above. **Game run.** This change ran in ProjectScarlett only as part of a combined build, on an RTX 5090. On the older line, that build (this change plus other fixes) gave 3 of 3 clean 15-minute runs into gameplay. On current upstream the game still loses the GPU to a separate mesh-draw MMU fault (Xid 13), which this change doesn't address. It hasn't been run in the game on its own. ## Checks CI runs the [code checks](../CONTRIBUTING.md#code-checks): the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU. No evidence JSON changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
JeffreyBytes commented 2026-12-03 15:07:22 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T15:07:22Z.


AMD run on a discrete card, head a023d862. RX 6700 XT 12 GB (1002:73df), Mesa 26.3.1 RADV, GE-Proton11-15, full check:

Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run

All the Lanes selftests passed here, including queue-page-mappings and ray-tracing-rehydrate, so the three failures you saw on the iGPU (#656) don't show up on this card. Main 106120ca also passed 17 of 17 on the same card and prefix. The kernel log had no amdgpu faults or resets. I didn't run the game on it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7382599513 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/672#issuecomment-7382599513). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T15:07:22Z. --- AMD run on a discrete card, head a023d862. RX 6700 XT 12 GB (`1002:73df`), Mesa 26.3.1 RADV, GE-Proton11-15, full check: ```text Evidence: TuxBox check of a023d862acd2, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run ``` All the Lanes selftests passed here, including `queue-page-mappings` and `ray-tracing-rehydrate`, so the three failures you saw on the iGPU (#656) don't show up on this card. Main `106120ca` also passed 17 of 17 on the same card and prefix. The kernel log had no amdgpu faults or resets. I didn't run the game on it.
JeffreyBytes commented 2026-12-03 15:49:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T15:49:45Z.


Doing game runs now, results to follow.

<!-- greyfinch-sync:brcly/TuxBox:comment:7383800756 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/672#issuecomment-7383800756). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T15:49:45Z. --- Doing game runs now, results to follow.
JeffreyBytes commented 2026-12-03 17:18:04 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T17:18:04Z.


Game runs on AMD too. RX 6700 XT 12 GB, Mesa 26.3.1 RADV, GE-Proton11-15, ProjectScarlett from a fixed save state. A is #667 alone and B is #667 with this PR on top, alternating, both on 106120ca with the same translator and cache.

Build Ended Placement/min
#667 + #672 exit 5 at 359 s 5.1 s
#667 + #672 exit 5 at 356 s 4.5 s
#667 + #672 gfx-ring page fault (ring reset worked)
#667 exit 5 at 469 s 10.6 s
#667 gfx-ring page fault at 290 s (ring reset worked) 7.7 s

On this card it doesn't change how the runs end: the watchdog exit 5 from #669 and the gfx-ring TCP fault both still show up with it. The placement time is lower with it, but that's two runs against two, and it moved that much between runs of the same build before (https://github.com/brcly/TuxBox/pull/668#issuecomment-7368648561). I didn't see anything that looked like a regression from it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7386288590 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/672#issuecomment-7386288590). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T17:18:04Z. --- Game runs on AMD too. RX 6700 XT 12 GB, Mesa 26.3.1 RADV, GE-Proton11-15, ProjectScarlett from a fixed save state. A is #667 alone and B is #667 with this PR on top, alternating, both on `106120ca` with the same translator and cache. | Build | Ended | Placement/min | |---|---|---| | #667 + #672 | exit 5 at 359 s | 5.1 s | | #667 + #672 | exit 5 at 356 s | 4.5 s | | #667 + #672 | gfx-ring page fault (ring reset worked) | | | #667 | exit 5 at 469 s | 10.6 s | | #667 | gfx-ring page fault at 290 s (ring reset worked) | 7.7 s | On this card it doesn't change how the runs end: the watchdog exit 5 from #669 and the gfx-ring TCP fault both still show up with it. The placement time is lower with it, but that's two runs against two, and it moved that much between runs of the same build before (https://github.com/brcly/TuxBox/pull/668#issuecomment-7368648561). I didn't see anything that looked like a regression from it.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/672:upstream-pr/672'
git switch 'upstream-pr/672'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/672'
git switch 'upstream-pr/672'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/672'
git switch 'upstream-pr/672'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/672'
git switch 'main'
git merge --squash 'upstream-pr/672'
git switch 'main'
git merge --ff-only 'upstream-pr/672'
git switch 'main'
git merge 'upstream-pr/672'
git push origin 'main'
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!672
No description provided.