Skip to content

D3D12.X: XCL's own heaps get their residency priority by default - #3582

Open
throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:residency-priority-default
Open

throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:residency-priority-default

Conversation

@throny

@throny throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

XCL_RESIDENCY_PRIORITY (#3156) gives XCL's own heaps (render-target arenas, window tile pools, texture page pools holding targets) D3D12_RESIDENCY_PRIORITY_HIGH, so that over the video memory budget Windows demotes idle texture pages first. It was off unless XCL_RESIDENCY_PRIORITY=1. This turns it on by default; XCL_RESIDENCY_PRIORITY=0 turns it off. Part of #505.

Evidence: on an RTX 4080 16 GB (Windows), four world runs on #3156 gave 3.37 / 3.49 presents/s with it against 2.22 / 2.39 without (+50 %). lucsoft's A/B on an AMD RX 7800 XT under Linux/RADV (comment on #3156) shows no change. Missing: a Windows + AMD run. If you have one, please run the title in the world with and without XCL_RESIDENCY_PRIORITY=0 and post the presents/s here or on #3156.

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: the parse moves into residency_priority_enabled (on unless the value is 0), the doc comments say so, and residency_priority_is_on_by_default tests unset, 1, 0 and 0.
  • README.md: one bullet for the heap priority and the switch.

Tested

  • NVIDIA GeForce RTX 4080, Windows 11 build 26300, Rust stable-x86_64-pc-windows-msvc, debug for the tests, release for the smoke runs. Nothing else was on the GPU.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 5b8ac52: 2905 passed, 0 failed, 51 ignored (sum of the test result lines).
  • SKIPPED on this adapter: the wave64 variants of the gpu::recomp::lower / lower_dxil tests and dispatch_chain_native_wave64_builds_whole (no wave64); heap_window_out_of_memory_falls_back_to_the_switch_form and hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap (no heap windows); shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (driver cache cannot be disabled).

Regression run

  • main 6bfb5c5 (scripts/smoke.ps1, 120 s, release build):
xcl-smoke v1
commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3370 (PresentX 3370)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 16355 MB
  • this PR's head commit (clean tree, committed), same title, 120 s, release build:
xcl-smoke v1
commit: 5b8ac52b3c6dae4ef4153dc49d4a4b701cba6d9f
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3380 (PresentX 3380)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 17926 MB

Not tested

AI use

🤖 Generated with Claude Code

Over its video memory budget a process has heaps demoted to system memory,
and Windows has no hint which matter. XCL_RESIDENCY_PRIORITY (xcl-dev#3156) gives
render-target arenas, window tile pools and texture page pools holding
targets HIGH, so idle texture pages are demoted first. It was off unless
XCL_RESIDENCY_PRIORITY=1.

Measured on an RTX 4080 16 GB (Windows) in four world runs on xcl-dev#3156:
3.37 / 3.49 presents/s with it against 2.22 / 2.39 without (+50 %).
lucsoft's A/B on an AMD RX 7800 XT under Linux/RADV shows no change.
Windows + AMD is not measured yet.

It is now on unless XCL_RESIDENCY_PRIORITY=0, which turns it off. The parse
moves into residency_priority_enabled so a unit test covers unset, 0 and 1.

Part of xcl-dev#505

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: b2b1f10
head: 5b8ac52
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 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 (+20/-4). #3156's residency priority (HIGH for XCL's render-target arenas, window tile pools and texture-page pools holding targets) is now on unless XCL_RESIDENCY_PRIORITY is 0 (trimmed); any other value, false / off included, keeps it on, like the repo's other default-on switches. Findings: (1) The "HIGH only grows" point from #3156 now applies to everyone. Pools keep HIGH after their target pages are freed (vram.rs ~2187; cleared only when the heap is reclaimed, ~1728), and the window tile pools hold the title's GPU-visible memory by default. Logged HIGH sets were about 12 GiB on a 5070 Ti and at least 7.6 GiB on lucsoft's AMD card, so on an 8 GB card the HIGH set alone would pass the budget (unverified) and the priority could only demote sampled textures. Nobody has an on / off run on the 8 GB card that motivated #3156. (2) Thin evidence for a default. The +50 % is from #3156 on an older base with a local input-timing patch on one RTX 4080, and the 5070 Ti result was a lab cherry-pick. AMD was run only on Linux with vkd3d-proton (no effect). Windows + AMD, 8-12 GB cards and Intel are missing. (3) Peak commit rises with it on in both runs that exist: 16355 -> 17926 MB in this PR's smoke, 17174 -> 18004 MB in my #3156 run with the switch. That's within the gate but unexplained, since neither run went over the budget. (4) The new test (vram.rs ~4162) covers only the env parse; nothing checks that place_on_pages / remap_if_unmapped reach keep_pools. (5) README ~420-422: page pools get HIGH when a target lands on them, not when they're made, and they keep it. Every non-target texture page is NORMAL, not only idle ones. Fine: a failing ID3D12Device1 cast or SetResidencyPriority is logged once and the heap keeps the default (~1038). It never sets MAXIMUM and makes one call per heap, none per frame. Both smoke blocks are present (120 s, 3380 vs 3370 frames). A 60 s run here reaches the calls but stays under the 16 GB budget, so it shows that nothing breaks and the peak-commit delta, not the speed-up or a small-card regression.
performance: 60 s smoke of a retail title, main b2b1f10 vs this merge (5b8ac52): 1671 -> 1657 frames shown (99 %; last presents per 2 s: 60 60 60), peak commit 17394 -> 18126 MB, 0 device removals, 0 crashes. With the priority now on by default, the log shows window tile pools getting HIGH from 1 s in. On a 16 GB card a 60 s run stays under the budget, so this shows the calls break nothing (no device removal, frames at 99 %), not the speed-up or a small-card regression. Peak commit is 5.6 % above main here, smaller than the PR's own +9.6 %.
verdict: not yet: the code is fine and passes here, but as a default it needs the evidence #3156 didn't have: an on / off run on an 8-12 GB card (where the HIGH set can pass the budget, finding 1) and a Windows + AMD run; with those it would be safe to merge
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

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

One correction to the evidence above: the four runs behind "+50 %" used XCL_TWO_PASS_MB=512, which makes XCL skip a share of mesh draws (13–21 % in those runs, similar with and without the switch, so the comparison holds). With the default two-pass reserve and no draws skipped: 1.90 presents/s without XCL_RESIDENCY_PRIORITY (run 362) vs 3.31 with it (run 389, main 6bfb5c51 + #3395 built in, switch of #3395 unset), RTX 4080 16 GB, 900 s each, same save and inputs.

AI use: Claude Code (Claude Opus 5.5).

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Same-build check for the default flip: main 6bfb5c51 + #2987 (its switch unset), RTX 4080 16 GB, default two-pass reserve, no draws skipped: 2.19 presents/s without XCL_RESIDENCY_PRIORITY (run 395) against 3.31 with it on the same main (run 389), and 3.04 / 2.97 with it plus #2987's XCL_SPARSE_SYSMEM=1 (runs 394, 396). No device removal in any of them.

AI use: Claude Code (Claude Opus 5.5).

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:docs-ci Documentation, scripts, workflows, repo governance area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants