D3D12.X: budget sampled L0 textures with a physical RAM floor #3740

Open
jeroenhaentjens wants to merge 1 commit from upstream-pr/3740 into main
jeroenhaentjens commented 2026-12-02 23:06:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T23:06:13Z.


What & Why

This splits sampled texture admission and the physical RAM floor out of #3682. Under local DXGI pressure, new sampled backing may use system memory while leaving local space for render target, depth and UAV pools. The default soft caps of up to 4,350 MiB for committed textures and 4,000 MiB for sampled tile pools are tuned for 6–8 GB discrete cards. XCL_TEXTURE_SOFT_CAP_MIB adjusts both caps. #3620 offers a related spill policy and overlaps this allocator.

What is in it

  • Opt in with XCL_TEXTURE_BUDGET=1. Charge concurrent admissions to the matching DXGI segment. Apply the same sampled classification to eager mappings and lazy mip levels under XCL_TEXTURE_LEVEL_PAGES=1.
  • Try CUSTOM/L0 after the local soft cap. After L0 refusal, try the local reserve. If budget admission refuses both segments, the original local driver allocation decides for committed textures and sampled tile pools. The sampled pool reserve leaves another 64 MiB free for target backing when admission succeeds.
  • Replace idle L0 tiles with local tiles for local-only aliases. A superseded GPU target remapped over live L0 tiles receives private local tiles for those overlaps. The sampled owners retain their L0 mappings. A remap denied by the driver remains eligible for retry.
  • Guard new L0 backing with GlobalMemoryStatusEx and in-flight reservations. XCL_L0_MIN_FREE_PHYS_MIB defaults to 3072 and takes 0 to disable the RAM floor. Report l0_phys_ram_guard_denials at powers of two.
  • Cover private remap, idle L0 replacement, lazy mip mapping with both options, heap-slot reuse, in-flight charging and both final driver fallbacks.

Tested

  • Commit 2ff3383881. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5.
  • git diff --check passed. cargo test --locked --workspace -- --test-threads=4 reported 3013 passed, 0 failed, 52 ignored and 26 SKIPPED diagnostics. The test log recorded 0 D3D12 Debug Layer validation warnings or errors during execution. The integration fixture emitted 8 live-object reporting warnings at process shutdown.
  • The native fixture opted into both texture options, verified private local remap over live sampled L0, and exercised actual local driver heap creation after both pool admissions were refused. It measured zero D3D12 Debug Layer messages. The complete workspace run succeeded after an earlier process exited with STATUS_ACCESS_VIOLATION.
  • Both 60-second runs used the same reference input schedule and existing shader cache. Both smoke runs set XCL_TEXTURE_BUDGET=1.

Regression run

Baseline (main)

xcl-smoke v1
commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1480 (PresentX 1480)
presents per 2 s (last 3): 48 59 62
device removals: 0
crashes: 0
peak commit: 13962 MB

PR head

xcl-smoke v1
commit: 2ff338388145f750f314ffdc59f30a5ede3d395c
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1537 (PresentX 1537)
presents per 2 s (last 3): 60 57 61
device removals: 0
crashes: 0
peak commit: 14028 MB

Not tested

AMD, Intel discrete GPUs, and Linux.

AI use

OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update. The author reviewed the diff and the recorded test results.

<!-- greyfinch-sync:ivall/xcl:issue:5616317344 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-02T23:06:13Z. --- **What & Why** This splits sampled texture admission and the physical RAM floor out of #3682. Under local DXGI pressure, new sampled backing may use system memory while leaving local space for render target, depth and UAV pools. The default soft caps of up to 4,350 MiB for committed textures and 4,000 MiB for sampled tile pools are tuned for 6–8 GB discrete cards. XCL_TEXTURE_SOFT_CAP_MIB adjusts both caps. #3620 offers a related spill policy and overlaps this allocator. **What is in it** - Opt in with XCL_TEXTURE_BUDGET=1. Charge concurrent admissions to the matching DXGI segment. Apply the same sampled classification to eager mappings and lazy mip levels under XCL_TEXTURE_LEVEL_PAGES=1. - Try CUSTOM/L0 after the local soft cap. After L0 refusal, try the local reserve. If budget admission refuses both segments, the original local driver allocation decides for committed textures and sampled tile pools. The sampled pool reserve leaves another 64 MiB free for target backing when admission succeeds. - Replace idle L0 tiles with local tiles for local-only aliases. A superseded GPU target remapped over live L0 tiles receives private local tiles for those overlaps. The sampled owners retain their L0 mappings. A remap denied by the driver remains eligible for retry. - Guard new L0 backing with GlobalMemoryStatusEx and in-flight reservations. XCL_L0_MIN_FREE_PHYS_MIB defaults to 3072 and takes 0 to disable the RAM floor. Report l0_phys_ram_guard_denials at powers of two. - Cover private remap, idle L0 replacement, lazy mip mapping with both options, heap-slot reuse, in-flight charging and both final driver fallbacks. **Tested** - Commit 2ff338388145f750f314ffdc59f30a5ede3d395c. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5. - git diff --check passed. cargo test --locked --workspace -- --test-threads=4 reported 3013 passed, 0 failed, 52 ignored and 26 SKIPPED diagnostics. The test log recorded 0 D3D12 Debug Layer validation warnings or errors during execution. The integration fixture emitted 8 live-object reporting warnings at process shutdown. - The native fixture opted into both texture options, verified private local remap over live sampled L0, and exercised actual local driver heap creation after both pool admissions were refused. It measured zero D3D12 Debug Layer messages. The complete workspace run succeeded after an earlier process exited with STATUS_ACCESS_VIOLATION. - Both 60-second runs used the same reference input schedule and existing shader cache. Both smoke runs set XCL_TEXTURE_BUDGET=1. **Regression run** Baseline (main) ``` xcl-smoke v1 commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a gpu: NVIDIA Quadro RTX 3000 title: 0ba91dcb seconds: 60 exit: 0x0 frames shown: 1480 (PresentX 1480) presents per 2 s (last 3): 48 59 62 device removals: 0 crashes: 0 peak commit: 13962 MB ``` PR head ``` xcl-smoke v1 commit: 2ff338388145f750f314ffdc59f30a5ede3d395c gpu: NVIDIA Quadro RTX 3000 title: 0ba91dcb seconds: 60 exit: 0x0 frames shown: 1537 (PresentX 1537) presents per 2 s (last 3): 60 57 61 device removals: 0 crashes: 0 peak commit: 14028 MB ``` **Not tested** AMD, Intel discrete GPUs, and Linux. **AI use** OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update. The author reviewed the diff and the recorded test results.
Foniass commented 2026-12-02 23:16:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:16:06Z.


