D3D12.X: XCL_UMA_UPLOAD_PRIORITY=1 keeps a mixed window's GPU_UPLOAD segment resident (nvidia-dev) #3007

Merged
Kalmarv merged 7 commits from upstream-pr/3007 into nvidia-dev 2026-11-28 03:51:45 +00:00
Kalmarv commented 2026-11-27 11:54:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-27T11:54:37Z.


Stacked on #3006; only the top commit (da9c69f7) belongs here. Part of #2688.

With XCL_UMA_DRIVER=mixed:<start_mb>:<size_mb> one range of the coherent window lives in a GPU_UPLOAD heap: video memory the CPU writes through the BAR, which every console program reads its buffers from. When the process is over its video memory budget, Windows demotes heaps to system memory, and it can pick that one. Then every read of the window's hot range goes over PCIe. This switch gives the GPU_UPLOAD segment D3D12_RESIDENCY_PRIORITY_MAXIMUM, so Windows demotes other heaps first. It is opt-in and does nothing without mixed.

Why
On a 16 GB card in a retail title's world (title: ea3b5e4d, Series X profile; the nvidia-dev port with the mixed window), the process ran about 1.9 GB over its budget. A live ETW timeline of the run (locum mem timeline) showed exactly one demoted heap of 1,792 MiB, the size of window 3's GPU_UPLOAD segment (mixed:1536:1792). The same run with this switch, everything else equal (the env differs by this switch only up to the measured frames):

without (run NS7) with (run NS8)
fps in the world, per 300 frames 1.4-1.9 5.1-5.2
frame wall time (GPU_TIMES, 2 frames) 560-577 ms 194-202 ms
top program b78fa10b (one 160x90 dispatch a frame) 214.5 ms/frame 4.4 ms/frame
over the video memory budget 1.9 GB 2.3 GB

The process stays over budget: Windows takes other heaps instead (the 64 MiB pool heaps), which cost far less per frame.

What is in it

  • crates/xcl/src/hle/d3d12x/uma_driver.rs: upload_priority_wanted (the switch, read once); mapped_segment calls ID3D12Device1::SetResidencyPriority(MAXIMUM) on a GPU_UPLOAD segment's heap and logs it (or the error).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), Ryzen 9 9950X, Windows 11 Pro 26200, Rust 1.99.0 MSVC, debug tests, release smoke; DXC 1.9.2609 via XCL_DXC_DIR.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on da9c69f7 (with CARGO_PROFILE_DEV_DEBUG=0: no debug info, for disk space): 1832 passed, 9 failed, 48 ignored. The same command on nvidia-dev a5e2d851: 1822 passed, 10 failed, 48 ignored.
  • Failed here and on a5e2d851 as well: console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • Failed here only: hle::d3d12x::vram::tests::gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark.
    • gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark alone, 10 times on 2fc61b64 (cargo test -p xcl --lib gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark): 10 passed, 0 failed.
    • gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark alone, 10 times on a5e2d851 (cargo test -p xcl --lib gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark): 10 passed, 0 failed.
  • 26 SKIPPED: 8 no wave64; 1 const_mask, wave64: no wave64; 1 f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); 1 f16 arithmetic, wave64: no wave64; 1 f32 arithmetic, wave64: no wave64; 1 f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); 1 f16 packed, wave64: no wave64; 1 f32 compares, wave64: no wave64; 1 integer arithmetic, wave64: no wave64; 1 mask_ff0_flbit, wave64: no wave64; 1 f64, wave64: no wave64; 1 f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); 1 f32 conversions, wave64: no wave64; 1 integer carries, wave64: no wave64; 1 f32 rounding, wave64: no wave64; 1 f32 transcendentals, wave64: no wave64; 1 f32 three-source, wave64: no wave64; 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1); 1 no heap windows.
  • CI: Build and test (Windows, no GPU) is red on nvidia-dev itself and on every PR into it, this one included: the lib test process ends with 0x887a0020 in a sparse test on the runner's software adapter, with no test reported failed. #2837 fixes that test; nothing here touches it.
  • The two runs in the table: 900 s each from the world's first frame, timed, GPU alone, the same DXIL cache.

