D3D12.X: XCL's render-target arenas and window pools get a residency priority #3156

Merged
Raul-Paiva merged 1 commit from upstream-pr/3156 into main 2026-12-01 12:23:02 +00:00
Raul-Paiva commented 2026-11-28 13:37:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-28T13:37:15Z.


On an 8 GB card a retail title's world holds about 16 GB of local video memory against a 7.25 GB DXGI budget (10 GB with XCL_TEXTURE_LEVEL_PAGES=1 XCL_SPARSE_LAZY=1). Windows then demotes allocations to system memory with no hint which ones matter, so per-frame render targets and the title's buffers can be paged out while idle texture pages stay resident. XCL never calls ID3D12Device1::SetResidencyPriority on its own heaps; #3007 does it only for the GPU_UPLOAD segment under XCL_UMA_DRIVER=mixed, and this builds on the rest.

With XCL_RESIDENCY_PRIORITY=1 (off by default so it can be measured first) XCL's own heaps get a priority by role, once; nothing runs per frame. By default vram::place puts a render target or depth buffer on texture pages, not in an arena (andrewDoing's measurement), so a 64 MiB texture page pool gets HIGH once it holds pages of a render target, depth buffer or UAV texture; a pool of only sampled textures stays at the default. Related: the "residency under a budget" work in #2688 and #3098 (evicting texture mips): this does not evict anything, it only tells Windows what to demote last.

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs:
    • HeapRole (target arena, window pool, texture pages holding a target, other texture pages), pages_role and the pure mapping role_priority: the first three HIGH, other texture pages NORMAL (the default, no call); nothing MAXIMUM, which stays #3007's.
    • set_heap_priority behind the switch, called from arena_heap and alloc_pool_heap; a failure is logged once and leaves the default; the heaps given HIGH are counted by role and logged at each power of two of the total.
    • Pages::keep_pools: when a target is mapped onto texture pages (place_on_pages, and remap_if_unmapped when a superseded target comes back), the pools holding its pages get HIGH, each pool once (newly_high); a reclaimed pool's slot forgets it.
    • unit tests role_priority_keeps_targets_and_windows_over_texture_pages and a_target_on_texture_pages_gets_its_pools_high_once.
  • crates/xcl/src/hle/d3d12x/sparse.rs: a new sparse-window tile pool gets HIGH; a retired pool taken back keeps the priority it got.

Tested

  • Hardware: RTX 3070 Laptop GPU 8 GB, driver 621.40, i7-11800H, 32 GB, Windows 10 19045, rustc 1.100.0, release build.
  • Base for the comparison: main 5b0d5fa3 (same commands, same machine). The head pushed here is the same change rebased onto main 9dfbe3ea without conflicts; main's newer commits also change vram.rs, which the rebase merged. CI on this head stopped with an access violation (0xc0000005) in the lib test binary while eh::tests::the_process_ends_while_another_thread_holds_the_heap was running, a test of code this PR does not touch (it changes only sparse.rs and vram.rs); I cannot rerun it from my side. The test counts below were measured before that rebase.
  • On the previous head 2a96db19 (the same change on main d52ff48c), the lib tests of the modules this PR touches (hle::d3d12x::sparse, hle::d3d12x::vram), release, serial, with the 20 skips: 199 passed, 0 failed, 2 ignored.
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4: the lib test binary ends early on main too (exit 0x80004005 after sparse upload preparation still failed after bounded retries), so the lib was also run alone, serially (--test-threads=1), with --skip for the 20 tests that end the binary on main (6 list_x, 12 sparse, 1 texture_upload, 1 uma_driver; each passes alone).
  • This PR tested at 7cf99beb (on main 5b0d5fa3):
    • integration tests: 138 passed, 1 failed, 20 ignored; main: 139 passed, 0 failed, 20 ignored. The failure, gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs ("releasing the title PSOs releases their two-pass state", 1 vs 0), is intermittent on main too: run 8 times alone, it failed 2 times on this head and 2 times on main.
    • lib, serial with the 20 skips: 2605 passed, 13 failed, 29 ignored; main: 2604 passed, 13 failed, 29 ignored. The 13 failures are main's except that vram::d32s8_targets_take_their_own_size_of_video_memory (which fails on main in the long run) ended the binary here instead and was skipped, and alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads failed. The first passes alone 2/2 on this head and on main; the second passes alone 3/3 on main and failed the same way in the serial run of #3119, whose change does not reach it. The first needs about 1 GB of depth targets and depends on what the run before left in video memory.
    • The suite does not set XCL_RESIDENCY_PRIORITY, so the change is off there; the two new unit tests pass.
  • SKIPPED on this adapter (same on main): the wave64 forms (no wave64), three f16/f32 per-lane forms refused by the recompiler, and the heap-window tests (no heap windows).

Regression run
scripts/smoke.ps1 -Seconds 120 -Title 'retail title A', release builds of clean trees, one after the other on the machine in Tested, with XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000. The title is left on its own, with no input; the shader cache was warmed by two runs of main before.

