D3D12.X: texture workers copy title memory instead of borrowing it #2877

Closed
b3IKK wants to merge 1 commit from upstream-pr/2877 into main
b3IKK commented 2026-11-26 20:35:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-26T20:35:39Z.


A texture subresource's bytes come from title_bytes(), which lends the title's page in place when readable says the range reads. A texture worker detiles them while the title may decommit a page; the borrow then faults in the copy — a VCRUNTIME 0xc0000005 read at a title VA (#2841).

The workers now read through title_bytes_read: read_committed copies the committed pages with ReadProcessMemory, page run by page run, and zeroes the rest, so a decommit during the copy reads short instead of faulting. The title's own submit (content_hash) keeps the in-place path.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: title_bytes_read; subresources uses it for its volume and slice reads; test a_texture_worker_copies_title_memory_instead_of_borrowing_it (a readable page is still borrowed by title_bytes; the worker helper copies it).

Tested

  • hardware: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 1447 passed, 0 failed, 47 ignored
  • the new test alone: 1 passed, 0 failed. With the worker helper forced to borrow: 0 passed, 1 failed.
  • in-title: on the RTX 5080 (retail 1.0.2.1, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, #2404 5b9d4ff + #2519 + #684 + the 1 GiB shader heap), one 600 s run presented to 434.5 s with no VCRUNTIME read AV, then ended in the title's own null write at game_scarlett_master.exe+0x23cf683 (#846). The read AV is intermittent, so this is one observation, not proof.

Regression run
Blocked on this machine by the startup preparation in #2555: on main 8b957be the preparation builds the whole form of every split compute program (26,503 shaders; the DXIL cache grew to 28,847 entries over ~1 h) and scripts/smoke.ps1 never starts the title — XCL printed no log path with -StartupTimeoutSeconds 120, 300, 600 and 3600. XCL_PIPELINE_MAX_KB=8192 does not help: those whole forms are 0.7–1.1 MB, under the cap. No smoke block is written by hand; the pair will be added once the preparation is bounded (the same branch smokes in seconds on 5b9d4ff, before #2555).

Not tested

  • the title's own submit path keeps the in-place borrow (content_hash), and a deterministic decommit-during-detile inside a title run
  • AMD GPUs, other titles, Linux / Wine

AI use

  • OpenCode, Claude Fable 5.2: implemented the worker copy and its test, checked the test fails when the worker path borrows, ran the suite and the in-title comparison, and wrote this.
<!-- greyfinch-sync:ivall/xcl:issue:5516809679 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-26T20:35:39Z. --- A texture subresource's bytes come from `title_bytes()`, which lends the title's page in place when `readable` says the range reads. A texture worker detiles them while the title may decommit a page; the borrow then faults in the copy — a VCRUNTIME `0xc0000005` read at a title VA (#2841). The workers now read through `title_bytes_read`: `read_committed` copies the committed pages with `ReadProcessMemory`, page run by page run, and zeroes the rest, so a decommit during the copy reads short instead of faulting. The title's own submit (`content_hash`) keeps the in-place path. **What is in it** - `crates/xcl/src/hle/d3d12x/title_textures.rs`: `title_bytes_read`; `subresources` uses it for its volume and slice reads; test `a_texture_worker_copies_title_memory_instead_of_borrowing_it` (a readable page is still borrowed by `title_bytes`; the worker helper copies it). **Tested** - hardware: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): **1447 passed, 0 failed, 47 ignored** - the new test alone: 1 passed, 0 failed. With the worker helper forced to borrow: 0 passed, 1 failed. - in-title: on the RTX 5080 (retail 1.0.2.1, `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1`, #2404 `5b9d4ff` + #2519 + #684 + the 1 GiB shader heap), one 600 s run presented to **434.5 s with no VCRUNTIME read AV**, then ended in the title's own null write at `game_scarlett_master.exe+0x23cf683` (#846). The read AV is intermittent, so this is one observation, not proof. **Regression run** Blocked on this machine by the startup preparation in #2555: on `main` `8b957be` the preparation builds the whole form of every split compute program (26,503 shaders; the DXIL cache grew to 28,847 entries over ~1 h) and `scripts/smoke.ps1` never starts the title — `XCL printed no log path` with `-StartupTimeoutSeconds` 120, 300, 600 and 3600. `XCL_PIPELINE_MAX_KB=8192` does not help: those whole forms are 0.7–1.1 MB, under the cap. No smoke block is written by hand; the pair will be added once the preparation is bounded (the same branch smokes in seconds on `5b9d4ff`, before #2555). **Not tested** - the title's own submit path keeps the in-place borrow (`content_hash`), and a deterministic decommit-during-detile inside a title run - AMD GPUs, other titles, Linux / Wine **AI use** - OpenCode, Claude Fable 5.2: implemented the worker copy and its test, checked the test fails when the worker path borrows, ran the suite and the in-title comparison, and wrote this.
b3IKK commented 2026-11-26 21:23:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-26T21:23:50Z.


In-title validation update: this fix is part of the stack that just ran a stable 600 s world on the RTX 5080 (0 device removals, 0 crashes, frames to 599.2 s, exit 0x0), with #684, the 2 GiB shader heap, #2519's scratch and the free_aside patch. The earlier run without #2555's startup preparation hit no VCRUNTIME read AV either; with this fix the copy path reads through read_committed, so the borrowed-page race is gone. The PR description check stays blocked by #2555's first-launch preparation on this machine; the suite (1447/0/47) and the 600 s run are the evidence.

AI use: OpenCode, Claude Fable 5.2 ran the stable stack and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7203685675 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7203685675). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-26T21:23:50Z. --- In-title validation update: this fix is part of the stack that just ran a **stable 600 s world** on the RTX 5080 (0 device removals, 0 crashes, frames to 599.2 s, `exit 0x0`), with #684, the 2 GiB shader heap, #2519's scratch and the `free_aside` patch. The earlier run without #2555's startup preparation hit no VCRUNTIME read AV either; with this fix the copy path reads through `read_committed`, so the borrowed-page race is gone. The PR description check stays blocked by #2555's first-launch preparation on this machine; the suite (1447/0/47) and the 600 s run are the evidence. AI use: OpenCode, Claude Fable 5.2 ran the stable stack and wrote this.
throny commented 2026-11-27 02:49:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T02:49:32Z.


Two contributors checked independently and found that #2849 solves the same problem (for #2841) in a different way: #1607, group D142. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7208468678 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7208468678). Originally posted by [throny](https://github.com/throny) on 2026-11-27T02:49:32Z. --- <!-- xcl-1607-hint:D142 --> Two contributors checked independently and found that #2849 solves the same problem (for #2841) in a different way: #1607, group D142. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
andrewDoing commented 2026-11-27 03:38:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T03:38:56Z.


On #2877 head c1c22863e8ec6d52198f9c1b465226f538cbacb1, a controlled source change between hashing and worker detiling left a native RTX 5070 texture stale on the next refresh. The full 64 × 64 R8 readback retained 0x81 in all 4,096 texels after the source returned to 0x17.

The synthetic fixture recorded the normal content hash for 0x17, filled the same source with 0x81, and called the production detile and upload helpers. A fenced readback confirmed all texels were 0x81. I then restored the source to 0x17 and called upload_all. Its unchanged-content counter incremented once and every GPU texel remained 0x81. A forced detile and upload of the same source restored 0x17 in every texel.

This distinguishes the bytes used for the skip decision from those actually uploaded. The fixture scheduled the writes explicitly between helpers. It used stable allocated memory, without a decommit, retail title, or timing measurement. The result establishes the behavior on this PR head. No parent comparison was run, so it is not attributed to the PR.

The staged fixture’s first run stopped before GPU work because its native device pointer had not been initialized. The reported run explicitly initialized the real backend and asserted the adapter name. One diagnostic test passed with zero skips.

AI use: OpenAI Codex with GPT-6.2 Astra prepared the test fixture, corrected its device initialization and ran the native checks; Codex coordinated and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7209159502 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7209159502). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-27T03:38:56Z. --- On #2877 head `c1c22863e8ec6d52198f9c1b465226f538cbacb1`, a controlled source change between hashing and worker detiling left a native RTX 5070 texture stale on the next refresh. The full 64 × 64 R8 readback retained `0x81` in all 4,096 texels after the source returned to `0x17`. The synthetic fixture recorded the normal content hash for `0x17`, filled the same source with `0x81`, and called the production detile and upload helpers. A fenced readback confirmed all texels were `0x81`. I then restored the source to `0x17` and called `upload_all`. Its unchanged-content counter incremented once and every GPU texel remained `0x81`. A forced detile and upload of the same source restored `0x17` in every texel. This distinguishes the bytes used for the skip decision from those actually uploaded. The fixture scheduled the writes explicitly between helpers. It used stable allocated memory, without a decommit, retail title, or timing measurement. The result establishes the behavior on this PR head. No parent comparison was run, so it is not attributed to the PR. The staged fixture’s first run stopped before GPU work because its native device pointer had not been initialized. The reported run explicitly initialized the real backend and asserted the adapter name. One diagnostic test passed with zero skips. AI use: OpenAI Codex with GPT-6.2 Astra prepared the test fixture, corrected its device initialization and ran the native checks; Codex coordinated and prepared this report.
andrewDoing commented 2026-11-27 03:41:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T03:41:02Z.


Follow-up to the A→B→A readback above: the identical test-only fixture on this PR's exact parent 8b957bec6f82495aec940944c6bf47faa02db590 reproduced the same behavior. upload_all recorded one unchanged-content skip, all 4,096 texels retained B, and a forced upload restored A in all 4,096 texels. The diagnostic test passed without a reported skip.

This establishes that the tested hash/detile mismatch is inherited rather than introduced by #2877. The related single-snapshot and post-success publication work is tracked by #504 and proposed in #508. Retail frequency and performance impact remain unmeasured.

AI use: OpenAI Codex with GPT-6.2 Astra ran the parent control; Codex coordinated and prepared this follow-up.

<!-- greyfinch-sync:ivall/xcl:comment:7209187572 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7209187572). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-27T03:41:02Z. --- Follow-up to the A→B→A readback above: the identical test-only fixture on this PR's exact parent `8b957bec6f82495aec940944c6bf47faa02db590` reproduced the same behavior. `upload_all` recorded one unchanged-content skip, all 4,096 texels retained B, and a forced upload restored A in all 4,096 texels. The diagnostic test passed without a reported skip. This establishes that the tested hash/detile mismatch is inherited rather than introduced by #2877. The related single-snapshot and post-success publication work is tracked by #504 and proposed in #508. Retail frequency and performance impact remain unmeasured. AI use: OpenAI Codex with GPT-6.2 Astra ran the parent control; Codex coordinated and prepared this follow-up.
Foniass commented 2026-12-01 09:06:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:06:29Z.


Triage (#1607) – head c1c2286

The fault in #2841 is fixed on main by b84e0378 'title texture reads outside the coherent window use the safe copy' (merged with #2844). title_bytes no longer exists there. with_title_bytes reads in place only inside the coherent committed window, which XCL never decommits, and copies everything else through read_committed_into, so texture workers no longer borrow memory the title can decommit.
This PR always copies, inside the window too, which main avoids on purpose because of the cost. It also conflicts with main. #2849 makes the same fix as main.
Recommendation: close (superseded by main commit b84e037).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306225042 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7306225042). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:06:29Z. --- **Triage (#1607)** – head c1c2286 The fault in #2841 is fixed on main by b84e0378 'title texture reads outside the coherent window use the safe copy' (merged with #2844). title_bytes no longer exists there. with_title_bytes reads in place only inside the coherent committed window, which XCL never decommits, and copies everything else through read_committed_into, so texture workers no longer borrow memory the title can decommit. This PR always copies, inside the window too, which main avoids on purpose because of the cost. It also conflicts with main. #2849 makes the same fix as main. Recommendation: close (superseded by main commit b84e037). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 13:00:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T13:00:40Z.


Closing as superseded: this change is already on main (b84e0378). main title_textures.rs with_title_bytes reads outside the coherent window through read_committed into a buffer (no borrow of title memory); tests title_bytes_are_copied_outside_the_coherent_window and title_bytes_survive_concurrent_decommit exist

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311971387 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2877#issuecomment-7311971387). Originally posted by [throny](https://github.com/throny) on 2026-12-01T13:00:40Z. --- Closing as superseded: this change is already on `main` (b84e0378). main title_textures.rs with_title_bytes reads outside the coherent window through read_committed into a buffer (no borrow of title memory); tests title_bytes_are_copied_outside_the_coherent_window and title_bytes_survive_concurrent_decommit exist Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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
xcl-dev/xcl!2877
No description provided.