Regression run
150 s runs, same title, same env (XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000, DXC 1.9), no switch of this PR set. The main run from a hard-link copy of our team branch's DXIL cache; the base and head runs from hard-link copies of one cache warmed on nvidia-dev a5e2d851 (on this branch the title starts after about 75-90 s of startup shader preparation, so 60 s would end inside it).

A commit of main (b49be183, the last one before the shader preparation screen of #2555):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1917 (PresentX 1917)
presents per 2 s (last 3): 0 0 2
device removals: 0
crashes: 0
peak commit: 33080 MB

The base, nvidia-dev a5e2d851:

xcl-smoke v1
commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2464 (PresentX 2464)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 34597 MB

This PR's head:

xcl-smoke v1
commit: da9c69f7f979c6a3e4b666ab6c24b032c59ab610
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2463 (PresentX 2463)
presents per 2 s (last 3): 0 0 3
device removals: 0
crashes: 0
peak commit: 38008 MB

Not tested

  • No unit test: D3D12 has no call that reads a heap's residency priority back, so the log line is the check; it appears once per GPU_UPLOAD segment in run NS8.
  • The regression run above has the switch off (and no mixed), so it shows the default path is unchanged; the switch itself ran only in NS8.
  • AMD (a GPU_UPLOAD heap there may already be placed differently), cards with other budgets, titles other than ea3b5e4d, layouts other than mixed:1536:1792.
  • Whether it should be on by default with mixed: left opt-in.

AI use
Claude Code: the change was written with Claude Fable 5; Claude Code (Claude Opus 5.5) ran the suite and the regression runs on the hardware above and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5526181678 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3007). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-27T11:54:37Z. --- Stacked on #3006; only the top commit (da9c69f7) belongs here. Part of #2688. With `XCL_UMA_DRIVER=mixed:<start_mb>:<size_mb>` one range of the coherent window lives in a `GPU_UPLOAD` heap: video memory the CPU writes through the BAR, which every console program reads its buffers from. When the process is over its video memory budget, Windows demotes heaps to system memory, and it can pick that one. Then every read of the window's hot range goes over PCIe. This switch gives the `GPU_UPLOAD` segment `D3D12_RESIDENCY_PRIORITY_MAXIMUM`, so Windows demotes other heaps first. It is opt-in and does nothing without `mixed`. **Why** On a 16 GB card in a retail title's world (title: ea3b5e4d, Series X profile; the nvidia-dev port with the mixed window), the process ran about 1.9 GB over its budget. A live ETW timeline of the run (locum `mem timeline`) showed exactly one demoted heap of 1,792 MiB, the size of window 3's `GPU_UPLOAD` segment (`mixed:1536:1792`). The same run with this switch, everything else equal (the env differs by this switch only up to the measured frames): | | without (run NS7) | with (run NS8) | |---|---|---| | fps in the world, per 300 frames | 1.4-1.9 | 5.1-5.2 | | frame wall time (GPU_TIMES, 2 frames) | 560-577 ms | 194-202 ms | | top program b78fa10b (one 160x90 dispatch a frame) | 214.5 ms/frame | 4.4 ms/frame | | over the video memory budget | 1.9 GB | 2.3 GB | The process stays over budget: Windows takes other heaps instead (the 64 MiB pool heaps), which cost far less per frame. **What is in it** - `crates/xcl/src/hle/d3d12x/uma_driver.rs`: `upload_priority_wanted` (the switch, read once); `mapped_segment` calls `ID3D12Device1::SetResidencyPriority(MAXIMUM)` on a `GPU_UPLOAD` segment's heap and logs it (or the error). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), Ryzen 9 9950X, Windows 11 Pro 26200, Rust 1.99.0 MSVC, debug tests, release smoke; DXC 1.9.2609 via `XCL_DXC_DIR`. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` on da9c69f7 (with `CARGO_PROFILE_DEV_DEBUG=0`: no debug info, for disk space): 1832 passed, 9 failed, 48 ignored. The same command on `nvidia-dev` `a5e2d851`: 1822 passed, 10 failed, 48 ignored. - Failed here and on `a5e2d851` as well: `console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly`, `hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays`, `hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels`, `split_compute_prefers_the_offline_whole_pipeline`, `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs`. - Failed here only: `hle::d3d12x::vram::tests::gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`. - `gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark` alone, 10 times on `2fc61b64` (`cargo test -p xcl --lib gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`): 10 passed, 0 failed. - `gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark` alone, 10 times on `a5e2d851` (`cargo test -p xcl --lib gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`): 10 passed, 0 failed. - 26 `SKIPPED`: 8 no wave64; 1 const_mask, wave64: no wave64; 1 f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); 1 f16 arithmetic, wave64: no wave64; 1 f32 arithmetic, wave64: no wave64; 1 f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); 1 f16 packed, wave64: no wave64; 1 f32 compares, wave64: no wave64; 1 integer arithmetic, wave64: no wave64; 1 mask_ff0_flbit, wave64: no wave64; 1 f64, wave64: no wave64; 1 f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); 1 f32 conversions, wave64: no wave64; 1 integer carries, wave64: no wave64; 1 f32 rounding, wave64: no wave64; 1 f32 transcendentals, wave64: no wave64; 1 f32 three-source, wave64: no wave64; 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1); 1 no heap windows. - CI: `Build and test (Windows, no GPU)` is red on `nvidia-dev` itself and on every PR into it, this one included: the lib test process ends with `0x887a0020` in a sparse test on the runner's software adapter, with no test reported failed. #2837 fixes that test; nothing here touches it. - The two runs in the table: 900 s each from the world's first frame, timed, GPU alone, the same DXIL cache. **Regression run** 150 s runs, same title, same env (`XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000`, DXC 1.9), no switch of this PR set. The `main` run from a hard-link copy of our team branch's DXIL cache; the base and head runs from hard-link copies of one cache warmed on `nvidia-dev` `a5e2d851` (on this branch the title starts after about 75-90 s of startup shader preparation, so 60 s would end inside it). A commit of `main` (`b49be183`, the last one before the shader preparation screen of #2555): ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1917 (PresentX 1917) presents per 2 s (last 3): 0 0 2 device removals: 0 crashes: 0 peak commit: 33080 MB ``` The base, `nvidia-dev` `a5e2d851`: ``` xcl-smoke v1 commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 2464 (PresentX 2464) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 34597 MB ``` This PR's head: ``` xcl-smoke v1 commit: da9c69f7f979c6a3e4b666ab6c24b032c59ab610 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 2463 (PresentX 2463) presents per 2 s (last 3): 0 0 3 device removals: 0 crashes: 0 peak commit: 38008 MB ``` **Not tested** - No unit test: D3D12 has no call that reads a heap's residency priority back, so the log line is the check; it appears once per `GPU_UPLOAD` segment in run NS8. - The regression run above has the switch off (and no `mixed`), so it shows the default path is unchanged; the switch itself ran only in NS8. - AMD (a `GPU_UPLOAD` heap there may already be placed differently), cards with other budgets, titles other than ea3b5e4d, layouts other than `mixed:1536:1792`. - Whether it should be on by default with `mixed`: left opt-in. **AI use** Claude Code: the change was written with Claude Fable 5; Claude Code (Claude Opus 5.5) ran the suite and the regression runs on the hardware above and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
throny commented 2026-11-27 16:09:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T16:09:05Z.