main:

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 3070 Laptop GPU
title: retail title A
seconds: 120
exit: 0x0
frames shown: 3362 (PresentX 3362)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16519 MB

This PR:

xcl-smoke v1
commit: 813778957e7acdb610e7d79fdddf682a4a899716
gpu: NVIDIA GeForce RTX 3070 Laptop GPU
title: retail title A
seconds: 120
exit: 0x0
frames shown: 3360 (PresentX 3360)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 16556 MB

Not tested

  • A world run with the switch on vs off, and how many heaps get HIGH in it.
  • Eviction under a budget, frame times.
  • AMD and Intel GPUs, cards with more than 8 GB.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, and ran the tests; I read the diff.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5540672902 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156). Originally posted by [Raul-Paiva](https://github.com/Raul-Paiva) on 2026-11-28T13:37:15Z. --- On an 8 GB card a retail title's world holds about 16 GB of local video memory against a 7.25 GB DXGI budget (10 GB with `XCL_TEXTURE_LEVEL_PAGES=1 XCL_SPARSE_LAZY=1`). Windows then demotes allocations to system memory with no hint which ones matter, so per-frame render targets and the title's buffers can be paged out while idle texture pages stay resident. XCL never calls `ID3D12Device1::SetResidencyPriority` on its own heaps; #3007 does it only for the `GPU_UPLOAD` segment under `XCL_UMA_DRIVER=mixed`, and this builds on the rest. With `XCL_RESIDENCY_PRIORITY=1` (off by default so it can be measured first) XCL's own heaps get a priority by role, once; nothing runs per frame. By default `vram::place` puts a render target or depth buffer on texture pages, not in an arena (andrewDoing's measurement), so a 64 MiB texture page pool gets `HIGH` once it holds pages of a render target, depth buffer or UAV texture; a pool of only sampled textures stays at the default. Related: the "residency under a budget" work in #2688 and #3098 (evicting texture mips): this does not evict anything, it only tells Windows what to demote last. **What is in it** - `crates/xcl/src/hle/d3d12x/vram.rs`: - `HeapRole` (target arena, window pool, texture pages holding a target, other texture pages), `pages_role` and the pure mapping `role_priority`: the first three `HIGH`, other texture pages `NORMAL` (the default, no call); nothing `MAXIMUM`, which stays #3007's. - `set_heap_priority` behind the switch, called from `arena_heap` and `alloc_pool_heap`; a failure is logged once and leaves the default; the heaps given `HIGH` are counted by role and logged at each power of two of the total. - `Pages::keep_pools`: when a target is mapped onto texture pages (`place_on_pages`, and `remap_if_unmapped` when a superseded target comes back), the pools holding its pages get `HIGH`, each pool once (`newly_high`); a reclaimed pool's slot forgets it. - unit tests `role_priority_keeps_targets_and_windows_over_texture_pages` and `a_target_on_texture_pages_gets_its_pools_high_once`. - `crates/xcl/src/hle/d3d12x/sparse.rs`: a new sparse-window tile pool gets `HIGH`; a retired pool taken back keeps the priority it got. **Tested** - Hardware: RTX 3070 Laptop GPU 8 GB, driver 621.40, i7-11800H, 32 GB, Windows 10 19045, rustc 1.100.0, release build. - Base for the comparison: `main` 5b0d5fa3 (same commands, same machine). The head pushed here is the same change rebased onto `main` 9dfbe3ea without conflicts; `main`'s newer commits also change `vram.rs`, which the rebase merged. CI on this head stopped with an access violation (0xc0000005) in the lib test binary while `eh::tests::the_process_ends_while_another_thread_holds_the_heap` was running, a test of code this PR does not touch (it changes only `sparse.rs` and `vram.rs`); I cannot rerun it from my side. The test counts below were measured before that rebase. - On the previous head 2a96db19 (the same change on `main` d52ff48c), the lib tests of the modules this PR touches (`hle::d3d12x::sparse`, `hle::d3d12x::vram`), release, serial, with the 20 skips: 199 passed, 0 failed, 2 ignored. - `cargo test --release --workspace --no-fail-fast -- --test-threads=4`: the lib test binary ends early on `main` too (exit 0x80004005 after `sparse upload preparation still failed after bounded retries`), so the lib was also run alone, serially (`--test-threads=1`), with `--skip` for the 20 tests that end the binary on `main` (6 `list_x`, 12 `sparse`, 1 `texture_upload`, 1 `uma_driver`; each passes alone). - This PR tested at 7cf99beb (on `main` 5b0d5fa3): - integration tests: 138 passed, 1 failed, 20 ignored; `main`: 139 passed, 0 failed, 20 ignored. The failure, `gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` ("releasing the title PSOs releases their two-pass state", 1 vs 0), is intermittent on `main` too: run 8 times alone, it failed 2 times on this head and 2 times on `main`. - lib, serial with the 20 skips: 2605 passed, 13 failed, 29 ignored; `main`: 2604 passed, 13 failed, 29 ignored. The 13 failures are `main`'s except that `vram::d32s8_targets_take_their_own_size_of_video_memory` (which fails on `main` in the long run) ended the binary here instead and was skipped, and `alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads` failed. The first passes alone 2/2 on this head and on `main`; the second passes alone 3/3 on `main` and failed the same way in the serial run of #3119, whose change does not reach it. The first needs about 1 GB of depth targets and depends on what the run before left in video memory. - The suite does not set `XCL_RESIDENCY_PRIORITY`, so the change is off there; the two new unit tests pass. - SKIPPED on this adapter (same on `main`): the wave64 forms (no wave64), three f16/f32 per-lane forms refused by the recompiler, and the heap-window tests (no heap windows). **Regression run** `scripts/smoke.ps1 -Seconds 120 -Title 'retail title A'`, release builds of clean trees, one after the other on the machine in **Tested**, with `XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000`. The title is left on its own, with no input; the shader cache was warmed by two runs of `main` before. `main`: ``` xcl-smoke v1 commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b gpu: NVIDIA GeForce RTX 3070 Laptop GPU title: retail title A seconds: 120 exit: 0x0 frames shown: 3362 (PresentX 3362) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16519 MB ``` This PR: ``` xcl-smoke v1 commit: 813778957e7acdb610e7d79fdddf682a4a899716 gpu: NVIDIA GeForce RTX 3070 Laptop GPU title: retail title A seconds: 120 exit: 0x0 frames shown: 3360 (PresentX 3360) presents per 2 s (last 3): 61 60 61 device removals: 0 crashes: 0 peak commit: 16556 MB ``` **Not tested** - A world run with the switch on vs off, and how many heaps get `HIGH` in it. - Eviction under a budget, frame times. - AMD and Intel GPUs, cards with more than 8 GB. **AI use** - Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, and ran the tests; I read the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
andrewDoing commented 2026-11-28 17:48:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T17:48:08Z.


On an RTX 5070, enabling residency priority alone issued no HIGH request for the three target placements I tested. All three went through tiled texture pages under the default backing policy. Forcing arena backing supplied a positive control: the native driver accepted HIGH for each of the three arena heaps.

I tested exact head 599a31dc95214c06f3f6d71e93318bb17fa76532, native Windows, RTX 5070 12 GB, NVIDIA 616.92. Each fresh process called production vram::place for three live, nonoverlapping 256×256 single-sample targets: RGBA8 render target, D32_FLOAT depth target, and R32_UINT UAV. Test-only logging recorded the heap role on creation and the result of each actual SetResidencyPriority call. I also checked the arena registry and individual tile mappings after each placement.

Backing policy Priority switch Observed backing Native HIGH calls
Default 0 All three in texture pages, four tiles each 0
Default 1 Same; one new pool classified TexturePages 0
XCL_VRAM_ARENAS=1 0 Three distinct target arenas 0
XCL_VRAM_ARENAS=1 1 Three distinct target arenas 3 successful

For the proposed world-load comparison, counting target placements by actual backing would help interpret an on/off result: a hot render or depth target can share a default-priority texture-page pool on this adapter. This was a bounded placement test, four passes and zero skips. It did not exercise sparse-window buffer pools or measure OS eviction order, residency under pressure, frame time, or a retail workload.

AI use: OpenAI Codex (GPT-6) prepared the test-only fixture, ran the native controls, and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7243297827 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7243297827). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T17:48:08Z. --- **On an RTX 5070, enabling residency priority alone issued no HIGH request for the three target placements I tested.** All three went through tiled texture pages under the default backing policy. Forcing arena backing supplied a positive control: the native driver accepted HIGH for each of the three arena heaps. I tested exact head `599a31dc95214c06f3f6d71e93318bb17fa76532`, native Windows, RTX 5070 12 GB, NVIDIA 616.92. Each fresh process called production `vram::place` for three live, nonoverlapping 256×256 single-sample targets: RGBA8 render target, D32_FLOAT depth target, and R32_UINT UAV. Test-only logging recorded the heap role on creation and the result of each actual `SetResidencyPriority` call. I also checked the arena registry and individual tile mappings after each placement. | Backing policy | Priority switch | Observed backing | Native HIGH calls | | --- | ---: | --- | ---: | | Default | 0 | All three in texture pages, four tiles each | 0 | | Default | 1 | Same; one new pool classified `TexturePages` | 0 | | `XCL_VRAM_ARENAS=1` | 0 | Three distinct target arenas | 0 | | `XCL_VRAM_ARENAS=1` | 1 | Three distinct target arenas | 3 successful | For the proposed world-load comparison, counting target placements by actual backing would help interpret an on/off result: a hot render or depth target can share a default-priority texture-page pool on this adapter. This was a bounded placement test, four passes and zero skips. It did not exercise sparse-window buffer pools or measure OS eviction order, residency under pressure, frame time, or a retail workload. AI use: OpenAI Codex (GPT-6) prepared the test-only fixture, ran the native controls, and wrote this report.
Raul-Paiva commented 2026-11-30 00:14:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-30T00:14:26Z.


