D3D12.X: system-memory sparse pools (#2987) give back heaps whose tiles are all free #3613

Open
throny wants to merge 2 commits from upstream-pr/3613 into main
throny commented 2026-12-01 19:52:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T19:52:56Z.


Carries #2987 (treybertram06's commit unchanged, rebased on main) and adds the system-pool retirement asked for in its review; supersedes #2987 if its author does not return.

The system-memory pools of XCL_SPARSE_SYSMEM=1 only grew: unlike the video pools they had no way to give back a heap whose tiles are all free, so the process kept its peak (about 3.8 GB in our world runs). Review point: https://github.com/xcl-dev/xcl/pull/2987#discussion_r4759072509

What is in it

  • D3D12.X: sparse tiles outside the GPU heaps can live in system memory - treybertram06's commit, unchanged (sparse.rs, kernelx.rs); default off.
  • D3D12.X: system-memory sparse pools give back heaps whose tiles are all free (crates/xcl/src/hle/d3d12x/sparse.rs): SysPools::retire releases a heap whose 64 tiles are all free or cooled (COOL), keeps it in a retired list until the sparse queue's fence is past its mark (as State::retired does), and a retired heap is taken back before a new one is made. Heap slots are Option so the indexes in live tile handles never move; the next heap takes a free slot. State::retire_free_pools_with calls it, and the submit path's retire_due also looks at the system pools' cooling queue. Test: a_system_memory_heap_with_all_tiles_free_is_given_back (checks bytes() drops, live heap keeps its index, retired heap waits for the fence, a later heap reuses the slot); it fails with the retirement disabled.

Tested

  • Hardware: NVIDIA GeForce RTX 4080 16 GB (driver 621.40), Intel i9-12900K, Windows 11 26300, stable-x86_64-pc-windows-msvc, debug.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on head b98038bb (after bmjask's third review): 3012 passed, 0 failed, 52 ignored, 25 SKIPPED lines.
  • Video memory, retail title, two 900 s warm world runs of this head (XCL_RESIDENCY_PRIORITY=1): run 505 with XCL_SPARSE_SYSMEM off: peak 18,948 MB of a 15,171 MB budget, 3.13 presents/s. Run 506 with it on: peak 15,737 MB of 15,166 MB (−3.2 GB), 3.01 presents/s (−4 %). Neither run had a device removal or crash.
  • SKIPPED lines in the log: 25 (gpu, hle, shaders and heap_window_out_of_memory_falls_back_to_the_switch_form); not counted as coverage.
  • The new test also ran alone before the full suite and failed with retire disabled (panic at the first bytes() assertion after retirement).

Regression run

main 817eb1fc9:

xcl-smoke v1
commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 17215 MB

this PR's head:

xcl-smoke v1
commit: b98038bb434dfdc8257dde82b9b6a2f40ea6ab1c
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16719 MB

Not tested

  • Whether the retirement lowers the title's peak in a world run (not measured here; the unit test covers the logic with local heaps, not the GPU mapping path).
  • AMD / NVIDIA specifics of dropping an L0 custom heap while the sparse queue still has work against it: relies on the fence mark, the same as the video pools.

AI use

  • Claude Code (Claude Sonnet 5.5) wrote the retirement and its test; the first commit is treybertram06's.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5593346693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613). Originally posted by [throny](https://github.com/throny) on 2026-12-01T19:52:56Z. --- Carries #2987 (treybertram06's commit unchanged, rebased on main) and adds the system-pool retirement asked for in its review; supersedes #2987 if its author does not return. The system-memory pools of `XCL_SPARSE_SYSMEM=1` only grew: unlike the video pools they had no way to give back a heap whose tiles are all free, so the process kept its peak (about 3.8 GB in our world runs). Review point: https://github.com/xcl-dev/xcl/pull/2987#discussion_r4759072509 **What is in it** - `D3D12.X: sparse tiles outside the GPU heaps can live in system memory` - treybertram06's commit, unchanged (`sparse.rs`, `kernelx.rs`); default off. - `D3D12.X: system-memory sparse pools give back heaps whose tiles are all free` (`crates/xcl/src/hle/d3d12x/sparse.rs`): `SysPools::retire` releases a heap whose 64 tiles are all free or cooled (`COOL`), keeps it in a retired list until the sparse queue's fence is past its mark (as `State::retired` does), and a retired heap is taken back before a new one is made. Heap slots are `Option` so the indexes in live tile handles never move; the next heap takes a free slot. `State::retire_free_pools_with` calls it, and the submit path's `retire_due` also looks at the system pools' cooling queue. Test: `a_system_memory_heap_with_all_tiles_free_is_given_back` (checks `bytes()` drops, live heap keeps its index, retired heap waits for the fence, a later heap reuses the slot); it fails with the retirement disabled. **Tested** - Hardware: NVIDIA GeForce RTX 4080 16 GB (driver 621.40), Intel i9-12900K, Windows 11 26300, stable-x86_64-pc-windows-msvc, debug. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` on head `b98038bb` (after bmjask's third review): 3012 passed, 0 failed, 52 ignored, 25 `SKIPPED` lines. - Video memory, retail title, two 900 s warm world runs of this head (`XCL_RESIDENCY_PRIORITY=1`): run 505 with `XCL_SPARSE_SYSMEM` off: peak 18,948 MB of a 15,171 MB budget, 3.13 presents/s. Run 506 with it on: peak 15,737 MB of 15,166 MB (−3.2 GB), 3.01 presents/s (−4 %). Neither run had a device removal or crash. - `SKIPPED` lines in the log: 25 (gpu, hle, shaders and `heap_window_out_of_memory_falls_back_to_the_switch_form`); not counted as coverage. - The new test also ran alone before the full suite and failed with `retire` disabled (panic at the first `bytes()` assertion after retirement). **Regression run** main `817eb1fc9`: ``` xcl-smoke v1 commit: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1559 (PresentX 1559) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 17215 MB ``` this PR's head: ``` xcl-smoke v1 commit: b98038bb434dfdc8257dde82b9b6a2f40ea6ab1c gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1575 (PresentX 1575) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16719 MB ``` **Not tested** - Whether the retirement lowers the title's peak in a world run (not measured here; the unit test covers the logic with local heaps, not the GPU mapping path). - AMD / NVIDIA specifics of dropping an L0 custom heap while the sparse queue still has work against it: relies on the fence mark, the same as the video pools. **AI use** - Claude Code (Claude Sonnet 5.5) wrote the retirement and its test; the first commit is treybertram06's. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-01 20:11:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:11:51Z.


merge-check
base: 6bfb5c5153
head: 24a84ca327
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2908 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+354/-12). The new commit makes the system-memory pools retire heaps the same way the video pools already do, and I found no problem in when a heap is released, but two open points from #2987's review are still unfixed and the new tests skip part of the path. Findings: (1) The mixed hot/cold skip from #2987 is still there. In materialize (sparse.rs ~3978), wait = left > 0 || … means that once one tile in a GPU heap finds no video memory, every later tile in the same call is skipped, including cold tiles that would have got system memory. The carried commit is byte-identical to #2987's head 15b74314 (range-diff =), so the regression reported on that head still applies; nobody answered it. (2) A refused system-memory heap is retried for every cold tile. When CreateHeap fails in take_sys_tile (~3637), it logs, falls back to take_tile and remembers nothing, so the next cold tile asks for a new 64 MiB heap again. This was raised in two #2987 merge-checks (one run showed 15 failed creations in a row), and retirement can make heap creation more frequent. (3) The test leaves out part of the path. a_system_memory_heap_with_all_tiles_free_is_given_back (~11645) calls SysPools directly. It covers the negative cases (a heap with one live tile is kept, a heap still cooling is kept, a heap waits for the fence), but not take_sys_tile taking back a retired heap through retired.pop() (~3624), the call from retire_free_pools_with (~3747), or the sys_waiting term added to retire_due on the submit path (~7953), so broken wiring would still pass. (4) A run can't show that retirement works. sys_pool_bytes() (~583) has no caller, and neither pool_bytes nor memory_bytes_for counts the system-memory heaps. Retirement writes no log line, and bytes() drops as soon as a heap is retired although the heap stays allocated in retired until the fence passes and 2 s have gone by. The growth log (~3647) now counts only live heaps, so it prints again each time the count climbs back to a power of two. A world run therefore can't confirm the 3.8 GB this PR is meant to give back (the description says so under Not tested). (5) SYS_POOLS outlives a replaced state (older than this PR). init swaps STATE (~3554) but leaves the global system-memory pools in place, so tiles the old state had mapped never come back and their heaps are never retired; only matters if init runs twice (unverified that any title does). Fine: a heap is retired only when all 64 of its tiles are free or have cooled for the full COOL time; tiles reach cooling only through quarantine (behind the sparse queue's and the title queues' fences) or when a placed buffer is released, so parked, kept, pinned and quarantined tiles keep their heap. A retired heap stays in retired until the sparse queue's fence reaches self.value and 2 s have passed, and is taken back before a new heap is created, as in the video path. Live heap indexes never move, and FreePools::clear_heap runs before a slot is reused. retire, take_sys_tile, cool and pool_heap all run with the STATE lock held and take SYS_POOLS inside it in the same order, so a map into the same heap can't race a retirement. With the switch off, SYS_POOLS stays None and take_tile_for goes to take_tile; the only additions on the default path are the HOT note/forget once per GPU heap and one uncontended lock per submit and per retire. The kernelx.rs change matches sparse::free.
performance: 60 s smoke of a retail title, main 6bfb5c51 vs this merge (24a84ca3): 1646 -> 1670 frames shown (101 %; last presents per 2 s: 60 60 61), peak commit 18685 -> 18803 MB, 0 device removals, 0 crashes. With XCL_SPARSE_SYSMEM=1: 1663 frames, peak commit 18343 MB, 0 device removals, 0 crashes; the system-memory pools were used (up to 512 MB of heaps in the log), but no retirement shows in a 60 s run and nothing logs one (finding 4).
verdict: not yet: two points from #2987's review are still open on the carried commit (finding 1, cold tiles skipped after one tile finds no video memory, and finding 2, a refused system-memory heap retried for every cold tile), and nothing yet shows the 3.8 GB coming back (finding 4). Nothing breaks: the suite passes and both smoke runs, with the switch off and on, are clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7324231618 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7324231618). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T20:11:51Z. --- merge-check base: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c head: 24a84ca327cdbed51c37f2622585b2ea89d77336 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2908 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (+354/-12). The new commit makes the system-memory pools retire heaps the same way the video pools already do, and I found no problem in when a heap is released, but two open points from #2987's review are still unfixed and the new tests skip part of the path. Findings: (1) **The mixed hot/cold skip from #2987 is still there.** In `materialize` (`sparse.rs` ~3978), `wait = left > 0 || …` means that once one tile in a GPU heap finds no video memory, every later tile in the same call is skipped, including cold tiles that would have got system memory. The carried commit is byte-identical to #2987's head `15b74314` (range-diff `=`), so the regression reported on that head still applies; nobody answered it. (2) **A refused system-memory heap is retried for every cold tile.** When `CreateHeap` fails in `take_sys_tile` (~3637), it logs, falls back to `take_tile` and remembers nothing, so the next cold tile asks for a new 64 MiB heap again. This was raised in two #2987 merge-checks (one run showed 15 failed creations in a row), and retirement can make heap creation more frequent. (3) **The test leaves out part of the path.** `a_system_memory_heap_with_all_tiles_free_is_given_back` (~11645) calls `SysPools` directly. It covers the negative cases (a heap with one live tile is kept, a heap still cooling is kept, a heap waits for the fence), but not `take_sys_tile` taking back a retired heap through `retired.pop()` (~3624), the call from `retire_free_pools_with` (~3747), or the `sys_waiting` term added to `retire_due` on the submit path (~7953), so broken wiring would still pass. (4) **A run can't show that retirement works.** `sys_pool_bytes()` (~583) has no caller, and neither `pool_bytes` nor `memory_bytes_for` counts the system-memory heaps. Retirement writes no log line, and `bytes()` drops as soon as a heap is retired although the heap stays allocated in `retired` until the fence passes and 2 s have gone by. The growth log (~3647) now counts only live heaps, so it prints again each time the count climbs back to a power of two. A world run therefore can't confirm the 3.8 GB this PR is meant to give back (the description says so under Not tested). (5) **`SYS_POOLS` outlives a replaced state (older than this PR).** `init` swaps `STATE` (~3554) but leaves the global system-memory pools in place, so tiles the old state had mapped never come back and their heaps are never retired; only matters if `init` runs twice (unverified that any title does). Fine: a heap is retired only when all 64 of its tiles are free or have cooled for the full `COOL` time; tiles reach cooling only through quarantine (behind the sparse queue's and the title queues' fences) or when a placed buffer is released, so parked, kept, pinned and quarantined tiles keep their heap. A retired heap stays in `retired` until the sparse queue's fence reaches `self.value` and 2 s have passed, and is taken back before a new heap is created, as in the video path. Live heap indexes never move, and `FreePools::clear_heap` runs before a slot is reused. `retire`, `take_sys_tile`, `cool` and `pool_heap` all run with the `STATE` lock held and take `SYS_POOLS` inside it in the same order, so a map into the same heap can't race a retirement. With the switch off, `SYS_POOLS` stays `None` and `take_tile_for` goes to `take_tile`; the only additions on the default path are the `HOT` note/forget once per GPU heap and one uncontended lock per submit and per retire. The `kernelx.rs` change matches `sparse::free`. performance: 60 s smoke of a retail title, main 6bfb5c51 vs this merge (24a84ca3): 1646 -> 1670 frames shown (101 %; last presents per 2 s: 60 60 61), peak commit 18685 -> 18803 MB, 0 device removals, 0 crashes. With `XCL_SPARSE_SYSMEM=1`: 1663 frames, peak commit 18343 MB, 0 device removals, 0 crashes; the system-memory pools were used (up to 512 MB of heaps in the log), but no retirement shows in a 60 s run and nothing logs one (finding 4). verdict: not yet: two points from #2987's review are still open on the carried commit (finding 1, cold tiles skipped after one tile finds no video memory, and finding 2, a refused system-memory heap retried for every cold tile), and nothing yet shows the 3.8 GB coming back (finding 4). Nothing breaks: the suite passes and both smoke runs, with the switch off and on, are clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
vasanex commented 2026-12-02 00:18:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T00:18:13Z.


merge-check claim
head: 24a84ca327

<!-- greyfinch-sync:ivall/xcl:comment:7330386748 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7330386748). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-02T00:18:13Z. --- merge-check claim head: 24a84ca327cdbed51c37f2622585b2ea89d77336
vasanex commented 2026-12-02 00:33:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T00:33:17Z.