In-world test of this stack on an RTX 4080 16 GB (driver 621.40, 2 GiB shader-heap profile, Resizable BAR on: 16 GB BAR1), i9-12900K, Windows 11 26300, 64 GB + 32 GB page file. Tree: nvidia-dev d1be8103 + this PR's diff (which carries #3003-#3006) + #3008 + #3036 + #2987, and #684 / #2951 / a local press-timing patch so launches are quick and the scripted presses arrive. One build; the runs differ only in switches. Same save, 600 s each, default heap placement, XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072. Presents per second are taken from 240 s after the first game frame to the end (356-358 s in the world).

run switches of this stack coherent window presents/s video memory at the end (budget 15.2 GB)
A none one driver CUSTOM heap (the default-on part, #3003) 2.75 18.6 GB, 3.4 GB over
B XCL_UMA_DRIVER=mixed:1536:1792 1536 MB CUSTOM + 1792 MB GPU_UPLOAD + 767 MB CUSTOM 3.71 20.5 GB, 5.3 GB over
C B + XCL_UMA_UPLOAD_PRIORITY=1 + XCL_SMALL_TEXTURES=1 same 3.30 19.9 GB, 4.7 GB over

No device removal, crash or pipeline-wait timeout in any of the three; process commit about 50 GB.

For scale, on the same card and save: nvidia-dev without this stack does about 0.3 presents/s at default placement, and 1.5-1.7 with XCL_COHERENT_HEAPS=sparse (runs earlier today on 3f39671d / d1be8103). So the driver heap of #3003 alone is the big step here (0.3 → 2.75), and the mixed window adds about a third on top (2.75 → 3.71). The two extra switches in run C did not help on this card (3.30 against 3.71; one run each, so I would not call it a loss either). I see nothing like the 24-25 fps of #2938 here; the frame is GPU-bound at 100 % in all three.

Not tested: the picture (the world is black on this machine on every build, see #505), runs longer than 10 minutes, an adapter without Resizable BAR, other range layouts, each of #3008 and #3036 on its own.

Numbers are from the logs of these runs. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7222917240 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3007#issuecomment-7222917240). Originally posted by [throny](https://github.com/throny) on 2026-11-27T16:09:05Z. --- **In-world test of this stack on an RTX 4080 16 GB** (driver 621.40, 2 GiB shader-heap profile, Resizable BAR on: 16 GB BAR1), i9-12900K, Windows 11 26300, 64 GB + 32 GB page file. Tree: `nvidia-dev` `d1be8103` + this PR's diff (which carries #3003-#3006) + #3008 + #3036 + #2987, and #684 / #2951 / a local press-timing patch so launches are quick and the scripted presses arrive. One build; the runs differ only in switches. Same save, 600 s each, default heap placement, `XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072`. Presents per second are taken from 240 s after the first game frame to the end (356-358 s in the world). | run | switches of this stack | coherent window | presents/s | video memory at the end (budget 15.2 GB) | |---|---|---|---|---| | A | none | one driver CUSTOM heap (the default-on part, #3003) | 2.75 | 18.6 GB, 3.4 GB over | | B | `XCL_UMA_DRIVER=mixed:1536:1792` | 1536 MB CUSTOM + 1792 MB `GPU_UPLOAD` + 767 MB CUSTOM | **3.71** | 20.5 GB, 5.3 GB over | | C | B + `XCL_UMA_UPLOAD_PRIORITY=1` + `XCL_SMALL_TEXTURES=1` | same | 3.30 | 19.9 GB, 4.7 GB over | No device removal, crash or pipeline-wait timeout in any of the three; process commit about 50 GB. For scale, on the same card and save: `nvidia-dev` without this stack does about 0.3 presents/s at default placement, and 1.5-1.7 with `XCL_COHERENT_HEAPS=sparse` (runs earlier today on `3f39671d` / `d1be8103`). So the driver heap of #3003 alone is the big step here (0.3 → 2.75), and the mixed window adds about a third on top (2.75 → 3.71). The two extra switches in run C did not help on this card (3.30 against 3.71; one run each, so I would not call it a loss either). I see nothing like the 24-25 fps of #2938 here; the frame is GPU-bound at 100 % in all three. **Not tested:** the picture (the world is black on this machine on every build, see #505), runs longer than 10 minutes, an adapter without Resizable BAR, other range layouts, each of #3008 and #3036 on its own. Numbers are from the logs of these runs. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this.
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!3007
No description provided.