Thanks @andrewDoing, the placement test and the arena control made this clear. Confirmed: vram::place puts a target on texture pages (place_on_pages) unless XCL_VRAM_ARENAS=1 is set or the target cannot be reserved, and those 64 MiB pools were NORMAL, so with the default backing the switch gave HIGH to no target.

What changed (amended into the single commit; rebased onto main, head now a067891d):

  • a texture page pool holding pages of a render target, depth buffer or UAV texture now gets HIGH when the target is mapped onto it (place_on_pages, and remap_if_unmapped when a superseded target comes back), once per pool and never per frame; a pool of only sampled textures stays NORMAL, and a reclaimed pool's slot forgets it
  • nothing changes with the switch off, and no placement moves; still no MAXIMUM (that stays #3007's)
  • the heaps given HIGH are counted by role (arenas, window tile pools, texture page pools holding targets) and logged at each power of two of the total, as you suggested, so a world run can say how many got it
  • unit tests: role_priority covers the new role, and a new test checks that render, depth and UAV flags give their pools HIGH, each pool once

The full suite was run against main (counts in the description, no new failure); the world run with the switch off/on and the smoke runs are still to come.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7265090879 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7265090879). Originally posted by [Raul-Paiva](https://github.com/Raul-Paiva) on 2026-11-30T00:14:26Z. --- Thanks @andrewDoing, the placement test and the arena control made this clear. Confirmed: `vram::place` puts a target on texture pages (`place_on_pages`) unless `XCL_VRAM_ARENAS=1` is set or the target cannot be reserved, and those 64 MiB pools were NORMAL, so with the default backing the switch gave HIGH to no target. What changed (amended into the single commit; rebased onto `main`, head now `a067891d`): - a texture page pool holding pages of a render target, depth buffer or UAV texture now gets HIGH when the target is mapped onto it (`place_on_pages`, and `remap_if_unmapped` when a superseded target comes back), once per pool and never per frame; a pool of only sampled textures stays NORMAL, and a reclaimed pool's slot forgets it - nothing changes with the switch off, and no placement moves; still no MAXIMUM (that stays #3007's) - the heaps given HIGH are counted by role (arenas, window tile pools, texture page pools holding targets) and logged at each power of two of the total, as you suggested, so a world run can say how many got it - unit tests: `role_priority` covers the new role, and a new test checks that render, depth and UAV flags give their pools HIGH, each pool once The full suite was run against `main` (counts in the description, no new failure); the world run with the switch off/on and the smoke runs are still to come. Written with Claude Code (Claude Opus 5.5).
claudetools-gh commented 2026-12-01 09:26:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by claudetools-gh on 2026-12-01T09:26:31Z.


World test of 81377895 with XCL_RESIDENCY_PRIORITY=1, which the PR lists under Not tested. Not a merge-check: I cherry-picked the commit cleanly onto an older lab line of mine, not onto main, and ran its two new unit tests (2 passed). I did not run the full suite or smoke.ps1.

  • RTX 5070 Ti 16 GB, driver 621.40, Windows 11, release build.
  • Retail title, prologue cell. The game clock is dilated, so world frame N shows the same scene in every run.
  • Video memory runs ~4.5–5 GB over a 14.9 GB budget.
  • Log: HIGH given to 21 render-target arenas, 1956 window tile pools, 71 texture page pools holding targets. No crash or device removal in 4 runs.

Seconds per 100 world frames (frames 50→150), same exe, the write-combined GPU heaps in video memory as #505 describes:

s / 100 frames heaviest compute program
without the switch (runs 593/594/596) 81–83 128–160 ms
XCL_RESIDENCY_PRIORITY=1 (595) 44 17 ms
XCL_RESIDENCY_PRIORITY=1 + the heaps in the sparse windows (597/598/599/600) 32–47, typically 42–47 1.7–18 ms

Without the priorities, Windows demotes per-frame targets and tile pools while over budget, and the GPU sits at ~59 W with ~4.6 GB/s read over PCIe. On this card the switch is the larger half of a ~2.2× gain. Not tested: main itself, AMD, and cards that are not over budget.

AI-assisted.

<!-- greyfinch-sync:ivall/xcl:comment:7306705723 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7306705723). Originally posted by [claudetools-gh](https://github.com/claudetools-gh) on 2026-12-01T09:26:31Z. --- World test of 81377895 with `XCL_RESIDENCY_PRIORITY=1`, which the PR lists under **Not tested**. Not a merge-check: I cherry-picked the commit cleanly onto an older lab line of mine, not onto `main`, and ran its two new unit tests (2 passed). I did not run the full suite or `smoke.ps1`. - RTX 5070 Ti 16 GB, driver 621.40, Windows 11, release build. - Retail title, prologue cell. The game clock is dilated, so world frame N shows the same scene in every run. - Video memory runs ~4.5–5 GB over a 14.9 GB budget. - Log: `HIGH given to 21 render-target arenas, 1956 window tile pools, 71 texture page pools holding targets`. No crash or device removal in 4 runs. Seconds per 100 world frames (frames 50→150), same exe, the write-combined GPU heaps in video memory as #505 describes: | | s / 100 frames | heaviest compute program | |---|---|---| | without the switch (runs 593/594/596) | 81–83 | 128–160 ms | | `XCL_RESIDENCY_PRIORITY=1` (595) | **44** | 17 ms | | `XCL_RESIDENCY_PRIORITY=1` + the heaps in the sparse windows (597/598/599/600) | **32–47**, typically 42–47 | 1.7–18 ms | Without the priorities, Windows demotes per-frame targets and tile pools while over budget, and the GPU sits at ~59 W with ~4.6 GB/s read over PCIe. On this card the switch is the larger half of a ~2.2× gain. Not tested: `main` itself, AMD, and cards that are not over budget. AI-assisted.
Foniass commented 2026-12-01 09:38:26 +00:00 (Migrated from github.com)

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


Triage (#1607) – head 8137789

No open or merged PR sets residency priorities on these heaps. The merged #3007 (XCL_UMA_UPLOAD_PRIORITY) covers only the UMA upload segment, and #3098 / #3037 handle VRAM pressure by evicting mips or gating uploads, not through residency priority.
No problems found in the diff. It is opt-in (XCL_RESIDENCY_PRIORITY=1). Minor: the set_heap_priority(.., HeapRole::TexturePages) call in alloc_pool_heap (vram.rs) never does anything because role_priority returns None for that role.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7306992117 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7306992117). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:38:26Z. --- **Triage (#1607)** – head 8137789 No open or merged PR sets residency priorities on these heaps. The merged #3007 (`XCL_UMA_UPLOAD_PRIORITY`) covers only the UMA upload segment, and #3098 / #3037 handle VRAM pressure by evicting mips or gating uploads, not through residency priority. No problems found in the diff. It is opt-in (`XCL_RESIDENCY_PRIORITY=1`). Minor: the `set_heap_priority(.., HeapRole::TexturePages)` call in `alloc_pool_heap` (vram.rs) never does anything because `role_priority` returns `None` for that role. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 10:13:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T10:13:53Z.


Queued an in-world A/B of this on an RTX 4080 16 GB: 9dfbe3ea + this head 81377895, same build with XCL_RESIDENCY_PRIORITY unset vs =1, 900 s each with XCL_GPU_PROFILE=1. Our runs sit 3.3–4 GB over the video-memory budget in the world (render targets ~6.4 GB of it), so this is exactly the situation it targets; numbers here when done.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7307869402 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7307869402). Originally posted by [throny](https://github.com/throny) on 2026-12-01T10:13:53Z. --- Queued an in-world A/B of this on an RTX 4080 16 GB: `9dfbe3ea` + this head `81377895`, same build with `XCL_RESIDENCY_PRIORITY` unset vs `=1`, 900 s each with `XCL_GPU_PROFILE=1`. Our runs sit 3.3–4 GB over the video-memory budget in the world (render targets ~6.4 GB of it), so this is exactly the situation it targets; numbers here when done. AI use: Claude Code (Claude Opus 5.5).
Foniass commented 2026-12-01 10:42:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:42:44Z.


merge-check
base: 493dbd3dd0
head: 813778957e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 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 (+150/-1). With XCL_RESIDENCY_PRIORITY unset it returns early. With it set, XCL's render-target arenas, window pools and texture-page pools get ID3D12Device1::SetResidencyPriority(HIGH) once per heap (vram.rs ~1029, through ID3D12Pageable), never MAXIMUM, which stays #3007's. Findings: (1) The HIGH set only grows. A texture-page pool keeps HIGH after its target's pages are freed and it fills with sampled textures; the mark goes only when the whole heap is reclaimed (keep_pools ~2183, take_heap ~1724). In claudetools' log, 1956 window pools x 4 MiB plus 71 page pools x 64 MiB plus 21 arenas come to about 12 GiB against a 14.9 GB budget. On the author's 8 GB card the HIGH set alone would pass the budget, and the priority would stop separating anything (unverified). (2) Only the pure helpers are tested; nothing checks that place_on_pages (~2486) or remap_if_unmapped (~2616) reach keep_pools. (3) The only on / off measurement (81 -> 44 s per 100 frames in a world cell) was a cherry-pick onto a lab branch, not this head. The README doesn't mention the switch. Nit: the TexturePages call at ~1684 never does anything. The PR's red CI is the lib-binary access violation in the eh / agility tests (#1487), seen on unrelated PRs too. Fine: off by default, one call per heap and never per frame, the level-pages path covers only flagless textures so no targets are missed, and a retired window pool taken back keeps its heap and priority.
performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (b108d492): 1670 -> 1696 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17174 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with XCL_RESIDENCY_PRIORITY=1: 1676 frames shown (last presents per 2 s: 60 60 60), peak commit 18004 MB, 0 device removals, 0 crashes; the log shows HIGH given to window tile pools. On this 16 GB card a 60 s run stays under budget, so it shows only that turning it on breaks nothing.
verdict: safe to merge (opt-in; a README line for XCL_RESIDENCY_PRIORITY and a test that place_on_pages / remap_if_unmapped reach keep_pools would round it off)
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:7308594984 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7308594984). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:42:44Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 813778957e7acdb610e7d79fdddf682a4a899716 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 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 (+150/-1). With `XCL_RESIDENCY_PRIORITY` unset it returns early. With it set, XCL's render-target arenas, window pools and texture-page pools get `ID3D12Device1::SetResidencyPriority(HIGH)` once per heap (`vram.rs` ~1029, through `ID3D12Pageable`), never `MAXIMUM`, which stays #3007's. Findings: (1) **The HIGH set only grows.** A texture-page pool keeps HIGH after its target's pages are freed and it fills with sampled textures; the mark goes only when the whole heap is reclaimed (`keep_pools` ~2183, `take_heap` ~1724). In claudetools' log, 1956 window pools x 4 MiB plus 71 page pools x 64 MiB plus 21 arenas come to about 12 GiB against a 14.9 GB budget. On the author's 8 GB card the HIGH set alone would pass the budget, and the priority would stop separating anything (unverified). (2) Only the pure helpers are tested; nothing checks that `place_on_pages` (~2486) or `remap_if_unmapped` (~2616) reach `keep_pools`. (3) The only on / off measurement (81 -> 44 s per 100 frames in a world cell) was a cherry-pick onto a lab branch, not this head. The README doesn't mention the switch. Nit: the `TexturePages` call at ~1684 never does anything. The PR's red CI is the lib-binary access violation in the eh / agility tests (#1487), seen on unrelated PRs too. Fine: off by default, one call per heap and never per frame, the level-pages path covers only flagless textures so no targets are missed, and a retired window pool taken back keeps its heap and priority. performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (b108d492): 1670 -> 1696 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17174 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with `XCL_RESIDENCY_PRIORITY=1`: 1676 frames shown (last presents per 2 s: 60 60 60), peak commit 18004 MB, 0 device removals, 0 crashes; the log shows HIGH given to window tile pools. On this 16 GB card a 60 s run stays under budget, so it shows only that turning it on breaks nothing. verdict: safe to merge (opt-in; a README line for `XCL_RESIDENCY_PRIORITY` and a test that `place_on_pages` / `remap_if_unmapped` reach `keep_pools` would round it off) 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.
throny commented 2026-12-01 11:02:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T11:02:45Z.


First in-world pair, RTX 4080 16 GB (621.40), 9dfbe3ea + this head 81377895 (plus our local input-timing patch), same build, same save and inputs, 900 s each, XCL_TWO_PASS_MB=512, XCL_GPU_PROFILE=1:

run XCL_RESIDENCY_PRIORITY presents/s after 240 s video memory peak / budget most expensive program, GPU ms per call
369 unset 2.22 18.6 / 15.2 GB 39.4
370 1 3.37 18.8 / 15.1 GB 18.6

No device removal or crash in either. That is the largest single gain we have measured from a switch (+52 %), while video memory stays just as far over budget, which fits the switch deciding what stays resident rather than how much. A repeat pair in reverse order is running to rule out run-to-run noise; I'll add it here.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7309089936 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7309089936). Originally posted by [throny](https://github.com/throny) on 2026-12-01T11:02:45Z. --- First in-world pair, RTX 4080 16 GB (621.40), `9dfbe3ea` + this head `81377895` (plus our local input-timing patch), same build, same save and inputs, 900 s each, `XCL_TWO_PASS_MB=512`, `XCL_GPU_PROFILE=1`: | run | `XCL_RESIDENCY_PRIORITY` | presents/s after 240 s | video memory peak / budget | most expensive program, GPU ms per call | |---|---|---|---|---| | 369 | unset | 2.22 | 18.6 / 15.2 GB | 39.4 | | 370 | 1 | **3.37** | 18.8 / 15.1 GB | 18.6 | No device removal or crash in either. That is the largest single gain we have measured from a switch (+52 %), while video memory stays just as far over budget, which fits the switch deciding *what* stays resident rather than how much. A repeat pair in reverse order is running to rule out run-to-run noise; I'll add it here. AI use: Claude Code (Claude Opus 5.5).
throny commented 2026-12-01 11:34:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T11:34:13Z.


Repeat pair in reverse order confirms it (same build and settings as above):

run XCL_RESIDENCY_PRIORITY presents/s after 240 s most expensive program, GPU ms per call
369 unset 2.22 39.4
370 1 3.37 18.6
371 1 3.49 18.7
372 unset 2.39 38.2

So about +50 % presents/s and half the GPU time per call for the most expensive program on an RTX 4080 16 GB, with video memory just as far over budget either way; no device removal or crash in four runs. I'm doing a merge check on this head next.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7309824003 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7309824003). Originally posted by [throny](https://github.com/throny) on 2026-12-01T11:34:13Z. --- Repeat pair in reverse order confirms it (same build and settings as above): | run | `XCL_RESIDENCY_PRIORITY` | presents/s after 240 s | most expensive program, GPU ms per call | |---|---|---|---| | 369 | unset | 2.22 | 39.4 | | 370 | 1 | 3.37 | 18.6 | | 371 | 1 | 3.49 | 18.7 | | 372 | unset | 2.39 | 38.2 | So about **+50 % presents/s** and half the GPU time per call for the most expensive program on an RTX 4080 16 GB, with video memory just as far over budget either way; no device removal or crash in four runs. I'm doing a merge check on this head next. AI use: Claude Code (Claude Opus 5.5).
throny commented 2026-12-01 11:34:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T11:34:15Z.


merge-check claim
head: 813778957e

<!-- greyfinch-sync:ivall/xcl:comment:7309824620 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7309824620). Originally posted by [throny](https://github.com/throny) on 2026-12-01T11:34:15Z. --- merge-check claim head: 813778957e7acdb610e7d79fdddf682a4a899716
throny commented 2026-12-01 11:44:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T11:44:05Z.


merge-check
base: 493dbd3dd0
head: 813778957e (unchanged since the claim)
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines in the log: 22 gpu, 1 hle, 1 shaders, 1 heap_window_out_of_memory test; skips are not coverage); no test binary ended abnormally; no base comparison needed
review: Read the whole diff (sparse.rs +2, vram.rs +~140 with two tests). Heaps XCL creates (render-target arenas, sparse window tile pools, texture page pools that hold a render target / depth buffer / UAV texture) get D3D12_RESIDENCY_PRIORITY_HIGH through ID3D12Device1::SetResidencyPriority once, when made or when a target's pages first land in a pool (newly_high keeps each pool to one call; the entry is removed in take_heap); a failure is logged once and leaves the default, nothing is called per frame. Both tests are pure logic (role to priority mapping, the once-per-pool set) and run without a GPU, so they do not exercise SetResidencyPriority itself or the driver's behaviour; that rests on the in-world measurement. Minor: a pool that got HIGH keeps it after its target pages are freed until the heap is released; the GIVEN log counters are process-wide statics.
performance: in-world on this RTX 4080, four 900 s runs of 9dfbe3ea + this head (not this merge base): XCL_RESIDENCY_PRIORITY=1 gave 3.37 and 3.49 presents/s vs 2.22 and 2.39 unset, the most expensive program's GPU time per call halved (39 -> 19 ms); off by default, so merging changes nothing until the switch is set.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report and made the in-world runs

