D3D12.X: report UMA DXGI backing and D3D12 heap commit without allocating UMA #3229

Merged
lnqigr merged 1 commit from upstream-pr/3229 into main 2026-11-29 13:55:14 +00:00
lnqigr commented 2026-11-28 23:25:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lnqigr on 2026-11-28T23:25:18Z.


Follow-up to #2697; part of #3211 (Workstream C) and #1773.

On current main, memory_report::snapshot() calls uma::get(), which can allocate and commit the coherent UMA window on a fresh process before the title asks for it (noted by @thehollowedone on #2697). It also leaves both WDDM's commit charge for D3D12 heaps and the DXGI-backed coherent UMA window unattributed inside other.

This PR adds a read-only uma::existing() accessor, tracks per-device coherent UMA bytes counted by DXGI across all open_uma modes (driver CUSTOM L0, mixed: GPU_UPLOAD + L0, legacy OpenExistingHeapFromAddress, and shadowed windows without double counting), and reports D3D12 heaps on Commit plus UMA window on its DXGI segment.

What is in it

  • crates/xcl/src/gpu/uma.rs: add uma::existing() returning the initialized Uma without allocating one.
  • crates/xcl/src/hle/d3d12x/real.rs: record per-device coherent UMA (non_local, local) bytes backed by DXGI in open_uma (0 for shadowed windows whose CPU and GPU allocations are separate) and expose uma_dxgi_bytes_for(device).
  • crates/xcl/src/hle/d3d12x/memory_report.rs: switch snapshot() to uma::existing(), add D3D12 heaps ((local + non_local).saturating_sub(uma_dxgi_shared)) on Commit and UMA window on its DXGI segment (UMA window (local) when mixed: places GPU_UPLOAD segments in local VRAM), plus unit tests and a child-process regression proving snapshot() does not initialize UMA.

Tested

  • Hardware: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 610.88), Intel Core i9-14900HX, 32 GB RAM, Windows 11 Build 26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug + release.
  • cargo test -p xcl --lib memory_report -- --nocapture --test-threads=1: 5 passed, 0 failed, 0 ignored (0 skipped).
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2,596 passed, 0 failed, 49 ignored across 41 test targets.
  • SKIPPED GPU tests (30 total): 21 no wave64 (NVIDIA wave32 adapter), 4 no D3D12 debug layer / Developer Mode (0x887A002D / missing d3d12SDKLayers.dll), 3 per-lane f16/f32 refused (#1426), 2 no heap windows.
  • Retail title (dc7b94e1, 60 s XCL_ACTIVITY=1 XCL_PREPARE=0, NVIDIA driver CUSTOM L0 UMA): at t=60 s, commit other dropped from 9235 MB (main 7db2f391) to 2799 MB (D3D12 heaps 6812), and non-local other dropped from 4765 MB to 754 MB (UMA window 4095).

Regression run
main baseline (XCL_PREPARE=0):

xcl-smoke v1
commit: 7db2f391cefd748d47c7de63d50dd43ebb852185
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: dc7b94e1
seconds: 60
exit: 0x0
frames shown: 1410 (PresentX 1410)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

PR head (XCL_PREPARE=0):

xcl-smoke v1
commit: 0ba1060ca196d0a937087307cfb750bb2c1e11ed
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: dc7b94e1
seconds: 60
exit: 0x0
frames shown: 1585 (PresentX 1585)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14850 MB

Not tested

  • AMD GPUs / native wave64 hardware.
  • Single-segment integrated GPUs (non_local.budget == 0), XCL_UMA_DRIVER=mixed:..., XCL_UMA_SHADOW=1, and Wine on live hardware (covered by unit tests only).

AI use

  • Antigravity (Google DeepMind; exact model version string not exposed to the agent): reviewed #2697 / current main UMA paths, wrote the code, unit tests, and PR description, and ran the workspace tests and smoke runs locally; the human contributor (lnqigr) directed the scope and reviewed the diff and results before opening the PR.
<!-- greyfinch-sync:ivall/xcl:issue:5545603382 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3229). Originally posted by [lnqigr](https://github.com/lnqigr) on 2026-11-28T23:25:18Z. --- Follow-up to #2697; part of #3211 (Workstream C) and #1773. On current `main`, `memory_report::snapshot()` calls `uma::get()`, which can allocate and commit the coherent UMA window on a fresh process before the title asks for it (noted by `@thehollowedone` on #2697). It also leaves both WDDM's commit charge for D3D12 heaps and the DXGI-backed coherent UMA window unattributed inside `other`. This PR adds a read-only `uma::existing()` accessor, tracks per-device coherent UMA bytes counted by DXGI across all `open_uma` modes (driver CUSTOM L0, `mixed:` GPU_UPLOAD + L0, legacy `OpenExistingHeapFromAddress`, and shadowed windows without double counting), and reports `D3D12 heaps` on `Commit` plus `UMA window` on its DXGI segment. **What is in it** - `crates/xcl/src/gpu/uma.rs`: add `uma::existing()` returning the initialized `Uma` without allocating one. - `crates/xcl/src/hle/d3d12x/real.rs`: record per-device coherent UMA `(non_local, local)` bytes backed by DXGI in `open_uma` (0 for shadowed windows whose CPU and GPU allocations are separate) and expose `uma_dxgi_bytes_for(device)`. - `crates/xcl/src/hle/d3d12x/memory_report.rs`: switch `snapshot()` to `uma::existing()`, add `D3D12 heaps` (`(local + non_local).saturating_sub(uma_dxgi_shared)`) on `Commit` and `UMA window` on its DXGI segment (`UMA window (local)` when `mixed:` places `GPU_UPLOAD` segments in local VRAM), plus unit tests and a child-process regression proving `snapshot()` does not initialize UMA. **Tested** - Hardware: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 610.88), Intel Core i9-14900HX, 32 GB RAM, Windows 11 Build 26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, debug + release. - `cargo test -p xcl --lib memory_report -- --nocapture --test-threads=1`: 5 passed, 0 failed, 0 ignored (0 skipped). - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 2,596 passed, 0 failed, 49 ignored across 41 test targets. - `SKIPPED` GPU tests (30 total): 21 `no wave64` (NVIDIA wave32 adapter), 4 `no D3D12 debug layer / Developer Mode` (`0x887A002D` / missing `d3d12SDKLayers.dll`), 3 `per-lane f16/f32 refused (#1426)`, 2 `no heap windows`. - Retail title (`dc7b94e1`, 60 s `XCL_ACTIVITY=1 XCL_PREPARE=0`, NVIDIA driver CUSTOM L0 UMA): at t=60 s, `commit other` dropped from `9235 MB` (`main` `7db2f391`) to `2799 MB` (`D3D12 heaps 6812`), and `non-local other` dropped from `4765 MB` to `754 MB` (`UMA window 4095`). **Regression run** `main` baseline (`XCL_PREPARE=0`): ``` xcl-smoke v1 commit: 7db2f391cefd748d47c7de63d50dd43ebb852185 gpu: NVIDIA GeForce RTX 4060 Laptop GPU title: dc7b94e1 seconds: 60 exit: 0x0 frames shown: 1410 (PresentX 1410) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14593 MB ``` PR head (`XCL_PREPARE=0`): ``` xcl-smoke v1 commit: 0ba1060ca196d0a937087307cfb750bb2c1e11ed gpu: NVIDIA GeForce RTX 4060 Laptop GPU title: dc7b94e1 seconds: 60 exit: 0x0 frames shown: 1585 (PresentX 1585) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14850 MB ``` **Not tested** - AMD GPUs / native wave64 hardware. - Single-segment integrated GPUs (`non_local.budget == 0`), `XCL_UMA_DRIVER=mixed:...`, `XCL_UMA_SHADOW=1`, and Wine on live hardware (covered by unit tests only). **AI use** - Antigravity (Google DeepMind; exact model version string not exposed to the agent): reviewed `#2697` / current `main` UMA paths, wrote the code, unit tests, and PR description, and ran the workspace tests and smoke runs locally; the human contributor (`lnqigr`) directed the scope and reviewed the diff and results before opening the PR.
Kalmarv commented 2026-11-29 01:20:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T01:20:47Z.


merge-check
base: fa204595a4
head: 0ba1060ca1
merge: clean (trial merge 66558152906181c51030745b97a582dbcea1aa8e, local, not pushed; git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2609 passed, 1 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: hle::d3d12x::list_x::tests::bundle_generations_propagate_and_final_release_runs_outside_lists ("final COM Release ran under LISTS"). This PR doesn't touch list_x, and the test passed 3 of 3 times when rerun alone on the same merge. Its probe is LISTS.try_lock().is_ok(), so any parallel test holding the global LISTS lock at that moment fails it. All five memory_report::tests ran and passed, including the new heap_charge_and_uma_segment_avoid_double_counting and snapshot_does_not_initialize_uma (child process) and the extended device_snapshot_has_budget_and_all_owners.
review: none blocking; whole diff read (uma.rs, memory_report.rs, real.rs). snapshot() now reads the UMA region with uma::existing() instead of uma::get(), so a report no longer creates the region; in a run it already exists, so values don't change. open_uma records, per device, the coherent window bytes DXGI counts: a non-shadowed CPU-built window goes to non-local in full. A driver-remade window goes to non-local for its write-watched CUSTOM L0 segments and to local for the rest, which in a mixed window are its GPU_UPLOAD segments; uma_driver::Remade documents watched regions as exactly the CUSTOM ones. Shadowed windows are left out. The new "D3D12 heaps" Commit part is local + non-local usage minus that shared amount, saturating and 0 when either segment is unknown. The "UMA window" non-local part goes to Kind::Video on a single-segment adapter. The new parts change the other remainders the report prints, as intended. That Windows charges process commit for D3D12 local heaps is the PR's model; I didn't verify it independently, but the numbers below are consistent with it.
performance: reporting only; one extra mutex read per snapshot. Title run (release build of the merge, scratch/fast-world.py fast profile, 30 s in world; same cache snapshot and harness as a main fa204595 run): exit 0, 0 crashes, 0 removals, world entry 91.1 s (main 90.6 s), peak commit 29,964 MB (main 28,620 MB, +4.7 %; this run compiled more pipelines in the world, and the PR allocates nothing), 91 WARN lines (main 70), no new WARN kinds, failed_pipelines 0, no translation errors. All 125 "memory by owner" lines have non-negative remainders. The last one: commit 29,661 (UMA window 5,094, sparse CPU copy 1,561, D3D12 heaps 12,016, other 10,989); video 12,555 (... UMA window (local) 1,792, other 1,831); non-local 4,555 (UMA window 3,302, other 1,253). So DXGI's shared bytes (3,302 + 1,792) equal the 5,094 MB window, and Commit "other" drops from about 21,985 MB on main to 10,989 MB. Both runs show 0 fps in the world because the cache doesn't match the translator identity; timings are noise.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only, Resizable BAR), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite, title run and full-diff review; this report.

<!-- greyfinch-sync:ivall/xcl:comment:7248721865 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3229#issuecomment-7248721865). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T01:20:47Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: 0ba1060ca196d0a937087307cfb750bb2c1e11ed merge: clean (trial merge 66558152906181c51030745b97a582dbcea1aa8e, local, not pushed; `git diff --check` clean) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2609 passed, 1 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: `hle::d3d12x::list_x::tests::bundle_generations_propagate_and_final_release_runs_outside_lists` ("final COM Release ran under LISTS"). This PR doesn't touch `list_x`, and the test passed 3 of 3 times when rerun alone on the same merge. Its probe is `LISTS.try_lock().is_ok()`, so any parallel test holding the global `LISTS` lock at that moment fails it. All five `memory_report::tests` ran and passed, including the new `heap_charge_and_uma_segment_avoid_double_counting` and `snapshot_does_not_initialize_uma` (child process) and the extended `device_snapshot_has_budget_and_all_owners`. review: none blocking; whole diff read (uma.rs, memory_report.rs, real.rs). `snapshot()` now reads the UMA region with `uma::existing()` instead of `uma::get()`, so a report no longer creates the region; in a run it already exists, so values don't change. `open_uma` records, per device, the coherent window bytes DXGI counts: a non-shadowed CPU-built window goes to non-local in full. A driver-remade window goes to non-local for its write-watched CUSTOM L0 segments and to local for the rest, which in a mixed window are its `GPU_UPLOAD` segments; `uma_driver::Remade` documents watched regions as exactly the CUSTOM ones. Shadowed windows are left out. The new "D3D12 heaps" Commit part is local + non-local usage minus that shared amount, saturating and 0 when either segment is unknown. The "UMA window" non-local part goes to `Kind::Video` on a single-segment adapter. The new parts change the `other` remainders the report prints, as intended. That Windows charges process commit for D3D12 local heaps is the PR's model; I didn't verify it independently, but the numbers below are consistent with it. performance: reporting only; one extra mutex read per snapshot. Title run (release build of the merge, scratch/fast-world.py fast profile, 30 s in world; same cache snapshot and harness as a main fa204595 run): exit 0, 0 crashes, 0 removals, world entry 91.1 s (main 90.6 s), peak commit 29,964 MB (main 28,620 MB, +4.7 %; this run compiled more pipelines in the world, and the PR allocates nothing), 91 WARN lines (main 70), no new WARN kinds, `failed_pipelines` 0, no translation errors. All 125 "memory by owner" lines have non-negative remainders. The last one: commit 29,661 (UMA window 5,094, sparse CPU copy 1,561, D3D12 heaps 12,016, other 10,989); video 12,555 (... UMA window (local) 1,792, other 1,831); non-local 4,555 (UMA window 3,302, other 1,253). So DXGI's shared bytes (3,302 + 1,792) equal the 5,094 MB window, and Commit "other" drops from about 21,985 MB on main to 10,989 MB. Both runs show 0 fps in the world because the cache doesn't match the translator identity; timings are noise. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only, Resizable BAR), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite, title run and full-diff review; this report.
throny commented 2026-11-29 08:41:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T08:41:42Z.


merge-check claim
head: 0ba1060ca1

<!-- greyfinch-sync:ivall/xcl:comment:7253271055 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3229#issuecomment-7253271055). Originally posted by [throny](https://github.com/throny) on 2026-11-29T08:41:42Z. --- merge-check claim head: 0ba1060ca196d0a937087307cfb750bb2c1e11ed
throny commented 2026-11-29 09:01:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:01:01Z.


merge-check
base: d8bd9a38
head: 0ba1060ca1
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2620 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored. The new test starts its own test binary once more as a child for one test; nothing else is spawned.
review: no blocking finding. Diagnostics only: the snapshot no longer creates the UMA region, a "D3D12 heaps" commit estimate is added, and the UMA window is listed under the segment it lives in. The split by segment is right for the write-watched, upload and shadowed cases. One assumption is not shown in the code: that Windows charges D3D12 video-memory use to the process's commit; a measurement in the description would settle it.
performance: none for a title (report code).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7253479294 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3229#issuecomment-7253479294). Originally posted by [throny](https://github.com/throny) on 2026-11-29T09:01:01Z. --- merge-check base: d8bd9a38 head: 0ba1060ca196d0a937087307cfb750bb2c1e11ed merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2620 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored. The new test starts its own test binary once more as a child for one test; nothing else is spawned. review: no blocking finding. Diagnostics only: the snapshot no longer creates the UMA region, a "D3D12 heaps" commit estimate is added, and the UMA window is listed under the segment it lives in. The split by segment is right for the write-watched, upload and shadowed cases. One assumption is not shown in the code: that Windows charges D3D12 video-memory use to the process's commit; a measurement in the description would settle it. performance: none for a title (report code). verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
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!3229
No description provided.