Review of 3940fe38 (code reading only, not a merge-check; draft) · 1 high, 5 medium

In short: This PR splits the sampled-texture budget and the physical RAM floor out of #3682, rewritten into a new texture_budget.rs. Behind XCL_TEXTURE_BUDGET=1, committed sampled textures and sampled tile pools move to CUSTOM/L0 once the local soft limit is reached. With the variable unset, the default path is unchanged, and it merges cleanly on main without #3734. Under the opt-in, three things go wrong:

  • the new local-only alias refusal drops uploads of lazy-level textures;
  • a refused admission now fails the title's call;
  • the default limits move textures to system memory early on large GPUs.

High

  1. Lazy-level textures are refused on L0 pages and lose their uploads.

    • map_levels still calls bind_range(..., false) (vram.rs ~3622). The lazy shape at ~3585 is the same as texture_budget::sampled, so with XCL_TEXTURE_LEVEL_PAGES=1 these sampled textures count as local-only aliases.
    • A level whose address still has a page on an L0 heap hits return None at ~2642, and map_levels continues. The level gets no pages, its upload goes to unmapped tiles, and it reads as zeros until a later upload. The L0 page can be another texture's live page or an idle one (kept 2 s).
    • These textures also never get budgeted L0 backing.

    Fix: pass the same sampled flag from map_levels that bind now passes, and add a test with both switches on.

Medium

  1. A refused admission now fails the title's allocation.

    • When the local limit, L0 and RequiredLocal all refuse, committed_sampled (texture_budget.rs ~264) returns E_OUTOFMEMORY without calling CreateCommittedResource. Both the committed path in real.rs and the committed fallback of CreatePlacedResourceX (device_x.rs ~1307) then fail.
    • main would have created the resource, and WDDM can serve it over budget. L0 is refused whenever free physical RAM minus in-flight L0 is under 3,072 MiB, which can happen under the pressure the feature is for.

    Fix: try a plain local allocation as the last step, or say in the README that the call fails.

  2. Idle L0 pages force render targets into arenas.

    • The guard at vram.rs ~2642 also refuses pages with users == 0 that wait out IDLE before sweep_idle drops them.
    • On main, a render target, depth or UAV texture placed within 2 s on memory a sampled texture just released reuses those tiles. With the opt-in it falls back to place's arena path: an extra heap, and no sharing with later aliases at that address.

    Fix: treat an idle L0 page as missing and refuse only pages that still have users. The README's "usual placement fallback" sentence should mention the idle window.

  3. The default soft limits are fixed sizes, not shares of the budget. Admission::limit (texture_budget.rs ~30-31) uses min(4350 MiB, budget - 800 MiB) for textures and min(4000 MiB, budget - 1150 MiB) for pools. On a 12 or 16 GB GPU, sampled textures and pools go to system memory at about 4 GB, with most of the budget free. Derive the default from the budget, or document the fixed defaults and the cards they suit.

  4. This overlaps #3620. #3620 also changes alloc_pool_heap to alloc_pool_heap(dev, evictable) -> Option<(ID3D12Heap, bool)>, sends sampled-only tile pools to L0 under XCL_L0_VRAM_MARGIN_MB, and promotes L0 pages to local memory when a target aliases them instead of refusing. The two conflict in vram.rs and implement the same spill differently, so one has to be chosen or rebased on the other.

  5. The new vram.rs routing has no test, and one test claim is broader than the code.

    • Untested: bind passing the sampled class, the non_local slot tracking in PoolHeaps, and the local-only alias refusal.
    • The description says the tests cover "concurrent L0 backing", but l0_physical_ram_floor_includes_in_flight_backing only passes in_flight as an argument to fits_physical_ram. Nothing tests how reserve adds up unfinished L0 requests (~131).

    Fix: a CPU-only test of PoolHeaps and the guard, and one of reserve with an outstanding L0 reservation.

Checked and fine
  • With XCL_TEXTURE_BUDGET unset, enabled() is false. Both committed paths call create with the original heap properties, bind passes false, and alloc_pool_heap(dev, false) builds the same heap. non_local stays empty, so the guard never triggers.
  • A reservation that is not committed is removed on drop. A committed one is kept while an older sample is alive. The registry lock is not held across create.
  • PoolHeaps::take_heap clears non_local, so a reused slot does not inherit the L0 mark.
  • L0 pool heaps use D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES, and sampled() requires Flags == NONE, so no RT, DS or UAV texture goes there.
  • A CreateCommittedResource call with a null ppv returns S_FALSE and is not charged.
  • A UMA adapter, or no local budget from DXGI, falls back to the plain allocation.
  • Independent of #3734 except for a README conflict. 381+/23-, README updated.

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

<!-- greyfinch-sync:ivall/xcl:comment:7361776361 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#issuecomment-7361776361). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T23:16:06Z. --- **Review** of `3940fe38` (code reading only, not a merge-check; draft) · 1 high, 5 medium **In short:** This PR splits the sampled-texture budget and the physical RAM floor out of #3682, rewritten into a new `texture_budget.rs`. Behind `XCL_TEXTURE_BUDGET=1`, committed sampled textures and sampled tile pools move to CUSTOM/L0 once the local soft limit is reached. With the variable unset, the default path is unchanged, and it merges cleanly on `main` without #3734. Under the opt-in, three things go wrong: - the new local-only alias refusal drops uploads of lazy-level textures; - a refused admission now fails the title's call; - the default limits move textures to system memory early on large GPUs. #### High 1. **Lazy-level textures are refused on L0 pages and lose their uploads.** - `map_levels` still calls `bind_range(..., false)` (`vram.rs` ~3622). The lazy shape at ~3585 is the same as `texture_budget::sampled`, so with `XCL_TEXTURE_LEVEL_PAGES=1` these sampled textures count as local-only aliases. - A level whose address still has a page on an L0 heap hits `return None` at ~2642, and `map_levels` `continue`s. The level gets no pages, its upload goes to unmapped tiles, and it reads as zeros until a later upload. The L0 page can be another texture's live page or an idle one (kept 2 s). - These textures also never get budgeted L0 backing. Fix: pass the same `sampled` flag from `map_levels` that `bind` now passes, and add a test with both switches on. #### Medium 2. **A refused admission now fails the title's allocation.** - When the local limit, L0 and `RequiredLocal` all refuse, `committed_sampled` (`texture_budget.rs` ~264) returns `E_OUTOFMEMORY` without calling `CreateCommittedResource`. Both the committed path in `real.rs` and the committed fallback of `CreatePlacedResourceX` (`device_x.rs` ~1307) then fail. - `main` would have created the resource, and WDDM can serve it over budget. L0 is refused whenever free physical RAM minus in-flight L0 is under 3,072 MiB, which can happen under the pressure the feature is for. Fix: try a plain local allocation as the last step, or say in the README that the call fails. 3. **Idle L0 pages force render targets into arenas.** - The guard at `vram.rs` ~2642 also refuses pages with `users == 0` that wait out `IDLE` before `sweep_idle` drops them. - On `main`, a render target, depth or UAV texture placed within 2 s on memory a sampled texture just released reuses those tiles. With the opt-in it falls back to `place`'s arena path: an extra heap, and no sharing with later aliases at that address. Fix: treat an idle L0 page as missing and refuse only pages that still have users. The README's "usual placement fallback" sentence should mention the idle window. 4. **The default soft limits are fixed sizes, not shares of the budget.** `Admission::limit` (`texture_budget.rs` ~30-31) uses `min(4350 MiB, budget - 800 MiB)` for textures and `min(4000 MiB, budget - 1150 MiB)` for pools. On a 12 or 16 GB GPU, sampled textures and pools go to system memory at about 4 GB, with most of the budget free. Derive the default from the budget, or document the fixed defaults and the cards they suit. 5. **This overlaps #3620.** #3620 also changes `alloc_pool_heap` to `alloc_pool_heap(dev, evictable) -> Option<(ID3D12Heap, bool)>`, sends sampled-only tile pools to L0 under `XCL_L0_VRAM_MARGIN_MB`, and promotes L0 pages to local memory when a target aliases them instead of refusing. The two conflict in `vram.rs` and implement the same spill differently, so one has to be chosen or rebased on the other. 6. **The new `vram.rs` routing has no test, and one test claim is broader than the code.** - Untested: `bind` passing the sampled class, the `non_local` slot tracking in `PoolHeaps`, and the local-only alias refusal. - The description says the tests cover "concurrent L0 backing", but `l0_physical_ram_floor_includes_in_flight_backing` only passes `in_flight` as an argument to `fits_physical_ram`. Nothing tests how `reserve` adds up unfinished L0 requests (~131). Fix: a CPU-only test of `PoolHeaps` and the guard, and one of `reserve` with an outstanding L0 reservation. <details><summary>Checked and fine</summary> - With `XCL_TEXTURE_BUDGET` unset, `enabled()` is false. Both committed paths call `create` with the original heap properties, `bind` passes `false`, and `alloc_pool_heap(dev, false)` builds the same heap. `non_local` stays empty, so the guard never triggers. - A reservation that is not committed is removed on drop. A committed one is kept while an older sample is alive. The registry lock is not held across `create`. - `PoolHeaps::take_heap` clears `non_local`, so a reused slot does not inherit the L0 mark. - L0 pool heaps use `D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES`, and `sampled()` requires `Flags == NONE`, so no RT, DS or UAV texture goes there. - A `CreateCommittedResource` call with a null `ppv` returns `S_FALSE` and is not charged. - A UMA adapter, or no local budget from DXGI, falls back to the plain allocation. - Independent of #3734 except for a README conflict. 381+/23-, README updated. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
jeroenhaentjens commented 2026-12-03 07:32:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T07:32:21Z.


@Foniass Lazy mip mapping now uses the same sampled classification as eager mapping. An idle L0 page can be replaced at the same address with local backing, while a live page still takes the existing placement fallback. If admission refuses every committed allocation route, the original local driver call decides the result. The README documents the default caps and their override, and the PR records the new CPU and GPU regression checks.

<!-- greyfinch-sync:ivall/xcl:comment:7371117931 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#issuecomment-7371117931). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-03T07:32:21Z. --- @Foniass Lazy mip mapping now uses the same sampled classification as eager mapping. An idle L0 page can be replaced at the same address with local backing, while a live page still takes the existing placement fallback. If admission refuses every committed allocation route, the original local driver call decides the result. The README documents the default caps and their override, and the PR records the new CPU and GPU regression checks.
Foniass commented 2026-12-03 07:37:45 +00:00 (Migrated from github.com)

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


Follow-up review of 1a2bef64, since 3940fe38 (code reading only, not a merge-check) · 1 high, 3 medium

In short: Since 3940fe38, the PR:

  • passes the sampled class from map_levels;
  • falls back to the driver's own allocation when admission refuses a committed texture;
  • replaces idle L0 pages with local tiles for render-target aliases;
  • documents the fixed soft limits;
  • adds tests for PoolHeaps, reserve and the alias cases.

Five of the six earlier points are fixed. But the live-L0 refusal now leaves a superseded render target unmapped when it is used again, the overlap with #3620 is still open, and the PR has grown to 598+/35- with no reason given.

