d3d12: record a lazy publication on access on copy lists of its own #657

Merged
gtb-sbe merged 1 commit from upstream-pr/657 into main 2026-12-02 21:21:13 +00:00
gtb-sbe commented 2026-12-02 17:29:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-12-02T17:29:26Z.


Summary

With lazy publication on (the default), ProjectScarlett loses the device on my RX 9060 XT at the same point every time: 6 title frames after the story intro's mission is set, right after the first textures are published on access. 4 runs out of 4 on 53782eed, with radv/amdgpu: The CS has been rejected, see dmesg for more information (-22) and nothing in dmesg. With TUXBOX_LAZY_PUBLICATION=0 the run gets past that point.

The rejected submission comes from the copy queue lazy::publish_now creates on its first publication on access. publish_now records Readback::record(device, COPY, ..) with the readback spares of the queue that deferred the texture (Held::spares, the queue worker's worker.spares). Parts::get reuses a spare (allocator, list) whatever its type, so after that queue has published something itself, a publication on access takes the queue's spare direct list and executes it on the copy queue. D3D12 doesn't allow that, and vkd3d-proton passes it through: a graphics-family command buffer on a compute-family VkQueue.

What RADV makes of it, from a bpftrace probe on amdgpu_cs_ioctl during the run (kernel 6.18, Mesa 26.3.1):

amdgpu_ctx_get_entity=-22
amdgpu_cs_ioctl=-22 ctx=1 bo_list=0 chunks=6
  chunk 0: IB ip_type=1 (compute) ring=3 bytes=288
  chunk 1: IB ip_type=0 (gfx)     ring=3 bytes=1600
  fence, timeline wait, timeline signal, BO handles

RADV tags every IB with the queue's index in its family (radv_amdgpu_cs.c, ring = queue_idx), so the graphics IB from the direct list gets ring 3. A context has one graphics entity, so the kernel rejects it. On compute queue 0 the same mistake would go through. That is likely why it depends on the host and on how many queues a title creates before the copy queue: here it landed on index 3 every time.

The change gives publish_now readback parts of its own next to its copy queue, as heap_writes already does for its copy queue, so it always records copy lists. Held no longer needs the deferring queue's spares, and lazy::defer loses that parameter.

Tested

Run the checks relevant to this change.

  • 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 texture-publication-copy-queue: three compute queues first; the direct queue writes a texture with a smaller alias at the same address (published at once, which leaves a direct readback list spare), then a texture that waits for an access; reading that texture's title memory publishes it on the provider's copy queue. On 1b4ed472 without the change it fails on my card the same way the game does (device after publishing a texture on access failed: 0x887a0005, The CS has been rejected (-22), the probe shows a graphics IB with ring 1). With the change it passes.

GPU, driver and backend:

  • AMD Radeon RX 9060 XT (RADV GFX1200, 1002:7590), Mesa 26.3.1, kernel 6.18, GE-Proton11-15, NixOS.

The Evidence: line tuxbox.py check prints last:

Evidence: TuxBox check of 288aeecf849a, no uncommitted changes, GPU 1002:7590: 13 passed, 4 failed, 0 not run

Commands run and their results:

$ python tuxbox.py check --backend proton --adapter 1002:7590 --proton GE-Proton11-15 --prefix build/check-prefix --windows-dxc <Windows DXC>
  passed  Build the shader compiler / Synthetic shaders through the runtime's DXC flags / Shader compiler tests /
          DXBC tests / XG layout tests / XG entry point tests / BVH layout tests / Storage codec tests /
          ACP HAL tests / Windows typecheck / Clippy / Formatting / Build
  FAILED  Python tests               (GuestWatch: NixOS python wrapper, fails on main too)
  FAILED  Lanes and fixtures         (queue-page-mappings, ray-tracing-rehydrate: E_NOTIMPL queue page mappings on RADV since 9c3cf86f, fail on main too)
  FAILED  D3D12 regression controls  (buffer-remap: the same page-mapping E_NOTIMPL, fails on main too)
  FAILED  Shader translator on GPU   (alu: 23 NaN payloads through multiply-add, fails on main too)

All four failures fail the same way on unchanged 1b4ed472 on this card. texture-publication and the new texture-publication-copy-queue pass; without the change the new scenario fails with 0x887a0005 (device removed).

ProjectScarlett with this change on 53782eed (the base of my four failing runs, so the caches stayed warm), lazy publication on, private views, one run: 16 textures published on access, no CS rejection, and the title ran 45 frames past the point where the four runs without the change died (6 frames after the intro mission is set). That run then ended on a GPU page fault, a TCP read with MAPPING_ERROR in draws that include PS 89f6b548. That looks like the #603 family that DrArroway's run on #634 also ended on (the same pixel program was unfinished there), and this change doesn't touch it.

AI use

I worked on this with an AI coding agent (Claude Code, following AGENTS.md). It found the common pattern in my four game logs, wrote the bpftrace probes I ran as root during the runs, traced the rejected submission to the reused spare list, wrote the fix and the Lanes scenario, and ran the checks above on my machine.

<!-- greyfinch-sync:brcly/TuxBox:issue:5611591586 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/657). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-12-02T17:29:26Z. --- ## Summary With lazy publication on (the default), ProjectScarlett loses the device on my RX 9060 XT at the same point every time: 6 title frames after the story intro's mission is set, right after the first textures are published on access. 4 runs out of 4 on `53782eed`, with `radv/amdgpu: The CS has been rejected, see dmesg for more information (-22)` and nothing in dmesg. With `TUXBOX_LAZY_PUBLICATION=0` the run gets past that point. The rejected submission comes from the copy queue `lazy::publish_now` creates on its first publication on access. `publish_now` records `Readback::record(device, COPY, ..)` with the readback spares of the queue that deferred the texture (`Held::spares`, the queue worker's `worker.spares`). `Parts::get` reuses a spare `(allocator, list)` whatever its type, so after that queue has published something itself, a publication on access takes the queue's spare **direct** list and executes it on the **copy** queue. D3D12 doesn't allow that, and vkd3d-proton passes it through: a graphics-family command buffer on a compute-family VkQueue. What RADV makes of it, from a bpftrace probe on `amdgpu_cs_ioctl` during the run (kernel 6.18, Mesa 26.3.1): ``` amdgpu_ctx_get_entity=-22 amdgpu_cs_ioctl=-22 ctx=1 bo_list=0 chunks=6 chunk 0: IB ip_type=1 (compute) ring=3 bytes=288 chunk 1: IB ip_type=0 (gfx) ring=3 bytes=1600 fence, timeline wait, timeline signal, BO handles ``` RADV tags every IB with the queue's index in its family (`radv_amdgpu_cs.c`, `ring = queue_idx`), so the graphics IB from the direct list gets ring 3. A context has one graphics entity, so the kernel rejects it. On compute queue 0 the same mistake would go through. That is likely why it depends on the host and on how many queues a title creates before the copy queue: here it landed on index 3 every time. The change gives `publish_now` readback parts of its own next to its copy queue, as `heap_writes` already does for its copy queue, so it always records copy lists. `Held` no longer needs the deferring queue's spares, and `lazy::defer` loses that parameter. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [ ] 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 `texture-publication-copy-queue`: three compute queues first; the direct queue writes a texture with a smaller alias at the same address (published at once, which leaves a direct readback list spare), then a texture that waits for an access; reading that texture's title memory publishes it on the provider's copy queue. On `1b4ed472` without the change it fails on my card the same way the game does (`device after publishing a texture on access failed: 0x887a0005`, `The CS has been rejected (-22)`, the probe shows a graphics IB with ring 1). With the change it passes. GPU, driver and backend: - AMD Radeon RX 9060 XT (RADV GFX1200, `1002:7590`), Mesa 26.3.1, kernel 6.18, GE-Proton11-15, NixOS. The `Evidence:` line `tuxbox.py check` prints last: ```text Evidence: TuxBox check of 288aeecf849a, no uncommitted changes, GPU 1002:7590: 13 passed, 4 failed, 0 not run ``` Commands run and their results: ```text $ python tuxbox.py check --backend proton --adapter 1002:7590 --proton GE-Proton11-15 --prefix build/check-prefix --windows-dxc <Windows DXC> passed Build the shader compiler / Synthetic shaders through the runtime's DXC flags / Shader compiler tests / DXBC tests / XG layout tests / XG entry point tests / BVH layout tests / Storage codec tests / ACP HAL tests / Windows typecheck / Clippy / Formatting / Build FAILED Python tests (GuestWatch: NixOS python wrapper, fails on main too) FAILED Lanes and fixtures (queue-page-mappings, ray-tracing-rehydrate: E_NOTIMPL queue page mappings on RADV since 9c3cf86f, fail on main too) FAILED D3D12 regression controls (buffer-remap: the same page-mapping E_NOTIMPL, fails on main too) FAILED Shader translator on GPU (alu: 23 NaN payloads through multiply-add, fails on main too) ``` All four failures fail the same way on unchanged `1b4ed472` on this card. `texture-publication` and the new `texture-publication-copy-queue` pass; without the change the new scenario fails with `0x887a0005` (device removed). ProjectScarlett with this change on `53782eed` (the base of my four failing runs, so the caches stayed warm), lazy publication on, private views, one run: 16 textures published on access, no CS rejection, and the title ran 45 frames past the point where the four runs without the change died (6 frames after the intro mission is set). That run then ended on a GPU page fault, a TCP read with `MAPPING_ERROR` in draws that include `PS 89f6b548`. That looks like the #603 family that DrArroway's run on #634 also ended on (the same pixel program was unfinished there), and this change doesn't touch it. ## AI use I worked on this with an AI coding agent (Claude Code, following `AGENTS.md`). It found the common pattern in my four game logs, wrote the bpftrace probes I ran as root during the runs, traced the rejected submission to the reused spare list, wrote the fix and the Lanes scenario, and ran the checks above on my machine.
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!657
No description provided.