merge-check
base: 1c8b551475
head: 24a84ca327
merge: clean (merged tree 7cbdd9c3, git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> two runs on the merge: 2912 passed, 1 failed, 51 ignored, then 2913 passed, 0 failed, 51 ignored; SKIPPED: 25 in both (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; base alone, same machine: 2909 passed, 0 failed, 51 ignored. Failing in the first run only: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (tests/gpu_two_pass_cache_e2e.rs:584, "releasing the title PSOs releases their two-pass state", left 1, right 0, in its warm case). That is the assertion of the open issue #3441. Alone with --exact --test-threads=1: on the merge 9 of 11 passed (the 2 failures came right after the suite run, the next 8 runs passed), on the base 6 of 6. I do not see how this PR reaches that test (it does not set XCL_SPARSE_SYSMEM, and the change touches no pipeline or late-release code), and the second whole run is clean, so I count it as #3441's flake, not as this PR's; the numbers are here so that others can judge. The PR's four new tests pass in both runs (a_system_memory_heap_with_all_tiles_free_is_given_back, a_lazy_tile_outside_the_gpu_heaps_gets_system_memory, a_parked_system_memory_tile_gives_way_to_a_gpu_heap, the_title_gpu_heaps_are_hot_and_nothing_around_them); the two GPU ones did not skip here, so the L0 custom heap was made and mapped on this card.
review: whole diff read (sparse.rs, kernelx.rs), in the merge result. No blocking finding. Checked: SYS (bit 31 of the pool index) against the LAZY sentinel (all bits set): every path that reaches cool, pool_heap or the quarantine count already leaves LAZY out, as on main. All frees of a pool tile go through State::cool, so no SYS index reaches the video pools' FreePools table (the second GPU test asserts that). Lock order is always the sparse state, then SYS_POOLS / HOT; take_sys_tile drops SYS_POOLS before it falls back to take_tile. A heap slot given back is None and reused by add_heap, so indexes in live tile handles stay valid; a retired heap waits for the sparse queue's fence and 2 s, as the video pools do. Smaller points: (1) XCL_SPARSE_SYSMEM has no line in README.md (the switch comes from #2987's commit); (2) the retirement test uses plain default heaps and no tile mapping, as the description says, so giving back an L0 heap that was mapped is covered only by reasoning (the fence mark); (3) sys_pool_bytes() has no caller, so the memory lines of the log do not show these heaps yet; (4) I did not repeat the "fails with retire disabled" run. Duplicates: it carries #2987 (open, same first commit; #1607 group D262 with #3112) and adds one commit; nothing else found for XCL_SPARSE_SYSMEM.
performance: off by default. With the switch off the cost is one OnceLock read per tile taken, one uncontended SYS_POOLS lock per submit (retire_waiting) and per pool retirement, and a bit test per freed tile: reasoned, not measured. No title run in this check; nothing here says what the switch does to frame time on a 10 GB card.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7330694628 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7330694628). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-02T00:33:17Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 24a84ca327cdbed51c37f2622585b2ea89d77336 merge: clean (merged tree 7cbdd9c3, `git diff --check` clean) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> two runs on the merge: 2912 passed, 1 failed, 51 ignored, then 2913 passed, 0 failed, 51 ignored; SKIPPED: 25 in both (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; base alone, same machine: 2909 passed, 0 failed, 51 ignored. Failing in the first run only: `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` (tests/gpu_two_pass_cache_e2e.rs:584, "releasing the title PSOs releases their two-pass state", left 1, right 0, in its `warm` case). That is the assertion of the open issue #3441. Alone with `--exact --test-threads=1`: on the merge 9 of 11 passed (the 2 failures came right after the suite run, the next 8 runs passed), on the base 6 of 6. I do not see how this PR reaches that test (it does not set `XCL_SPARSE_SYSMEM`, and the change touches no pipeline or late-release code), and the second whole run is clean, so I count it as #3441's flake, not as this PR's; the numbers are here so that others can judge. The PR's four new tests pass in both runs (`a_system_memory_heap_with_all_tiles_free_is_given_back`, `a_lazy_tile_outside_the_gpu_heaps_gets_system_memory`, `a_parked_system_memory_tile_gives_way_to_a_gpu_heap`, `the_title_gpu_heaps_are_hot_and_nothing_around_them`); the two GPU ones did not skip here, so the L0 custom heap was made and mapped on this card. review: whole diff read (sparse.rs, kernelx.rs), in the merge result. No blocking finding. Checked: `SYS` (bit 31 of the pool index) against the `LAZY` sentinel (all bits set): every path that reaches `cool`, `pool_heap` or the quarantine count already leaves `LAZY` out, as on main. All frees of a pool tile go through `State::cool`, so no `SYS` index reaches the video pools' `FreePools` table (the second GPU test asserts that). Lock order is always the sparse state, then `SYS_POOLS` / `HOT`; `take_sys_tile` drops `SYS_POOLS` before it falls back to `take_tile`. A heap slot given back is `None` and reused by `add_heap`, so indexes in live tile handles stay valid; a retired heap waits for the sparse queue's fence and 2 s, as the video pools do. Smaller points: (1) `XCL_SPARSE_SYSMEM` has no line in README.md (the switch comes from #2987's commit); (2) the retirement test uses plain default heaps and no tile mapping, as the description says, so giving back an L0 heap that was mapped is covered only by reasoning (the fence mark); (3) `sys_pool_bytes()` has no caller, so the memory lines of the log do not show these heaps yet; (4) I did not repeat the "fails with `retire` disabled" run. Duplicates: it carries #2987 (open, same first commit; #1607 group D262 with #3112) and adds one commit; nothing else found for `XCL_SPARSE_SYSMEM`. performance: off by default. With the switch off the cost is one `OnceLock` read per tile taken, one uncontended `SYS_POOLS` lock per submit (`retire_waiting`) and per pool retirement, and a bit test per freed tile: reasoned, not measured. No title run in this check; nothing here says what the switch does to frame time on a 10 GB card. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
throny commented 2026-12-02 08:39:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T08:39:24Z.


In the world with #3617 and residency priority on current main (RTX 4080 16 GB, 900 s, same save and inputs, no draws skipped): XCL_SPARSE_SYSMEM=1 2.95 and 2.97 presents/s at 15.6 / 15.8 GB video memory (runs 429, 431) against 3.15 at 18.7 GB without it (run 430), so ~3 GB less video memory for ~6 % frame rate in this combination. Non-local (system) video memory at the end of the runs: 8.9 GB with the switch, 4.9 GB without — the retirement here gives back heaps only once all their tiles are free, which this title's working set apparently never reaches within 15 minutes; the unit test covers the logic, but no measurable drop in the world yet.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7339745697 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7339745697). Originally posted by [throny](https://github.com/throny) on 2026-12-02T08:39:24Z. --- In the world with #3617 and residency priority on current `main` (RTX 4080 16 GB, 900 s, same save and inputs, no draws skipped): `XCL_SPARSE_SYSMEM=1` 2.95 and 2.97 presents/s at 15.6 / 15.8 GB video memory (runs 429, 431) against 3.15 at 18.7 GB without it (run 430), so ~3 GB less video memory for ~6 % frame rate in this combination. Non-local (system) video memory at the end of the runs: 8.9 GB with the switch, 4.9 GB without — the retirement here gives back heaps only once all their tiles are free, which this title's working set apparently never reaches within 15 minutes; the unit test covers the logic, but no measurable drop in the world yet. AI use: Claude Code (Claude Opus 5.5).
thehollowedone commented 2026-12-02 08:45:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-02T08:45:18Z.


Follow-up on exact head 24a84ca3, addressing the mixed hot/cold allocation finding.

I added a synthetic regression to the unchanged head. It failed because the failed hot-tile allocation caused the adjacent cold tile to remain LAZY. With the candidate below, that same test passed on the RTX 3080 Ti, and GPU readback matched the CPU-written bytes. The full sparse test module passed: 145 passed, 0 failed, 1 ignored, no SKIPPED notices.

The change tracks failure separately for video and system-memory allocation, so failure in one pool does not suppress an attempt from the other. If both the L0 request and its video fallback fail, it preserves the existing no_memory retry state. This addresses finding 1 only; repeated L0 heap attempts after a successful video fallback remain open, as do the other review coverage and measurement points. This is not a merge-check: I did not run the full workspace or paired title smoke on this candidate.

cargo test --offline --locked --manifest-path .codex-scratch-pr3613/Cargo.toml -p xcl --lib hle::d3d12x::sparse --quiet -- --test-threads=1
145 passed; 0 failed; 1 ignored; 0 SKIPPED notices

NVIDIA GeForce RTX 3080 Ti (driver 621.40), AMD Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1.

Candidate diff
diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index f31636e5..c0958fa9 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -3970,13 +3970,15 @@ impl State {
         let end = a.saturating_add(n);
         let mut t = a & !(TILE - 1);
         let (mut got, mut left) = (0, 0);
+        let (mut video_failed, mut sys_failed) = (false, false);
         while t < end {
             if self.mapped.get(&t).is_some_and(|e| e.pool == LAZY) {
                 let at_hand = !self.free.is_empty() || cooled(&self.cooling, std::time::Instant::now()) || !self.retired.is_empty();
                 // (short of video memory: a tile of the system-memory pools does not wait for it)
                 let sys = sysmem_tiles() && !is_hot(t);
-                let wait = left > 0 || (!force && !sys && self.short_of_memory() && !at_hand);
-                match if wait { None } else { self.take_tile_for(t) } {
+                let wait = if sys { sys_failed } else { video_failed }
+                    || (!force && !sys && self.short_of_memory() && !at_hand);
+                match if wait { None } else if sys { self.take_sys_tile() } else { self.take_tile() } {
@@ -3988,9 +3990,13 @@ impl State {
                         got += 1;
                     }
                     None => {
                         if !wait {
+                            // `take_sys_tile` falls back to video memory if an L0 heap
+                            // cannot be made; if that fallback also fails, retain the
+                            // existing video-memory retry backoff.
                             self.no_memory = Some(std::time::Instant::now());
+                            if sys { sys_failed = true; } else { video_failed = true; }
                         }
                         left += 1;
                     }
@@ -11602,6 +11608,44 @@ mod tests {
         drop(lazy);
     }
 
+    /// A failed video-memory allocation for a hot tile does not skip the next cold tile, which
+    /// can still be backed by the system-memory pool.
+    #[test]
+    fn a_hot_tile_without_video_memory_does_not_block_a_cold_system_memory_tile() {
+        let lazy = Lazy::on(true);
+        lazy.sysmem(true);
+        unsafe {
+            let Some((base, mut s, queue)) = lazy_state(3) else { return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2") };
+            let probe = base + 2 * TILE;
+            s.ensure_mapped(probe, TILE, |_| (0, 0));
+            if !s.mapped.get(&probe).is_some_and(|entry| entry.pool != LAZY && entry.pool.0 & SYS != 0) {
+                return crate::gpu::recomp::runner::skip_test("no system-memory pool heap");
+            }
+            s.commit_range(base, 2 * TILE);
+            assert_eq!(s.mapped[&base].pool, LAZY);
+            assert_eq!(s.mapped[&(base + TILE)].pool, LAZY);
+
+            struct ForgetHot(usize);
+            impl Drop for ForgetHot {
+                fn drop(&mut self) { forget_hot(self.0); }
+            }
+            note_hot(base, TILE);
+            let _hot = ForgetHot(base);
+
+            lazy.no_tiles(true);
+            s.give_memory(&[(base, 2 * TILE)]);
+            assert_eq!(s.mapped[&base].pool, LAZY, "the hot tile had no video memory");
+            assert_ne!(s.mapped[&(base + TILE)].pool, LAZY, "the cold tile still got a pool tile");
+            assert_ne!(s.mapped[&(base + TILE)].pool.0 & SYS, 0, "the cold tile used system memory");
+
+            let dirty = write_tile(base + TILE, 17);
+            s.before_execute_on(&queue, &dirty, PAGE);
+            let cpu = std::slice::from_raw_parts((base + TILE) as *const u8, TILE).to_vec();
+            assert_eq!(window_bytes(&mut s, base + TILE, TILE), cpu, "the CPU bytes reached the GPU through the system-memory tile");
+        }
+        drop(lazy);
+    }

AI use: OpenAI Codex (GPT-6.2 Sol) prepared and tested this candidate.

<!-- greyfinch-sync:ivall/xcl:comment:7339882018 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7339882018). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-12-02T08:45:18Z. --- Follow-up on exact head [`24a84ca3`](https://github.com/xcl-dev/xcl/commit/24a84ca327cdbed51c37f2622585b2ea89d77336), addressing the [mixed hot/cold allocation finding](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7324231618). I added a synthetic regression to the unchanged head. It failed because the failed hot-tile allocation caused the adjacent cold tile to remain `LAZY`. With the candidate below, that same test passed on the RTX 3080 Ti, and GPU readback matched the CPU-written bytes. The full sparse test module passed: 145 passed, 0 failed, 1 ignored, no `SKIPPED` notices. The change tracks failure separately for video and system-memory allocation, so failure in one pool does not suppress an attempt from the other. If both the L0 request and its video fallback fail, it preserves the existing `no_memory` retry state. This addresses finding 1 only; repeated L0 heap attempts after a successful video fallback remain open, as do the other review coverage and measurement points. This is not a merge-check: I did not run the full workspace or paired title smoke on this candidate. ```text cargo test --offline --locked --manifest-path .codex-scratch-pr3613/Cargo.toml -p xcl --lib hle::d3d12x::sparse --quiet -- --test-threads=1 145 passed; 0 failed; 1 ignored; 0 SKIPPED notices ``` NVIDIA GeForce RTX 3080 Ti (driver 621.40), AMD Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1. <details> <summary>Candidate diff</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index f31636e5..c0958fa9 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -3970,13 +3970,15 @@ impl State { let end = a.saturating_add(n); let mut t = a & !(TILE - 1); let (mut got, mut left) = (0, 0); + let (mut video_failed, mut sys_failed) = (false, false); while t < end { if self.mapped.get(&t).is_some_and(|e| e.pool == LAZY) { let at_hand = !self.free.is_empty() || cooled(&self.cooling, std::time::Instant::now()) || !self.retired.is_empty(); // (short of video memory: a tile of the system-memory pools does not wait for it) let sys = sysmem_tiles() && !is_hot(t); - let wait = left > 0 || (!force && !sys && self.short_of_memory() && !at_hand); - match if wait { None } else { self.take_tile_for(t) } { + let wait = if sys { sys_failed } else { video_failed } + || (!force && !sys && self.short_of_memory() && !at_hand); + match if wait { None } else if sys { self.take_sys_tile() } else { self.take_tile() } { @@ -3988,9 +3990,13 @@ impl State { got += 1; } None => { if !wait { + // `take_sys_tile` falls back to video memory if an L0 heap + // cannot be made; if that fallback also fails, retain the + // existing video-memory retry backoff. self.no_memory = Some(std::time::Instant::now()); + if sys { sys_failed = true; } else { video_failed = true; } } left += 1; } @@ -11602,6 +11608,44 @@ mod tests { drop(lazy); } + /// A failed video-memory allocation for a hot tile does not skip the next cold tile, which + /// can still be backed by the system-memory pool. + #[test] + fn a_hot_tile_without_video_memory_does_not_block_a_cold_system_memory_tile() { + let lazy = Lazy::on(true); + lazy.sysmem(true); + unsafe { + let Some((base, mut s, queue)) = lazy_state(3) else { return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2") }; + let probe = base + 2 * TILE; + s.ensure_mapped(probe, TILE, |_| (0, 0)); + if !s.mapped.get(&probe).is_some_and(|entry| entry.pool != LAZY && entry.pool.0 & SYS != 0) { + return crate::gpu::recomp::runner::skip_test("no system-memory pool heap"); + } + s.commit_range(base, 2 * TILE); + assert_eq!(s.mapped[&base].pool, LAZY); + assert_eq!(s.mapped[&(base + TILE)].pool, LAZY); + + struct ForgetHot(usize); + impl Drop for ForgetHot { + fn drop(&mut self) { forget_hot(self.0); } + } + note_hot(base, TILE); + let _hot = ForgetHot(base); + + lazy.no_tiles(true); + s.give_memory(&[(base, 2 * TILE)]); + assert_eq!(s.mapped[&base].pool, LAZY, "the hot tile had no video memory"); + assert_ne!(s.mapped[&(base + TILE)].pool, LAZY, "the cold tile still got a pool tile"); + assert_ne!(s.mapped[&(base + TILE)].pool.0 & SYS, 0, "the cold tile used system memory"); + + let dirty = write_tile(base + TILE, 17); + s.before_execute_on(&queue, &dirty, PAGE); + let cpu = std::slice::from_raw_parts((base + TILE) as *const u8, TILE).to_vec(); + assert_eq!(window_bytes(&mut s, base + TILE, TILE), cpu, "the CPU bytes reached the GPU through the system-memory tile"); + } + drop(lazy); + } ``` </details> AI use: OpenAI Codex (GPT-6.2 Sol) prepared and tested this candidate.
bmjask commented 2026-12-02 16:03:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:39Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 11598

@@ -11345,6 +11578,114 @@ mod tests {
         drop(lazy);
     }
 
+    /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the
+    /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU.
+    #[test]
+    fn a_lazy_tile_outside_the_gpu_heaps_gets_system_memory() {
+        let lazy = Lazy::on(true);
+        lazy.sysmem(true);
+        unsafe {
+            let Some((base, mut s, queue)) = lazy_state(2) else { return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2") };
+            let eager = base + TILE;
+            s.ensure_mapped(eager, TILE, |_| (0, 0));
+            if s.mapped[&eager].pool.0 & SYS == 0 {
+                return crate::gpu::recomp::runner::skip_test("no system-memory pool heap");
+            }
+            s.commit_range(base, TILE);
+            assert_eq!(s.mapped[&base].pool, LAZY);
+            let dirty = write_tile(base, 11);
+            s.before_execute_on(&queue, &dirty, PAGE);
+            assert_ne!(s.mapped[&base].pool.0 & SYS, 0, "its first bytes gave it a system-memory tile");

Medium: LAZY is (u32::MAX, u32::MAX), which has the SYS bit set. So a LAZY handle that reaches pool_heap or cool is routed to SYS_POOLS with index 0x7FFFFFFF, an out-of-bounds panic where it used to hit the existing "live pool" check. In the test, assert_ne!(pool.0 & SYS, 0, ...) also passes even when the tile never got memory. Checking for LAZY before the SYS test (in pool_heap, cool and the test) would avoid both.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772465632 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4772465632). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:39Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 11598 ~~~~diff @@ -11345,6 +11578,114 @@ mod tests { drop(lazy); } + /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the + /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU. + #[test] + fn a_lazy_tile_outside_the_gpu_heaps_gets_system_memory() { + let lazy = Lazy::on(true); + lazy.sysmem(true); + unsafe { + let Some((base, mut s, queue)) = lazy_state(2) else { return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2") }; + let eager = base + TILE; + s.ensure_mapped(eager, TILE, |_| (0, 0)); + if s.mapped[&eager].pool.0 & SYS == 0 { + return crate::gpu::recomp::runner::skip_test("no system-memory pool heap"); + } + s.commit_range(base, TILE); + assert_eq!(s.mapped[&base].pool, LAZY); + let dirty = write_tile(base, 11); + s.before_execute_on(&queue, &dirty, PAGE); + assert_ne!(s.mapped[&base].pool.0 & SYS, 0, "its first bytes gave it a system-memory tile"); ~~~~ --- **Medium**: `LAZY` is (u32::MAX, u32::MAX), which has the SYS bit set. So a LAZY handle that reaches `pool_heap` or `cool` is routed to SYS_POOLS with index 0x7FFFFFFF, an out-of-bounds panic where it used to hit the existing "live pool" check. In the test, `assert_ne!(pool.0 & SYS, 0, ...)` also passes even when the tile never got memory. Checking for LAZY before the SYS test (in `pool_heap`, `cool` and the test) would avoid both.
bmjask commented 2026-12-02 16:03:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:39Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 3658

@@ -3508,6 +3612,71 @@ impl State {
         Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source })
     }
 
+    /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`).
+    unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> {
+        self.drain_quarantined();
+        let mut g = SYS_POOLS.lock().unwrap();
+        let p = g.get_or_insert_with(SysPools::default);
+        if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) {
+            return Some(((SYS | h, t), true));
+        }
+        // a heap given back a moment ago is taken back first (as `take_tile` does)
+        if let Some((heap, _, _)) = p.retired.pop() {
+            let h = p.add_heap(heap);
+            return Some(((SYS | h, 0), true));
+        }
+        let desc = D3D12_HEAP_DESC {
+            SizeInBytes: POOL_TILES as u64 * TILE as u64,
+            Properties: D3D12_HEAP_PROPERTIES {
+                Type: D3D12_HEAP_TYPE_CUSTOM,
+                CPUPageProperty: D3D12_CPU_PAGE_PROPERTY_WRITE_BACK,
+                MemoryPoolPreference: D3D12_MEMORY_POOL_L0,
+                ..Default::default()
+            },
+            Alignment: 0,
+            Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES,
+        };
+        let mut heap: Option<ID3D12Heap> = None;
+        if let Err(e) = super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) {
+            crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead");
+            drop(g);
+            return self.take_tile();
+        }
+        let heap = heap?;
+        let _ = heap.SetName(windows::core::w!("xcl sparse system-memory pool"));
+        let h = p.add_heap(heap);
+        let n = p.heaps.iter().flatten().count();
+        if n.is_power_of_two() {
+            crate::xlog_info!("sparse windows: {} MB of system-memory pool heaps", n * POOL_TILES as usize * TILE >> 20);
+        }
+        Some(((SYS | h, 0), false))
+    }
+
+    /// A pool tile for window tile `t`: from the system-memory pools under `XCL_SPARSE_SYSMEM`
+    /// unless `t` is in a GPU heap of the title.
+    unsafe fn take_tile_for(&mut self, t: usize) -> Option<((u32, u32), bool)> {
+        if sysmem_tiles() && !is_hot(t) { self.take_sys_tile() } else { self.take_tile() }

Medium: Only the XCL_COHERENT_HEAPS=sparse heaps are marked hot, so every other GPU-critical sparse allocation goes to system memory under the flag: XMemAllocDefault graphics memory and MEM_GRAPHICS VirtualAlloc (kernelx.rs:967 and 1432), console descriptor tables (console_heap.rs:869 via alloc_in), and command-list scratch (console_list.rs:662, bind.rs:4978). With XCL_SPARSE_SYSMEM=1, a title's XMemAlloc render targets and textures, and the descriptor tables shaders read every draw, get L0 tiles and are read and written over PCIe. The flag is described as moving only tiles outside the title's GPU heaps, so marking those allocations hot too would match the description.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772465643 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4772465643). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:39Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 3658 ~~~~diff @@ -3508,6 +3612,71 @@ impl State { Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source }) } + /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`). + unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> { + self.drain_quarantined(); + let mut g = SYS_POOLS.lock().unwrap(); + let p = g.get_or_insert_with(SysPools::default); + if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) { + return Some(((SYS | h, t), true)); + } + // a heap given back a moment ago is taken back first (as `take_tile` does) + if let Some((heap, _, _)) = p.retired.pop() { + let h = p.add_heap(heap); + return Some(((SYS | h, 0), true)); + } + let desc = D3D12_HEAP_DESC { + SizeInBytes: POOL_TILES as u64 * TILE as u64, + Properties: D3D12_HEAP_PROPERTIES { + Type: D3D12_HEAP_TYPE_CUSTOM, + CPUPageProperty: D3D12_CPU_PAGE_PROPERTY_WRITE_BACK, + MemoryPoolPreference: D3D12_MEMORY_POOL_L0, + ..Default::default() + }, + Alignment: 0, + Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES, + }; + let mut heap: Option<ID3D12Heap> = None; + if let Err(e) = super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) { + crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead"); + drop(g); + return self.take_tile(); + } + let heap = heap?; + let _ = heap.SetName(windows::core::w!("xcl sparse system-memory pool")); + let h = p.add_heap(heap); + let n = p.heaps.iter().flatten().count(); + if n.is_power_of_two() { + crate::xlog_info!("sparse windows: {} MB of system-memory pool heaps", n * POOL_TILES as usize * TILE >> 20); + } + Some(((SYS | h, 0), false)) + } + + /// A pool tile for window tile `t`: from the system-memory pools under `XCL_SPARSE_SYSMEM` + /// unless `t` is in a GPU heap of the title. + unsafe fn take_tile_for(&mut self, t: usize) -> Option<((u32, u32), bool)> { + if sysmem_tiles() && !is_hot(t) { self.take_sys_tile() } else { self.take_tile() } ~~~~ --- **Medium**: Only the XCL_COHERENT_HEAPS=sparse heaps are marked hot, so every other GPU-critical sparse allocation goes to system memory under the flag: XMemAllocDefault graphics memory and MEM_GRAPHICS VirtualAlloc (kernelx.rs:967 and 1432), console descriptor tables (console_heap.rs:869 via `alloc_in`), and command-list scratch (console_list.rs:662, bind.rs:4978). With XCL_SPARSE_SYSMEM=1, a title's XMemAlloc render targets and textures, and the descriptor tables shaders read every draw, get L0 tiles and are read and written over PCIe. The flag is described as moving only tiles outside the title's GPU heaps, so marking those allocations hot too would match the description.
bmjask commented 2026-12-02 16:03:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:39Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 4035

@@ -3850,11 +4024,29 @@ impl State {
         let end = a.saturating_add(n);
         let mut new = false;
         let mut unparked = false;
+        // parked system-memory tiles at addresses of a GPU heap now (`XCL_SPARSE_SYSMEM`)
+        let mut replaced = Vec::new();
         let mut t = first;
         while t < end {
             if !self.mapped.contains_key(&t) && !self.mirror_src.contains_key(&t) && self.window_index(t).is_some() {
-                // still mapped there: no new mapping, what it held is cleared
-                if let Some(tile) = self.parked.remove(&t).or_else(|| self.kept.remove(&t)) {
+                // a tile parked here from before is in system memory and a GPU heap of the title
+                // is here now: a video-memory tile takes its place, mapped over it at once, and it
+                // goes once the GPU is past that (one a placed buffer uses stays; none found: it stays)
+                let swap = self.parked.get(&t).is_some_and(|tile| tile.0 & SYS != 0 && !self.pinned.contains_key(tile)) && is_hot(t);

Medium: The swap from a system-memory tile to a video tile at a GPU-heap address only checks parked, so a SYS tile held in kept at that address is taken back as-is by .or_else(|| self.kept.remove(&t)). With XCL_SPARSE_SYSMEM=1 plus XCL_VIEW_KEEP or a placed buffer's kept tile, a non-hot reservation leaves a SYS tile in kept. If the address is then reused for a title GPU heap (alloc_as(.., true)), ensure_mapped finds the tile in kept, swap is false, and the GPU heap's tile stays in system memory.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772465660 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4772465660). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:39Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 4035 ~~~~diff @@ -3850,11 +4024,29 @@ impl State { let end = a.saturating_add(n); let mut new = false; let mut unparked = false; + // parked system-memory tiles at addresses of a GPU heap now (`XCL_SPARSE_SYSMEM`) + let mut replaced = Vec::new(); let mut t = first; while t < end { if !self.mapped.contains_key(&t) && !self.mirror_src.contains_key(&t) && self.window_index(t).is_some() { - // still mapped there: no new mapping, what it held is cleared - if let Some(tile) = self.parked.remove(&t).or_else(|| self.kept.remove(&t)) { + // a tile parked here from before is in system memory and a GPU heap of the title + // is here now: a video-memory tile takes its place, mapped over it at once, and it + // goes once the GPU is past that (one a placed buffer uses stays; none found: it stays) + let swap = self.parked.get(&t).is_some_and(|tile| tile.0 & SYS != 0 && !self.pinned.contains_key(tile)) && is_hot(t); ~~~~ --- **Medium**: The swap from a system-memory tile to a video tile at a GPU-heap address only checks `parked`, so a SYS tile held in `kept` at that address is taken back as-is by `.or_else(|| self.kept.remove(&t))`. With XCL_SPARSE_SYSMEM=1 plus XCL_VIEW_KEEP or a placed buffer's kept tile, a non-hot reservation leaves a SYS tile in `kept`. If the address is then reused for a title GPU heap (`alloc_as(.., true)`), `ensure_mapped` finds the tile in `kept`, `swap` is false, and the GPU heap's tile stays in system memory.
bmjask commented 2026-12-02 16:03:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:39Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 549

@@ -481,6 +481,109 @@ impl FreePools {
     }
 }
 
+/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the
+/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by
+/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool
+/// tile of these heaps has `SYS` set in its pool index.
+const SYS: u32 = 1 << 31;
+
+#[derive(Default)]
+struct SysPools {
+    /// None: a heap given back (`retire`); its index is taken by the next heap (`add_heap`), the
+    /// indexes of the live heaps are in the tile handles and never move
+    heaps: Vec<Option<ID3D12Heap>>,
+    /// (by the heap's index without `SYS`: `FreePools` sizes its table by it)
+    free: FreePools,
+    cooling: VecDeque<((u32, u32), std::time::Instant)>,
+    /// heaps given back, kept until the sparse queue's fence is past the value they got
+    /// (`State::retired` of the video pools)
+    retired: Vec<(ID3D12Heap, u64, std::time::Instant)>,
+}
+
+impl SysPools {
+    /// `heap` becomes a pool (in a given-back heap's index if there is one); its tiles but the
+    /// first, which the caller takes, go to the free list.
+    fn add_heap(&mut self, heap: ID3D12Heap) -> u32 {
+        let h = match self.heaps.iter().position(|p| p.is_none()) {
+            Some(i) => {
+                self.heaps[i] = Some(heap);
+                i as u32
+            }
+            None => {
+                self.heaps.push(Some(heap));
+                self.heaps.len() as u32 - 1
+            }
+        };
+        self.free.add_heap(h);
+        h
+    }
+
+    /// Heaps whose every tile is free again (cooled, `COOL`) are given back (`State::retire_free_pools_with`
+    /// does the same for video memory): `value` is the sparse queue's last fence value, `done` what
+    /// it has reached; a retired heap is dropped once it is past its mark.
+    fn retire(&mut self, value: u64, done: u64, now: std::time::Instant) {
+        self.retired.retain(|(_, v, at)| !(done >= *v && now.duration_since(*at).as_secs() >= 2));
+        self.free.drain_cooling(&mut self.cooling, now);
+        let gone: Vec<usize> = free_heaps(&self.free, &self.cooling, self.heaps.len(), now).into_iter().filter(|&h| self.heaps[h].is_some()).collect();
+        for h in gone {
+            self.free.clear_heap(h);
+            if let Some(heap) = self.heaps[h].take() {
+                self.retired.push((heap, value, now));
+            }
+        }
+    }
+
+    /// Whether `State::retire_free_pools_with` has something to do here at `now` (`retire_due`).
+    fn retire_waiting(&self, now: std::time::Instant) -> bool {
+        !self.retired.is_empty() || self.free.has_empty_heap() || cooled(&self.cooling, now)
+    }
+
+    fn bytes(&self) -> usize {
+        self.heaps.iter().flatten().count() * POOL_TILES as usize * TILE
+    }
+}
+
+// D3D12 heaps are free-threaded
+unsafe impl Send for SysPools {}
+
+static SYS_POOLS: Mutex<Option<SysPools>> = Mutex::new(None);

Medium: Not certain about this one: SYS_POOLS is a process-global static, but the video pools, the fence and the quarantine live in State, which sparse::init replaces, so the system-memory pools outlive the State whose tiles and fence values they track. If sparse::init runs again (two first real::init calls, or crates/xcl/tests/sparse_reinit.rs), the old State's mapped, parked and quarantined SYS tiles are dropped without being cooled, so SYS_POOLS counts them in use forever and those heaps never retire. Retired heaps also keep fence marks from the old fence, compared against a new one that restarts at 0, and heaps made on the old device can be handed to the new State's UpdateTileMappings. Keeping the sys pools inside State would tie their lifetime to it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772465669 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4772465669). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:39Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 549 ~~~~diff @@ -481,6 +481,109 @@ impl FreePools { } } +/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the +/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by +/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool +/// tile of these heaps has `SYS` set in its pool index. +const SYS: u32 = 1 << 31; + +#[derive(Default)] +struct SysPools { + /// None: a heap given back (`retire`); its index is taken by the next heap (`add_heap`), the + /// indexes of the live heaps are in the tile handles and never move + heaps: Vec<Option<ID3D12Heap>>, + /// (by the heap's index without `SYS`: `FreePools` sizes its table by it) + free: FreePools, + cooling: VecDeque<((u32, u32), std::time::Instant)>, + /// heaps given back, kept until the sparse queue's fence is past the value they got + /// (`State::retired` of the video pools) + retired: Vec<(ID3D12Heap, u64, std::time::Instant)>, +} + +impl SysPools { + /// `heap` becomes a pool (in a given-back heap's index if there is one); its tiles but the + /// first, which the caller takes, go to the free list. + fn add_heap(&mut self, heap: ID3D12Heap) -> u32 { + let h = match self.heaps.iter().position(|p| p.is_none()) { + Some(i) => { + self.heaps[i] = Some(heap); + i as u32 + } + None => { + self.heaps.push(Some(heap)); + self.heaps.len() as u32 - 1 + } + }; + self.free.add_heap(h); + h + } + + /// Heaps whose every tile is free again (cooled, `COOL`) are given back (`State::retire_free_pools_with` + /// does the same for video memory): `value` is the sparse queue's last fence value, `done` what + /// it has reached; a retired heap is dropped once it is past its mark. + fn retire(&mut self, value: u64, done: u64, now: std::time::Instant) { + self.retired.retain(|(_, v, at)| !(done >= *v && now.duration_since(*at).as_secs() >= 2)); + self.free.drain_cooling(&mut self.cooling, now); + let gone: Vec<usize> = free_heaps(&self.free, &self.cooling, self.heaps.len(), now).into_iter().filter(|&h| self.heaps[h].is_some()).collect(); + for h in gone { + self.free.clear_heap(h); + if let Some(heap) = self.heaps[h].take() { + self.retired.push((heap, value, now)); + } + } + } + + /// Whether `State::retire_free_pools_with` has something to do here at `now` (`retire_due`). + fn retire_waiting(&self, now: std::time::Instant) -> bool { + !self.retired.is_empty() || self.free.has_empty_heap() || cooled(&self.cooling, now) + } + + fn bytes(&self) -> usize { + self.heaps.iter().flatten().count() * POOL_TILES as usize * TILE + } +} + +// D3D12 heaps are free-threaded +unsafe impl Send for SysPools {} + +static SYS_POOLS: Mutex<Option<SysPools>> = Mutex::new(None); ~~~~ --- **Medium**: Not certain about this one: SYS_POOLS is a process-global static, but the video pools, the fence and the quarantine live in State, which `sparse::init` replaces, so the system-memory pools outlive the State whose tiles and fence values they track. If `sparse::init` runs again (two first `real::init` calls, or crates/xcl/tests/sparse_reinit.rs), the old State's mapped, parked and quarantined SYS tiles are dropped without being cooled, so SYS_POOLS counts them in use forever and those heaps never retire. Retired heaps also keep fence marks from the old fence, compared against a new one that restarts at 0, and heaps made on the old device can be handed to the new State's UpdateTileMappings. Keeping the sys pools inside State would tie their lifetime to it.
bmjask commented 2026-12-02 16:03:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:39Z.

Review: COMMENTED


Review of 24a84ca3: 4 finding(s) (4 medium), most severe first.

  1. Medium crates/xcl/src/hle/d3d12x/sparse.rs:11598: LAZY is (u32::MAX, u32::MAX), which has the SYS bit set. (inline)
  2. Medium crates/xcl/src/hle/d3d12x/sparse.rs:3658: Only the XCL_COHERENT_HEAPS=sparse heaps are marked hot, so every other GPU-critical sparse allocation goes to system memory under the flag: XMemAllocDefault graphics memory and MEM_GRAPHICS VirtualAlloc (kernelx.rs:967 and 1432), consol.... (inline)
  3. Medium crates/xcl/src/hle/d3d12x/sparse.rs:4035: The swap from a system-memory tile to a video tile at a GPU-heap address only checks parked, so a SYS tile held in kept at that address is taken back as-is by .or_else(|| self.kept.remove(&t)). (inline)
  4. Medium crates/xcl/src/hle/d3d12x/sparse.rs:549: Not certain about this one: SYS_POOLS is a process-global static, but the video pools, the fence and the quarantine live in State, which sparse::init replaces, so the system-memory pools outlive the State whose tiles and fence values t.... (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6154498097 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#pullrequestreview-6154498097). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:39Z. **Review:** COMMENTED --- Review of `24a84ca3`: 4 finding(s) (4 medium), most severe first. 1. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:11598`: `LAZY` is (u32::MAX, u32::MAX), which has the SYS bit set. (inline) 2. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:3658`: Only the XCL_COHERENT_HEAPS=sparse heaps are marked hot, so every other GPU-critical sparse allocation goes to system memory under the flag: XMemAllocDefault graphics memory and MEM_GRAPHICS VirtualAlloc (kernelx.rs:967 and 1432), consol.... (inline) 3. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:4035`: The swap from a system-memory tile to a video tile at a GPU-heap address only checks `parked`, so a SYS tile held in `kept` at that address is taken back as-is by `.or_else(|| self.kept.remove(&t))`. (inline) 4. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:549`: Not certain about this one: SYS_POOLS is a process-global static, but the video pools, the fence and the quarantine live in State, which `sparse::init` replaces, so the system-memory pools outlive the State whose tiles and fence values t.... (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 16:03:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:03:46Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7351377634 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7351377634). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:03:46Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
ClosetPie107 commented 2026-12-02 17:13:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-12-02T17:13:21Z.


Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on 24a84ca

Merged onto main 5eaadb54 (clean merge) and compared with main run twice on the same machine.

Setup

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, 30 GiB RAM, CachyOS (kernel 7.3.7)
  • Wine 11.23 (system), stock vkd3d-proton v3.1-83-gcae8353ed and DXVK dxgi.dll from GE-Proton11-16, DXC 1.9.2609.5
  • Debug build, cross-compiled for x86_64-pc-windows-msvc with cargo-xwin; test binaries run under Wine

Tested: cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>

passed failed ignored
main 5eaadb54 2769 177 52
this PR merged 2771 179 52
  • Tests that fail with this PR and pass on main: none.
  • Tests this PR adds: 2 of 4 pass (the_title_gpu_heaps_are_hot_and_nothing_around_them, a_system_memory_heap_with_all_tiles_free_is_given_back).
    • a_lazy_tile_outside_the_gpu_heaps_gets_system_memory: fails with Invalid parameter (0x80070057), the #175 failure above, as main's tests of the same kind do here.
    • a_parked_system_memory_tile_gives_way_to_a_gpu_heap: fails with Invalid parameter (0x80070057), the #175 failure above, as main's tests of the same kind do here.
About the failures on main and the 31 skipped tests (same for every PR in this batch)
  • Most of main's 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (d3d12_command_list_Reset: Invalid command allocator), and later tests get E_INVALIDARG (0x80070057). Running vkd3d-proton master with its vtable check taken out, hle::d3d12x::sparse::tests goes from 106 passed / 38 failed to 144 / 0.
  • The 31 skipped tests make vkd3d-proton's dxil-spirv call std::terminate() (Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private), which kills the whole test binary. They are the split-wave64, dispatch-chain and bridged-mask GPU tests, gpu_compute_mode_dispatch_abi, gpu_compute_thread_limits_leave_the_lanes_past_them_out, the two gpu_mesh_mode_* tests, and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, plus serialize_root_signature_strips_console_flags_and_preserves_pc_flags, whose null descriptor vkd3d-proton dereferences. The dxil-spirv ones crash the same way with vkd3d-proton master (f8c1cae8, dxil-spirv 93ab44c5).
  • main was run twice: same counts, same failure set. SKIPPED lines (same as main): no heap windows (2), no D3D12 debug layer (2-3), driver cache control not implemented in vkd3d-proton (1).

Not tested: Windows, NVIDIA, a retail title / scripts/smoke.ps1, a review of the diff. This is a test report, not a merge-check.

AI use: omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with main, and drafted this report. The user asked for it to be posted.

<!-- greyfinch-sync:ivall/xcl:comment:7353066768 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7353066768). Originally posted by [ClosetPie107](https://github.com/ClosetPie107) on 2026-12-02T17:13:21Z. --- **Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on `24a84ca`** Merged onto `main` `5eaadb54` (clean merge) and compared with `main` run twice on the same machine. **Setup** - AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, 30 GiB RAM, CachyOS (kernel 7.3.7) - Wine 11.23 (system), stock vkd3d-proton `v3.1-83-gcae8353ed` and DXVK `dxgi.dll` from GE-Proton11-16, DXC 1.9.2609.5 - Debug build, cross-compiled for `x86_64-pc-windows-msvc` with `cargo-xwin`; test binaries run under Wine **Tested:** `cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>` | | passed | failed | ignored | |---|---|---|---| | `main` `5eaadb54` | 2769 | 177 | 52 | | this PR merged | 2771 | 179 | 52 | - **Tests that fail with this PR and pass on `main`:** none. - **Tests this PR adds:** 2 of 4 pass (`the_title_gpu_heaps_are_hot_and_nothing_around_them`, `a_system_memory_heap_with_all_tiles_free_is_given_back`). - `a_lazy_tile_outside_the_gpu_heaps_gets_system_memory`: fails with `Invalid parameter (0x80070057)`, the #175 failure above, as `main`'s tests of the same kind do here. - `a_parked_system_memory_tile_gives_way_to_a_gpu_heap`: fails with `Invalid parameter (0x80070057)`, the #175 failure above, as `main`'s tests of the same kind do here. <details><summary>About the failures on <code>main</code> and the 31 skipped tests (same for every PR in this batch)</summary> - Most of `main`'s 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (`d3d12_command_list_Reset: Invalid command allocator`), and later tests get `E_INVALIDARG` (`0x80070057`). Running vkd3d-proton master with its vtable check taken out, `hle::d3d12x::sparse::tests` goes from 106 passed / 38 failed to 144 / 0. - The 31 skipped tests make vkd3d-proton's dxil-spirv call `std::terminate()` (`Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private`), which kills the whole test binary. They are the split-wave64, dispatch-chain and bridged-mask GPU tests, `gpu_compute_mode_dispatch_abi`, `gpu_compute_thread_limits_leave_the_lanes_past_them_out`, the two `gpu_mesh_mode_*` tests, and `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back`, plus `serialize_root_signature_strips_console_flags_and_preserves_pc_flags`, whose null descriptor vkd3d-proton dereferences. The dxil-spirv ones crash the same way with vkd3d-proton master (`f8c1cae8`, dxil-spirv `93ab44c5`). - `main` was run twice: same counts, same failure set. `SKIPPED` lines (same as `main`): no heap windows (2), no D3D12 debug layer (2-3), driver cache control not implemented in vkd3d-proton (1). </details> **Not tested:** Windows, NVIDIA, a retail title / `scripts/smoke.ps1`, a review of the diff. This is a test report, not a `merge-check`. **AI use:** omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with `main`, and drafted this report. The user asked for it to be posted.
stijn-boer commented 2026-12-02 17:22:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T17:22:29Z.


merge-check
base: 5eaadb54c1
head: 24a84ca327
verdict: not yet: the workspace abort affected both trees. The mixed-range allocation concern remains, and retail heap release and frame performance were unverified on this head.

Windows / AMD RDNA4 (native D3D12) — workspace suite and sparse heap checks on 24a84ca

Clean merge onto main at 5eaadb54 (merge commit f882efbc75f69e7d01e9aff52d347240876622e4). git diff --check was clean.

Setup

  • AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332
  • Rust 1.100.0, debug builds, Agility SDK 1.620.2 with matching d3d12SDKLayers.dll, DXC 1.9.2609.5

Tested

cargo build --workspace passed. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101. The table reuses the recorded main run from the same commit, machine, SDK, and command.

Build Passed Failed Ignored SKIPPED notices
main 335 3 23 0
Merged PR 335 3 23 0

Counts are partial because two test processes aborted on each build.

  • Tests that failed on the PR and passed on main — none observed in the comparable results.
  • Tests added by the PR — 4 passed, 0 failed, 0 ignored, 0 skip notices with isolated libtest invocations using --exact --test-threads=1 --show-output. These cover hot heap classification, GPU readback from a system-backed lazy tile, replacing a parked system-backed tile with a video-memory tile, and releasing a fully free heap after cooling and fence completion.
  • Debug-layer coverage — both debug-layer E2E tests, including DRED, and uploads_start_from_each_subresources_state passed.
Shared failures and process aborts
  • fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs reported failures on both builds.
  • The library and gpu_compute_e2e test processes exited with 0xc0000409 on both builds.

Retail smoke

Ran scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary> with XCL_UMA_DRIVER=mixed for title hash 2c508222. The main row is from the prior run under that setup.

Build Exit Frames logged Device removals logged Peak commit
main 0xc0000409 None 0 1320 MB
Merged PR, switch unset 0xc0000409 None 0 1320 MB
Merged PR, XCL_SPARSE_SYSMEM=1 0xc0000409 None 0 1320 MB

The enabled run logged seven pool-allocation milestones, up to 256 MiB of system-memory pool heaps. It ended before retail heap reclamation could be measured.

Diff review

Read the full diff and confirmed the existing mixed-range concern in materialize. Once a tile increments left, later system-memory candidates also wait even if only video-memory allocation failed first. take_sys_tile can also retry a refused system-memory heap creation on the next eligible tile when the video-memory fallback succeeds. Neither failure path was exercised in this run.

Not tested

Tests after the aborts, retail pool reclamation, frame performance, and allocation behavior under forced VRAM pressure.

AI use

Codex (GPT-6) merged and built the PR, ran the tests and smoke checks, compared the results with the prior main run, reviewed the diff, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7353236074 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7353236074). Originally posted by [stijn-boer](https://github.com/stijn-boer) on 2026-12-02T17:22:29Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: 24a84ca327cdbed51c37f2622585b2ea89d77336 verdict: not yet: the workspace abort affected both trees. The mixed-range allocation concern remains, and retail heap release and frame performance were unverified on this head. **Windows / AMD RDNA4 (native D3D12) — workspace suite and sparse heap checks on `24a84ca`** Clean merge onto `main` at `5eaadb54` (merge commit `f882efbc75f69e7d01e9aff52d347240876622e4`). `git diff --check` was clean. **Setup** - AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332 - Rust 1.100.0, debug builds, Agility SDK 1.620.2 with matching `d3d12SDKLayers.dll`, DXC 1.9.2609.5 **Tested** `cargo build --workspace` passed. `cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output` exited 101. The table reuses the recorded `main` run from the same commit, machine, SDK, and command. | Build | Passed | Failed | Ignored | `SKIPPED` notices | |---|---:|---:|---:|---:| | `main` | 335 | 3 | 23 | 0 | | Merged PR | 335 | 3 | 23 | 0 | Counts are partial because two test processes aborted on each build. - **Tests that failed on the PR and passed on `main`** — none observed in the comparable results. - **Tests added by the PR** — 4 passed, 0 failed, 0 ignored, 0 skip notices with isolated libtest invocations using `--exact --test-threads=1 --show-output`. These cover hot heap classification, GPU readback from a system-backed lazy tile, replacing a parked system-backed tile with a video-memory tile, and releasing a fully free heap after cooling and fence completion. - **Debug-layer coverage** — both debug-layer E2E tests, including DRED, and `uploads_start_from_each_subresources_state` passed. <details><summary>Shared failures and process aborts</summary> - `fuzz_validate_and_gpu_1`, `fuzz_validate_and_gpu_3`, and `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` reported failures on both builds. - The library and `gpu_compute_e2e` test processes exited with `0xc0000409` on both builds. </details> **Retail smoke** Ran `scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>` with `XCL_UMA_DRIVER=mixed` for title hash `2c508222`. The `main` row is from the prior run under that setup. | Build | Exit | Frames logged | Device removals logged | Peak commit | |---|---|---|---:|---:| | `main` | `0xc0000409` | None | 0 | 1320 MB | | Merged PR, switch unset | `0xc0000409` | None | 0 | 1320 MB | | Merged PR, `XCL_SPARSE_SYSMEM=1` | `0xc0000409` | None | 0 | 1320 MB | The enabled run logged seven pool-allocation milestones, up to 256 MiB of system-memory pool heaps. It ended before retail heap reclamation could be measured. **Diff review** Read the full diff and confirmed the existing mixed-range concern in `materialize`. Once a tile increments `left`, later system-memory candidates also wait even if only video-memory allocation failed first. `take_sys_tile` can also retry a refused system-memory heap creation on the next eligible tile when the video-memory fallback succeeds. Neither failure path was exercised in this run. **Not tested** Tests after the aborts, retail pool reclamation, frame performance, and allocation behavior under forced VRAM pressure. **AI use** Codex (GPT-6) merged and built the PR, ran the tests and smoke checks, compared the results with the prior `main` run, reviewed the diff, and drafted this report.
UncommonDLL commented 2026-12-02 18:18:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by UncommonDLL on 2026-12-02T18:18:30Z.


Following up on the retry reported above, we tested 24a84ca327cdbed51c37f2622585b2ea89d77336 on an RTX 5070 Ti with NVIDIA driver 621.40. In one materialize call for two cold tiles, the test forced an out-of-memory response at the system-memory CreateHeap boundary. We counted two heap creation requests of 4 MiB each.

Video-memory fallback succeeded for both tiles, and each received a distinct slot. The only assertion that failed was the request count: expected one, observed two. This was a synthetic allocator test. No title was run.

<!-- greyfinch-sync:ivall/xcl:comment:7354338544 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7354338544). Originally posted by [UncommonDLL](https://github.com/UncommonDLL) on 2026-12-02T18:18:30Z. --- Following up on the retry reported above, we tested `24a84ca327cdbed51c37f2622585b2ea89d77336` on an RTX 5070 Ti with NVIDIA driver `621.40`. In one `materialize` call for two cold tiles, the test forced an out-of-memory response at the system-memory `CreateHeap` boundary. We counted two heap creation requests of 4 MiB each. Video-memory fallback succeeded for both tiles, and each received a distinct slot. The only assertion that failed was the request count: expected one, observed two. This was a synthetic allocator test. No title was run.
UncommonDLL commented 2026-12-02 18:25:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by UncommonDLL on 2026-12-02T18:25:37Z.


On 24a84ca3, I tested the repeated L0 heap request after successful video fallback. The fixture injected E_OUTOFMEMORY at the 4 MiB system-memory CreateHeap boundary. Video fallback and tile placement used native D3D12 on an RTX 5070 Ti, driver 621.40.

For two consecutive cold LAZY tiles in one materialize call, the baseline made two refused requests. The candidate made one. The unchanged regression observed the same two successful DEFAULT placements in both runs: heap 0, slots 1 and 2. A second call on the same allocator made a fresh L0 request and placed a third tile in slot 3.

The candidate checks reusable tiles and retired system heaps before suppressing another creation attempt. The refusal expires when materialize returns. The sparse module finished with 146 passed, 0 failed, 1 ignored (early_commit_timing), and 0 runtime skips. OpenAI Codex implemented the candidate and ran the synthetic tests.

The production patch applies independently to 24a84ca327cdbed51c37f2622585b2ea89d77336. To reproduce the tested source, apply the original regression, production change, and call-boundary test in that order.

1. Original regression
diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index f31636e5e4edacbadb0f00646fa79aade29aca6f..6654aa545fa3658f3f5da5cdf47b464369c74e41 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -3615,7 +3615,12 @@ impl State {
     /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`).
     unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> {
         self.drain_quarantined();
-        let mut g = SYS_POOLS.lock().unwrap();
+        let pools = &SYS_POOLS;
+        #[cfg(test)]
+        let refusal = tests::SYS_HEAP_REFUSAL.with_borrow(Clone::clone);
+        #[cfg(test)]
+        let pools = refusal.as_ref().map_or(pools, |r| &r.pools);
+        let mut g = pools.lock().unwrap();
         let p = g.get_or_insert_with(SysPools::default);
         if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) {
             return Some(((SYS | h, t), true));
@@ -3637,7 +3642,14 @@ impl State {
             Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES,
         };
         let mut heap: Option<ID3D12Heap> = None;
-        if let Err(e) = super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) {
+        if let Err(e) = super::title_textures::own_work(|| {
+            #[cfg(test)]
+            if let Some(r) = &refusal {
+                r.requests.borrow_mut().push(desc.SizeInBytes);
+                return Err(windows::Win32::Foundation::E_OUTOFMEMORY.into());
+            }
+            self.dev.CreateHeap(&desc, &mut heap)
+        }) {
             crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead");
             drop(g);
             return self.take_tile();
@@ -8650,7 +8662,16 @@ fn forget_in(s: &mut State, res: usize) {
 mod tests {
     use super::*;
 
+    #[derive(Default)]
+    pub(super) struct SysHeapRefusal {
+        // Start empty even when another test has reusable system-memory tiles.
+        pub(super) pools: Mutex<Option<SysPools>>,
+        pub(super) requests: std::cell::RefCell<Vec<u64>>,
+    }
+
     thread_local! {
+        pub(super) static SYS_HEAP_REFUSAL: std::cell::RefCell<Option<std::rc::Rc<SysHeapRefusal>>> =
+            const { std::cell::RefCell::new(None) };
         /// The VirtualQuery calls `source_holes` made on this thread.
         pub(super) static VIRTUAL_QUERIES: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
         /// Run by `take_asks` on this thread between the look up of the asked tiles' pairs and
@@ -11500,6 +11521,7 @@ mod tests {
             LAZY_COMMITS_FOR_TEST.with(|c| c.set(None));
             NO_TILES.with(|c| c.set(false));
             SYSMEM_FOR_TEST.with(|c| c.set(false));
+            SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = None);
         }
     }
 
@@ -11578,6 +11600,42 @@ mod tests {
         drop(lazy);
     }
 
+    #[test]
+    fn one_materialize_call_only_requests_a_refused_system_heap_once() {
+        let lazy = Lazy::on(true);
+        lazy.sysmem(true);
+        unsafe {
+            let Some((base, mut s, _queue)) = lazy_state(2) else {
+                return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2");
+            };
+            let tiles = [base, base + TILE];
+            s.commit_range(base, tiles.len() * TILE);
+            assert!(tiles.iter().all(|t| s.mapped[t].pool == LAZY && !is_hot(*t)));
+
+            let ((video_heap, _), _) = s.take_tile().expect("seed the video fallback heap");
+            assert!(s.free.heap_len(video_heap as usize) >= tiles.len());
+            let heap = s.pools[video_heap as usize].as_ref().expect("live video heap");
+            assert_eq!(heap.GetDesc().Properties.Type, D3D12_HEAP_TYPE_DEFAULT);
+
+            let refusal = std::rc::Rc::new(SysHeapRefusal::default());
+            SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = Some(refusal.clone()));
+            let (got, left) = s.materialize(base, tiles.len() * TILE, false, &mut Vec::new());
+            let backing = tiles.map(|t| s.mapped[&t].pool);
+            let requests = refusal.requests.borrow();
+            let luid = s.dev.GetAdapterLuid();
+            eprintln!("L0 fallback: requested_bytes={requests:?} attempts={} materialized={got} left={left} \
+                       video_heap={video_heap} tile_backing={backing:?} adapter_luid={:08x}:{:08x}",
+                      requests.len(), luid.HighPart as u32, luid.LowPart);
+            drop(s);
+            assert_ne!(VirtualFree(base as *mut c_void, 0, windows_sys::Win32::System::Memory::MEM_RELEASE), 0);
+            assert_eq!((got, left), (tiles.len(), 0));
+            assert!(backing.iter().all(|&(h, t)| h == video_heap && t < POOL_TILES));
+            assert_ne!(backing[0], backing[1], "the tiles need distinct video backing");
+            assert!(requests.iter().all(|&bytes| bytes == POOL_TILES as u64 * TILE as u64));
+            assert_eq!(requests.len(), 1, "retry the refused system heap only on a later call");
+        }
+    }
+
     /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the
     /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU.
     #[test]
2. Production change
diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index f31636e5e4edacbadb0f00646fa79aade29aca6f..693f60d3aab1cd83f495a0137eea3db91e3e69e3 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -3615,3 +3615,3 @@ impl State {
     /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`).
-    unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> {
+    unsafe fn take_sys_tile(&mut self, sys_heap_refused: &mut bool) -> Option<((u32, u32), bool)> {
         self.drain_quarantined();
@@ -3627,2 +3627,7 @@ impl State {
         }
+        // Reuse is still possible after a new heap was refused in this call.
+        if *sys_heap_refused {
+            drop(g);
+            return self.take_tile();
+        }
         let desc = D3D12_HEAP_DESC {
@@ -3641,2 +3646,3 @@ impl State {
             crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead");
+            *sys_heap_refused = true;
             drop(g);
@@ -3656,4 +3662,4 @@ impl State {
     /// unless `t` is in a GPU heap of the title.
-    unsafe fn take_tile_for(&mut self, t: usize) -> Option<((u32, u32), bool)> {
-        if sysmem_tiles() && !is_hot(t) { self.take_sys_tile() } else { self.take_tile() }
+    unsafe fn take_tile_for(&mut self, t: usize, sys_heap_refused: &mut bool) -> Option<((u32, u32), bool)> {
+        if sysmem_tiles() && !is_hot(t) { self.take_sys_tile(sys_heap_refused) } else { self.take_tile() }
     }
@@ -3972,2 +3978,3 @@ impl State {
         let (mut got, mut left) = (0, 0);
+        let mut sys_heap_refused = false;
         while t < end {
@@ -3978,3 +3985,3 @@ impl State {
                 let wait = left > 0 || (!force && !sys && self.short_of_memory() && !at_hand);
-                match if wait { None } else { self.take_tile_for(t) } {
+                match if wait { None } else { self.take_tile_for(t, &mut sys_heap_refused) } {
                     Some((tile, used)) => {
@@ -4057,3 +4064,4 @@ impl State {
                 } else {
-                    let Some((tile, reused)) = self.take_tile_for(t) else { break };
+                    let mut sys_heap_refused = false;
+                    let Some((tile, reused)) = self.take_tile_for(t, &mut sys_heap_refused) else { break };
                     let (holes, not_rw) = initial_state(t);
3. Call-boundary test
diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index 9265f14275502aaf9d0f60389b879be2097aae9f..fecbd6ea7d7099039f86368185ca2adeec8ef5be 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -11644,6 +11644,56 @@ mod tests {
         }
     }
 
+    #[test]
+    fn refused_system_heap_is_retried_on_the_next_materialize_call() {
+        let lazy = Lazy::on(true);
+        lazy.sysmem(true);
+        unsafe {
+            let Some((base, mut s, _queue)) = lazy_state(3) else {
+                return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2");
+            };
+            let tiles = [base, base + TILE, base + 2 * TILE];
+            s.commit_range(base, 2 * TILE);
+            assert!(tiles[..2].iter().all(|t| s.mapped[t].pool == LAZY && !is_hot(*t)));
+
+            let ((video_heap, _), _) = s.take_tile().expect("seed the video fallback heap");
+            assert!(s.free.heap_len(video_heap as usize) >= tiles.len());
+            let heap = s.pools[video_heap as usize].as_ref().expect("live video heap");
+            assert_eq!(heap.GetDesc().Properties.Type, D3D12_HEAP_TYPE_DEFAULT);
+
+            let refusal = std::rc::Rc::new(SysHeapRefusal::default());
+            SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = Some(refusal.clone()));
+            let first = s.materialize(base, 2 * TILE, false, &mut Vec::new());
+            let first_attempts = refusal.requests.borrow().len();
+
+            let fresh = tiles[2];
+            s.commit_range(fresh, TILE);
+            assert!(s.mapped[&fresh].pool == LAZY && !is_hot(fresh));
+            {
+                let pools = refusal.pools.lock().unwrap();
+                let pools = pools.as_ref().expect("first call checked the system pools");
+                assert!(pools.heaps.is_empty() && pools.free.is_empty()
+                    && pools.cooling.is_empty() && pools.retired.is_empty());
+            }
+            let second = s.materialize(fresh, TILE, false, &mut Vec::new());
+            let backing = tiles.map(|t| s.mapped[&t].pool);
+            let requests = refusal.requests.borrow();
+            let luid = s.dev.GetAdapterLuid();
+            eprintln!("L0 call boundary: first_attempts={first_attempts} total_attempts={} requested_bytes={requests:?} \
+                       first={first:?} second={second:?} video_heap={video_heap} tile_backing={backing:?} \
+                       adapter_luid={:08x}:{:08x}", requests.len(), luid.HighPart as u32, luid.LowPart);
+            drop(s);
+            assert_ne!(VirtualFree(base as *mut c_void, 0, windows_sys::Win32::System::Memory::MEM_RELEASE), 0);
+            assert_eq!(first, (2, 0));
+            assert_eq!(second, (1, 0));
+            assert!(backing.iter().all(|&(h, t)| h == video_heap && t < POOL_TILES));
+            assert!(backing[0] != backing[1] && !backing[..2].contains(&backing[2]));
+            assert_eq!(first_attempts, 1);
+            let heap_bytes = POOL_TILES as u64 * TILE as u64;
+            assert_eq!(requests.as_slice(), &[heap_bytes, heap_bytes]);
+        }
+    }
+
     /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the
     /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU.
     #[test]
<!-- greyfinch-sync:ivall/xcl:comment:7354563042 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7354563042). Originally posted by [UncommonDLL](https://github.com/UncommonDLL) on 2026-12-02T18:25:37Z. --- On `24a84ca3`, I tested the repeated L0 heap request after successful video fallback. The fixture injected `E_OUTOFMEMORY` at the 4 MiB system-memory `CreateHeap` boundary. Video fallback and tile placement used native D3D12 on an RTX 5070 Ti, driver 621.40. For two consecutive cold `LAZY` tiles in one `materialize` call, the baseline made two refused requests. The candidate made one. The unchanged regression observed the same two successful DEFAULT placements in both runs: heap 0, slots 1 and 2. A second call on the same allocator made a fresh L0 request and placed a third tile in slot 3. The candidate checks reusable tiles and retired system heaps before suppressing another creation attempt. The refusal expires when `materialize` returns. The sparse module finished with 146 passed, 0 failed, 1 ignored (`early_commit_timing`), and 0 runtime skips. OpenAI Codex implemented the candidate and ran the synthetic tests. The production patch applies independently to `24a84ca327cdbed51c37f2622585b2ea89d77336`. To reproduce the tested source, apply the original regression, production change, and call-boundary test in that order. <details> <summary>1. Original regression</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index f31636e5e4edacbadb0f00646fa79aade29aca6f..6654aa545fa3658f3f5da5cdf47b464369c74e41 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -3615,7 +3615,12 @@ impl State { /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`). unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> { self.drain_quarantined(); - let mut g = SYS_POOLS.lock().unwrap(); + let pools = &SYS_POOLS; + #[cfg(test)] + let refusal = tests::SYS_HEAP_REFUSAL.with_borrow(Clone::clone); + #[cfg(test)] + let pools = refusal.as_ref().map_or(pools, |r| &r.pools); + let mut g = pools.lock().unwrap(); let p = g.get_or_insert_with(SysPools::default); if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) { return Some(((SYS | h, t), true)); @@ -3637,7 +3642,14 @@ impl State { Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES, }; let mut heap: Option<ID3D12Heap> = None; - if let Err(e) = super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) { + if let Err(e) = super::title_textures::own_work(|| { + #[cfg(test)] + if let Some(r) = &refusal { + r.requests.borrow_mut().push(desc.SizeInBytes); + return Err(windows::Win32::Foundation::E_OUTOFMEMORY.into()); + } + self.dev.CreateHeap(&desc, &mut heap) + }) { crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead"); drop(g); return self.take_tile(); @@ -8650,7 +8662,16 @@ fn forget_in(s: &mut State, res: usize) { mod tests { use super::*; + #[derive(Default)] + pub(super) struct SysHeapRefusal { + // Start empty even when another test has reusable system-memory tiles. + pub(super) pools: Mutex<Option<SysPools>>, + pub(super) requests: std::cell::RefCell<Vec<u64>>, + } + thread_local! { + pub(super) static SYS_HEAP_REFUSAL: std::cell::RefCell<Option<std::rc::Rc<SysHeapRefusal>>> = + const { std::cell::RefCell::new(None) }; /// The VirtualQuery calls `source_holes` made on this thread. pub(super) static VIRTUAL_QUERIES: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; /// Run by `take_asks` on this thread between the look up of the asked tiles' pairs and @@ -11500,6 +11521,7 @@ mod tests { LAZY_COMMITS_FOR_TEST.with(|c| c.set(None)); NO_TILES.with(|c| c.set(false)); SYSMEM_FOR_TEST.with(|c| c.set(false)); + SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = None); } } @@ -11578,6 +11600,42 @@ mod tests { drop(lazy); } + #[test] + fn one_materialize_call_only_requests_a_refused_system_heap_once() { + let lazy = Lazy::on(true); + lazy.sysmem(true); + unsafe { + let Some((base, mut s, _queue)) = lazy_state(2) else { + return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2"); + }; + let tiles = [base, base + TILE]; + s.commit_range(base, tiles.len() * TILE); + assert!(tiles.iter().all(|t| s.mapped[t].pool == LAZY && !is_hot(*t))); + + let ((video_heap, _), _) = s.take_tile().expect("seed the video fallback heap"); + assert!(s.free.heap_len(video_heap as usize) >= tiles.len()); + let heap = s.pools[video_heap as usize].as_ref().expect("live video heap"); + assert_eq!(heap.GetDesc().Properties.Type, D3D12_HEAP_TYPE_DEFAULT); + + let refusal = std::rc::Rc::new(SysHeapRefusal::default()); + SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = Some(refusal.clone())); + let (got, left) = s.materialize(base, tiles.len() * TILE, false, &mut Vec::new()); + let backing = tiles.map(|t| s.mapped[&t].pool); + let requests = refusal.requests.borrow(); + let luid = s.dev.GetAdapterLuid(); + eprintln!("L0 fallback: requested_bytes={requests:?} attempts={} materialized={got} left={left} \ + video_heap={video_heap} tile_backing={backing:?} adapter_luid={:08x}:{:08x}", + requests.len(), luid.HighPart as u32, luid.LowPart); + drop(s); + assert_ne!(VirtualFree(base as *mut c_void, 0, windows_sys::Win32::System::Memory::MEM_RELEASE), 0); + assert_eq!((got, left), (tiles.len(), 0)); + assert!(backing.iter().all(|&(h, t)| h == video_heap && t < POOL_TILES)); + assert_ne!(backing[0], backing[1], "the tiles need distinct video backing"); + assert!(requests.iter().all(|&bytes| bytes == POOL_TILES as u64 * TILE as u64)); + assert_eq!(requests.len(), 1, "retry the refused system heap only on a later call"); + } + } + /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU. #[test] ``` </details> <details> <summary>2. Production change</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index f31636e5e4edacbadb0f00646fa79aade29aca6f..693f60d3aab1cd83f495a0137eea3db91e3e69e3 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -3615,3 +3615,3 @@ impl State { /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`). - unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> { + unsafe fn take_sys_tile(&mut self, sys_heap_refused: &mut bool) -> Option<((u32, u32), bool)> { self.drain_quarantined(); @@ -3627,2 +3627,7 @@ impl State { } + // Reuse is still possible after a new heap was refused in this call. + if *sys_heap_refused { + drop(g); + return self.take_tile(); + } let desc = D3D12_HEAP_DESC { @@ -3641,2 +3646,3 @@ impl State { crate::xlog_warn!("sparse windows: no system-memory pool heap ({e}) - video memory instead"); + *sys_heap_refused = true; drop(g); @@ -3656,4 +3662,4 @@ impl State { /// unless `t` is in a GPU heap of the title. - unsafe fn take_tile_for(&mut self, t: usize) -> Option<((u32, u32), bool)> { - if sysmem_tiles() && !is_hot(t) { self.take_sys_tile() } else { self.take_tile() } + unsafe fn take_tile_for(&mut self, t: usize, sys_heap_refused: &mut bool) -> Option<((u32, u32), bool)> { + if sysmem_tiles() && !is_hot(t) { self.take_sys_tile(sys_heap_refused) } else { self.take_tile() } } @@ -3972,2 +3978,3 @@ impl State { let (mut got, mut left) = (0, 0); + let mut sys_heap_refused = false; while t < end { @@ -3978,3 +3985,3 @@ impl State { let wait = left > 0 || (!force && !sys && self.short_of_memory() && !at_hand); - match if wait { None } else { self.take_tile_for(t) } { + match if wait { None } else { self.take_tile_for(t, &mut sys_heap_refused) } { Some((tile, used)) => { @@ -4057,3 +4064,4 @@ impl State { } else { - let Some((tile, reused)) = self.take_tile_for(t) else { break }; + let mut sys_heap_refused = false; + let Some((tile, reused)) = self.take_tile_for(t, &mut sys_heap_refused) else { break }; let (holes, not_rw) = initial_state(t); ``` </details> <details> <summary>3. Call-boundary test</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index 9265f14275502aaf9d0f60389b879be2097aae9f..fecbd6ea7d7099039f86368185ca2adeec8ef5be 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -11644,6 +11644,56 @@ mod tests { } } + #[test] + fn refused_system_heap_is_retried_on_the_next_materialize_call() { + let lazy = Lazy::on(true); + lazy.sysmem(true); + unsafe { + let Some((base, mut s, _queue)) = lazy_state(3) else { + return crate::gpu::recomp::runner::skip_test("no GPU with tiled resources tier 2"); + }; + let tiles = [base, base + TILE, base + 2 * TILE]; + s.commit_range(base, 2 * TILE); + assert!(tiles[..2].iter().all(|t| s.mapped[t].pool == LAZY && !is_hot(*t))); + + let ((video_heap, _), _) = s.take_tile().expect("seed the video fallback heap"); + assert!(s.free.heap_len(video_heap as usize) >= tiles.len()); + let heap = s.pools[video_heap as usize].as_ref().expect("live video heap"); + assert_eq!(heap.GetDesc().Properties.Type, D3D12_HEAP_TYPE_DEFAULT); + + let refusal = std::rc::Rc::new(SysHeapRefusal::default()); + SYS_HEAP_REFUSAL.with_borrow_mut(|r| *r = Some(refusal.clone())); + let first = s.materialize(base, 2 * TILE, false, &mut Vec::new()); + let first_attempts = refusal.requests.borrow().len(); + + let fresh = tiles[2]; + s.commit_range(fresh, TILE); + assert!(s.mapped[&fresh].pool == LAZY && !is_hot(fresh)); + { + let pools = refusal.pools.lock().unwrap(); + let pools = pools.as_ref().expect("first call checked the system pools"); + assert!(pools.heaps.is_empty() && pools.free.is_empty() + && pools.cooling.is_empty() && pools.retired.is_empty()); + } + let second = s.materialize(fresh, TILE, false, &mut Vec::new()); + let backing = tiles.map(|t| s.mapped[&t].pool); + let requests = refusal.requests.borrow(); + let luid = s.dev.GetAdapterLuid(); + eprintln!("L0 call boundary: first_attempts={first_attempts} total_attempts={} requested_bytes={requests:?} \ + first={first:?} second={second:?} video_heap={video_heap} tile_backing={backing:?} \ + adapter_luid={:08x}:{:08x}", requests.len(), luid.HighPart as u32, luid.LowPart); + drop(s); + assert_ne!(VirtualFree(base as *mut c_void, 0, windows_sys::Win32::System::Memory::MEM_RELEASE), 0); + assert_eq!(first, (2, 0)); + assert_eq!(second, (1, 0)); + assert!(backing.iter().all(|&(h, t)| h == video_heap && t < POOL_TILES)); + assert!(backing[0] != backing[1] && !backing[..2].contains(&backing[2])); + assert_eq!(first_attempts, 1); + let heap_bytes = POOL_TILES as u64 * TILE as u64; + assert_eq!(requests.as_slice(), &[heap_bytes, heap_bytes]); + } + } + /// Under `XCL_SPARSE_SYSMEM` a lazy tile outside the title's GPU heaps gets its memory from the /// system-memory pools at its first bytes, as an eager one does, and the bytes reach the GPU. #[test] ``` </details>
throny commented 2026-12-02 21:25:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T21:25:49Z.


Rebased onto main 5ad98adb and fixed the two open points; new head 84646d4d. Both fixes are folded into the first commit (the one that adds the system-memory tiles). The second commit is still only the heap retirement.

(1) Cold tiles skipped after one tile finds no video memory. materialize (sparse.rs:4004) used to wait on left > 0. Now it keeps one "found nothing" flag per kind of memory (no_video, no_sys), so when a GPU heap's tile finds no video memory, the cold tiles after it in the same run still go to the system-memory pools. The short_of_memory wait still applies only to video-memory tiles. Test: a_gpu_heap_tile_without_video_memory_leaves_the_next_cold_tile_its_system_memory (sparse.rs:11694). It sets up a hot tile with no video memory (NO_TILES) next to a cold tile in one upload, checks that the cold tile gets a SYS tile, and reads its bytes back from the GPU. It fails without the fix.

(2) A refused system-memory heap is retried for every cold tile. take_sys_tile now records the time of a failed CreateHeap in State::sys_refused (sparse.rs:3669). For 1 s after that, cold tiles reuse free or retired system-memory tiles first and otherwise take video memory without asking for a new heap (sparse.rs:3646). This is the same 1 s wait no_memory uses for video memory. Test: a_refused_system_memory_heap_is_not_asked_for_at_each_tile (sparse.rs:11724). A test-only switch (NO_SYS_HEAP, sparse.rs:580) makes the pools refuse. The test maps 3 cold tiles and checks for 1 heap request (it was 3 without the fix), then 2 requests once a second has passed.

(3) "Workspace suite aborted on both builds." I don't think this PR causes it. The report's own table shows the same abort (0xc0000409) in the lib and gpu_compute_e2e processes on main, with the same counts. The PR doesn't touch gpu_compute_e2e. Every GPU test this PR adds calls skip_test when the adapter can't run it, and none of them sets anything up that could bring the process down rather than fail the test.

Tested at 84646d4d (RTX 4080, Windows 11 26300, debug; a game run was using the GPU at the same time): cargo build --workspace -> ok. cargo test -p xcl --lib sparse -- --test-threads=1 -> 164 passed, 0 failed, 1 ignored, 0 SKIPPED. With 4 threads: 164 passed, 0 failed, 1 ignored. Some GPU tests printed SKIPPED (no tiled resources tier 2) with 4 threads, and the PR head without these fixes did the same while the game run was going. With the two fixes undone, the two new tests failed (0 passed, 2 failed).

Still open: showing the 3.8 GB coming back in a title run (finding 4). We will measure it.

The memory coming back, measured at 84646d4d: two 900 s warm runs. Peak video memory 18,948 MB with XCL_SPARSE_SYSMEM off and 15,737 MB with it on (−3.2 GB, now at the 15.2 GB budget). 3.13 vs 3.01 presents/s (−4 %). No device removal or crash in either. The whole suite: 3011 passed, 0 failed. Smoke blocks are in the description.

@Foniass @stijn-boer could you re-check 84646d4d? An AMD check would help too (gpu:both).

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7359268545 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7359268545). Originally posted by [throny](https://github.com/throny) on 2026-12-02T21:25:49Z. --- Rebased onto main `5ad98adb` and fixed the two open points; new head `84646d4d`. Both fixes are folded into the first commit (the one that adds the system-memory tiles). The second commit is still only the heap retirement. **(1) Cold tiles skipped after one tile finds no video memory.** `materialize` (`sparse.rs:4004`) used to wait on `left > 0`. Now it keeps one "found nothing" flag per kind of memory (`no_video`, `no_sys`), so when a GPU heap's tile finds no video memory, the cold tiles after it in the same run still go to the system-memory pools. The `short_of_memory` wait still applies only to video-memory tiles. Test: `a_gpu_heap_tile_without_video_memory_leaves_the_next_cold_tile_its_system_memory` (`sparse.rs:11694`). It sets up a hot tile with no video memory (`NO_TILES`) next to a cold tile in one upload, checks that the cold tile gets a `SYS` tile, and reads its bytes back from the GPU. It fails without the fix. **(2) A refused system-memory heap is retried for every cold tile.** `take_sys_tile` now records the time of a failed `CreateHeap` in `State::sys_refused` (`sparse.rs:3669`). For 1 s after that, cold tiles reuse free or retired system-memory tiles first and otherwise take video memory without asking for a new heap (`sparse.rs:3646`). This is the same 1 s wait `no_memory` uses for video memory. Test: `a_refused_system_memory_heap_is_not_asked_for_at_each_tile` (`sparse.rs:11724`). A test-only switch (`NO_SYS_HEAP`, `sparse.rs:580`) makes the pools refuse. The test maps 3 cold tiles and checks for 1 heap request (it was 3 without the fix), then 2 requests once a second has passed. **(3) "Workspace suite aborted on both builds."** I don't think this PR causes it. The report's own table shows the same abort (`0xc0000409`) in the lib and `gpu_compute_e2e` processes on `main`, with the same counts. The PR doesn't touch `gpu_compute_e2e`. Every GPU test this PR adds calls `skip_test` when the adapter can't run it, and none of them sets anything up that could bring the process down rather than fail the test. Tested at `84646d4d` (RTX 4080, Windows 11 26300, debug; a game run was using the GPU at the same time): `cargo build --workspace` -> ok. `cargo test -p xcl --lib sparse -- --test-threads=1` -> 164 passed, 0 failed, 1 ignored, 0 SKIPPED. With 4 threads: 164 passed, 0 failed, 1 ignored. Some GPU tests printed `SKIPPED` (no tiled resources tier 2) with 4 threads, and the PR head without these fixes did the same while the game run was going. With the two fixes undone, the two new tests failed (0 passed, 2 failed). Still open: showing the 3.8 GB coming back in a title run (finding 4). We will measure it. **The memory coming back, measured at `84646d4d`:** two 900 s warm runs. Peak video memory 18,948 MB with `XCL_SPARSE_SYSMEM` off and 15,737 MB with it on (−3.2 GB, now at the 15.2 GB budget). 3.13 vs 3.01 presents/s (−4 %). No device removal or crash in either. The whole suite: 3011 passed, 0 failed. Smoke blocks are in the description. @Foniass @stijn-boer could you re-check `84646d4d`? An AMD check would help too (`gpu:both`). *AI use: Claude Code (Claude Opus 5.5).*
stijn-boer commented 2026-12-02 21:44:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T21:44:38Z.


merge-check
base: 5ad98adbc3
head: 84646d4de8
verdict: not yet: all six focused tests passed and the workspace abort affected both trees. Enabling sparse system memory moved frames and peak commit in opposite directions between the two tested stacks. On this head, retail heap release and repeatable performance remained unverified.

Windows / AMD RDNA4 — sparse system-memory heaps on 84646d4

Follow-up for the later #3613 head. I applied #3707 at 912ff558e932264511f386eb8b7e97cbf7cf46e2 to both test builds so the comparison isolates #3613 on top of that patch. Both local merges were clean and git diff --check passed. The baseline was main + #3707 at 3a6d3b1206e84742d369309a7ca50651e1b42b59. The comparison build was #3613 + #3707 at 56396bfec31a746d8cf4c66348a47628bfa09eff. Each build used a separate Cargo target directory for the reported runs.

Setup

AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332, Rust 1.100.0 debug, Agility SDK 1.620.2 with matching debug layer, DXC 1.9.2609.5.

Tested

cargo build --workspace passed on both builds. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101 on both.

Build Passed Failed Ignored SKIPPED notices
main + #3707 1584 9 47 2
#3613 + #3707 1584 9 47 2

Counts are partial because the library process exited with 0x80004005 on both builds. No additional named failure appeared in the comparison. Both debug-layer E2E tests, including DRED, and the texture-state test passed on both.

Focused sparse tests — 6 passed, 0 failed, 0 ignored, 0 skip notices with isolated libtest invocations using --exact --test-threads=1 --show-output --nocapture. Both new regression tests passed. A hot tile that runs out of video memory leaves the following cold tile eligible for system memory, and a refused system-memory heap is not requested again for each successive tile. The heap-retirement test also passed.

Shared failures and skips
  • Both builds reported failures in fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, gpu_smem_flat_descriptor_windows_and_limits, f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random, and gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends. two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs reported two failures on each build.
  • The two skip notices were for two_pass_binds_set_the_shared_view_heap and heap_window_out_of_memory_falls_back_to_the_switch_form with heap windows disabled.

Retail smoke

Ran scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary> with XCL_UMA_DRIVER=mixed and a fresh data root for each run. Title hash 2c508222.

Build XCL_SPARSE_SYSMEM Exit Frames Peak commit
main + #3707 Unset 0x0 1341 11611 MB
#3613 + #3707 Unset 0x0 1202 15501 MB
#3613 + #3707 1 0x0 1035 15922 MB

All three runs logged zero device removals and zero crashes. The enabled run logged system-memory pool allocation milestones up to 512 MiB. On the same build, enabling the flag corresponded to about 14% fewer frames and 421 MB more peak process commit in this pair. One run per setting leaves repeatability and the cause open. The allocation milestones do not measure subsequent heap release or net VRAM savings.

Merge request

Could maintainers prioritize merging #3707 and #3455 once their required checks pass? In this retest, plain main exited before logging frames and the builds with #3707 completed the smoke run. The request for #3455 is based on the AMD tester’s separate experience of a substantial improvement on AMD cards.

Not tested

A standalone #3613 retail run, retail heap reclamation and net VRAM savings, repeated performance pairs, and #3455 in this test configuration.

AI use

Codex (GPT-6) prepared the two local builds, ran the tests and smoke comparisons, reviewed the changed allocation paths, and drafted this report.

Follow-up with #3455 added to both builds

Same #3613 head, 84646d4de8e5655c32a1a9b20e9b0d987adb4da1, and same main base, 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd. Both local builds included #3707 at 912ff558e932264511f386eb8b7e97cbf7cf46e2 and #3455 at 1895d9e8ea3c64f7e91f4a0211f2a7aacff5c525. The resulting baseline was cfdacf961cf9cced7aba34f4f11e6219ce55df2d and the #3613 build was 5b9a3ea398a8c62fc9de5659d0c113a08b922ab5. Both merges were clean. Separate Cargo target directories were used.

Tested

cargo build --workspace passed on both. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101 on both.

Build Passed Failed Ignored SKIPPED notices
main + #3707 + #3455 1585 9 47 2
#3613 + #3707 + #3455 1585 9 47 2

The library exited 0x80004005 on both builds. These counts are partial. Both had the same named failures and skip notices listed in the earlier run above. Both debug-layer E2E tests and the texture-state check passed. All six focused sparse tests passed again in isolated libtest runs with --exact --test-threads=1 --show-output --nocapture, with zero skips.

Retail smoke

Same AMD host, title hash 2c508222, and 60-second scripts/smoke.ps1 runs with XCL_UMA_DRIVER=mixed. Each run used a fresh data root.

Build XCL_SPARSE_SYSMEM Exit Frames Peak commit
main + #3707 + #3455 Unset 0x0 1050 15709 MB
#3613 + #3707 + #3455 Unset 0x0 1086 15916 MB
#3613 + #3707 + #3455 1 0x0 1333 11003 MB

All three runs logged zero device removals and zero crashes. With both companion PRs included, enabling the switch corresponded to about 23% more frames and 31% lower peak process commit versus leaving it unset on the same build. The enabled run again logged a 512 MiB system-memory pool allocation milestone. This single pair reversed the earlier switch comparison. An isolated #3455 effect, repeatability, retail heap release, and net VRAM savings remain unverified.

Follow-up verdict — not yet. The combined smoke runs completed and the focused checks passed. Both full workspace runs still aborted.

<!-- greyfinch-sync:ivall/xcl:comment:7359717781 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7359717781). Originally posted by [stijn-boer](https://github.com/stijn-boer) on 2026-12-02T21:44:38Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd head: 84646d4de8e5655c32a1a9b20e9b0d987adb4da1 verdict: not yet: all six focused tests passed and the workspace abort affected both trees. Enabling sparse system memory moved frames and peak commit in opposite directions between the two tested stacks. On this head, retail heap release and repeatable performance remained unverified. **Windows / AMD RDNA4 — sparse system-memory heaps on `84646d4`** Follow-up for the later #3613 head. I applied **#3707 at `912ff558e932264511f386eb8b7e97cbf7cf46e2` to both test builds** so the comparison isolates #3613 on top of that patch. Both local merges were clean and `git diff --check` passed. The baseline was `main` + #3707 at `3a6d3b1206e84742d369309a7ca50651e1b42b59`. The comparison build was #3613 + #3707 at `56396bfec31a746d8cf4c66348a47628bfa09eff`. Each build used a separate Cargo target directory for the reported runs. **Setup** AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332, Rust 1.100.0 debug, Agility SDK 1.620.2 with matching debug layer, DXC 1.9.2609.5. **Tested** `cargo build --workspace` passed on both builds. `cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output` exited 101 on both. | Build | Passed | Failed | Ignored | `SKIPPED` notices | |---|---:|---:|---:|---:| | `main` + #3707 | 1584 | 9 | 47 | 2 | | #3613 + #3707 | 1584 | 9 | 47 | 2 | Counts are partial because the library process exited with `0x80004005` on both builds. No additional named failure appeared in the comparison. Both debug-layer E2E tests, including DRED, and the texture-state test passed on both. **Focused sparse tests** — 6 passed, 0 failed, 0 ignored, 0 skip notices with isolated libtest invocations using `--exact --test-threads=1 --show-output --nocapture`. Both new regression tests passed. A hot tile that runs out of video memory leaves the following cold tile eligible for system memory, and a refused system-memory heap is not requested again for each successive tile. The heap-retirement test also passed. <details><summary>Shared failures and skips</summary> - Both builds reported failures in `fuzz_validate_and_gpu_1`, `fuzz_validate_and_gpu_3`, `gpu_smem_flat_descriptor_windows_and_limits`, `f32_programs_on_the_gpu`, `gpu_f32_compares_with_nan`, `gpu_float_compares_random`, and `gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends`. `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` reported two failures on each build. - The two skip notices were for `two_pass_binds_set_the_shared_view_heap` and `heap_window_out_of_memory_falls_back_to_the_switch_form` with heap windows disabled. </details> **Retail smoke** Ran `scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>` with `XCL_UMA_DRIVER=mixed` and a fresh data root for each run. Title hash `2c508222`. | Build | `XCL_SPARSE_SYSMEM` | Exit | Frames | Peak commit | |---|---|---|---:|---:| | `main` + #3707 | Unset | `0x0` | 1341 | 11611 MB | | #3613 + #3707 | Unset | `0x0` | 1202 | 15501 MB | | #3613 + #3707 | `1` | `0x0` | 1035 | 15922 MB | All three runs logged zero device removals and zero crashes. The enabled run logged system-memory pool allocation milestones up to 512 MiB. On the same build, enabling the flag corresponded to about 14% fewer frames and 421 MB more peak process commit in this pair. One run per setting leaves repeatability and the cause open. The allocation milestones do not measure subsequent heap release or net VRAM savings. **Merge request** Could maintainers prioritize merging #3707 and #3455 once their required checks pass? In this retest, plain `main` exited before logging frames and the builds with #3707 completed the smoke run. The request for #3455 is based on the AMD tester’s separate experience of a substantial improvement on AMD cards. **Not tested** A standalone #3613 retail run, retail heap reclamation and net VRAM savings, repeated performance pairs, and #3455 in this test configuration. **AI use** Codex (GPT-6) prepared the two local builds, ran the tests and smoke comparisons, reviewed the changed allocation paths, and drafted this report. **Follow-up with #3455 added to both builds** Same #3613 head, `84646d4de8e5655c32a1a9b20e9b0d987adb4da1`, and same `main` base, `5ad98adbc360225ac8a57ad9661e16fe8df9d8dd`. Both local builds included #3707 at `912ff558e932264511f386eb8b7e97cbf7cf46e2` and #3455 at `1895d9e8ea3c64f7e91f4a0211f2a7aacff5c525`. The resulting baseline was `cfdacf961cf9cced7aba34f4f11e6219ce55df2d` and the #3613 build was `5b9a3ea398a8c62fc9de5659d0c113a08b922ab5`. Both merges were clean. Separate Cargo target directories were used. **Tested** `cargo build --workspace` passed on both. `cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output` exited 101 on both. | Build | Passed | Failed | Ignored | `SKIPPED` notices | |---|---:|---:|---:|---:| | `main` + #3707 + #3455 | 1585 | 9 | 47 | 2 | | #3613 + #3707 + #3455 | 1585 | 9 | 47 | 2 | The library exited `0x80004005` on both builds. These counts are partial. Both had the same named failures and skip notices listed in the earlier run above. Both debug-layer E2E tests and the texture-state check passed. All six focused sparse tests passed again in isolated libtest runs with `--exact --test-threads=1 --show-output --nocapture`, with zero skips. **Retail smoke** Same AMD host, title hash `2c508222`, and 60-second `scripts/smoke.ps1` runs with `XCL_UMA_DRIVER=mixed`. Each run used a fresh data root. | Build | `XCL_SPARSE_SYSMEM` | Exit | Frames | Peak commit | |---|---|---|---:|---:| | `main` + #3707 + #3455 | Unset | `0x0` | 1050 | 15709 MB | | #3613 + #3707 + #3455 | Unset | `0x0` | 1086 | 15916 MB | | #3613 + #3707 + #3455 | `1` | `0x0` | 1333 | 11003 MB | All three runs logged zero device removals and zero crashes. With both companion PRs included, enabling the switch corresponded to about 23% more frames and 31% lower peak process commit versus leaving it unset on the same build. The enabled run again logged a 512 MiB system-memory pool allocation milestone. This single pair reversed the earlier switch comparison. An isolated #3455 effect, repeatability, retail heap release, and net VRAM savings remain unverified. **Follow-up verdict** — **not yet**. The combined smoke runs completed and the focused checks passed. Both full workspace runs still aborted.
Pipodi commented 2026-12-02 22:08:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T22:08:53Z.


merge-check
base: 5ad98adbc3
head: 84646d4de8
merge: clean (git merge --no-ff onto 5ad98adb, merge 63f1ebe8; d3d12x/sparse.rs +448/-11, kernelx.rs +2/-1)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The six new sparse tests all ran and passed (none printed SKIPPED: the system-memory pool heap was made on this adapter).
title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes, same env and frame presses for every run, 420 s each (ended by XCL_RUN_SECONDS). Switch off (default), two runs: 379 s and 370 s in the cutscenes (from the first 2 s window with cutscene draws to the end), 4.24 and 3.92 presents/s there (from the log's 2 s activity lines), 0 device removals, 0 crashes (exit 0x0), peak video memory 21201 / 21785 MB local, peak private 43.4 / 44.2 GB. Main 5ad98adb, two runs tonight: 4.83 presents/s over 388 s, exit 0x0, 21394 MB local, 43.5 GB; and a device hang (0x887a0006) on main itself at 297.8 s after 238 s in the cutscenes at 4.64 presents/s. With XCL_SPARSE_SYSMEM=1, one run: 390 s in the cutscenes, 4.82 presents/s, 0 removals, 0 crashes, peak video memory 16804 MB local (-4.4 to -5.0 GB against the switch-off runs) and 11834 MB non-local (+4.8 GB; the log grew the system-memory pools to 4096 MB), peak private 44.0 GB. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs.
review: read the whole diff and the paths it changes in sparse.rs (take_tile, materialize, ensure_mapped, retire_free_pools_with, the quarantine/cooling code). No blocking findings. 1) Switch off, the behaviour is the same as main: take_tile_for and the sys test short-circuit on sysmem_tiles() before is_hot, no tile gets SYS, and the materialize change from left > 0 to no_video gives the same waits (a tile that waited leaves short_of_memory/at_hand as they were, so the later ones wait too). What runs by default is one uncontended SYS_POOLS lock per submit (the retire check) and per retire, an AddRef/Release of the heap in pool_heap per tile-mapping call, and note_hot/forget_hot per sparse GPU heap alloc/free. 2) Lock order is State, then SYS_POOLS everywhere; take_sys_tile drops SYS_POOLS before it falls back to take_tile; I found no path taking them the other way round. 3) The two points of the first check on 24a84ca are addressed on this head (no_video/no_sys per kind, sys_refused for 1 s), each with a test that passes here; the memory coming back (its point 4) shows above on NVIDIA. 4) Minor: without XCL_COHERENT_HEAPS=sparse no tile is "hot", so the switch puts every sparse-window tile in system memory (the 4 GB above); XCL_SPARSE_SYSMEM is not in README.md yet. 5) HOT is matched by the reservation's start address; whole-reservation releases only, which is what sparse_release does.
performance: default off: nothing per frame beyond the lock and AddRef above; the switch-off runs (4.24, 3.92 presents/s) are below the main run (4.83), but the spread between runs of builds that cannot differ per frame is as large tonight (another PR whose diff is never called per frame: 3.86; main's second run 4.64 before it hung), and peak private and video memory match main. With the switch on: -4.4 GB video memory, +4.8 GB non-local, 4.82 presents/s, no removal.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title runs); Claude Code, Claude Opus 5.5

<!-- greyfinch-sync:ivall/xcl:comment:7360289650 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7360289650). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-12-02T22:08:53Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd head: 84646d4de8e5655c32a1a9b20e9b0d987adb4da1 merge: clean (`git merge --no-ff` onto 5ad98adb, merge 63f1ebe8; d3d12x/sparse.rs +448/-11, kernelx.rs +2/-1) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The six new sparse tests all ran and passed (none printed SKIPPED: the system-memory pool heap was made on this adapter). title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes, same env and frame presses for every run, 420 s each (ended by XCL_RUN_SECONDS). Switch off (default), two runs: 379 s and 370 s in the cutscenes (from the first 2 s window with cutscene draws to the end), 4.24 and 3.92 presents/s there (from the log's 2 s activity lines), 0 device removals, 0 crashes (exit 0x0), peak video memory 21201 / 21785 MB local, peak private 43.4 / 44.2 GB. Main 5ad98adb, two runs tonight: 4.83 presents/s over 388 s, exit 0x0, 21394 MB local, 43.5 GB; and a device hang (0x887a0006) on main itself at 297.8 s after 238 s in the cutscenes at 4.64 presents/s. With XCL_SPARSE_SYSMEM=1, one run: 390 s in the cutscenes, 4.82 presents/s, 0 removals, 0 crashes, peak video memory 16804 MB local (-4.4 to -5.0 GB against the switch-off runs) and 11834 MB non-local (+4.8 GB; the log grew the system-memory pools to 4096 MB), peak private 44.0 GB. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs. review: read the whole diff and the paths it changes in sparse.rs (`take_tile`, `materialize`, `ensure_mapped`, `retire_free_pools_with`, the quarantine/cooling code). No blocking findings. 1) Switch off, the behaviour is the same as main: `take_tile_for` and the `sys` test short-circuit on `sysmem_tiles()` before `is_hot`, no tile gets `SYS`, and the `materialize` change from `left > 0` to `no_video` gives the same waits (a tile that waited leaves `short_of_memory`/`at_hand` as they were, so the later ones wait too). What runs by default is one uncontended `SYS_POOLS` lock per submit (the retire check) and per retire, an AddRef/Release of the heap in `pool_heap` per tile-mapping call, and `note_hot`/`forget_hot` per sparse GPU heap alloc/free. 2) Lock order is State, then `SYS_POOLS` everywhere; `take_sys_tile` drops `SYS_POOLS` before it falls back to `take_tile`; I found no path taking them the other way round. 3) The two points of the first check on 24a84ca are addressed on this head (`no_video`/`no_sys` per kind, `sys_refused` for 1 s), each with a test that passes here; the memory coming back (its point 4) shows above on NVIDIA. 4) Minor: without `XCL_COHERENT_HEAPS=sparse` no tile is "hot", so the switch puts every sparse-window tile in system memory (the 4 GB above); `XCL_SPARSE_SYSMEM` is not in README.md yet. 5) `HOT` is matched by the reservation's start address; whole-reservation releases only, which is what `sparse_release` does. performance: default off: nothing per frame beyond the lock and AddRef above; the switch-off runs (4.24, 3.92 presents/s) are below the main run (4.83), but the spread between runs of builds that cannot differ per frame is as large tonight (another PR whose diff is never called per frame: 3.86; main's second run 4.64 before it hung), and peak private and video memory match main. With the switch on: -4.4 GB video memory, +4.8 GB non-local, 4.82 presents/s, no removal. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title runs); Claude Code, Claude Opus 5.5
bmjask commented 2026-12-02 22:09:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:09:56Z.

Review: COMMENTED


Review of 84646d4d: 4 finding(s) (1 high, 3 medium), most severe first.

  1. High crates/xcl/src/hle/d3d12x/sparse.rs:549: The system-memory pools (SYS_POOLS) are a process global, but the tiles, quarantine, fence (value/done) and device that drive them belong to one State, so the pools don't follow that State's lifetime or device. (inline)
  2. Medium crates/xcl/src/hle/d3d12x/sparse.rs:3650: When the system-memory pools are refused, take_sys_tile falls back to take_tile() and skips the video-memory waits materialize applies to hot tiles (no_video, and short_of_memory() && !at_hand). (inline)
  3. Medium crates/xcl/src/hle/d3d12x/sparse.rs:3666: take_sys_tile calls CreateHeap with the state lock held but without the flush_pending() that take_tile does first, and take_tile's comment explains why: a CPU signal waiting meanwhile gives up after 2 ms. (inline)
  4. Medium crates/xcl/src/hle/d3d12x/sparse.rs:488: The SYS tag (bit 31) overlaps the sentinels LAZY = (u32::MAX, u32::MAX) and SHADOW_POOL = u32::MAX, so pool.0 & SYS != 0 is also true for a tile with no memory or a shadow tile. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6159915468 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#pullrequestreview-6159915468). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:09:56Z. **Review:** COMMENTED --- Review of `84646d4d`: 4 finding(s) (1 high, 3 medium), most severe first. 1. **High** `crates/xcl/src/hle/d3d12x/sparse.rs:549`: The system-memory pools (`SYS_POOLS`) are a process global, but the tiles, quarantine, fence (`value`/`done`) and device that drive them belong to one `State`, so the pools don't follow that State's lifetime or device. (inline) 2. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:3650`: When the system-memory pools are refused, `take_sys_tile` falls back to `take_tile()` and skips the video-memory waits `materialize` applies to hot tiles (`no_video`, and `short_of_memory() && !at_hand`). (inline) 3. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:3666`: `take_sys_tile` calls CreateHeap with the state lock held but without the `flush_pending()` that `take_tile` does first, and `take_tile`'s comment explains why: a CPU signal waiting meanwhile gives up after 2 ms. (inline) 4. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:488`: The `SYS` tag (bit 31) overlaps the sentinels `LAZY = (u32::MAX, u32::MAX)` and `SHADOW_POOL = u32::MAX`, so `pool.0 & SYS != 0` is also true for a tile with no memory or a shadow tile. (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 22:09:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:09:56Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 549

@@ -481,6 +481,117 @@ impl FreePools {
     }
 }
 
+/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the
+/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by
+/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool
+/// tile of these heaps has `SYS` set in its pool index.
+const SYS: u32 = 1 << 31;
+
+#[derive(Default)]
+struct SysPools {
+    /// None: a heap given back (`retire`); its index is taken by the next heap (`add_heap`), the
+    /// indexes of the live heaps are in the tile handles and never move
+    heaps: Vec<Option<ID3D12Heap>>,
+    /// (by the heap's index without `SYS`: `FreePools` sizes its table by it)
+    free: FreePools,
+    cooling: VecDeque<((u32, u32), std::time::Instant)>,
+    /// heaps given back, kept until the sparse queue's fence is past the value they got
+    /// (`State::retired` of the video pools)
+    retired: Vec<(ID3D12Heap, u64, std::time::Instant)>,
+}
+
+impl SysPools {
+    /// `heap` becomes a pool (in a given-back heap's index if there is one); its tiles but the
+    /// first, which the caller takes, go to the free list.
+    fn add_heap(&mut self, heap: ID3D12Heap) -> u32 {
+        let h = match self.heaps.iter().position(|p| p.is_none()) {
+            Some(i) => {
+                self.heaps[i] = Some(heap);
+                i as u32
+            }
+            None => {
+                self.heaps.push(Some(heap));
+                self.heaps.len() as u32 - 1
+            }
+        };
+        self.free.add_heap(h);
+        h
+    }
+
+    /// Heaps whose every tile is free again (cooled, `COOL`) are given back (`State::retire_free_pools_with`
+    /// does the same for video memory): `value` is the sparse queue's last fence value, `done` what
+    /// it has reached; a retired heap is dropped once it is past its mark.
+    fn retire(&mut self, value: u64, done: u64, now: std::time::Instant) {
+        self.retired.retain(|(_, v, at)| !(done >= *v && now.duration_since(*at).as_secs() >= 2));
+        self.free.drain_cooling(&mut self.cooling, now);
+        let gone: Vec<usize> = free_heaps(&self.free, &self.cooling, self.heaps.len(), now).into_iter().filter(|&h| self.heaps[h].is_some()).collect();
+        for h in gone {
+            self.free.clear_heap(h);
+            if let Some(heap) = self.heaps[h].take() {
+                self.retired.push((heap, value, now));
+            }
+        }
+    }
+
+    /// Whether `State::retire_free_pools_with` has something to do here at `now` (`retire_due`).
+    fn retire_waiting(&self, now: std::time::Instant) -> bool {
+        !self.retired.is_empty() || self.free.has_empty_heap() || cooled(&self.cooling, now)
+    }
+
+    fn bytes(&self) -> usize {
+        self.heaps.iter().flatten().count() * POOL_TILES as usize * TILE
+    }
+}
+
+// D3D12 heaps are free-threaded
+unsafe impl Send for SysPools {}
+
+static SYS_POOLS: Mutex<Option<SysPools>> = Mutex::new(None);

High: The system-memory pools (SYS_POOLS) are a process global, but the tiles, quarantine, fence (value/done) and device that drive them belong to one State, so the pools don't follow that State's lifetime or device. init can replace STATE (when the windows are set up again). The old State takes its mapped, parked and quarantined SYS tiles with it, so their heaps never become all free and leak. Entries in SysPools.retired keep the old fence's marks and are compared with the new fence's done, which restarts at 0, so heaps can be reused while the GPU may still use them. A new State on another device then maps heaps made on the old device (pool_heap -> UpdateTileMappings), which gives a D3D12 error or device removal. Owning the system pools in State, like the video pools, would fix all three.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776801273 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4776801273). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:09:56Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 549 ~~~~diff @@ -481,6 +481,117 @@ impl FreePools { } } +/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the +/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by +/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool +/// tile of these heaps has `SYS` set in its pool index. +const SYS: u32 = 1 << 31; + +#[derive(Default)] +struct SysPools { + /// None: a heap given back (`retire`); its index is taken by the next heap (`add_heap`), the + /// indexes of the live heaps are in the tile handles and never move + heaps: Vec<Option<ID3D12Heap>>, + /// (by the heap's index without `SYS`: `FreePools` sizes its table by it) + free: FreePools, + cooling: VecDeque<((u32, u32), std::time::Instant)>, + /// heaps given back, kept until the sparse queue's fence is past the value they got + /// (`State::retired` of the video pools) + retired: Vec<(ID3D12Heap, u64, std::time::Instant)>, +} + +impl SysPools { + /// `heap` becomes a pool (in a given-back heap's index if there is one); its tiles but the + /// first, which the caller takes, go to the free list. + fn add_heap(&mut self, heap: ID3D12Heap) -> u32 { + let h = match self.heaps.iter().position(|p| p.is_none()) { + Some(i) => { + self.heaps[i] = Some(heap); + i as u32 + } + None => { + self.heaps.push(Some(heap)); + self.heaps.len() as u32 - 1 + } + }; + self.free.add_heap(h); + h + } + + /// Heaps whose every tile is free again (cooled, `COOL`) are given back (`State::retire_free_pools_with` + /// does the same for video memory): `value` is the sparse queue's last fence value, `done` what + /// it has reached; a retired heap is dropped once it is past its mark. + fn retire(&mut self, value: u64, done: u64, now: std::time::Instant) { + self.retired.retain(|(_, v, at)| !(done >= *v && now.duration_since(*at).as_secs() >= 2)); + self.free.drain_cooling(&mut self.cooling, now); + let gone: Vec<usize> = free_heaps(&self.free, &self.cooling, self.heaps.len(), now).into_iter().filter(|&h| self.heaps[h].is_some()).collect(); + for h in gone { + self.free.clear_heap(h); + if let Some(heap) = self.heaps[h].take() { + self.retired.push((heap, value, now)); + } + } + } + + /// Whether `State::retire_free_pools_with` has something to do here at `now` (`retire_due`). + fn retire_waiting(&self, now: std::time::Instant) -> bool { + !self.retired.is_empty() || self.free.has_empty_heap() || cooled(&self.cooling, now) + } + + fn bytes(&self) -> usize { + self.heaps.iter().flatten().count() * POOL_TILES as usize * TILE + } +} + +// D3D12 heaps are free-threaded +unsafe impl Send for SysPools {} + +static SYS_POOLS: Mutex<Option<SysPools>> = Mutex::new(None); ~~~~ --- **High**: The system-memory pools (`SYS_POOLS`) are a process global, but the tiles, quarantine, fence (`value`/`done`) and device that drive them belong to one `State`, so the pools don't follow that State's lifetime or device. `init` can replace STATE (when the windows are set up again). The old State takes its mapped, parked and quarantined SYS tiles with it, so their heaps never become all free and leak. Entries in `SysPools.retired` keep the old fence's marks and are compared with the new fence's `done`, which restarts at 0, so heaps can be reused while the GPU may still use them. A new State on another device then maps heaps made on the old device (`pool_heap` -> UpdateTileMappings), which gives a D3D12 error or device removal. Owning the system pools in State, like the video pools, would fix all three.
bmjask commented 2026-12-02 22:09:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:09:57Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 3650

@@ -3511,6 +3627,84 @@ impl State {
         Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source })
     }
 
+    /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`).
+    unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> {
+        self.drain_quarantined();
+        let mut g = SYS_POOLS.lock().unwrap();
+        let p = g.get_or_insert_with(SysPools::default);
+        let refuse = sys_pools_refuse_for_test();
+        if !refuse {
+            if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) {
+                return Some(((SYS | h, t), true));
+            }
+            // a heap given back a moment ago is taken back first (as `take_tile` does)
+            if let Some((heap, _, _)) = p.retired.pop() {
+                let h = p.add_heap(heap);
+                return Some(((SYS | h, 0), true));
+            }
+        }
+        // a heap refused a moment ago (`sys_refused`, 1 s) is not asked for again at each cold
+        // tile (each asked, and logged it): video memory meanwhile
+        if self.sys_refused.is_some_and(|t| t.elapsed() < std::time::Duration::from_secs(1)) {
+            drop(g);
+            return self.take_tile();

Medium: When the system-memory pools are refused, take_sys_tile falls back to take_tile() and skips the video-memory waits materialize applies to hot tiles (no_video, and short_of_memory() && !at_hand). After a hot tile fails to get video memory (setting no_video/no_memory), the next cold tile computes wait = no_sys (false) and calls take_sys_tile, which within 1 s of sys_refused goes to take_tile(), runs flush_pending and another failing CreateHeap, and logs 'no video memory for more tiles'. This repeats on every materialize in that second, which is exactly what no_memory/short_of_memory prevent. When it does succeed, cold tiles take video memory while hot GPU-heap tiles are made to wait. Respecting no_video in the fallback would fix it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776801290 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4776801290). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:09:57Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 3650 ~~~~diff @@ -3511,6 +3627,84 @@ impl State { Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source }) } + /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`). + unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> { + self.drain_quarantined(); + let mut g = SYS_POOLS.lock().unwrap(); + let p = g.get_or_insert_with(SysPools::default); + let refuse = sys_pools_refuse_for_test(); + if !refuse { + if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) { + return Some(((SYS | h, t), true)); + } + // a heap given back a moment ago is taken back first (as `take_tile` does) + if let Some((heap, _, _)) = p.retired.pop() { + let h = p.add_heap(heap); + return Some(((SYS | h, 0), true)); + } + } + // a heap refused a moment ago (`sys_refused`, 1 s) is not asked for again at each cold + // tile (each asked, and logged it): video memory meanwhile + if self.sys_refused.is_some_and(|t| t.elapsed() < std::time::Duration::from_secs(1)) { + drop(g); + return self.take_tile(); ~~~~ --- **Medium**: When the system-memory pools are refused, `take_sys_tile` falls back to `take_tile()` and skips the video-memory waits `materialize` applies to hot tiles (`no_video`, and `short_of_memory() && !at_hand`). After a hot tile fails to get video memory (setting `no_video`/`no_memory`), the next cold tile computes `wait = no_sys` (false) and calls `take_sys_tile`, which within 1 s of `sys_refused` goes to `take_tile()`, runs `flush_pending` and another failing CreateHeap, and logs 'no video memory for more tiles'. This repeats on every `materialize` in that second, which is exactly what `no_memory`/`short_of_memory` prevent. When it does succeed, cold tiles take video memory while hot GPU-heap tiles are made to wait. Respecting `no_video` in the fallback would fix it.
bmjask commented 2026-12-02 22:09:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:09:57Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 3666

@@ -3511,6 +3627,84 @@ impl State {
         Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source })
     }
 
+    /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`).
+    unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> {
+        self.drain_quarantined();
+        let mut g = SYS_POOLS.lock().unwrap();
+        let p = g.get_or_insert_with(SysPools::default);
+        let refuse = sys_pools_refuse_for_test();
+        if !refuse {
+            if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) {
+                return Some(((SYS | h, t), true));
+            }
+            // a heap given back a moment ago is taken back first (as `take_tile` does)
+            if let Some((heap, _, _)) = p.retired.pop() {
+                let h = p.add_heap(heap);
+                return Some(((SYS | h, 0), true));
+            }
+        }
+        // a heap refused a moment ago (`sys_refused`, 1 s) is not asked for again at each cold
+        // tile (each asked, and logged it): video memory meanwhile
+        if self.sys_refused.is_some_and(|t| t.elapsed() < std::time::Duration::from_secs(1)) {
+            drop(g);
+            return self.take_tile();
+        }
+        let desc = D3D12_HEAP_DESC {
+            SizeInBytes: POOL_TILES as u64 * TILE as u64,
+            Properties: D3D12_HEAP_PROPERTIES {
+                Type: D3D12_HEAP_TYPE_CUSTOM,
+                CPUPageProperty: D3D12_CPU_PAGE_PROPERTY_WRITE_BACK,
+                MemoryPoolPreference: D3D12_MEMORY_POOL_L0,
+                ..Default::default()
+            },
+            Alignment: 0,
+            Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES,
+        };
+        let mut heap: Option<ID3D12Heap> = None;
+        #[cfg(test)]
+        tests::SYS_HEAPS_ASKED.with(|c| c.set(c.get() + 1));
+        let made = if refuse { Err(windows::Win32::Foundation::E_OUTOFMEMORY.into()) } else { super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) };

Medium: take_sys_tile calls CreateHeap with the state lock held but without the flush_pending() that take_tile does first, and take_tile's comment explains why: a CPU signal waiting meanwhile gives up after 2 ms. Tiles already pending in self.pending (e.g. from earlier iterations of the same ensure_mapped loop) aren't sent before the slow custom-L0 CreateHeap, so a title queue or CPU signal waiting on their mapping times out, the regression take_tile guards against. Calling flush_pending() first would match.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776801304 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4776801304). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:09:57Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 3666 ~~~~diff @@ -3511,6 +3627,84 @@ impl State { Some(UploadPageObservation { page, pool: entry.pool, hole, sent, source }) } + /// `take_tile` from the system-memory pools (`XCL_SPARSE_SYSMEM`). + unsafe fn take_sys_tile(&mut self) -> Option<((u32, u32), bool)> { + self.drain_quarantined(); + let mut g = SYS_POOLS.lock().unwrap(); + let p = g.get_or_insert_with(SysPools::default); + let refuse = sys_pools_refuse_for_test(); + if !refuse { + if let Some((h, t)) = reuse_tile(&mut p.free, &mut p.cooling, std::time::Instant::now()) { + return Some(((SYS | h, t), true)); + } + // a heap given back a moment ago is taken back first (as `take_tile` does) + if let Some((heap, _, _)) = p.retired.pop() { + let h = p.add_heap(heap); + return Some(((SYS | h, 0), true)); + } + } + // a heap refused a moment ago (`sys_refused`, 1 s) is not asked for again at each cold + // tile (each asked, and logged it): video memory meanwhile + if self.sys_refused.is_some_and(|t| t.elapsed() < std::time::Duration::from_secs(1)) { + drop(g); + return self.take_tile(); + } + let desc = D3D12_HEAP_DESC { + SizeInBytes: POOL_TILES as u64 * TILE as u64, + Properties: D3D12_HEAP_PROPERTIES { + Type: D3D12_HEAP_TYPE_CUSTOM, + CPUPageProperty: D3D12_CPU_PAGE_PROPERTY_WRITE_BACK, + MemoryPoolPreference: D3D12_MEMORY_POOL_L0, + ..Default::default() + }, + Alignment: 0, + Flags: D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES, + }; + let mut heap: Option<ID3D12Heap> = None; + #[cfg(test)] + tests::SYS_HEAPS_ASKED.with(|c| c.set(c.get() + 1)); + let made = if refuse { Err(windows::Win32::Foundation::E_OUTOFMEMORY.into()) } else { super::title_textures::own_work(|| self.dev.CreateHeap(&desc, &mut heap)) }; ~~~~ --- **Medium**: `take_sys_tile` calls CreateHeap with the state lock held but without the `flush_pending()` that `take_tile` does first, and `take_tile`'s comment explains why: a CPU signal waiting meanwhile gives up after 2 ms. Tiles already pending in `self.pending` (e.g. from earlier iterations of the same `ensure_mapped` loop) aren't sent before the slow custom-L0 CreateHeap, so a title queue or CPU signal waiting on their mapping times out, the regression `take_tile` guards against. Calling `flush_pending()` first would match.
bmjask commented 2026-12-02 22:09:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:09:57Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 488

@@ -481,6 +481,117 @@ impl FreePools {
     }
 }
 
+/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the
+/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by
+/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool
+/// tile of these heaps has `SYS` set in its pool index.
+const SYS: u32 = 1 << 31;

Medium: The SYS tag (bit 31) overlaps the sentinels LAZY = (u32::MAX, u32::MAX) and SHADOW_POOL = u32::MAX, so pool.0 & SYS != 0 is also true for a tile with no memory or a shadow tile. In a_lazy_tile_outside_the_gpu_heaps_gets_system_memory, assert_ne!(s.mapped[&base].pool.0 & SYS, 0, ...) passes when the tile is still LAZY, so that check proves nothing. Any SYS check that sees a LAZY or shadow entry (in cool, pool_heap or pool_bytes) would treat it as system heap 0x7FFF_FFFF, so FreePools::push would resize by_heap to 2^31 entries, or pool_heap would index out of bounds and panic. Excluding the sentinels in an is_sys() helper would close it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776801313 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#discussion_r4776801313). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:09:57Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 488 ~~~~diff @@ -481,6 +481,117 @@ impl FreePools { } } +/// `XCL_SPARSE_SYSMEM=1`: sparse-window tiles outside the +/// title's GPU heaps (`note_hot`) get pool tiles in system memory (custom heaps in L0, read by +/// the GPU over PCIe) instead of video memory; the GPU heaps' tiles keep video memory. A pool +/// tile of these heaps has `SYS` set in its pool index. +const SYS: u32 = 1 << 31; ~~~~ --- **Medium**: The `SYS` tag (bit 31) overlaps the sentinels `LAZY = (u32::MAX, u32::MAX)` and `SHADOW_POOL = u32::MAX`, so `pool.0 & SYS != 0` is also true for a tile with no memory or a shadow tile. In `a_lazy_tile_outside_the_gpu_heaps_gets_system_memory`, `assert_ne!(s.mapped[&base].pool.0 & SYS, 0, ...)` passes when the tile is still LAZY, so that check proves nothing. Any SYS check that sees a LAZY or shadow entry (in `cool`, `pool_heap` or `pool_bytes`) would treat it as system heap 0x7FFF_FFFF, so `FreePools::push` would resize `by_heap` to 2^31 entries, or `pool_heap` would index out of bounds and panic. Excluding the sentinels in an `is_sys()` helper would close it.
throny commented 2026-12-02 22:16:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T22:16:00Z.


@stijn-boer thanks for the AMD run. On the two points:

  • The library aborting: your own table shows the same abort and the same counts on main + #3707 (1584 passed, 9 failed, 47 ignored on both builds). So it comes from the base or the machine, not from this PR. On an RTX 4080 the whole suite runs through at 84646d4d (3011 passed, 0 failed).
  • Higher peak commit and fewer frames with the switch on: that is what the switch does. It moves sparse tiles from video memory into system memory, so commit goes up and video memory goes down. On the 4080: −3.2 GB video memory peak for −4 % presents/s in a 900 s world run. It stays opt-in (XCL_SPARSE_SYSMEM=1), and without the switch nothing changes.

Did the RX 9060 XT reach the world with the switch on, and how much video memory did it save there?

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7360455602 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7360455602). Originally posted by [throny](https://github.com/throny) on 2026-12-02T22:16:00Z. --- @stijn-boer thanks for the AMD run. On the two points: - **The library aborting:** your own table shows the same abort and the same counts on `main` + #3707 (1584 passed, 9 failed, 47 ignored on both builds). So it comes from the base or the machine, not from this PR. On an RTX 4080 the whole suite runs through at `84646d4d` (3011 passed, 0 failed). - **Higher peak commit and fewer frames with the switch on:** that is what the switch does. It moves sparse tiles from video memory into system memory, so commit goes up and video memory goes down. On the 4080: −3.2 GB video memory peak for −4 % presents/s in a 900 s world run. It stays opt-in (`XCL_SPARSE_SYSMEM=1`), and without the switch nothing changes. Did the RX 9060 XT reach the world with the switch on, and how much video memory did it save there? *AI use: Claude Code (Claude Opus 5.5).*
throny commented 2026-12-03 01:43:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T01:43:59Z.


Thanks for the third round. One of the four points is a real bug and is fixed. The other three are explained below with what I would do as follow-ups. Since the code changed, the merge check claimed on 84646d4d has to be redone on the new head (b98038bb4, amended locally, not pushed yet when this was written).

3. Medium: take_sys_tile calls CreateHeap without flush_pending(). Fixed in our commit (the second one). Before it asks for a new system-memory heap, take_sys_tile now sends the pending mappings (crates/xcl/src/hle/d3d12x/sparse.rs:3663-3668), as take_tile does. It releases the SYS_POOLS lock for that and takes it again, because flush_pending → map_tiles → pool_heap takes it, and keeping it would deadlock. Test: pending_mappings_go_out_before_a_system_memory_heap_is_made (:11758). A GPU-heap tile takes video memory and waits for its mapping, then a cold tile asks for a system heap. The test records how many tiles are pending at that moment: 0 with the fix. Without it the test fails (left: 1, right: 0); I checked that by removing the flush and running it.

1. High: SYS_POOLS is process-global while the tiles and fence are per State. Correct as a description of the structure, but no title run can reach it. sparse::init is called only from real::open_uma, and that runs only from init_with_remap when no device exists yet. init_with_remap returns early once DEVICE is set, and the device is kept for the life of the process. So a process has one device and one State, and that State is never replaced while system tiles exist. All three effects need a second init: leaked heaps, retired marks compared with a new fence, and heaps of an old device mapped by a new one. The unit tests make their own States on the one adapter's device (D3D12 gives the same device for the same adapter), so they do not mix devices either. Owning the pools in State is the right shape, and I would do it as a follow-up. It moves the carried commit's structure (every SYS_POOLS use plus sys_pool_bytes), which I would rather not do inside this PR.

2. Medium: the fallback to take_tile() skips the video-memory waits. The fallback happens, but only when both kinds of memory fail in the same second: the system heap was refused less than 1 s ago and video memory is short. Even then, each materialize call makes at most one failing CreateHeap, because the first None sets no_sys for the rest of the call. That is the same as what every eager tile does on main: ensure_mapped calls take_tile with no short_of_memory gate. The cost is a log line and a failing call per materialize during that second, not a wrong mapping. A follow-up can treat a cold tile as a video tile in materialize's wait while sys_refused is recent. I would rather not make that change and reset the merge check for it.

4. Medium: SYS (bit 31) overlaps the LAZY / SHADOW_POOL sentinels. True of the encoding, but no SYS check sees a sentinel. pool_heap is reached through map_tiles, which asserts that no tile is LAZY, and buffer tiles filter LAZY out. cool is reached through release_if_unused and drain_quarantined_with, which only handle real pool tiles. pool_bytes only counts quarantined tiles. A sentinel reaching any of these would already break the video path on main: FreePools would be indexed with u32::MAX, or pools[u32::MAX] used. So SYS adds no new way to reach them. In a_lazy_tile_outside_the_gpu_heaps_gets_system_memory, the & SYS assertion alone would pass for LAZY, as you say. But the next assertion compares the window's bytes with the written tile, and a LAZY tile reads zeros, so the test still fails if no tile was given. An is_sys() helper that leaves out the sentinels is a good hardening follow-up.

Tests (Windows, debug, RTX 4080): cargo test -p xcl --lib d3d12x::sparse -- --test-threads=4 was run 3 times on the new head, each with 147 passed, 0 failed, 1 ignored (early_commit_timing) and 0 SKIPPED. Runs with the default thread count (24 here) sometimes failed or hung, with E_OUTOFMEMORY from CreateCommandQueue. That happened on 84646d4d as well, so it is not this change.

Each round has found new points so far. Would the remaining ones (1, 2, 4) block the merge, or can they be follow-ups once this round is in?

Pushed as b98038bb. The whole suite passes there (3012 passed, 0 failed), and the smoke block in the description is updated.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7364672056 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7364672056). Originally posted by [throny](https://github.com/throny) on 2026-12-03T01:43:59Z. --- Thanks for the third round. One of the four points is a real bug and is fixed. The other three are explained below with what I would do as follow-ups. Since the code changed, the merge check claimed on `84646d4d` has to be redone on the new head (`b98038bb4`, amended locally, not pushed yet when this was written). **3. Medium: `take_sys_tile` calls CreateHeap without `flush_pending()`.** Fixed in our commit (the second one). Before it asks for a new system-memory heap, `take_sys_tile` now sends the pending mappings (`crates/xcl/src/hle/d3d12x/sparse.rs:3663-3668`), as `take_tile` does. It releases the `SYS_POOLS` lock for that and takes it again, because `flush_pending` → `map_tiles` → `pool_heap` takes it, and keeping it would deadlock. Test: `pending_mappings_go_out_before_a_system_memory_heap_is_made` (`:11758`). A GPU-heap tile takes video memory and waits for its mapping, then a cold tile asks for a system heap. The test records how many tiles are pending at that moment: 0 with the fix. Without it the test fails (`left: 1, right: 0`); I checked that by removing the flush and running it. **1. High: `SYS_POOLS` is process-global while the tiles and fence are per `State`.** Correct as a description of the structure, but no title run can reach it. `sparse::init` is called only from `real::open_uma`, and that runs only from `init_with_remap` when no device exists yet. `init_with_remap` returns early once `DEVICE` is set, and the device is kept for the life of the process. So a process has one device and one `State`, and that `State` is never replaced while system tiles exist. All three effects need a second `init`: leaked heaps, retired marks compared with a new fence, and heaps of an old device mapped by a new one. The unit tests make their own `State`s on the one adapter's device (D3D12 gives the same device for the same adapter), so they do not mix devices either. Owning the pools in `State` is the right shape, and I would do it as a follow-up. It moves the carried commit's structure (every `SYS_POOLS` use plus `sys_pool_bytes`), which I would rather not do inside this PR. **2. Medium: the fallback to `take_tile()` skips the video-memory waits.** The fallback happens, but only when both kinds of memory fail in the same second: the system heap was refused less than 1 s ago and video memory is short. Even then, each `materialize` call makes at most one failing `CreateHeap`, because the first `None` sets `no_sys` for the rest of the call. That is the same as what every eager tile does on main: `ensure_mapped` calls `take_tile` with no `short_of_memory` gate. The cost is a log line and a failing call per `materialize` during that second, not a wrong mapping. A follow-up can treat a cold tile as a video tile in `materialize`'s `wait` while `sys_refused` is recent. I would rather not make that change and reset the merge check for it. **4. Medium: `SYS` (bit 31) overlaps the `LAZY` / `SHADOW_POOL` sentinels.** True of the encoding, but no `SYS` check sees a sentinel. `pool_heap` is reached through `map_tiles`, which asserts that no tile is `LAZY`, and buffer tiles filter `LAZY` out. `cool` is reached through `release_if_unused` and `drain_quarantined_with`, which only handle real pool tiles. `pool_bytes` only counts quarantined tiles. A sentinel reaching any of these would already break the video path on main: `FreePools` would be indexed with `u32::MAX`, or `pools[u32::MAX]` used. So `SYS` adds no new way to reach them. In `a_lazy_tile_outside_the_gpu_heaps_gets_system_memory`, the `& SYS` assertion alone would pass for `LAZY`, as you say. But the next assertion compares the window's bytes with the written tile, and a `LAZY` tile reads zeros, so the test still fails if no tile was given. An `is_sys()` helper that leaves out the sentinels is a good hardening follow-up. Tests (Windows, debug, RTX 4080): `cargo test -p xcl --lib d3d12x::sparse -- --test-threads=4` was run 3 times on the new head, each with 147 passed, 0 failed, 1 ignored (`early_commit_timing`) and 0 SKIPPED. Runs with the default thread count (24 here) sometimes failed or hung, with `E_OUTOFMEMORY` from `CreateCommandQueue`. That happened on `84646d4d` as well, so it is not this change. Each round has found new points so far. Would the remaining ones (1, 2, 4) block the merge, or can they be follow-ups once this round is in? Pushed as `b98038bb`. The whole suite passes there (3012 passed, 0 failed), and the smoke block in the description is updated. *AI use: Claude Code (Claude Opus 5.5).*
throny commented 2026-12-03 01:44:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T01:44:10Z.


@Pipodi heads-up for your merge-check claim: the head moved from 84646d4d to b98038bb (one fix from bmjask's review: pending tile mappings are sent before a system-memory heap is made; details above). Sorry for the extra round. AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7364675478 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7364675478). Originally posted by [throny](https://github.com/throny) on 2026-12-03T01:44:10Z. --- @Pipodi heads-up for your merge-check claim: the head moved from `84646d4d` to `b98038bb` (one fix from bmjask's review: pending tile mappings are sent before a system-memory heap is made; details above). Sorry for the extra round. *AI use: Claude Code (Claude Opus 5.5).*
Foniass commented 2026-12-03 04:45:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T04:45:12Z.


merge-check
base: 078358a058
head: b98038bb43
merge: clean
build: ok
tests: 3013 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 5 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1649 frames (98 % of main), peak commit 17577 → 18134 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 221 s there, 0 device removals, 0 crashes, 2.6 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR carries #2987's opt-in XCL_SPARSE_SYSMEM commit and adds retirement of system-memory pool heaps whose tiles are all free. The new push (range-diff against 84646d4d) only adds flush_pending before a system-memory heap is made, with a test, and the rest of the diff is unchanged. Nothing blocks merging and the default path is unchanged, but the earlier medium points (cold-tile fallback skipping the video waits, kept SYS tiles at GPU-heap addresses, untested retirement wiring, a description that no longer matches the commits or the head) are still open.

Medium

  1. When system memory is refused, cold tiles skip the video-memory waits. Still open. In materialize (sparse.rs ~4018) a cold tile waits only on no_sys, then take_sys_tile falls back straight to take_tile during the 1 s sys_refused window (~3648-3650) and after a failed CreateHeap (~3679). So a cold tile asks for video memory without the short_of_memory/at_hand check and without no_video, even after a GPU-heap tile in the same run found none. That can make a video-memory heap even when the budget is already short. Apply the video-memory wait (no_video || short_of_memory && !at_hand) before the fallback, or return None and let materialize treat the tile as a video one.
  2. A kept system-memory tile is reused at a GPU-heap address. Still open. ensure_mapped (sparse.rs ~4076) swaps only a SYS tile in parked. A SYS tile in kept (XCL_VIEW_KEEP, not pinned) at an address that is now in a GPU heap is taken back unchanged in the branch below (~4089). So that GPU-heap tile stays in system memory and is read over PCIe. Check kept in the swap condition as well (excluding pinned tiles, as now), and add a case to the swap test.
  3. Retirement wiring still has no test and no visible effect. Still open. a_system_memory_heap_with_all_tiles_free_is_given_back (~11779) calls SysPools directly. Nothing tests take_sys_tile taking back a retired heap (retired.pop ~3641), the call from retire_free_pools_with (~3784) or the sys_waiting term in retire_due (~7994), so broken wiring would still pass. sys_pool_bytes (~591) still has no caller and retirement logs nothing, so a run cannot show heaps coming back. Throny's world numbers compare the switch on and off, not retirement. Add a State-level test through retire_free_pools_with and a log line or memory-line counter for the system-memory pool bytes.
  4. Description no longer matches the commits or the head. Still open. It says the first commit is treybertram06's "unchanged", but range-diff against #2987's head 15b74314 shows sys_refused, no_video/no_sys, NO_SYS_HEAP and their tests folded into it under Trey Bertram's authorship. Tested and both smoke blocks name 84646d4d, not b98038bb. AI use names only Claude Sonnet 5.5, while the second commit now also carries Opus 5.5 and the folded-in fixes were written with Opus 5.5 (per the PR comments). Say what was added to the first commit and by whom (or split the fixes into their own commit), and rerun the suite and smoke at b98038bb.
  5. Carries open #2987 and conflicts with it. Still open. #2987 is still open at 15b74314 with a different version of the same first commit, so merging either one leaves the other conflicting. Its review points now live only here. Close #2987 in favour of this PR, or rebase this one onto it, and note it in #1607 (group D262 with #3112; #3620 is also an opt-in L0 spill of the sparse pools).

Nit

  1. SYS_POOLS is process-global. Still open. SYS_POOLS (~549) and HOT are statics while the video pools live in State. init replacing STATE leaves the old system-memory heaps and their tiles in place, never retired. Keep them in State, or clear them in init.
  2. SYS bit overlaps the LAZY and SHADOW_POOL sentinels. Still open. LAZY (u32::MAX, ~142) and SHADOW_POOL (u32::MAX, ~3484) both have bit 31 set, so they read as SYS tiles. Today every path that tests SYS leaves them out first, but a future caller of pool_heap, cool or the quarantine count would be sent to SYS_POOLS. Compare against the sentinels explicitly in pool_heap and cool, or move SYS to a bit the sentinels do not use.
  3. XCL_SPARSE_SYSMEM is not in README.md. A new user-facing switch, with no README line saying what it does and that it needs XCL_COHERENT_HEAPS=sparse. Without that, nothing is hot and every sparse-window tile goes to system memory.
Checked and fine
  • Earlier finding fixed: take_sys_tile creates a heap without flush_pending. It now lets go of SYS_POOLS, calls flush_pending and locks it again before CreateHeap (~3664-3668), as take_tile does. The new test pending_mappings_go_out_before_a_system_memory_heap_is_made checks that nothing is pending at the heap request.
  • The re-lock around flush_pending is safe: every writer of SYS_POOLS (cool, retire, take_sys_tile) runs with the State lock held, so nothing can change the pools between the drop and the re-lock, and map_tiles/pool_heap no longer deadlock on SYS_POOLS.
  • With the switch off, take_tile_for and the sys test in materialize short-circuit on sysmem_tiles(), so no tile gets SYS. The default path adds only one uncontended SYS_POOLS lock per submit and per retire, and note_hot/forget_hot per GPU heap.
  • Retired system-memory heaps wait for the sparse queue's fence and 2 s before they are dropped, live heap indexes never move (Option slots), and clear_heap runs before a slot is reused, as in the video pools.
  • The kernelx.rs change (alloc_as with hot, forget_hot before sparse_release) matches sparse::alloc_as and sparse::free.
  • No test assertion deleted or weakened; the diff is +481/-12 in two files and still merges cleanly onto current origin/main.
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 61 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7368006577 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7368006577). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T04:45:12Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: b98038bb434dfdc8257dde82b9b6a2f40ea6ab1c merge: clean build: ok tests: 3013 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 5 medium, 3 nits (below) performance: 60 s smoke run: 1669 → 1649 frames (98 % of main), peak commit 17577 → 18134 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 221 s there, 0 device removals, 0 crashes, 2.6 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR carries #2987's opt-in XCL_SPARSE_SYSMEM commit and adds retirement of system-memory pool heaps whose tiles are all free. The new push (range-diff against 84646d4d) only adds flush_pending before a system-memory heap is made, with a test, and the rest of the diff is unchanged. Nothing blocks merging and the default path is unchanged, but the earlier medium points (cold-tile fallback skipping the video waits, kept SYS tiles at GPU-heap addresses, untested retirement wiring, a description that no longer matches the commits or the head) are still open. #### Medium 1. **When system memory is refused, cold tiles skip the video-memory waits.** Still open. In materialize (sparse.rs ~4018) a cold tile waits only on no_sys, then take_sys_tile falls back straight to take_tile during the 1 s sys_refused window (~3648-3650) and after a failed CreateHeap (~3679). So a cold tile asks for video memory without the short_of_memory/at_hand check and without no_video, even after a GPU-heap tile in the same run found none. That can make a video-memory heap even when the budget is already short. Apply the video-memory wait (no_video || short_of_memory && !at_hand) before the fallback, or return None and let materialize treat the tile as a video one. 2. **A kept system-memory tile is reused at a GPU-heap address.** Still open. ensure_mapped (sparse.rs ~4076) swaps only a SYS tile in parked. A SYS tile in kept (XCL_VIEW_KEEP, not pinned) at an address that is now in a GPU heap is taken back unchanged in the branch below (~4089). So that GPU-heap tile stays in system memory and is read over PCIe. Check kept in the swap condition as well (excluding pinned tiles, as now), and add a case to the swap test. 3. **Retirement wiring still has no test and no visible effect.** Still open. a_system_memory_heap_with_all_tiles_free_is_given_back (~11779) calls SysPools directly. Nothing tests take_sys_tile taking back a retired heap (retired.pop ~3641), the call from retire_free_pools_with (~3784) or the sys_waiting term in retire_due (~7994), so broken wiring would still pass. sys_pool_bytes (~591) still has no caller and retirement logs nothing, so a run cannot show heaps coming back. Throny's world numbers compare the switch on and off, not retirement. Add a State-level test through retire_free_pools_with and a log line or memory-line counter for the system-memory pool bytes. 4. **Description no longer matches the commits or the head.** Still open. It says the first commit is treybertram06's "unchanged", but range-diff against #2987's head 15b74314 shows sys_refused, no_video/no_sys, NO_SYS_HEAP and their tests folded into it under Trey Bertram's authorship. Tested and both smoke blocks name 84646d4d, not b98038bb. AI use names only Claude Sonnet 5.5, while the second commit now also carries Opus 5.5 and the folded-in fixes were written with Opus 5.5 (per the PR comments). Say what was added to the first commit and by whom (or split the fixes into their own commit), and rerun the suite and smoke at b98038bb. 5. **Carries open #2987 and conflicts with it.** Still open. #2987 is still open at 15b74314 with a different version of the same first commit, so merging either one leaves the other conflicting. Its review points now live only here. Close #2987 in favour of this PR, or rebase this one onto it, and note it in #1607 (group D262 with #3112; #3620 is also an opt-in L0 spill of the sparse pools). #### Nit 6. **SYS_POOLS is process-global.** Still open. SYS_POOLS (~549) and HOT are statics while the video pools live in State. init replacing STATE leaves the old system-memory heaps and their tiles in place, never retired. Keep them in State, or clear them in init. 7. **SYS bit overlaps the LAZY and SHADOW_POOL sentinels.** Still open. LAZY (u32::MAX, ~142) and SHADOW_POOL (u32::MAX, ~3484) both have bit 31 set, so they read as SYS tiles. Today every path that tests SYS leaves them out first, but a future caller of pool_heap, cool or the quarantine count would be sent to SYS_POOLS. Compare against the sentinels explicitly in pool_heap and cool, or move SYS to a bit the sentinels do not use. 8. **XCL_SPARSE_SYSMEM is not in README.md.** A new user-facing switch, with no README line saying what it does and that it needs XCL_COHERENT_HEAPS=sparse. Without that, nothing is hot and every sparse-window tile goes to system memory. <details><summary>Checked and fine</summary> - Earlier finding fixed: take_sys_tile creates a heap without flush_pending. It now lets go of SYS_POOLS, calls flush_pending and locks it again before CreateHeap (~3664-3668), as take_tile does. The new test pending_mappings_go_out_before_a_system_memory_heap_is_made checks that nothing is pending at the heap request. - The re-lock around flush_pending is safe: every writer of SYS_POOLS (cool, retire, take_sys_tile) runs with the State lock held, so nothing can change the pools between the drop and the re-lock, and map_tiles/pool_heap no longer deadlock on SYS_POOLS. - With the switch off, take_tile_for and the sys test in materialize short-circuit on sysmem_tiles(), so no tile gets SYS. The default path adds only one uncontended SYS_POOLS lock per submit and per retire, and note_hot/forget_hot per GPU heap. - Retired system-memory heaps wait for the sparse queue's fence and 2 s before they are dropped, live heap indexes never move (Option slots), and clear_heap runs before a slot is reused, as in the video pools. - The kernelx.rs change (alloc_as with hot, forget_hot before sparse_release) matches sparse::alloc_as and sparse::free. - No test assertion deleted or weakened; the diff is +481/-12 in two files and still merges cleanly onto current origin/main. </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 61 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Pipodi commented 2026-12-03 05:42:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-03T05:42:26Z.


merge-check
base: 395405e4c0
head: b98038bb43
merge: clean (git merge --no-ff onto 395405e4, merge 641b2e09; d3d12x/sparse.rs +479/-11, kernelx.rs +2/-1). main changed sparse.rs since the last check (#3702, staged-upload hashing); it does not touch the pool, tile or pending-mapping code this PR changes.
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 56 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The seven new sparse tests all ran and passed (none printed SKIPPED). With the new flush_pending() taken out again, pending_mappings_go_out_before_a_system_memory_heap_is_made fails (left: 1, right: 0), so the test covers the fix.
title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes, same env and frame presses for every run, 420 s each (ended by XCL_RUN_SECONDS); the binaries were warm (the measured-run gate passed). Presents/s are counted from the first 2 s activity window with more than 5000 dispatches (the cutscene's first) to the end. This differs from the 3000-draw window of my last check, so the numbers here are lower than there. Main 395405e4, two runs: 330 s and 342 s in the cutscenes, 2.02 and 2.09 presents/s, 0 removals, 0 crashes, peak video memory 21169 / 21550 MB local, peak private 43.4 / 44.2 GB. This PR, switch off (default), three runs: 338 s and 338 s at 2.01 and 2.11 presents/s, exit 0x0, 21225 / 21665 MB local, 43.4 / 44.7 GB. The third run hit a device hang (0x887a0006) at 210.7 s, after 89 s in the cutscenes at 1.98 presents/s. DRED reported device state 7 and no page fault, the same signature as the hang on main 5ad98adb itself in my last check (297.8 s). No system-memory heap was made in that run. With XCL_SPARSE_SYSMEM=1, one run: 336 s in the cutscenes, 2.02 presents/s, 0 removals, 0 crashes, peak video memory 16622 MB local (-4.6 to -5.0 GB against the switch-off runs) and 11924 MB non-local (+4.9 GB; the system-memory pools grew to 4096 MB, no heap refused), peak private 44.0 GB. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs.
review: read the incremental diff 84646d4d..b98038bb and the whole merge diff again. No blocking findings. 1) The fix: take_sys_tile drops SYS_POOLS, calls flush_pending() and locks again before CreateHeap, as take_tile does. Re-locking is needed because map_tiles -> pool_heap takes SYS_POOLS. Nothing read before the unlock is used after it: refuse is a test switch, and p is taken again. The State lock stays held, and there is one State per process, so the free/retired lists cannot change in between. If the flush's submit retires a heap meanwhile, a new heap is made instead of taking that one back, which is harmless. 2) Switch off, the behaviour is still the same as main: the new code is only on the system-memory path, which take_tile_for does not enter without XCL_SPARSE_SYSMEM. 3) The three review points left as follow-ups (pools process-global; the fallback to take_tile during the 1 s after a refusal; the SYS bit overlapping the sentinels) are as the author describes on this head. I found no path where a title creates a second State, and no SYS check that sees LAZY/SHADOW_POOL. 4) The other check on this head points out that a kept system-memory tile (XCL_VIEW_KEEP) is taken back unchanged at an address that is now in a GPU heap (ensure_mapped: only parked tiles are swapped). I see the same. The tile is still mapped, so it costs speed, not correctness, and only with the switch on. 5) Minor, as before: XCL_SPARSE_SYSMEM is not in README.md. When I looked, only CI had reported on this head (green); PR checks had not.
performance: default off: nothing per frame beyond one uncontended SYS_POOLS lock per submit and an AddRef/Release per tile-mapping call (same as the last head). Measured: the two full switch-off runs (2.01, 2.11 presents/s) match main's two runs (2.02, 2.09), and peak video and private memory match. The one device hang is not from this diff: it happened with the switch off, after no system-memory tile was ever made, with main's own hang signature. With the switch on: -4.6 to -5.0 GB video memory, +4.9 GB non-local, 2.02 presents/s, no removal.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title runs); Claude Code, Claude Opus 5.5

Replaces my check of 84646d4d (head moved).

<!-- greyfinch-sync:ivall/xcl:comment:7369025588 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7369025588). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-12-03T05:42:26Z. --- merge-check base: 395405e4c0ed814afde0610a724dc96a3af329de head: b98038bb434dfdc8257dde82b9b6a2f40ea6ab1c merge: clean (`git merge --no-ff` onto 395405e4, merge 641b2e09; d3d12x/sparse.rs +479/-11, kernelx.rs +2/-1). main changed sparse.rs since the last check (#3702, staged-upload hashing); it does not touch the pool, tile or pending-mapping code this PR changes. build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 56 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The seven new sparse tests all ran and passed (none printed SKIPPED). With the new `flush_pending()` taken out again, `pending_mappings_go_out_before_a_system_memory_heap_is_made` fails (`left: 1, right: 0`), so the test covers the fix. title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes, same env and frame presses for every run, 420 s each (ended by XCL_RUN_SECONDS); the binaries were warm (the measured-run gate passed). Presents/s are counted from the first 2 s activity window with more than 5000 dispatches (the cutscene's first) to the end. This differs from the 3000-draw window of my last check, so the numbers here are lower than there. Main 395405e4, two runs: 330 s and 342 s in the cutscenes, 2.02 and 2.09 presents/s, 0 removals, 0 crashes, peak video memory 21169 / 21550 MB local, peak private 43.4 / 44.2 GB. This PR, switch off (default), three runs: 338 s and 338 s at 2.01 and 2.11 presents/s, exit 0x0, 21225 / 21665 MB local, 43.4 / 44.7 GB. The third run hit a device hang (0x887a0006) at 210.7 s, after 89 s in the cutscenes at 1.98 presents/s. DRED reported device state 7 and no page fault, the same signature as the hang on main 5ad98adb itself in my last check (297.8 s). No system-memory heap was made in that run. With XCL_SPARSE_SYSMEM=1, one run: 336 s in the cutscenes, 2.02 presents/s, 0 removals, 0 crashes, peak video memory 16622 MB local (-4.6 to -5.0 GB against the switch-off runs) and 11924 MB non-local (+4.9 GB; the system-memory pools grew to 4096 MB, no heap refused), peak private 44.0 GB. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs. review: read the incremental diff 84646d4d..b98038bb and the whole merge diff again. No blocking findings. 1) The fix: `take_sys_tile` drops `SYS_POOLS`, calls `flush_pending()` and locks again before `CreateHeap`, as `take_tile` does. Re-locking is needed because `map_tiles` -> `pool_heap` takes `SYS_POOLS`. Nothing read before the unlock is used after it: `refuse` is a test switch, and `p` is taken again. The State lock stays held, and there is one State per process, so the free/retired lists cannot change in between. If the flush's submit retires a heap meanwhile, a new heap is made instead of taking that one back, which is harmless. 2) Switch off, the behaviour is still the same as main: the new code is only on the system-memory path, which `take_tile_for` does not enter without `XCL_SPARSE_SYSMEM`. 3) The three review points left as follow-ups (pools process-global; the fallback to `take_tile` during the 1 s after a refusal; the `SYS` bit overlapping the sentinels) are as the author describes on this head. I found no path where a title creates a second `State`, and no `SYS` check that sees `LAZY`/`SHADOW_POOL`. 4) The other check on this head points out that a `kept` system-memory tile (`XCL_VIEW_KEEP`) is taken back unchanged at an address that is now in a GPU heap (`ensure_mapped`: only `parked` tiles are swapped). I see the same. The tile is still mapped, so it costs speed, not correctness, and only with the switch on. 5) Minor, as before: `XCL_SPARSE_SYSMEM` is not in README.md. When I looked, only `CI` had reported on this head (green); `PR checks` had not. performance: default off: nothing per frame beyond one uncontended `SYS_POOLS` lock per submit and an AddRef/Release per tile-mapping call (same as the last head). Measured: the two full switch-off runs (2.01, 2.11 presents/s) match main's two runs (2.02, 2.09), and peak video and private memory match. The one device hang is not from this diff: it happened with the switch off, after no system-memory tile was ever made, with main's own hang signature. With the switch on: -4.6 to -5.0 GB video memory, +4.9 GB non-local, 2.02 presents/s, no removal. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title runs); Claude Code, Claude Opus 5.5 Replaces my check of 84646d4d (head moved).
stijn-boer commented 2026-12-03 06:48:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-03T06:48:54Z.


@throny when I tested it main still wouldn't reach world loading on main.

That's is why I would kindly request you to merge in #3707 and #3455 as they help get further.

I'll check today if I can find some combination of PRs that will let me run all test.

<!-- greyfinch-sync:ivall/xcl:comment:7370263449 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7370263449). Originally posted by [stijn-boer](https://github.com/stijn-boer) on 2026-12-03T06:48:54Z. --- @throny when I tested it main still wouldn't reach world loading on main. That's is why I would kindly request you to merge in #3707 and #3455 as they help get further. I'll check today if I can find some combination of PRs that will let me run all test.
throny commented 2026-12-03 17:20:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T17:20:52Z.


@stijn-boer thanks. On our side, current main reaches the world:

  • Build: main e99b0bdf, release, plus our scripted-press patch.
  • Hardware: RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300.
  • Run: 300 s in the world with XCL_RESIDENCY_PRIORITY=1, starting on an empty shader cache.
  • Result: first frame after 345 s, 2.44 presents/s, no crash, no device removal, 0 Aftermath dumps.

So what stops you there may depend on your setup. Could you post your GPU and driver, the commit you ran, the switches you set, and the last lines of the log before it stops (counts and messages only, no game data)? Then we can see whether #3707 or #3455 is the actual fix for you.

#3707 is already merged (12:48 UTC today), so main e99b0bdf includes it. Merges are paused for the moment; I am running a merge check of #3455 now.

Claude Code, Claude Opus 5.5 (ran the test and wrote this).

<!-- greyfinch-sync:ivall/xcl:comment:7386362143 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3613#issuecomment-7386362143). Originally posted by [throny](https://github.com/throny) on 2026-12-03T17:20:52Z. --- @stijn-boer thanks. On our side, current main reaches the world: - **Build:** main `e99b0bdf`, release, plus our scripted-press patch. - **Hardware:** RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300. - **Run:** 300 s in the world with `XCL_RESIDENCY_PRIORITY=1`, starting on an empty shader cache. - **Result:** first frame after 345 s, 2.44 presents/s, no crash, no device removal, 0 Aftermath dumps. So what stops you there may depend on your setup. Could you post your GPU and driver, the commit you ran, the switches you set, and the last lines of the log before it stops (counts and messages only, no game data)? Then we can see whether #3707 or #3455 is the actual fix for you. #3707 is already merged (12:48 UTC today), so main `e99b0bdf` includes it. Merges are paused for the moment; I am running a merge check of #3455 now. Claude Code, Claude Opus 5.5 (ran the test and wrote this).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3613:upstream-pr/3613'
git switch 'upstream-pr/3613'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3613'
git switch 'upstream-pr/3613'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3613'
git switch 'upstream-pr/3613'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3613'
git switch 'main'
git merge --squash 'upstream-pr/3613'
git switch 'main'
git merge --ff-only 'upstream-pr/3613'
git switch 'main'
git merge 'upstream-pr/3613'
git push origin 'main'
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!3613
No description provided.