High

  1. A superseded render target that is mapped again over a live L0 page gets no tiles.

    • remap_if_unmapped (vram.rs ~3091) calls pages.bind, which now returns None when any page in the range is on an L0 heap and still has users (~2649). remap_if_unmapped then returns false.
    • Its callers do not check that: placements::map_again (~480, from note_use ~550) and title_textures::forget (~1043). use_again (~558) has already set mapped = true by then.
    • Under the opt-in, the sequence is: a target is superseded and its pages are swept; a sampled texture gets fresh L0 tiles inside the target's range; the title uses the target again. The target stays fully unmapped, so its draws are lost and its reads return zeros. On main, bind shares the pages at that address.
    • The "usual placement fallback" in the description exists only for new placements; this path has none.

    Fix: handle None here, for example by giving the target private local tiles for the conflicting pages, or leaving it superseded in the registry. Add a test.

Medium

  1. This overlaps #3620 (still open). #3620 changes alloc_pool_heap to the same (dev, bool) -> Option<(ID3D12Heap, bool)> shape, sends sampled tile pools to L0, and promotes L0 pages to local memory when a target aliases them, instead of refusing. The description now names it, but the two still conflict in vram.rs and implement the same spill differently. One has to be chosen, or one rebased on the other.
  2. Over ~400 changed lines with no reason given. It went from 381+/23- to 598+/35-: about 195 lines of tests, 13 of README, about 425 of code. Split a part off, such as the idle-L0 replacement in bind_range or the physical RAM floor, or say why it cannot be split.
  3. Tested reports a filtered run, not the whole suite. It lists only hle::d3d12x::texture_budget::tests and hle::d3d12x::vram::tests (91 passed). Add the whole suite's counts and skips.
Checked and fine
  • Earlier finding fixed: lazy-level textures now pass the sampled class to bind_range (sampled_page_backing, vram.rs ~3639-3642). lazy_texture_levels_share_l0_and_idle_aliases_get_local_tiles runs with both switches on.
  • Earlier finding fixed: a refused admission now calls the driver with the original heap properties instead of returning E_OUTOFMEMORY (allocate_committed, texture_budget.rs ~279), with a test.
  • Earlier finding fixed: idle L0 pages no longer refuse a local-only alias. They are counted as missing and replaced only after take_batch succeeds, and the old tile goes through cooling (~2647-2673). When take_batch fails, nothing is removed.
  • Earlier finding fixed: the README documents the fixed soft limits as tuned for 6-8 GB cards and adjustable with XCL_TEXTURE_SOFT_CAP_MIB.
  • Earlier finding fixed: pool_heaps_clear_non_local_when_a_slot_is_reused tests the slot tracking, and reserve_charges_in_flight_l0_against_physical_ram_across_adapters tests reserve adding up an unfinished L0 reservation from another adapter.
  • With XCL_TEXTURE_BUDGET unset, the default path is unchanged.
  • #3742 and #3745 are stacked on this PR. #3745's diff still shows the earlier form of the guard, so it seems to be stacked on the previous revision.

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

<!-- greyfinch-sync:ivall/xcl:comment:7371227917 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#issuecomment-7371227917). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T07:37:45Z. --- **Follow-up review** of `1a2bef64`, since `3940fe38` (code reading only, not a merge-check) · 1 high, 3 medium **In short:** Since `3940fe38`, the PR: - passes the sampled class from `map_levels`; - falls back to the driver's own allocation when admission refuses a committed texture; - replaces idle L0 pages with local tiles for render-target aliases; - documents the fixed soft limits; - adds tests for `PoolHeaps`, `reserve` and the alias cases. Five of the six earlier points are fixed. But the live-L0 refusal now leaves a superseded render target unmapped when it is used again, the overlap with #3620 is still open, and the PR has grown to 598+/35- with no reason given. #### High 1. **A superseded render target that is mapped again over a live L0 page gets no tiles.** - `remap_if_unmapped` (`vram.rs` ~3091) calls `pages.bind`, which now returns `None` when any page in the range is on an L0 heap and still has users (~2649). `remap_if_unmapped` then returns `false`. - Its callers do not check that: `placements::map_again` (~480, from `note_use` ~550) and `title_textures::forget` (~1043). `use_again` (~558) has already set `mapped = true` by then. - Under the opt-in, the sequence is: a target is superseded and its pages are swept; a sampled texture gets fresh L0 tiles inside the target's range; the title uses the target again. The target stays fully unmapped, so its draws are lost and its reads return zeros. On `main`, `bind` shares the pages at that address. - The "usual placement fallback" in the description exists only for new placements; this path has none. Fix: handle `None` here, for example by giving the target private local tiles for the conflicting pages, or leaving it superseded in the registry. Add a test. #### Medium 2. **This overlaps #3620 (still open).** #3620 changes `alloc_pool_heap` to the same `(dev, bool) -> Option<(ID3D12Heap, bool)>` shape, sends sampled tile pools to L0, and promotes L0 pages to local memory when a target aliases them, instead of refusing. The description now names it, but the two still conflict in `vram.rs` and implement the same spill differently. One has to be chosen, or one rebased on the other. 3. **Over ~400 changed lines with no reason given.** It went from 381+/23- to 598+/35-: about 195 lines of tests, 13 of README, about 425 of code. Split a part off, such as the idle-L0 replacement in `bind_range` or the physical RAM floor, or say why it cannot be split. 4. **Tested reports a filtered run, not the whole suite.** It lists only `hle::d3d12x::texture_budget::tests` and `hle::d3d12x::vram::tests` (91 passed). Add the whole suite's counts and skips. <details><summary>Checked and fine</summary> - Earlier finding fixed: lazy-level textures now pass the sampled class to `bind_range` (`sampled_page_backing`, `vram.rs` ~3639-3642). `lazy_texture_levels_share_l0_and_idle_aliases_get_local_tiles` runs with both switches on. - Earlier finding fixed: a refused admission now calls the driver with the original heap properties instead of returning `E_OUTOFMEMORY` (`allocate_committed`, `texture_budget.rs` ~279), with a test. - Earlier finding fixed: idle L0 pages no longer refuse a local-only alias. They are counted as missing and replaced only after `take_batch` succeeds, and the old tile goes through `cooling` (~2647-2673). When `take_batch` fails, nothing is removed. - Earlier finding fixed: the README documents the fixed soft limits as tuned for 6-8 GB cards and adjustable with `XCL_TEXTURE_SOFT_CAP_MIB`. - Earlier finding fixed: `pool_heaps_clear_non_local_when_a_slot_is_reused` tests the slot tracking, and `reserve_charges_in_flight_l0_against_physical_ram_across_adapters` tests `reserve` adding up an unfinished L0 reservation from another adapter. - With `XCL_TEXTURE_BUDGET` unset, the default path is unchanged. - #3742 and #3745 are stacked on this PR. #3745's diff still shows the earlier form of the guard, so it seems to be stacked on the previous revision. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
vasanex commented 2026-12-03 07:43:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T07:43:39Z.

Review: COMMENTED


Review of 1a2bef64 (code reading and the tests named below, not a merge-check) - 1 finding, 2 notes

In short: this adds to Foniass's follow-up review of the same head and does not repeat it. I agree with its point 1 (the remap over a live L0 page), which my reading found as well. One point is new: under the opt-in, a tile-pool admission that both segments refuse has no last step, and a lazily mapped level then loses its upload. The whole suite and a smoke run on a merge with current main are below (their point 4 asks for the suite).

Measured (RTX 3080, Windows 11, merge of 1a2bef64 onto main 16c2fd08 = afd22f6a; the PR's base is 078358a0, the merge is clean):

  • cargo build --workspace: ok. cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 3018 passed, 0 failed, 56 ignored; 25 SKIPPED, the same tests as on main (main: 3012 / 0 / 56).
  • scripts/smoke.ps1, 60 s, offline, release, switch unset: 1699 frames (main 1696), no device removal, no crash, peak commit 17819 MB (main 18885 MB; two runs of the same runtime code differed by 4 % here tonight).
  • Nothing was run with XCL_TEXTURE_BUDGET=1 beyond the PR's own tests in the suite.

Finding (in its own thread):

  1. Medium, read: with both switches on, a sampled tile pool refused by the local limits and by L0 gets no heap at all, and map_levels skips the level: its upload is dropped. The committed route got a "driver decides" last step in this head, the pool route did not.

Notes, not blocking:

  • committed_sampled charges the admission with dev.GetResourceAllocationInfo on the title's device. That call goes through XCL's own hook (get_resource_allocation_info_x), which answers with the console's size for a texture it models and reads the description as a console one. real.rs has pc_allocation_size for the PC driver's size. Accounting only; I did not measure how far the two sizes are apart.
  • Every TextureBudget::sample makes a DXGI factory and looks the adapter up again (memory_report::video_memory): once per committed sampled texture, and once per new pool heap with PAGES locked. Not measured; keeping the adapter would avoid it.

Checked and fine, beyond what is listed there: no reachable panic in the registry's unwraps and indexing (an adapter's entry lives as long as one of its samples, retain never removes a request that is not committed), the registry lock is not held across create, and a render target cannot get a tile of a heap made with ALLOW_ONLY_NON_RT_DS_TEXTURES (L0 heaps are only made for the sampled class, and pick_heap keeps the classes apart, also after a slot is reused).

Not checked: a title run with the switch on and the card over its budget, AMD and Intel (whether their drivers take tile mappings onto CUSTOM/L0 heaps), how often the RAM floor refuses in a real run, the overlap with #3620.

Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review:6165538580 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#pullrequestreview-6165538580). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T07:43:39Z. **Review:** COMMENTED --- **Review** of 1a2bef64 (code reading and the tests named below, not a merge-check) - 1 finding, 2 notes In short: this adds to Foniass's follow-up review of the same head and does not repeat it. I agree with its point 1 (the remap over a live L0 page), which my reading found as well. One point is new: under the opt-in, a tile-pool admission that both segments refuse has no last step, and a lazily mapped level then loses its upload. The whole suite and a smoke run on a merge with current main are below (their point 4 asks for the suite). Measured (RTX 3080, Windows 11, merge of 1a2bef64 onto main 16c2fd08 = afd22f6a; the PR's base is 078358a0, the merge is clean): - `cargo build --workspace`: ok. `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): 3018 passed, 0 failed, 56 ignored; 25 SKIPPED, the same tests as on main (main: 3012 / 0 / 56). - `scripts/smoke.ps1`, 60 s, offline, release, switch unset: 1699 frames (main 1696), no device removal, no crash, peak commit 17819 MB (main 18885 MB; two runs of the same runtime code differed by 4 % here tonight). - Nothing was run with `XCL_TEXTURE_BUDGET=1` beyond the PR's own tests in the suite. Finding (in its own thread): 1. Medium, read: with both switches on, a sampled tile pool refused by the local limits and by L0 gets no heap at all, and `map_levels` skips the level: its upload is dropped. The committed route got a "driver decides" last step in this head, the pool route did not. Notes, not blocking: - `committed_sampled` charges the admission with `dev.GetResourceAllocationInfo` on the title's device. That call goes through XCL's own hook (`get_resource_allocation_info_x`), which answers with the console's size for a texture it models and reads the description as a console one. `real.rs` has `pc_allocation_size` for the PC driver's size. Accounting only; I did not measure how far the two sizes are apart. - Every `TextureBudget::sample` makes a DXGI factory and looks the adapter up again (`memory_report::video_memory`): once per committed sampled texture, and once per new pool heap with `PAGES` locked. Not measured; keeping the adapter would avoid it. Checked and fine, beyond what is listed there: no reachable panic in the registry's `unwrap`s and indexing (an adapter's entry lives as long as one of its samples, `retain` never removes a request that is not committed), the registry lock is not held across `create`, and a render target cannot get a tile of a heap made with `ALLOW_ONLY_NON_RT_DS_TEXTURES` (L0 heaps are only made for the sampled class, and `pick_heap` keeps the classes apart, also after a slot is reused). Not checked: a title run with the switch on and the card over its budget, AMD and Intel (whether their drivers take tile mappings onto CUSTOM/L0 heaps), how often the RAM floor refuses in a real run, the overlap with #3620. Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.
vasanex commented 2026-12-03 07:43:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T07:43:40Z.

