D3D12.X: count and report what console code cannot reach in unified memory #950

Closed
maximecmb wants to merge 1 commit from upstream-pr/956 into main
maximecmb commented 2026-11-24 09:29:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by maximecmb on 2026-11-24T09:29:32Z.


Part of #505. Diagnostics only: no behaviour change.

Once the coherent window is full, a console buffer XCL cannot place in unified memory becomes a plain PC resource, and every view of it gets an empty descriptor (num_records 0): a shader reads zeros there and its writes go nowhere. XCL counted these (NON_UMA_BUFFER_VIEWS) but never reported the count, and logged only the first one. So nobody can tell from a run whether the world load of the retail title creates thousands of them – which would fit the stop in #505 (the title stops submitting GPU work with no thread blocked in XCL, then its watchdog ends it) – or none.

In a hand-driven run of the retail title on main 077ce40 (RTX 5080): the coherent window was full (3998 / 4095 MB) from 43 s on; the world load started at ~44 s; the first #101 came at 59.5 s; presents and submits went to 0 at 62 s; the watchdog (+0x23cf683) at 90.4 s. 0 draws or dispatches skipped, 0 failed pipelines, 0 Wait64BitValueX timeouts, no title thread inside XCL or the driver at the crash. The single "buffer view … not in UMA" warning came at 14 s, and the log could say nothing more.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: OUTSIDE_UMA counts, by kind: buffer SRVs / UAVs / CBVs that get an empty V#, texture views XCL cannot shape (empty T#), console buffers that found no room in unified memory (coherent window and, where tried, sparse windows), committed console textures that found no room in the coherent window. The first of each kind is logged (its time shows when it starts). report.json gets them as d3d12.outside_uma (#[serde(default)], so older reports still read).
  • crates/xcl/src/host.rs: the XCL_ACTIVITY memory line (every 2 s) adds the coherent window's use and these counts, at its end (scripts/smoke.ps1 reads only its start). It reads unified memory through uma::current(), so reporting doesn't create it.
  • crates/xcl/src/gpu/uma.rs: current(), the title's graphics memory if it exists, without creating it (get() does), as @ettehn found; with a test that it's what get() made.
  • crates/xcl/src/hle/d3d12x/bind.rs: the "console code so far" line adds them too.
  • Tests in real.rs: each kind lands in its own field; a report without the field still reads.

Tested

  • NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug, DXC 1.9.2602.17
  • head 3261b74, rebased onto main 6efdabc
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 730 passed, 0 failed, 41 ignored
  • SKIPPED on this adapter (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware; no XCL_SAMPLE_* set

Regression run
main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1673 (PresentX 1673)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15184 MB

This PR:

xcl-smoke v1
commit: 3261b743ec8b256613b27978081f346f733bc7ee
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14764 MB

Not tested

  • AMD; Linux / Wine
  • this head in the world load. The counts from ad2f675 were posted on #505 and #697: the empty views sit in the title's 24 GB GPU-view reservation, and no resource ran out of room

AI use

  • Claude Code, Claude Opus 5.5: read the run's log and report, wrote the change, the tests and this description, and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6578723522 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/956). Originally posted by [maximecmb](https://github.com/maximecmb) on 2026-11-24T09:29:32Z. --- Part of #505. Diagnostics only: no behaviour change. Once the coherent window is full, a console buffer XCL cannot place in unified memory becomes a plain PC resource, and every view of it gets an empty descriptor (`num_records 0`): a shader reads zeros there and its writes go nowhere. XCL counted these (`NON_UMA_BUFFER_VIEWS`) but never reported the count, and logged only the first one. So nobody can tell from a run whether the world load of the retail title creates thousands of them – which would fit the stop in #505 (the title stops submitting GPU work with no thread blocked in XCL, then its watchdog ends it) – or none. In a hand-driven run of the retail title on `main` 077ce40 (RTX 5080): the coherent window was full (3998 / 4095 MB) from 43 s on; the world load started at ~44 s; the first `#101` came at 59.5 s; presents and submits went to 0 at 62 s; the watchdog (`+0x23cf683`) at 90.4 s. 0 draws or dispatches skipped, 0 failed pipelines, 0 `Wait64BitValueX` timeouts, no title thread inside XCL or the driver at the crash. The single "buffer view … not in UMA" warning came at 14 s, and the log could say nothing more. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `OUTSIDE_UMA` counts, by kind: buffer SRVs / UAVs / CBVs that get an empty V#, texture views XCL cannot shape (empty T#), console buffers that found no room in unified memory (coherent window and, where tried, sparse windows), committed console textures that found no room in the coherent window. The first of each kind is logged (its time shows when it starts). `report.json` gets them as `d3d12.outside_uma` (`#[serde(default)]`, so older reports still read). - `crates/xcl/src/host.rs`: the `XCL_ACTIVITY` memory line (every 2 s) adds the coherent window's use and these counts, at its end (`scripts/smoke.ps1` reads only its start). It reads unified memory through `uma::current()`, so reporting doesn't create it. - `crates/xcl/src/gpu/uma.rs`: `current()`, the title's graphics memory if it exists, without creating it (`get()` does), as @ettehn found; with a test that it's what `get()` made. - `crates/xcl/src/hle/d3d12x/bind.rs`: the "console code so far" line adds them too. - Tests in `real.rs`: each kind lands in its own field; a report without the field still reads. **Tested** - NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug, DXC 1.9.2602.17 - head `3261b74`, rebased onto `main` `6efdabc` - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 730 passed, 0 failed, 41 ignored - SKIPPED on this adapter (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`; no `XCL_SAMPLE_*` set **Regression run** `main`: ``` xcl-smoke v1 commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294 gpu: NVIDIA GeForce RTX 5080 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1673 (PresentX 1673) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15184 MB ``` This PR: ``` xcl-smoke v1 commit: 3261b743ec8b256613b27978081f346f733bc7ee gpu: NVIDIA GeForce RTX 5080 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14764 MB ``` **Not tested** - AMD; Linux / Wine - this head in the world load. The counts from `ad2f675` were posted on #505 and #697: the empty views sit in the title's 24 GB GPU-view reservation, and no resource ran out of room **AI use** - Claude Code, Claude Opus 5.5: read the run's log and report, wrote the change, the tests and this description, and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ettehn commented 2026-11-24 10:04:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-24T09:39:46Z.


At ad2f675, the new two-second activity sampler in host.rs calls uma::get(), which initializes the global UMA on first access. In a fresh Windows test process I isolated that exact sampling expression: GLOBAL was unset before the sample, but afterward the sample reported 64 MiB used / 512 MiB coherent capacity and the allocator logged 12 GiB of sparse virtual address space. These are allocator/window figures, not physical VRAM consumption.

A local coherent_usage() accessor using GLOBAL.get().and_then(Option::as_ref) instead returned (0, 0) and left the global unset. After explicit initialization, the same accessor matched used() and size(). This keeps enabling XCL_ACTIVITY from bringing UMA up just to report its size. No retail files used.

Verification assisted by OpenAI Codex (GPT-6.2 Astra).

<!-- greyfinch-sync:ivall/xcl:comment:7127716928 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7127716928). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-24T09:39:46Z. --- At `ad2f675`, the new two-second activity sampler in `host.rs` calls `uma::get()`, which initializes the global UMA on first access. In a fresh Windows test process I isolated that exact sampling expression: `GLOBAL` was unset before the sample, but afterward the sample reported 64 MiB used / 512 MiB coherent capacity and the allocator logged 12 GiB of sparse virtual address space. These are allocator/window figures, not physical VRAM consumption. A local `coherent_usage()` accessor using `GLOBAL.get().and_then(Option::as_ref)` instead returned `(0, 0)` and left the global unset. After explicit initialization, the same accessor matched `used()` and `size()`. This keeps enabling `XCL_ACTIVITY` from bringing UMA up just to report its size. No retail files used. Verification assisted by OpenAI Codex (GPT-6.2 Astra).
dcastell1 commented 2026-11-24 10:04:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T09:53:50Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@077ce40 (baseline 716 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
718 passed; 0 failed; 41 ignored   (exit 0)

Two more than the baseline. Note for the record: a first run of this patch, while the machine was also building another project, sat over 11 minutes in three title_textures tests and had to be stopped; with the box idle the same tree finishes in normal time and passes, so that was the environment, not the change.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7128036715 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7128036715). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T09:53:50Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@077ce40` (baseline **716 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 718 passed; 0 failed; 41 ignored (exit 0) ``` Two more than the baseline. Note for the record: a first run of this patch, while the machine was also building another project, sat over 11 minutes in three `title_textures` tests and had to be stopped; with the box idle the same tree finishes in normal time and passes, so that was the environment, not the change. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
maximecmb commented 2026-11-24 11:05:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by maximecmb on 2026-11-24T10:25:09Z.


@ettehn You're right, thank you. uma::get() is get_or_init, so the new activity line could create the title's graphics memory with default settings, in any process that hadn't made it yet. In a run the windows exist by 0.4 s and the first sample comes at 2 s, but nothing guaranteed that order.

Fixed in 3261b74 (squashed, rebased onto main 6efdabc):

  • gpu/uma.rs: uma::current(), GLOBAL.get().and_then(Option::as_ref), as you suggested. It doesn't create the memory.
  • host.rs: the activity line uses it. The other uma::get() calls this PR touches are main's own (the "console code so far" line, the report) and stay as they are.
  • A test that current() is what get() made. Whether it creates anything can't be checked in the shared test process, where other tests create the memory first; your isolated check covers that.

@dcastell1 thanks for the run. The head has changed since (above), and the regression run will be redone on it.

Tested on 3261b74: RTX 5080 (driver 617.42), Windows 11 26300, Rust 1.100.0 MSVC, debug. cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 730 passed, 0 failed, 41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7128754227 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7128754227). Originally posted by [maximecmb](https://github.com/maximecmb) on 2026-11-24T10:25:09Z. --- @ettehn You're right, thank you. `uma::get()` is `get_or_init`, so the new activity line could create the title's graphics memory with default settings, in any process that hadn't made it yet. In a run the windows exist by 0.4 s and the first sample comes at 2 s, but nothing guaranteed that order. Fixed in `3261b74` (squashed, rebased onto `main` `6efdabc`): - `gpu/uma.rs`: `uma::current()`, `GLOBAL.get().and_then(Option::as_ref)`, as you suggested. It doesn't create the memory. - `host.rs`: the activity line uses it. The other `uma::get()` calls this PR touches are `main`'s own (the "console code so far" line, the report) and stay as they are. - A test that `current()` is what `get()` made. Whether it creates anything can't be checked in the shared test process, where other tests create the memory first; your isolated check covers that. @dcastell1 thanks for the run. The head has changed since (above), and the regression run will be redone on it. Tested on `3261b74`: RTX 5080 (driver 617.42), Windows 11 26300, Rust 1.100.0 MSVC, debug. `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 730 passed, 0 failed, 41 ignored; SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.
SlopTart commented 2026-11-24 11:05:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T10:38:10Z.


Linux / AMD RDNA3 datapoint.

Merged state: head ad2f675 onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 719 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. unreachable-console-code counting tests green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7129043338 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7129043338). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T10:38:10Z. --- Linux / AMD RDNA3 datapoint. **Merged state:** head `ad2f675` onto main `9aec53d`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **719 passed, 7 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows. unreachable-console-code counting tests green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
thehollowedone commented 2026-11-24 13:03:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T12:37:04Z.