<!-- greyfinch-sync:ivall/xcl:comment:7310059309 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7310059309). Originally posted by [throny](https://github.com/throny) on 2026-12-01T11:44:05Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 813778957e7acdb610e7d79fdddf682a4a899716 (unchanged since the claim) merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines in the log: 22 gpu, 1 hle, 1 shaders, 1 heap_window_out_of_memory test; skips are not coverage); no test binary ended abnormally; no base comparison needed review: Read the whole diff (sparse.rs +2, vram.rs +~140 with two tests). Heaps XCL creates (render-target arenas, sparse window tile pools, texture page pools that hold a render target / depth buffer / UAV texture) get D3D12_RESIDENCY_PRIORITY_HIGH through ID3D12Device1::SetResidencyPriority once, when made or when a target's pages first land in a pool (`newly_high` keeps each pool to one call; the entry is removed in `take_heap`); a failure is logged once and leaves the default, nothing is called per frame. Both tests are pure logic (role to priority mapping, the once-per-pool set) and run without a GPU, so they do not exercise SetResidencyPriority itself or the driver's behaviour; that rests on the in-world measurement. Minor: a pool that got HIGH keeps it after its target pages are freed until the heap is released; the `GIVEN` log counters are process-wide statics. performance: in-world on this RTX 4080, four 900 s runs of 9dfbe3ea + this head (not this merge base): XCL_RESIDENCY_PRIORITY=1 gave 3.37 and 3.49 presents/s vs 2.22 and 2.39 unset, the most expensive program's GPU time per call halved (39 -> 19 ms); off by default, so merging changes nothing until the switch is set. verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report and made the in-world runs
throny commented 2026-12-01 12:23:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:23:10Z.


Merged at the checked head 81377895 on main 493dbd3d: two merge checks (Foniass, ours: 2902 passed, 0 failed, 51 ignored on that base), CI green, and +50 % presents/s in four world runs with XCL_RESIDENCY_PRIORITY=1 (above). It stays off by default; worth considering turning it on by default once someone with an AMD card has run it.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7311056194 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7311056194). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:23:10Z. --- Merged at the checked head `81377895` on `main` `493dbd3d`: two merge checks (Foniass, ours: 2902 passed, 0 failed, 51 ignored on that base), CI green, and +50 % presents/s in four world runs with `XCL_RESIDENCY_PRIORITY=1` (above). It stays off by default; worth considering turning it on by default once someone with an AMD card has run it. AI use: Claude Code (Claude Opus 5.5).
lucsoft commented 2026-12-01 14:01:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-01T14:01:51Z.