Code review location: crates/xcl/src/hle/d3d12x/vram.rs; line 3642

@@ -3588,9 +3636,10 @@ pub(super) unsafe fn map_levels(res: &ID3D12Resource, levels: Option<&[u32]>) ->
         let (va, console_bytes, total) = (t.va, t.console_bytes, t.total);
         let d = dev_key as *mut c_void;
         let Some(dev) = ID3D12Device::from_raw_borrowed(&d) else { return Vec::new() };
+        let sampled = sampled_page_backing(res);
         let mut fresh = Vec::new();
         for (k, sub, first, n, levels) in todo {
-            let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, false) else { continue };
+            let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, sampled) else { continue };

Medium, read (not measured). Needs XCL_TEXTURE_BUDGET=1 and XCL_TEXTURE_LEVEL_PAGES=1.

A refused tile-pool admission has no last step. The committed route now ends in the driver's own call (allocate_committed: None => create(properties)), but sampled_pool hands allocate's None straight back: alloc_pool_heap returns None, take_batch fails, bind_range returns None, and here the level is skipped.

Scenario: a lazy sampled level needs fresh tiles and no heap of its class has free ones. Local usage plus 64 MiB is over budget minus 72 MiB (Pool and PoolFallback both refuse), and L0 is refused too (free physical RAM under 3072 MiB plus the request, or the non-local budget is full). The level then has no pages, and its upload goes to unmapped tiles, which drops it (title_textures.rs, the comment over map_levels_from_present): it reads as zeros until the title writes that memory again. main calls CreateHeap in the same state and loses the level only if the driver refuses.

That state is the one the switch is for: a card at its budget on a machine short of RAM. The warning "sampled tile pool admission denied in both memory segments" already counts it. With the switch on it also comes up more often than a new heap does on main, because sampled textures now take tiles only from heaps of their own class (pick_heap), so free tiles in the other class's local heaps no longer serve them.

An eager sampled placement is not hit the same way: place_on_pages returns None and the committed fallback ends in the driver's call.

Suggested fix: give sampled_pool the same last step as the committed route (a local heap, the driver decides), at least when the caller is map_levels. A test of the refused route would be good: the GPU test takes its fresh tiles from the L0 heap it made itself and never gets to sampled_pool.

<!-- greyfinch-sync:ivall/xcl:review-comment:4781424262 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#discussion_r4781424262). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T07:43:40Z. **Code review location:** `crates/xcl/src/hle/d3d12x/vram.rs`; line 3642 ~~~~diff @@ -3588,9 +3636,10 @@ pub(super) unsafe fn map_levels(res: &ID3D12Resource, levels: Option<&[u32]>) -> let (va, console_bytes, total) = (t.va, t.console_bytes, t.total); let d = dev_key as *mut c_void; let Some(dev) = ID3D12Device::from_raw_borrowed(&d) else { return Vec::new() }; + let sampled = sampled_page_backing(res); let mut fresh = Vec::new(); for (k, sub, first, n, levels) in todo { - let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, false) else { continue }; + let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, sampled) else { continue }; ~~~~ --- **Medium, read (not measured). Needs `XCL_TEXTURE_BUDGET=1` and `XCL_TEXTURE_LEVEL_PAGES=1`.** A refused tile-pool admission has no last step. The committed route now ends in the driver's own call (`allocate_committed`: `None => create(properties)`), but `sampled_pool` hands `allocate`'s `None` straight back: `alloc_pool_heap` returns `None`, `take_batch` fails, `bind_range` returns `None`, and here the level is skipped. Scenario: a lazy sampled level needs fresh tiles and no heap of its class has free ones. Local usage plus 64 MiB is over budget minus 72 MiB (`Pool` and `PoolFallback` both refuse), and L0 is refused too (free physical RAM under 3072 MiB plus the request, or the non-local budget is full). The level then has no pages, and its upload goes to unmapped tiles, which drops it (`title_textures.rs`, the comment over `map_levels_from_present`): it reads as zeros until the title writes that memory again. main calls `CreateHeap` in the same state and loses the level only if the driver refuses. That state is the one the switch is for: a card at its budget on a machine short of RAM. The warning "sampled tile pool admission denied in both memory segments" already counts it. With the switch on it also comes up more often than a new heap does on main, because sampled textures now take tiles only from heaps of their own class (`pick_heap`), so free tiles in the other class's local heaps no longer serve them. An eager sampled placement is not hit the same way: `place_on_pages` returns `None` and the committed fallback ends in the driver's call. Suggested fix: give `sampled_pool` the same last step as the committed route (a local heap, the driver decides), at least when the caller is `map_levels`. A test of the refused route would be good: the GPU test takes its fresh tiles from the L0 heap it made itself and never gets to `sampled_pool`.
jeroenhaentjens commented 2026-12-03 11:25:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T11:25:02Z.


@Foniass @vasanex A superseded GPU target can now remap over live sampled L0 backing using private local tiles for the conflicting pages. A denied remap stays eligible for retry. Sampled pool allocation now has the same final local driver path as committed textures. The PR contains the complete workspace result and the exact-head smoke.

<!-- greyfinch-sync:ivall/xcl:comment:7376670191 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#issuecomment-7376670191). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-03T11:25:02Z. --- @Foniass @vasanex A superseded GPU target can now remap over live sampled L0 backing using private local tiles for the conflicting pages. A denied remap stays eligible for retry. Sampled pool allocation now has the same final local driver path as committed textures. The PR contains the complete workspace result and the exact-head smoke.
vasanex commented 2026-12-03 11:27:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T11:27:49Z.

Code review location: crates/xcl/src/hle/d3d12x/vram.rs; line 3642