A focused check on 3261b74 found that an intentional null CBV increments empty_cbv. D3D12 allows the view description pointer to be null. This can inflate the count or trigger the first warning before any real buffer falls outside unified memory.

Tested. Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. A scratch test called dev_create_cbv_x on a registered console heap slot.

View PR head With the guard below
Address in unified memory +0 +0
Real native D3D12 buffer outside unified memory +1 +1
Null description pointer +1 +0

Changing the counter guard to if !in_uma && !desc.is_null() made the scratch test pass and preserved the descriptor words in all three cases. The two stock outside_uma_tests also passed. Both runs used cargo test --offline --locked -p xcl --lib <filter> -- --test-threads=1.

Not tested. How often a retail title creates null CBVs. The fixture checks descriptor creation and counters only.

AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch checks and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7131688134 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7131688134). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T12:37:04Z. --- A focused check on [`3261b74`](https://github.com/ivall/xcl/commit/3261b743ec8b256613b27978081f346f733bc7ee) found that an intentional null CBV increments `empty_cbv`. [D3D12 allows the view description pointer to be null](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createconstantbufferview). This can inflate the count or trigger the first warning before any real buffer falls outside unified memory. **Tested.** Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. A scratch test called `dev_create_cbv_x` on a registered console heap slot. | View | PR head | With the guard below | | --- | ---: | ---: | | Address in unified memory | +0 | +0 | | Real native D3D12 buffer outside unified memory | +1 | +1 | | Null description pointer | +1 | +0 | Changing the counter guard to `if !in_uma && !desc.is_null()` made the scratch test pass and preserved the descriptor words in all three cases. The two stock `outside_uma_tests` also passed. Both runs used `cargo test --offline --locked -p xcl --lib <filter> -- --test-threads=1`. **Not tested.** How often a retail title creates null CBVs. The fixture checks descriptor creation and counters only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch checks and drafted this report.
DavidM1911 commented 2026-11-24 13:03:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:41:44Z.


Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib real: 21 passed, 0 failed — includes outside_uma_tests::each_kind_lands_in_its_own_field and an_older_report_without_the_field_reads, covering the new unreachable-in-UMA counters and their report serialization.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7131793022 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7131793022). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T12:41:44Z. --- Independent verification, merged onto current `main` `384f7f7` locally (clean merge). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug. - `cargo test -p xcl --lib real`: **21 passed, 0 failed** — includes `outside_uma_tests::each_kind_lands_in_its_own_field` and `an_older_report_without_the_field_reads`, covering the new unreachable-in-UMA counters and their report serialization. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
ettehn commented 2026-11-24 13:03:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-24T13:00:11Z.


Confirmed the XCL_ACTIVITY fix on 3261b74 with the same isolated Windows regression probe. In a fresh test process, the sampler expression returned (0, 0) and left the UMA global unset. After explicit initialization, it returned the same used bytes and capacity as the initialized UMA object. One targeted test passed on Windows x64 (RTX 5070 Ti Laptop). OpenAI Codex (GPT-6.2 Sol) assisted with verification.

<!-- greyfinch-sync:ivall/xcl:comment:7132211542 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/956#issuecomment-7132211542). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-24T13:00:11Z. --- Confirmed the `XCL_ACTIVITY` fix on `3261b74` with the same isolated Windows regression probe. In a fresh test process, the sampler expression returned `(0, 0)` and left the UMA global unset. After explicit initialization, it returned the same used bytes and capacity as the initialized UMA object. One targeted test passed on Windows x64 (RTX 5070 Ti Laptop). OpenAI Codex (GPT-6.2 Sol) assisted with verification.
upstream-sync closed this pull request 2026-11-24 14:05:29 +00:00
DavidM1911 commented 2026-11-26 04:07:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:23:34Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7181678419 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/956#issuecomment-7181678419). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T03:23:34Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.

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