Skip to content

D3D12.X: port XCL_TEXTURE_SYSMEM (#3039) to amd-dev with L0 heap reclamation - #3335

Draft
iggyvilla wants to merge 1 commit into
xcl-dev:amd-devfrom
iggyvilla:amd-texture-sysmem-3039
Draft

iggyvilla wants to merge 1 commit into
xcl-dev:amd-devfrom
iggyvilla:amd-texture-sysmem-3039

Conversation

@iggyvilla

@iggyvilla iggyvilla commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Ports @treybertram06's opt-in XCL_TEXTURE_SYSMEM=1 (#3039, which targets main and does not apply to amd-dev) to amd-dev f33df5a7. Off by default; needs XCL_TEXTURE_LEVEL_PAGES=1.

New pages that map_levels takes for lazily mapped texture levels come from 64 MiB L0 system-memory pool heaps (custom, write-back, sampled by the GPU over PCIe) instead of local video memory; a page there has SYS_TILE (bit 31) in its heap index. If an L0 heap cannot be made, local video memory is used. Pages already mapped at a title address keep their backing, so aliasing (an RT placed over a streamed page) is unchanged.

  • vram.rs: SYS_TILE, texture_sysmem(), alloc_sys_pool_heap(), heap_in(), cool_in(), sys_pools/sys_pool on Pages, bind_range_in(.., sys), SYS_TILE handling in drain_fenced_tiles, flush_zero_tiles, map, release_tiles, the byte counts, and empty L0 heap reclamation next to the local one in sweep_and_reclaim (per @thehollowedone's review on D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039; creation-order aliasing wording per @thehollowedone and @andrewDoing).
  • Two tests: a_system_memory_page_is_told_apart_and_cools_in_its_own_pool, cooled_system_memory_pool_heaps_are_reclaimed_independently.
  • Earlier drafts of this port also fixed apply_backing; that function no longer exists on f33df5a7.

Tested

  • Hardware / OS / Rust: AMD Radeon RX 6650 XT (8 GB RDNA2, driver 32.0.21045.29003), Ryzen 7 5700X, Windows 11, rustc 1.100.0, debug test build on origin/amd-dev f33df5a7 + this commit.
  • cargo test --lib system_memory: 2 passed (the GPU one ran, it did not skip). hle::d3d12x::vram::: 30 passed, 0 failed, 1 ignored.
  • cargo test --lib hle::d3d12x:: -- --test-threads=1: the same 8 tests fail with and without this commit; no new failures.
  • Retail: on the earlier base (a local branch on 7c795f5e) the port ran 600 s world-load runs on this card up to 3,027 presents with no crash. On f33df5a7 only the 60 s smoke below was run (with the option off); the option's path is not soaked on this base.

Regression run
Both 60 s runs with scripts/smoke.ps1 -Seconds 60, XCL_PREPARE=0, on the same retail title and RX 6650 XT, after xcl pso-precompile --used had warmed the compute pipeline cache (with a build that has all three ports of this series). First main d8bd9a38, then this PR's head. XCL_TEXTURE_SYSMEM was not set, so this run covers the off (no-change) path.

xcl-smoke v1
commit: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0
gpu: AMD Radeon RX 6650 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15479 MB
xcl-smoke v1
commit: 13500f30ef6fb1d7062b320bb042908200bf9f15
gpu: AMD Radeon RX 6650 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1441 (PresentX 1441)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 25048 MB

Peak commit is 1.56x main's, past the 1.25x rule, but that is amd-dev's, not this change's: the same 60 s run on amd-dev f33df5a7 without this commit peaks at 25,028 MB (1,429 frames). So every amd-dev PR will fail that one line of the check until amd-dev itself comes down.

Not tested

  • cargo test --workspace, NVIDIA, RDNA3/RDNA4.

AI use

  • The first version of this change (against amd-dev 7c795f5e) was written and tested by Antigravity with Gemini 4 Neon (High). Its port to f33df5a7 (the old patch no longer applied: the code moved) was done by Claude Code (Claude Sonnet 5.5, effort high), which also ran the tests below and wrote this text. The account owner did not write the code or this text.
  • Original D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039 by @treybertram06.

…ap reclamation

Ports @treybertram06's opt-in XCL_TEXTURE_SYSMEM=1 (xcl-dev#3039) to amd-dev:
new pages of lazily mapped texture levels come from 64 MiB L0 system-memory
pool heaps, tagged SYS_TILE in the heap index. Includes empty L0 pool heap
reclamation independent of the local heaps (per @thehollowedone's review on
xcl-dev#3039) and creation-order wording for page aliasing (per @thehollowedone and
@andrewDoing).

Based-on: xcl-dev#3039 (@treybertram06)
Signed-off-by: Enrique Villa <eevilla@up.edu.ph>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 13500f3, diff read, not a merge-check; draft, base amd-dev, conflicts with it):

  • A second change is bundled in. The L0 heap reclamation (sweep_and_reclaim, vram.rs ~1180-1218, and its test ~3598) isn't in D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039, the original on main (still open). Unless it goes into D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039 too, or into its own PR, main and amd-dev diverge on it.
  • System-memory tiles can stay cooling forever (reasoned, not run). The cool-probe arming (~1994, ~2017) and need_unmap_work (~2102) only look at pool.cooling, never sys_pool.cooling. Tiles freed into the L0 pool while no video-memory page is cooling get no probe, so their heaps are never reclaimed. Constant video-memory churn probably hides it.
  • L0 memory isn't reported anywhere. page_bytes_for (~2181) and page_bytes (~2261) now leave L0 pages out, but no L0 total is added, so the memory report undercounts.
  • No test binds or samples a texture through an L0 page (bind_range_in with sys=true). The debug layer wasn't run, and a render target placed over an L0 page inherits that backing.
  • The description is stale. amd-dev 8ea8524 made level pages the default, so "needs XCL_TEXTURE_LEVEL_PAGES=1" no longer holds.
  • The red CI tests (release_tests::the_last_release_drops_entries..., sparse::tests::a_gpu_write_into_a_gpu_view...) are in files this PR doesn't touch; amd-dev's own CI is red too.

Fine: off by default, and with it off the behaviour is unchanged (no tagged tiles, so the preferred filter is a no-op). The bit-31 tag is handled consistently in drain_fenced_tiles, flush_zero_tiles, map and release_tiles, and when no L0 heap can be made it falls back to video memory.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 13500f3

This is a port of the vram.rs half of open #3039 (XCL_TEXTURE_SYSMEM) to amd-dev, where #3039 does not apply. It also adds reclamation of empty L0 heaps. TEXTURE_SYSMEM is not on origin/amd-dev or main yet. It does not overlap #3112 (same author, sparse.rs pools under XCL_SPARSE_VRAM_CAP_MB). The large line overlap with #3111/#3361/#3099 comes from the amd-dev base, not from this commit. No problems found in the diff: SYS_TILE-tagged tiles are routed through cooling, fenced returns, zeroing, scratch heaps and reclaim, and the byte counts leave system-memory pages out. The PR conflicts with amd-dev.
Recommendation: keep open.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants