Skip to content

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

Open
NickStallman wants to merge 1 commit into
brcly:mainfrom
NickStallman:d3d12/lazy-publication-skips-reserved
Open

NickStallman wants to merge 1 commit into
brcly:mainfrom
NickStallman:d3d12/lazy-publication-skips-reserved

Conversation

@NickStallman

@NickStallman NickStallman commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

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 and waits for it. For reserved
(tiled) images that copy never ran: in ProjectScarlett runs the first
publication on access of a fully mapped 256x256 R32_FLOAT reserved image
sat at its fence's first value for good, on a copy queue and on a compute
queue alike, while an empty submission on the same kind of queue ran in a
few milliseconds. 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, has no such
trouble.

Reserved images are therefore not 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NickStallman
NickStallman marked this pull request as ready for review December 3, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant