D3D12.X: a list's own GPU writes land in a sparse chunk the CPU changed #3149

Merged
KOLESNiii merged 1 commit from upstream-pr/3149 into main 2026-11-28 14:07:15 +00:00
KOLESNiii commented 2026-11-28 13:02:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T13:02:04Z.


Since #2959, land_page (04de3234, "preserve CPU writes during sparse copy-back") keeps the CPU's
bytes for every 64-byte chunk the CPU changed since its last upload, and drops the GPU's bytes in
it. That is right for a chunk the CPU rewrote, but not when the two wrote different bytes of one
chunk. The test title's Wait32 / Wait64 at +0x300 / +0x308 and Write32 at +0x310 are such a case:
its CPU thread writes the wait cells after the submit, XCL sees the waits satisfied, the GPU writes
+0x310, and the copy-back after ExecuteCommandLists drops it (the three e2e title tests of #3093,
"post-Wait32/64 write failed (0x0)").

The copy-back after ExecuteCommandLists reads back only the intervals the lists' own commands
wrote (sparse_writes, recorded by note_write for in-segment GPU writes). Those bytes now land in
a changed chunk too, and the chunk keeps its old hash, so the next write-watch look uploads it whole,
the GPU's bytes with the CPU's. A Map readback (readback_now) still keeps a changed chunk's CPU
bytes, since its range is what the CPU reads, not what the GPU wrote.

Part of #3093.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: +40 / -11
  • new tests: gpu_written_bytes_land_in_a_chunk_the_cpu_changed

Tested

  • NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug
  • cargo test -p xcl --test e2e -- --test-threads=1 on the head before the final rebase onto main (identical tree): 5 passed, 0 failed (on main 336fddda: 3 failed, "post-Wait32/64 write failed (0x0)").
  • The new unit test gpu_written_bytes_land_in_a_chunk_the_cpu_changed and the two existing land_page tests: 3 passed; the new one fails without the change ("the GPU's write was dropped").

Regression run
Not run yet. scripts/smoke.ps1 on main and on this head, from the same warm cache, will be run; two earlier attempts were stopped by the harness (low memory) before they started. The two xcl-smoke blocks will be added here when they exist.

Not tested

  • The whole suite on this head has not been run (the e2e and land_page tests above only).
  • A title: the regression run is queued; two attempts were stopped by the harness (low memory).
  • AMD and Intel GPUs. The two e2e debug-layer tests need the D3D12 debug layer installed (they report SKIPPED without it).
  • AMD and Intel GPUs; wave64 hardware (the RTX 2070 SUPER is wave32).

AI use

  • Claude Code, Claude Opus 5.5 (cause, fix and test): the code and tests. The description and the test / suite runs: Claude Code, Claude Sonnet 5.5 and Claude Opus 5.5.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5540380794 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3149). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T13:02:04Z. --- Since #2959, land_page (04de3234, "preserve CPU writes during sparse copy-back") keeps the CPU's bytes for every 64-byte chunk the CPU changed since its last upload, and drops the GPU's bytes in it. That is right for a chunk the CPU rewrote, but not when the two wrote different bytes of one chunk. The test title's Wait32 / Wait64 at +0x300 / +0x308 and Write32 at +0x310 are such a case: its CPU thread writes the wait cells after the submit, XCL sees the waits satisfied, the GPU writes +0x310, and the copy-back after ExecuteCommandLists drops it (the three e2e title tests of #3093, "post-Wait32/64 write failed (0x0)"). The copy-back after ExecuteCommandLists reads back only the intervals the lists' own commands wrote (`sparse_writes`, recorded by note_write for in-segment GPU writes). Those bytes now land in a changed chunk too, and the chunk keeps its old hash, so the next write-watch look uploads it whole, the GPU's bytes with the CPU's. A Map readback (readback_now) still keeps a changed chunk's CPU bytes, since its range is what the CPU reads, not what the GPU wrote. Part of #3093. **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: +40 / -11 - new tests: `gpu_written_bytes_land_in_a_chunk_the_cpu_changed` **Tested** - NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug - `cargo test -p xcl --test e2e -- --test-threads=1` on the head before the final rebase onto `main` (identical tree): 5 passed, 0 failed (on `main` `336fddda`: 3 failed, "post-Wait32/64 write failed (0x0)"). - The new unit test `gpu_written_bytes_land_in_a_chunk_the_cpu_changed` and the two existing `land_page` tests: 3 passed; the new one fails without the change ("the GPU's write was dropped"). **Regression run** Not run yet. `scripts/smoke.ps1` on `main` and on this head, from the same warm cache, will be run; two earlier attempts were stopped by the harness (low memory) before they started. The two `xcl-smoke` blocks will be added here when they exist. **Not tested** - The whole suite on this head has not been run (the e2e and `land_page` tests above only). - A title: the regression run is queued; two attempts were stopped by the harness (low memory). - AMD and Intel GPUs. The two e2e debug-layer tests need the D3D12 debug layer installed (they report SKIPPED without it). - AMD and Intel GPUs; wave64 hardware (the RTX 2070 SUPER is wave32). **AI use** - Claude Code, Claude Opus 5.5 (cause, fix and test): the code and tests. The description and the test / suite runs: Claude Code, Claude Sonnet 5.5 and Claude Opus 5.5. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Aniseto commented 2026-11-28 13:17:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T13:17:47Z.


Ran the sparse-write copy-back tests at 5f284cc2 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_written_bytes_land_in_a_chunk_the_cpu_changed -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 2029 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --test e2e -- --test-threads=1
4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out      (exit 101)

The new unit test passes. Of the five e2e tests, test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred now pass here; both failed on main e429936 in my earlier run for issue #3093 with post-Wait32/64 write failed (0x0). One test still fails: test_title_runs_and_game_folder_is_untouched panics at e2e.rs:198 (Option::unwrap() on a missing window line); reproduced 2 of 2 times. I am reporting the measured outputs, not attributing that failure to the change. The PR has no comments yet.

Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:ivall/xcl:comment:7239834648 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3149#issuecomment-7239834648). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-28T13:17:47Z. --- Ran the sparse-write copy-back tests at `5f284cc2` on an NVIDIA Blackwell desktop part: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_written_bytes_land_in_a_chunk_the_cpu_changed -- --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 2029 filtered out (exit 0) XCL_ADAPTER=NVIDIA cargo test -p xcl --test e2e -- --test-threads=1 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (exit 101) ``` The new unit test passes. Of the five `e2e` tests, `test_title_draws_with_a_root_signature_under_the_debug_layer` and `test_title_runs_under_the_debug_layer_with_dred` now pass here; both failed on `main` `e429936` in my earlier run for issue #3093 with `post-Wait32/64 write failed (0x0)`. One test still fails: `test_title_runs_and_game_folder_is_untouched` panics at `e2e.rs:198` (`Option::unwrap()` on a missing window line); reproduced 2 of 2 times. I am reporting the measured outputs, not attributing that failure to the change. The PR has no comments yet. Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
kole07139 commented 2026-11-28 13:36:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by kole07139 on 2026-11-28T13:36:55Z.


Test report for head 5f284cc2, run against the whole suite. With this PR the 3 e2e title tests of #3093 pass, and nothing fails that does not already fail on main.

Tested: NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug, no XCL_* variable set. Two trees with separate target directories: main e429936c, and e429936c with this head merged (no conflict). The D3D12 debug layer is installed, so the two debug-layer e2e tests ran and were not skipped.

