D3D12.X: memory by owner counts the D3D12 heaps' charge to commit #3344

Closed
cj-tomlin wants to merge 2 commits from upstream-pr/3344 into main
cj-tomlin commented 2026-11-29 09:39:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-11-29T09:39:03Z.


Stacked on #3343; only the top commit (0f0cc342) belongs here.

Windows charges a process's D3D12 heaps, local and non-local, to its commit, so memory by owner left them in commit other and counted them a second time under video memory. A new D3D12 heaps commit part is both DXGI segments' usage less the committed windows the GPU reads in place (imported, or remade as a driver heap on NVIDIA), which the UMA window part already has. A shadowed window is a separate copy in video memory and is not subtracted. Part of #3211 (C).

The part and uma_imported_bytes() come from #2697 (@joeypercia), adapted to main's per-window heap list. #2999 carries them too but conflicts with main; I asked there before opening this, and will close this if #2999 is rebased first.

What is in it

  • hle/d3d12x/real.rs: uma_imported_bytes(), the bytes of the committed windows in UMA_HEAPS, 0 when shadowed or before they are opened
  • hle/d3d12x/memory_report.rs: heap_charge() and the D3D12 heaps part; a unit test of heap_charge, and the device test expects the new part

Tested

  • RTX 3080 10 GB (NVIDIA 621.40), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0; tests in debug, smoke and title runs in release
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 0f0cc342: 2,620 passed, 0 failed, 49 ignored (41 targets)
  • SKIPPED on this adapter: 21 no wave64, 3 refused per-lane forms (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer
  • A retail title into the world for 110 s with VMMap snapshots: the D3D12 heaps part against VMMap's write-combined private regions, and commit other against VMMap's private memory less the UMA window, sparse CPU copy and write-combined regions (MB):
32 s 44 s 51 s 64 s
D3D12 heaps 6,948 7,589 7,973 9,654
VMMap write-combined 6,803 7,636 7,829 9,766
commit other 3,757 4,644 5,034 6,857
VMMap rest 3,881 4,734 5,299 7,097

Before this, other at 64 s would have been 16,511 MB. Snapshots taken while the system was paging came back partial and are left out. A VirtualAlloc trace of an earlier run (#3211) put 19,470 MB of commit on dxgmms2.sys against 19,468 MB of local + non-local.

Regression run
A retail title, 120 s, XCL_PREPARE=0, XCL_PRESS_AT=25:A (loads a save into the world), the same DXIL cache copy and data root for both.

xcl-smoke v1
commit: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0
gpu: NVIDIA GeForce RTX 3080
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 1933 (PresentX 1933)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33571 MB
xcl-smoke v1
commit: 0f0cc3429f04c5a57192a1e414de8aa50682dec6
gpu: NVIDIA GeForce RTX 3080
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 1960 (PresentX 1960)
presents per 2 s (last 3): 43 35 0
device removals: 0
crashes: 0
peak commit: 32053 MB

Not tested

  • AMD (imported windows rather than a driver heap), integrated GPUs (one segment), a shadowed window (XCL_UMA_SHADOW=1), XCL_UMA_DRIVER=mixed, other NVIDIA drivers

AI use

  • Claude Code (Claude Opus 5.5): adapted the part to main, wrote the tests, ran the tests, title runs and smoke runs, wrote this description. I checked the diff and the results.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5549485981 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3344). Originally posted by [cj-tomlin](https://github.com/cj-tomlin) on 2026-11-29T09:39:03Z. --- Stacked on #3343; only the top commit (`0f0cc342`) belongs here. Windows charges a process's D3D12 heaps, local and non-local, to its commit, so `memory by owner` left them in commit `other` and counted them a second time under video memory. A new `D3D12 heaps` commit part is both DXGI segments' usage less the committed windows the GPU reads in place (imported, or remade as a driver heap on NVIDIA), which the `UMA window` part already has. A shadowed window is a separate copy in video memory and is not subtracted. Part of #3211 (C). The part and `uma_imported_bytes()` come from #2697 (@joeypercia), adapted to `main`'s per-window heap list. #2999 carries them too but conflicts with `main`; I asked there before opening this, and will close this if #2999 is rebased first. **What is in it** - `hle/d3d12x/real.rs`: `uma_imported_bytes()`, the bytes of the committed windows in `UMA_HEAPS`, 0 when shadowed or before they are opened - `hle/d3d12x/memory_report.rs`: `heap_charge()` and the `D3D12 heaps` part; a unit test of `heap_charge`, and the device test expects the new part **Tested** - RTX 3080 10 GB (NVIDIA 621.40), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0; tests in debug, smoke and title runs in release - `cargo test --workspace --no-fail-fast -- --test-threads=4` at `0f0cc342`: 2,620 passed, 0 failed, 49 ignored (41 targets) - SKIPPED on this adapter: 21 no wave64, 3 refused per-lane forms (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer - A retail title into the world for 110 s with VMMap snapshots: the `D3D12 heaps` part against VMMap's write-combined private regions, and commit `other` against VMMap's private memory less the UMA window, sparse CPU copy and write-combined regions (MB): | | 32 s | 44 s | 51 s | 64 s | |---|---:|---:|---:|---:| | `D3D12 heaps` | 6,948 | 7,589 | 7,973 | 9,654 | | VMMap write-combined | 6,803 | 7,636 | 7,829 | 9,766 | | commit `other` | 3,757 | 4,644 | 5,034 | 6,857 | | VMMap rest | 3,881 | 4,734 | 5,299 | 7,097 | Before this, `other` at 64 s would have been 16,511 MB. Snapshots taken while the system was paging came back partial and are left out. A `VirtualAlloc` trace of an earlier run ([#3211](https://github.com/xcl-dev/xcl/issues/3211#issuecomment-7247218444)) put 19,470 MB of commit on `dxgmms2.sys` against 19,468 MB of local + non-local. **Regression run** A retail title, 120 s, `XCL_PREPARE=0`, `XCL_PRESS_AT=25:A` (loads a save into the world), the same DXIL cache copy and data root for both. ``` xcl-smoke v1 commit: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0 gpu: NVIDIA GeForce RTX 3080 title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 1933 (PresentX 1933) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 33571 MB ``` ``` xcl-smoke v1 commit: 0f0cc3429f04c5a57192a1e414de8aa50682dec6 gpu: NVIDIA GeForce RTX 3080 title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 1960 (PresentX 1960) presents per 2 s (last 3): 43 35 0 device removals: 0 crashes: 0 peak commit: 32053 MB ``` **Not tested** - AMD (imported windows rather than a driver heap), integrated GPUs (one segment), a shadowed window (`XCL_UMA_SHADOW=1`), `XCL_UMA_DRIVER=mixed`, other NVIDIA drivers **AI use** - Claude Code (Claude Opus 5.5): adapted the part to `main`, wrote the tests, ran the tests, title runs and smoke runs, wrote this description. I checked the diff and the results. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
minimalhipster990 commented 2026-11-29 17:16:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by minimalhipster990 on 2026-11-29T17:16:11Z.


RTX 4090 24 GB, 32 GB RAM, retail world to device removal: with this PR other ends at 15.8–18.2 GB, against 33–36 GB in six earlier runs of the same setup without it, and D3D12 heaps ends at 18.8–19.2 GB. These runs go well past 110 s (to 268 and 437 s), on a card where video memory alone is 17.5 GB.

Setup

  • RTX 4090 24 GB, NVIDIA 621.40, 32 GB RAM, Windows 11 build 26300, system-managed page file, Rust 1.99.1, release with --locked.
  • Tree: main 7a649b0e + #3318 head f5496479 (without it this title does not reach the world on main with XCL_GFX_PSO_WAIT_MS set) + this PR's head 0f0cc342. Clean merges, local commit 966f035b.
  • cargo test --release --locked -p xcl --lib memory_report -- --test-threads=1: 5 passed, 0 failed (including snapshot_does_not_initialize_uma, heap_charge_is_both_segments_less_the_windows_read_in_place and device_snapshot_has_budget_and_all_owners on the 4090).
  • Retail title (Series X profile), the same save and inputs, 600 s limit, from a verified copy of the same warm XCL cache: XCL_ACTIVITY=1 XCL_GFX_PSO_WAIT_MS=50 XCL_CS_PSO_WAIT_MS=200 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_COHERENT_HEAPS=sparse XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=3990 XCL_TWO_PASS_MB=3072, XCL_PREPARE=0.

memory by owner, commit parts (MB), from the 2 s lines nearest each time. The in-place windows come to 3,989–3,990 MB here (local + non-local − D3D12 heaps), so the UMA window part is not counted twice.

run A 20 s 60 s 110 s 199 s 300 s 401 s 435 s (last)
process commit 25,740 28,274 37,293 43,342 43,523 45,975 44,384
D3D12 heaps 11,959 12,282 14,746 17,338 18,959 19,062 19,062
other 4,217 6,428 12,983 16,439 14,999 17,349 15,757
local / non-local 11,390 / 4,558 11,593 / 4,678 13,913 / 4,823 16,314 / 5,013 17,524 / 5,425 17,621 / 5,430 17,621 / 5,430
run B 20 s 60 s 110 s 199 s 268 s (last)
process commit 26,730 28,919 37,391 46,576 46,504
D3D12 heaps 11,593 12,318 14,922 19,154 18,761
other 5,573 7,037 12,905 17,858 18,178

UMA window (3,990) and sparse CPU copy (5,573) are flat in both runs.

  • other at 60 s is 6.4–7.0 GB, close to the 6.9 GB at 64 s in the description on an RTX 3080. After 110 s it keeps rising, to 15.8–18.2 GB: +2.8–5.3 GB from 110 s to the end, beside +3.8–4.3 GB of D3D12 heaps.
  • I did not take VMMap snapshots, so the split is not checked against VMMap here.

System commit. The rest of the system holds a steady 12.4–12.9 GB of commit. So on this 32 GB PC, system commit is at its limit once the process holds ~43–44 GB.

  • System commit was within 1 GB of the limit for 44 of A's 2 s samples (from 181 s) and 20 of B's (from 122 s). The closest point was 124 MB.
  • The page file grew in ~1 GB steps, taking the limit from 56.2 to 61.4–62.4 GB.
  • Both runs ended in device removal (0x887A0005) with 3.6–4.2 GB left, with no DRED breadcrumbs. Run A reached the world at 310.3 s; run B did not (last present 267.8 s).
  • I have not shown that commit causes the removal: removal comes after long stretches near the limit, but not at the minimum. Two earlier main runs without #3318 were removed at 133–144 s with 1.2–1.7 GB left, before the page file had grown at all.

Not tested: VMMap or a VirtualAlloc trace (no admin shell on this PC), AMD, this PR on main alone, without XCL_UMA_WINDOWS=16 / XCL_HEAP_WINDOWS=1, and a fixed-size page file.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the tests and the replays, and wrote this report. The person running these tests asked for it.

<!-- greyfinch-sync:ivall/xcl:comment:7259556837 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3344#issuecomment-7259556837). Originally posted by [minimalhipster990](https://github.com/minimalhipster990) on 2026-11-29T17:16:11Z. --- **RTX 4090 24 GB, 32 GB RAM, retail world to device removal: with this PR `other` ends at 15.8–18.2 GB, against 33–36 GB in six earlier runs of the same setup without it, and `D3D12 heaps` ends at 18.8–19.2 GB.** These runs go well past 110 s (to 268 and 437 s), on a card where video memory alone is 17.5 GB. **Setup** - RTX 4090 24 GB, NVIDIA 621.40, 32 GB RAM, Windows 11 build 26300, system-managed page file, Rust 1.99.1, release with `--locked`. - Tree: `main` `7a649b0e` + #3318 head `f5496479` (without it this title does not reach the world on `main` with `XCL_GFX_PSO_WAIT_MS` set) + this PR's head `0f0cc342`. Clean merges, local commit `966f035b`. - `cargo test --release --locked -p xcl --lib memory_report -- --test-threads=1`: 5 passed, 0 failed (including `snapshot_does_not_initialize_uma`, `heap_charge_is_both_segments_less_the_windows_read_in_place` and `device_snapshot_has_budget_and_all_owners` on the 4090). - Retail title (Series X profile), the same save and inputs, 600 s limit, from a verified copy of the same warm XCL cache: `XCL_ACTIVITY=1 XCL_GFX_PSO_WAIT_MS=50 XCL_CS_PSO_WAIT_MS=200 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_COHERENT_HEAPS=sparse XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=3990 XCL_TWO_PASS_MB=3072`, `XCL_PREPARE=0`. **`memory by owner`, commit parts (MB)**, from the 2 s lines nearest each time. The in-place windows come to 3,989–3,990 MB here (local + non-local − `D3D12 heaps`), so the `UMA window` part is not counted twice. | run A | 20 s | 60 s | 110 s | 199 s | 300 s | 401 s | 435 s (last) | |---|---:|---:|---:|---:|---:|---:|---:| | process commit | 25,740 | 28,274 | 37,293 | 43,342 | 43,523 | 45,975 | 44,384 | | `D3D12 heaps` | 11,959 | 12,282 | 14,746 | 17,338 | 18,959 | 19,062 | 19,062 | | `other` | 4,217 | 6,428 | 12,983 | 16,439 | 14,999 | 17,349 | 15,757 | | local / non-local | 11,390 / 4,558 | 11,593 / 4,678 | 13,913 / 4,823 | 16,314 / 5,013 | 17,524 / 5,425 | 17,621 / 5,430 | 17,621 / 5,430 | | run B | 20 s | 60 s | 110 s | 199 s | 268 s (last) | |---|---:|---:|---:|---:|---:| | process commit | 26,730 | 28,919 | 37,391 | 46,576 | 46,504 | | `D3D12 heaps` | 11,593 | 12,318 | 14,922 | 19,154 | 18,761 | | `other` | 5,573 | 7,037 | 12,905 | 17,858 | 18,178 | `UMA window` (3,990) and `sparse CPU copy` (5,573) are flat in both runs. - `other` at 60 s is 6.4–7.0 GB, close to the 6.9 GB at 64 s in the description on an RTX 3080. After 110 s it keeps rising, to 15.8–18.2 GB: +2.8–5.3 GB from 110 s to the end, beside +3.8–4.3 GB of `D3D12 heaps`. - I did not take VMMap snapshots, so the split is not checked against VMMap here. **System commit.** The rest of the system holds a steady 12.4–12.9 GB of commit. So on this 32 GB PC, system commit is at its limit once the process holds ~43–44 GB. - System commit was within 1 GB of the limit for 44 of A's 2 s samples (from 181 s) and 20 of B's (from 122 s). The closest point was 124 MB. - The page file grew in ~1 GB steps, taking the limit from 56.2 to 61.4–62.4 GB. - Both runs ended in device removal (`0x887A0005`) with 3.6–4.2 GB left, with no DRED breadcrumbs. Run A reached the world at 310.3 s; run B did not (last present 267.8 s). - I have not shown that commit causes the removal: removal comes after long stretches near the limit, but not at the minimum. Two earlier `main` runs without #3318 were removed at 133–144 s with 1.2–1.7 GB left, before the page file had grown at all. **Not tested:** VMMap or a `VirtualAlloc` trace (no admin shell on this PC), AMD, this PR on `main` alone, without `XCL_UMA_WINDOWS=16` / `XCL_HEAP_WINDOWS=1`, and a fixed-size page file. AI use: Claude Code (Claude Opus 5.5) built the tree, ran the tests and the replays, and wrote this report. The person running these tests asked for it.
cj-tomlin commented 2026-11-30 16:39:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-11-30T16:39:39Z.


Closing as a duplicate: #3229 (merged) adds the same D3D12 heaps commit part and also covers the mixed and legacy UMA modes.

<!-- greyfinch-sync:ivall/xcl:comment:7285028958 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3344#issuecomment-7285028958). Originally posted by [cj-tomlin](https://github.com/cj-tomlin) on 2026-11-30T16:39:39Z. --- Closing as a duplicate: #3229 (merged) adds the same D3D12 heaps commit part and also covers the mixed and legacy UMA modes.

Pull request closed

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!3344
No description provided.