A/B on AMD under Linux, for the "default on AMD too?" question:

Setup: AMD Radeon RX 7800 XT (16 GB, RADV NAVI32), Mesa 26.3.1, Linux 7.3, Wine 11.21 (staging), vkd3d-proton 3.1, Ryzen 7 7800X3D. The build is main b2b1f109 (with this PR) plus three not-yet-merged crash fixes (#3536, #3553/#3566 and an allocator leak fix), so that 600 s runs survive on this card. The same build was run twice, 600 s each, same title and input script, only XCL_RESIDENCY_PRIORITY changed.

XCL_RESIDENCY_PRIORITY frames shown video memory in use (s: MB) at the end removals / crashes / page faults
0 2573 104: 16410, 225: 22600, 346: 23948, 467: 24521, 588: 25028 24825 MB (8457 over the 16368 MB budget) 0 / 0 / 0
1 2594 104: 16450, 224: 22361, 345: 24279, 465: 24639, 586: 25168 25109 MB (8741 over) 0 / 0 / 0

The switch was active: the log shows HIGH given to 20 render-target arenas, 942 window tile pools, 62 texture page pools holding targets, and no failed SetResidencyPriority.

Result: no measurable effect on this AMD/Linux setup. Frames are within run-to-run noise (+0.8 %), and the memory curve is the same: it stays far over budget on both sides and spills to system memory either way. That matches an earlier measurement here: on vkd3d-proton + RADV, residency priorities do not change what gets demoted. It does no harm either: no extra faults or crashes. So on AMD under Linux there is no reason for or against a default; whether it helps AMD on Windows (AMD's own driver) is untested here.

<!-- greyfinch-sync:ivall/xcl:comment:7313579884 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7313579884). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-01T14:01:51Z. --- A/B on AMD under Linux, for the "default on AMD too?" question: **Setup:** AMD Radeon RX 7800 XT (16 GB, RADV NAVI32), Mesa 26.3.1, Linux 7.3, Wine 11.21 (staging), vkd3d-proton 3.1, Ryzen 7 7800X3D. The build is `main` b2b1f109 (with this PR) plus three not-yet-merged crash fixes (#3536, #3553/#3566 and an allocator leak fix), so that 600 s runs survive on this card. The same build was run twice, 600 s each, same title and input script, only `XCL_RESIDENCY_PRIORITY` changed. | `XCL_RESIDENCY_PRIORITY` | frames shown | video memory in use (s: MB) | at the end | removals / crashes / page faults | |---|---|---|---|---| | 0 | 2573 | 104: 16410, 225: 22600, 346: 23948, 467: 24521, 588: 25028 | 24825 MB (8457 over the 16368 MB budget) | 0 / 0 / 0 | | 1 | 2594 | 104: 16450, 224: 22361, 345: 24279, 465: 24639, 586: 25168 | 25109 MB (8741 over) | 0 / 0 / 0 | The switch was active: the log shows `HIGH given to 20 render-target arenas, 942 window tile pools, 62 texture page pools holding targets`, and no failed `SetResidencyPriority`. **Result:** no measurable effect on this AMD/Linux setup. Frames are within run-to-run noise (+0.8 %), and the memory curve is the same: it stays far over budget on both sides and spills to system memory either way. That matches an earlier measurement here: on vkd3d-proton + RADV, residency priorities do not change what gets demoted. It does no harm either: no extra faults or crashes. So on AMD under Linux there is no reason for or against a default; whether it helps AMD on Windows (AMD's own driver) is untested here.
throny commented 2026-12-01 15:31:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:31:55Z.


@lucsoft thanks for the RADV A/B. Since it changes nothing there and gives +50 % on our RTX 4080, I opened #3582 to make it the default (XCL_RESIDENCY_PRIORITY=0 turns it off); a Windows + AMD run would settle it.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7316071801 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3156#issuecomment-7316071801). Originally posted by [throny](https://github.com/throny) on 2026-12-01T15:31:55Z. --- @lucsoft thanks for the RADV A/B. Since it changes nothing there and gives +50 % on our RTX 4080, I opened #3582 to make it the default (`XCL_RESIDENCY_PRIORITY=0` turns it off); a Windows + AMD run would settle it. AI use: Claude Code (Claude Opus 5.5).
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!3156
No description provided.