cargo test --workspace --no-fail-fast -- --test-threads=4 main e429936c e429936c + 5f284cc2
all binaries 2126 passed, 9 failed, 48 ignored 2130 passed, 6 failed, 48 ignored
SKIPPED lines 26 26
e2e (5 tests) 3 failed: test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred, all post-Wait32/64 write failed (0x0) 5 passed
gpu_written_bytes_land_in_a_chunk_the_cpu_changed – ok
  • The 6 failures on the merge are #3093's second group, which fail the same way on main: dispatch_chain_oversized_loop_matches_whole, dispatch_chain_wave32_live_loops, dispatch_chain_wave64_live_loops_and_exchange, gpu_heap_flat_reads_match_guarded_and_root_output, gpu_compute_mode_dispatch_abi, gpu_float_cas_uses_ieee_equality.
  • cargo test -p xcl --test e2e -- --test-threads=1 on the merge: 5 passed, 0 failed, 3 runs out of 3. On main: 2 passed, 3 failed (post-Wait32/64 write failed (0x0)). Here test_title_runs_and_game_folder_is_untouched passes in all three runs.
  • Review of the diff: the ranges that land with gpu_written are the lists' sparse_writes. readback_after_execute_locked merges only overlapping or adjacent ones, and readback_ranges copies exactly those bytes page by page. So a changed chunk gets only the bytes the GPU's commands wrote, and the CPU's other bytes in it stay. readback_now (Map) keeps the old behaviour (false). I found nothing to change.
  • main has since moved to e13d6250 (#1809, #3102, #1873, #1908; none of them touches sparse.rs). This head merges into it without conflict; I did not rerun the suite there.

Not tested: a smoke or title run (the regression run the PR still needs), a release build, AMD and Intel GPUs, wave64 hardware.

AI use: Claude Code (Claude Opus 5.5) ran the merge, builds and tests, reviewed the diff, and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7240060843 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3149#issuecomment-7240060843). Originally posted by [kole07139](https://github.com/kole07139) on 2026-11-28T13:36:55Z. --- Test report for head `5f284cc2`, run against the whole suite. **With this PR the 3 `e2e` title tests of #3093 pass, and nothing fails that does not already fail on `main`.** **Tested:** NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug, no `XCL_*` variable set. Two trees with separate target directories: `main` `e429936c`, and `e429936c` with this head merged (no conflict). The D3D12 debug layer is installed, so the two debug-layer `e2e` tests ran and were not skipped. | `cargo test --workspace --no-fail-fast -- --test-threads=4` | `main` `e429936c` | `e429936c` + `5f284cc2` | |---|---|---| | all binaries | 2126 passed, 9 failed, 48 ignored | **2130 passed, 6 failed, 48 ignored** | | `SKIPPED` lines | 26 | 26 | | `e2e` (5 tests) | 3 failed: `test_title_draws_with_a_root_signature_under_the_debug_layer`, `test_title_runs_and_game_folder_is_untouched`, `test_title_runs_under_the_debug_layer_with_dred`, all `post-Wait32/64 write failed (0x0)` | 5 passed | | `gpu_written_bytes_land_in_a_chunk_the_cpu_changed` | – | ok | - The 6 failures on the merge are #3093's second group, which fail the same way on `main`: `dispatch_chain_oversized_loop_matches_whole`, `dispatch_chain_wave32_live_loops`, `dispatch_chain_wave64_live_loops_and_exchange`, `gpu_heap_flat_reads_match_guarded_and_root_output`, `gpu_compute_mode_dispatch_abi`, `gpu_float_cas_uses_ieee_equality`. - `cargo test -p xcl --test e2e -- --test-threads=1` on the merge: 5 passed, 0 failed, 3 runs out of 3. On `main`: 2 passed, 3 failed (`post-Wait32/64 write failed (0x0)`). Here `test_title_runs_and_game_folder_is_untouched` passes in all three runs. - Review of the diff: the ranges that land with `gpu_written` are the lists' `sparse_writes`. `readback_after_execute_locked` merges only overlapping or adjacent ones, and `readback_ranges` copies exactly those bytes page by page. So a changed chunk gets only the bytes the GPU's commands wrote, and the CPU's other bytes in it stay. `readback_now` (Map) keeps the old behaviour (`false`). I found nothing to change. - `main` has since moved to `e13d6250` (#1809, #3102, #1873, #1908; none of them touches `sparse.rs`). This head merges into it without conflict; I did not rerun the suite there. **Not tested:** a smoke or title run (the regression run the PR still needs), a release build, AMD and Intel GPUs, wave64 hardware. AI use: Claude Code (Claude Opus 5.5) ran the merge, builds and tests, reviewed the diff, and wrote this report.
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!3149
No description provided.