@@ -3588,9 +3636,10 @@ pub(super) unsafe fn map_levels(res: &ID3D12Resource, levels: Option<&[u32]>) ->
         let (va, console_bytes, total) = (t.va, t.console_bytes, t.total);
         let d = dev_key as *mut c_void;
         let Some(dev) = ID3D12Device::from_raw_borrowed(&d) else { return Vec::new() };
+        let sampled = sampled_page_backing(res);
         let mut fresh = Vec::new();
         for (k, sub, first, n, levels) in todo {
-            let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, false) else { continue };
+            let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, sampled) else { continue };

Fixed in 2ff33838. sampled_pool now ends in the driver's own call when both admissions refuse (allocate_sampled_pool: unwrap_or_else(|| create(false))), so alloc_pool_heap gets a local heap or the driver's error, as the committed route does, and a lazy level is skipped only when the driver itself refuses. The new unit test pins the refused route (attempts == [false]), and the GPU test now goes through it with a real CreateHeap.

Measured on the merge of 2ff33838 with main 0c725d5d (a7edc19c), RTX 3080: cargo test -p xcl --lib -- --test-threads=4 texture_budget hle::d3d12x::vram: 92 passed, 0 failed, 1 ignored. With the private tile key put back to the shared (va, i), the GPU test lazy_texture_levels_share_l0_and_idle_aliases_get_local_tiles fails (the private-key assertion), so the new remap is covered too. The suite and the smoke were not rerun on this head.

Follow-up by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review-comment:4783989695 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#discussion_r4783989695). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T11:27:49Z. **Code review location:** `crates/xcl/src/hle/d3d12x/vram.rs`; line 3642 ~~~~diff @@ -3588,9 +3636,10 @@ pub(super) unsafe fn map_levels(res: &ID3D12Resource, levels: Option<&[u32]>) -> let (va, console_bytes, total) = (t.va, t.console_bytes, t.total); let d = dev_key as *mut c_void; let Some(dev) = ID3D12Device::from_raw_borrowed(&d) else { return Vec::new() }; + let sampled = sampled_page_backing(res); let mut fresh = Vec::new(); for (k, sub, first, n, levels) in todo { - let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, false) else { continue }; + let Some((used, used_extra)) = pages.bind_range(dev, res, va, console_bytes, total, sub, first as usize..(first + n) as usize, sampled) else { continue }; ~~~~ --- Fixed in 2ff33838. `sampled_pool` now ends in the driver's own call when both admissions refuse (`allocate_sampled_pool`: `unwrap_or_else(|| create(false))`), so `alloc_pool_heap` gets a local heap or the driver's error, as the committed route does, and a lazy level is skipped only when the driver itself refuses. The new unit test pins the refused route (`attempts == [false]`), and the GPU test now goes through it with a real `CreateHeap`. Measured on the merge of 2ff33838 with main 0c725d5d (a7edc19c), RTX 3080: `cargo test -p xcl --lib -- --test-threads=4 texture_budget hle::d3d12x::vram`: 92 passed, 0 failed, 1 ignored. With the private tile key put back to the shared `(va, i)`, the GPU test `lazy_texture_levels_share_l0_and_idle_aliases_get_local_tiles` fails (the private-key assertion), so the new remap is covered too. The suite and the smoke were not rerun on this head. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Foniass commented 2026-12-03 11:31:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T11:31:25Z.


Follow-up review of 2ff33838, since 1a2bef64 (code reading only, not a merge-check) · 5 medium

In short: Since 1a2bef64:

  • a superseded render target mapped again over live L0 pages gets private local tiles;
  • a failed remap stays superseded in the placement registry, so the next use retries it;
  • sampled tile pools fall back to the driver's local allocation when admission refuses both segments;
  • Tested now reports the whole suite.

The earlier High is fixed: the private tiles are released on every path, their keys cannot collide with shared keys, and the registry counts stay consistent. But the private tiles end the memory sharing the use-again path exists for. The overlap with #3620 is still open, now joined by the stacked #3745, and the size has grown.

Medium

  1. Private tiles end the aliasing that the use-again path exists for. note_use (placements.rs ~553-557) maps a superseded target again because the title "may use both over one memory when it knows they share it". Under the opt-in, bind_range now gives the target private tiles for each live L0 page (vram.rs ~2649-2656, key ~2701) instead of sharing it, as main does. The target and the sampled texture then stop sharing memory on those pages. What the target renders never reaches the sampled texture, and the target starts with whatever the pool tile held. The README only says the target "gets private local tiles". Say in the README that they stop sharing memory, or move the L0 page to local memory instead, as #3620 and #3745 do.
  2. The overlap with #3620 is still open, and the stacked #3745 now duplicates part of this push. #3620 promotes L0 pages to local memory when a target aliases them, and #3745 (stacked on this PR at 1a2bef6) promotes live L0 aliases with their contents kept. This push handles the same case with private tiles, and changed bind_range's signature (private_live_l0), so #3745 no longer applies cleanly. Choose one approach, then rebase #3742 and #3745 on the current head.
  3. Over ~400 changed lines, with no reason given (still open). Now 699+/52-: about 230 lines of tests, 16 of README, 450 of code. Split a part off (the physical RAM floor, or the idle / private L0 replacement in bind_range), or say why it cannot be split.
  4. The registry side of a failed remap has no test. map_again (placements.rs ~477-489) now marks a placement unmapped again and counts it when remap_if_unmapped fails, and note_use (~564-569) skips use_again then. The new GPU test calls remap_if_unmapped directly on a Target inserted by hand (vram.rs ~4983-4990), so neither path is reached. Add a test where the remap fails: the placement stays superseded, SUPERSEDED and unmapped stay in step, and a later successful use clears it.
  5. An access violation in an earlier suite run, without details. Tested says "The complete workspace run succeeded after an earlier process exited with STATUS_ACCESS_VIOLATION". The new GPU test inserts into the global PAGES and calls real::adopt on its own device, so the crash could come from this PR. Name the test that crashed, and say whether it also happens on main.
