d3d12: keep a title's page protection across lazy publication #647

Merged
1093i3511 merged 2 commits from upstream-pr/647 into main 2026-12-02 08:30:07 +00:00
1093i3511 commented 2026-12-02 06:44:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-02T06:44:45Z.


Fixes #625.

Summary

Lazy publication (on by default since e40d8052) records each page's protection when it defers a texture, and gives that protection back on release. A page the title closed before the GPU wrote, and opened again before its first access, was closed again by that release. The title's next read of it faulted, and no handler took it. Lanes texture-publication died with exit 5.

  • Pages::release still restores the protection from deferral time, so the write-back sees the pages as an eager publication would and leaves the page the title had closed alone.
  • It now also returns the pages whose protection the title changed while they were held. lazy::release returns them in a Reopen guard that sets that protection again when it drops. publish_texture keeps the guard across the write-back. The access handler, a texture's teardown and #640's release of dead textures before a userptr import drop it at once.

Not covered: a page the title closes while it is held still looks like one lazy publication closed (PAGE_NOACCESS), and release opens it again. Nothing I have reproduces that.

Rebased onto #640: the deferral keeps its userptr check before protect, and #640's unit test now passes set_protection as restore and checks that nothing comes back to reopen.

The failure elsewhere

lanes-selftest-texture-publication fails the same way on main on other cards: an RX 6950 XT in #631's check, and an RTX 5090 and an AMD iGPU in #630's (both list it as #625).

Verification

RX 6600 (1002:73ff, RDNA2), Mesa 26.3.1 RADV, GE-Proton11-15.

  • On main 3e2839b1 (this branch): all d3d12 unit tests under Wine (cargo xwin test --locked -p tuxbox-d3d12 --lib): 603 pass; the 3 scene_publication tests need a hardware device and fail the same way on main. The new test a_page_the_title_reopened_while_held_is_handed_back_for_after_the_write failed before the change. Formatting clean; clippy reports only fetch_update deprecated in shader_cache/native_doubles.rs from #642, not this change.
  • On main 2a850114 + #640 + this fix (the same lazy.rs, writeback.rs and test file as this branch), default settings, lazy publication on:
    • tuxbox.py verify --only lanes-selftest --only lanes: 31/31, including texture-publication (5/5 FAIL before, 4/4 PASS with TUXBOX_LAZY_PUBLICATION=0).
    • ProjectScarlett, Series S: reached the world (mission frame 1035). Lazy publication published 4 textures on access from title code, with no unhandled fault. No CS rejection (#634). The run ended after 610 s on a GPU fault from client SQC (instruction fetch), PERMISSION_FAULTS 0xb, at 0x00000700137ff000; the ring reset succeeded.
    • The same run on main 3e2839b1 without this change also reached the world (mission frame 1153) and ended after 446 s on the #603 TCP read fault (PERMISSION_FAULTS 0x3); the ring reset succeeded. It had no SQC fault, and lazy publication published nothing on access, so this change's path did not run there. With one run each, I can't tie the SQC fault to this change. Both runs end on a GPU fault after a similar time in the world.
  • NVIDIA: not run; this host has only an AMD card.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5601338657 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/647). Originally posted by [1093i3511](https://github.com/1093i3511) on 2026-12-02T06:44:45Z. --- Fixes #625. ## Summary Lazy publication (on by default since e40d8052) records each page's protection when it defers a texture, and gives that protection back on release. A page the title closed before the GPU wrote, and opened again before its first access, was closed again by that release. The title's next read of it faulted, and no handler took it. Lanes `texture-publication` died with exit 5. - `Pages::release` still restores the protection from deferral time, so the write-back sees the pages as an eager publication would and leaves the page the title had closed alone. - It now also returns the pages whose protection the title changed while they were held. `lazy::release` returns them in a `Reopen` guard that sets that protection again when it drops. `publish_texture` keeps the guard across the write-back. The access handler, a texture's teardown and #640's release of dead textures before a userptr import drop it at once. Not covered: a page the title closes while it is held still looks like one lazy publication closed (`PAGE_NOACCESS`), and release opens it again. Nothing I have reproduces that. Rebased onto #640: the deferral keeps its userptr check before `protect`, and #640's unit test now passes `set_protection` as `restore` and checks that nothing comes back to reopen. ## The failure elsewhere `lanes-selftest-texture-publication` fails the same way on main on other cards: an RX 6950 XT in #631's check, and an RTX 5090 and an AMD iGPU in #630's (both list it as #625). ## Verification RX 6600 (1002:73ff, RDNA2), Mesa 26.3.1 RADV, GE-Proton11-15. - On main 3e2839b1 (this branch): all d3d12 unit tests under Wine (`cargo xwin test --locked -p tuxbox-d3d12 --lib`): 603 pass; the 3 `scene_publication` tests need a hardware device and fail the same way on main. The new test `a_page_the_title_reopened_while_held_is_handed_back_for_after_the_write` failed before the change. Formatting clean; clippy reports only `fetch_update` deprecated in `shader_cache/native_doubles.rs` from #642, not this change. - On main 2a850114 + #640 + this fix (the same `lazy.rs`, `writeback.rs` and test file as this branch), default settings, lazy publication on: - `tuxbox.py verify --only lanes-selftest --only lanes`: 31/31, including `texture-publication` (5/5 FAIL before, 4/4 PASS with `TUXBOX_LAZY_PUBLICATION=0`). - ProjectScarlett, Series S: reached the world (mission frame 1035). Lazy publication published 4 textures on access from title code, with no unhandled fault. No CS rejection (#634). The run ended after 610 s on a GPU fault from client SQC (instruction fetch), `PERMISSION_FAULTS 0xb`, at `0x00000700137ff000`; the ring reset succeeded. - The same run on main 3e2839b1 without this change also reached the world (mission frame 1153) and ended after 446 s on the #603 TCP read fault (`PERMISSION_FAULTS 0x3`); the ring reset succeeded. It had no SQC fault, and lazy publication published nothing on access, so this change's path did not run there. With one run each, I can't tie the SQC fault to this change. Both runs end on a GPU fault after a similar time in the world. - NVIDIA: not run; this host has only an AMD card. 🤖 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!647
No description provided.