Checked and fine
  • Earlier finding fixed: a superseded render target over a live L0 page stayed unmapped. remap_if_unmapped passes private_live_l0 for GPU-owned resources (vram.rs ~3095-3098), and every placement that can be superseded is Kind::Target. If a remap still fails, the placement stays superseded and use_again is not called (placements.rs ~481-485, ~567-569).
  • Earlier finding fixed: Tested reports the whole suite (3013 passed, 0 failed, 52 ignored, 26 skipped).
  • Private tile keys are (resource, i | PRIVATE_TILE_INDEX). Bit 63 is never set in a shared (va, i) key, so they cannot collide, and sweep_idle never queues one.
  • Private tiles do not outlive their target: release_tiles sends one to cooling when its users reach 0, without the idle window (~2587). This happens on the held unmap, forget_pages and unmap_superseded. A pending HeldUnmap keeps a COM reference until the tiles are released.
  • No private key is created twice. Private tiles come from local heaps, and the test checks that none is on a non_local slot.
  • Registry counts: a failed remap counts once in unmapped and is uncounted by release or use_again. SUPERSEDED is stored after map_again in placed and settle. The lock order is still registry, then PAGES.
  • allocate_sampled_pool calls create(false) when there is no sample or both reservations are refused, with two tests.
  • With XCL_TEXTURE_BUDGET unset, non_local stays empty. The only default-path change: a remap that fails (out of memory) now stays superseded and is retried, instead of being marked mapped with no tiles.

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

<!-- greyfinch-sync:ivall/xcl:comment:7376817623 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3740#issuecomment-7376817623). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T11:31:25Z. --- **Follow-up review** of `2ff33838`, since `1a2bef64` (code reading only, not a merge-check) · 5 medium **In short:** Since `1a2bef64`: - a superseded render target mapped again over live L0 pages gets private local tiles; - a failed remap stays superseded in the placement registry, so the next use retries it; - sampled tile pools fall back to the driver's local allocation when admission refuses both segments; - **Tested** now reports the whole suite. The earlier High is fixed: the private tiles are released on every path, their keys cannot collide with shared keys, and the registry counts stay consistent. But the private tiles end the memory sharing the use-again path exists for. The overlap with #3620 is still open, now joined by the stacked #3745, and the size has grown. #### Medium 1. **Private tiles end the aliasing that the use-again path exists for.** `note_use` (`placements.rs` ~553-557) maps a superseded target again because the title "may use both over one memory when it knows they share it". Under the opt-in, `bind_range` now gives the target private tiles for each live L0 page (`vram.rs` ~2649-2656, key ~2701) instead of sharing it, as `main` does. The target and the sampled texture then stop sharing memory on those pages. What the target renders never reaches the sampled texture, and the target starts with whatever the pool tile held. The README only says the target "gets private local tiles". Say in the README that they stop sharing memory, or move the L0 page to local memory instead, as #3620 and #3745 do. 2. **The overlap with #3620 is still open, and the stacked #3745 now duplicates part of this push.** #3620 promotes L0 pages to local memory when a target aliases them, and #3745 (stacked on this PR at `1a2bef6`) promotes live L0 aliases with their contents kept. This push handles the same case with private tiles, and changed `bind_range`'s signature (`private_live_l0`), so #3745 no longer applies cleanly. Choose one approach, then rebase #3742 and #3745 on the current head. 3. **Over ~400 changed lines, with no reason given (still open).** Now 699+/52-: about 230 lines of tests, 16 of README, 450 of code. Split a part off (the physical RAM floor, or the idle / private L0 replacement in `bind_range`), or say why it cannot be split. 4. **The registry side of a failed remap has no test.** `map_again` (`placements.rs` ~477-489) now marks a placement unmapped again and counts it when `remap_if_unmapped` fails, and `note_use` (~564-569) skips `use_again` then. The new GPU test calls `remap_if_unmapped` directly on a `Target` inserted by hand (`vram.rs` ~4983-4990), so neither path is reached. Add a test where the remap fails: the placement stays superseded, `SUPERSEDED` and `unmapped` stay in step, and a later successful use clears it. 5. **An access violation in an earlier suite run, without details.** **Tested** says "The complete workspace run succeeded after an earlier process exited with STATUS_ACCESS_VIOLATION". The new GPU test inserts into the global `PAGES` and calls `real::adopt` on its own device, so the crash could come from this PR. Name the test that crashed, and say whether it also happens on `main`. <details><summary>Checked and fine</summary> - Earlier finding fixed: a superseded render target over a live L0 page stayed unmapped. `remap_if_unmapped` passes `private_live_l0` for GPU-owned resources (`vram.rs` ~3095-3098), and every placement that can be superseded is `Kind::Target`. If a remap still fails, the placement stays superseded and `use_again` is not called (`placements.rs` ~481-485, ~567-569). - Earlier finding fixed: **Tested** reports the whole suite (3013 passed, 0 failed, 52 ignored, 26 skipped). - Private tile keys are `(resource, i | PRIVATE_TILE_INDEX)`. Bit 63 is never set in a shared `(va, i)` key, so they cannot collide, and `sweep_idle` never queues one. - Private tiles do not outlive their target: `release_tiles` sends one to `cooling` when its users reach 0, without the idle window (~2587). This happens on the held unmap, `forget_pages` and `unmap_superseded`. A pending `HeldUnmap` keeps a COM reference until the tiles are released. - No private key is created twice. Private tiles come from local heaps, and the test checks that none is on a `non_local` slot. - Registry counts: a failed remap counts once in `unmapped` and is uncounted by `release` or `use_again`. `SUPERSEDED` is stored after `map_again` in `placed` and `settle`. The lock order is still registry, then `PAGES`. - `allocate_sampled_pool` calls `create(false)` when there is no sample or both reservations are refused, with two tests. - With `XCL_TEXTURE_BUDGET` unset, `non_local` stays empty. The only default-path change: a remap that fails (out of memory) now stays superseded and is retried, instead of being marked mapped with no tiles. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3740:upstream-pr/3740'
git switch 'upstream-pr/3740'

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