Skip to content

D3D12.X: memory by owner on nvidia-dev: two-pass buffers, GPU-view tiles - #2999

Open
pr1sm-dev wants to merge 8 commits into
xcl-dev:nvidia-devfrom
pr1sm-dev:pr/memory-owners
Open

pr1sm-dev wants to merge 8 commits into
xcl-dev:nvidia-devfrom
pr1sm-dev:pr/memory-owners

Conversation

@pr1sm-dev

@pr1sm-dev pr1sm-dev commented Nov 27, 2026 •

Copy link
Copy Markdown

The memory line by owner (#2697, #2750, #2776) on nvidia-dev, with the two owners this branch has and main does not. Part of #2688 (workstream 1).

Stacked on #2697, #2750 and #2776: the first three commits are @joeypercia's, cherry-picked onto nvidia-dev with their authorship (three conflicts, both sides kept; git range-diff against the originals shows context lines only). Only the last five commits belong here: 93 added and 5 removed lines. The whole branch is 731 added and 14 removed.

What is in it

  • bind.rs, memory_report.rs: a two-pass buffers row, read from the count the buffers' cap keeps (the bytes asked for). On nvidia-dev these buffers were in other.
  • sparse.rs, texture_upload.rs: two census places, sparse readback jobs and texture upload jobs (both pooled; made on a pool miss only).
  • sparse.rs, memory_report.rs: a GPU-view tiles row, taken out of sparse tiles. A view tile parked since the last submit, or kept with XCL_VIEW_KEEP, still counts with the windows' own.
  • present.rs, memory_report.rs, host.rs: one more XCL_ACTIVITY line beside other: the swap chain's size (bytes computed, not counted) and pso_async's pipeline builds so far.
  • README.md: the XCL_ACTIVITY entry names the lines.

On nvidia-dev, sparse pools free also holds the tiles that are cooling or quarantined (pool_bytes leaves them out of the mapped ones here).

Tested

  • RTX 3070 8 GB (driver 621.40), Ryzen 7 5800X, 64 GB RAM, Windows 11 build 26300, rustc 1.100.0.
  • Head 71dad56b, debug: cargo test --workspace --offline --no-fail-fast -- --test-threads=4: 1829 passed, 8 failed, 48 ignored; 28 SKIPPED (no wave64: 21, per-lane f16 forms refused: 3, no heap windows: 2, no xgameruntime.dll: 2).
  • Base nvidia-dev 3f39671d, same command: 1824 passed, 8 failed, 48 ignored; the same 28 SKIPPED. The 8 failures are the same six tests on both: texture_upload's pieces_hold_the_texels_of_their_levels and gpu_parts_of_a_texture_go_up_and_the_rest_stays, async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, and split_compute_prefers_the_offline_whole_pipeline and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, each reported twice. The five more passes are this branch's tests.
  • In the world, on this PR's head plus one local commit (3292b096 reverted, which this card needs to stay in the world, nvidia-dev eae01502: title reads bad addresses 3-4 min in on the Series S profile with sparse GPU heaps; gone with 3292b096 reverted #2867): Series S profile, XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:1024 XCL_TWO_PASS_MB=3072 XCL_TEXTURE_LEVEL_PAGES=1 XCL_GFX_PSO_WAIT_MS=100 XCL_PREPARE_GRAPHICS=0 XCL_FRAME_DUMP=60, 2 GiB shader heap (xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590), warm caches, 540 s of title time, 421 s of it in the world. The lines at the end:
memory by owner (MB): commit 36569 (UMA window 968, sparse CPU copy 6157, D3D12 heaps 18826, other 10616); video memory 17231 of a 7145 budget (placed texture pages 4225, placed texture pools free 574, arenas 249, sparse tiles 5227, GPU-view tiles 930, sparse pools free 242, sparse pools retired 0, committed textures 173, two-pass buffers 3069, other 2538); non-local 2564 of a 48295 budget (UMA window 968, sparse readback 16, sparse readback jobs 0, sparse staging 64, sparse zero buffer 1, texture upload jobs 513, other 1001)
memory: XCL's own resources (alive): frame dump readback 0 of 37 made, 0 MB; sparse readback 1 of 1 made, 16 MB; sparse readback jobs 3 of 3 made, 0 MB; sparse staging 1 of 1 made, 64 MB; sparse zero buffer 1 of 1 made, 1 MB; texture upload jobs 16 of 18 made, 513 MB
memory: not in the rows: swap chain 3 buffers of 3840x2160, about 94 MB; pipeline builds so far: 9352 finished, 0 failed, 74919 pending

Without the two rows, other would have read 5,607 MB of the 17,231 and sparse tiles 6,157. Video memory was level by then (17,170 MB at 480 s). report.json had the same table.

Regression run
60 s each, the same settings (Series S profile, XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:1024 XCL_TWO_PASS_MB=3072 XCL_PREPARE_GRAPHICS=0), no input: the title's first screens.

main b49be183 (the commit #2697 is based on):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3070
title: 47452d35
seconds: 60
exit: 0x0
frames shown: 493 (PresentX 494)
presents per 2 s (last 3): 40 41 44
device removals: 0
crashes: 0
peak commit: 19296 MB

nvidia-dev 3f39671d (the base):

xcl-smoke v1
commit: 3f39671d5239c33100ba25b692d60b6582b779d2
gpu: NVIDIA GeForce RTX 3070
title: 47452d35
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18384 MB

This PR's head:

xcl-smoke v1
commit: 71dad56b13e366dd36a64b14af8defa448a82ed3
gpu: NVIDIA GeForce RTX 3070
title: 47452d35
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19043 MB

Not tested

  • AMD and Intel GPUs, Wine.
  • The world on this PR's head without the local revert.
  • XCL_VIEW_KEEP, an fp16 swap chain, a resize.
  • The new rows have no test of their values: the device test checks that the rows are there, and a unit test checks the new line's text.

AI use

  • Claude Code (Claude Fable 5.2) wrote the five commits, ran the tests and the title runs on the owner's machine and wrote this description. Two read-only Claude Opus sub-agents reviewed the branch before it was opened.

joeypercia and others added 8 commits November 27, 2026 01:39
What the video memory in use is made of could not be told from the
XCL_ACTIVITY memory line: it gives no budget, and three of XCL's owners
(xcl-dev#2688, workstream 1).

memory_report::snapshot() takes the process's commit, and DXGI's local
and non-local usage with their budgets, and XCL's parts of each:
- commit: the UMA coherent window, and the CPU copy of mapped sparse
  tiles (a title page in a sparse window is committed on the CPU too);
- video memory: target pages and the free part of their pools, arenas,
  mapped sparse tiles, free sparse pools, retired sparse pools (counted
  now: sparse::retired_bytes), and title textures that are committed
  resources of their own (title_textures::committed_bytes, console size).
What each total holds besides them is its own part, "other".

XCL_ACTIVITY logs it as a line of its own after the memory line, which
stays as it was (scripts/smoke.ps1 and the integration branches' tools
read it).

Part of xcl-dev#2688.

Assisted-by: Claude Code (Claude Opus 5.5)
…them

XCL's buffers sized per list or per submit (copy scratch, fill patterns,
readbacks, upload staging, ...) were not in the memory line, so memory
that grows with the title's submits could not be told apart from the
title's own (xcl-dev#2688, workstream 1).

resource_census::track gives a resource XCL made a small COM object as
private data; D3D12 releases it with the resource, which takes it off
its place's count. The eleven places XCL makes committed resources at
run time are tracked. Each place's bytes are a part of the memory line,
and a line of its own gives how many of each are alive and made.

Part of xcl-dev#2688. Stacked on xcl-dev#2697.

Assisted-by: Claude Code (Claude Opus 5.5)
… end

The XCL_ACTIVITY line by owner was only in the log, so comparing runs
meant reading logs (xcl-dev#2688, workstream 1: an end-of-run table).

The activity thread keeps each snapshot it logs (memory_report::note):
the last one, and the one where video memory in use was highest.
report.json gets them as memory_by_owner (MB: totals, budgets, XCL's
parts and the rest of each total, with the second of the run). The
report takes what was kept and makes no DXGI call, which a crash report
may make from any thread. Without XCL_ACTIVITY there is no table.

Part of xcl-dev#2688. Stacked on xcl-dev#2750.

Assisted-by: Claude Code (Claude Opus 5.5)
The mesh draws' two-pass buffers are committed UAV buffers XCL makes for
itself, up to XCL_TWO_PASS_MB alive (1024 MiB by default). The line by
owner (xcl-dev#2688) left them in other. The row reads the count the buffers'
own cap already keeps.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two pooled kinds of buffers XCL makes for itself were not among the
census's places (xcl-dev#2688): the readback buffers of the sparse windows'
copy-back jobs and the upload buffers of the texture upload jobs (up to
512 MB of them kept free). Both are made on a pool miss only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The mapped pool tiles are the sparse windows' own and those GPU views of
the title's memory hold; the line by owner (xcl-dev#2688) had both as sparse
tiles. The views' share is the count their cap already keeps: a view
tile parked since the last submit, or kept with XCL_VIEW_KEEP, is not in
it and stays with the windows' own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
What the line by owner (xcl-dev#2688) leaves in other has no count in XCL.
Two figures help to read it: the swap chain's back buffers (DXGI makes
them; their bytes are computed from their size) and pso_async's pipeline
builds so far (finished, failed, pending: counts of the run, not the
pipelines alive). One more XCL_ACTIVITY line has them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA RTX 4060 (8 GB) / Windows 11 --release verification of PR #2999 at 71dad56b13e366dd36a64b14af8defa448a82ed3 (8 commits stacked on exact parent and nvidia-dev merge-base 3f39671d5239c33100ba25b692d60b6582b779d2: 73a39337 -> 2c4a79e3 -> 2f7b2210 -> fda79731 -> 744c1419 -> ec24e607 -> fa74f7d0 -> 71dad56b).

Environment

  • OS: Windows 11 Home (build 26200)
  • CPU / RAM: Intel Core i5-11400F (6C / 12T), 32 GB RAM
  • GPU / Driver: NVIDIA GeForce RTX 4060 (8 GB VRAM, Ada, 32-lane waves), driver 32.0.16.2114 (NVIDIA 621.14), WDDM 3.2
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5

Release build & targeted --release --lib tests

All runs executed sequentially (--test-threads=1 --nocapture) on 71dad56b13e366dd36a64b14af8defa448a82ed3 against the RTX 4060:

  • cargo build --release -p xcl: passed (2m 00s), 0 new compiler warnings compared to exact parent 3f39671d (identical 8 pre-existing xcl lib warnings; 0 warnings in memory_report.rs, resource_census.rs, or modified hunks).
  • cargo test --release -p xcl --lib hle::d3d12x::memory_report:: -- --test-threads=1 --nocapture: 3/3 runs passed (4 passed; 0 failed; 0 ignored; 0 skipped, 0.37s–0.38s each) — includes live RTX 4060 execution of a_snapshot_on_the_device_has_its_budget_and_owners plus the_rest_is_the_total_less_the_parts, the_line_beside_other_has_the_swap_chain_and_the_builds, and the_table_keeps_the_last_snapshot_and_the_peak_of_video_memory.
  • cargo test --release -p xcl --lib hle::d3d12x::resource_census:: -- --test-threads=1 --nocapture: 3/3 runs passed (1 passed; 0 failed; 0 ignored; 0 skipped, 0.37s–0.39s each) — live RTX 4060 execution of a_tracked_resource_counts_until_it_is_destroyed (verifying DEFAULT local video vs UPLOAD non-local tracking, refcount retention across clones, and live-count drop on destruction while preserving made).
  • cargo test --release -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=1 --nocapture: 3/3 runs passed (66 passed; 0 failed; 1 ignored [early_commit_timing], 0 skipped, 4.09s–5.01s each) — covers the new committed_bytes() assertions alongside the sparse tile/view test suite.
  • cargo test --release -p xcl --lib hle::d3d12x::title_textures:: -- --test-threads=1 --nocapture: 3/3 runs passed (29 passed; 0 failed; 0 ignored; 0 skipped, 1.36s–1.39s each).
  • cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=1 --nocapture: 3/3 runs passed (53 passed; 0 failed; 0 ignored; 1 skipped, 0.60s–0.61s each; two_pass_binds_set_the_shared_view_heap skipped as expected without opt-in XCL_HEAP_WINDOWS=1).
  • cargo test --release -p xcl --lib report:: -- --test-threads=1 --nocapture: 1/1 run passed (5 passed; 0 failed; 0 ignored; 0 skipped, 0.49s; includes report::tests::a_crash_is_kept_while_another_thread_writes_the_report).

Paired quiet 60 s retail smoke (XCL_PREPARE=0, XCL_NETWORK=0)

Both runs used scripts/smoke.ps1 -Seconds 60 -StartupTimeoutSeconds 180 (which sets XCL_ACTIVITY=1) with XCL_PREPARE=0 and XCL_NETWORK=0 on a quiet machine against the same local retail title (title: 29640639):

Exact parent (3f39671d5239c33100ba25b692d60b6582b779d2):

xcl-smoke v1
commit: 3f39671d5239c33100ba25b692d60b6582b779d2
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1535 (PresentX 1535)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14725 MB

PR #2999 (71dad56b13e366dd36a64b14af8defa448a82ed3):

xcl-smoke v1
commit: 71dad56b13e366dd36a64b14af8defa448a82ed3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14790 MB

Both runs finished cleanly in 63 s wall time with 0 device removals, 0 crashes, steady 60 60 60 presents per 2 s, and no regression in frame count (1583 vs 1535) or peak commit (14790 vs 14725 MB). All 29 legacy memory: N MB committed lines were emitted alongside the new lines and parsed cleanly by scripts/smoke.ps1.

Runtime memory-by-owner telemetry & report.json verification

During the 60 s 71dad56b smoke on the RTX 4060 (8 GB), xcl.log emitted 29 memory by owner (MB) snapshots (t = 2.002 s to 58.097 s), 28 memory: XCL's own resources (alive) census lines (t = 4.003 s to 58.097 s), and 28 memory: not in the rows beside lines (t = 4.004 s to 58.100 s), with 0 negative other values across all 29 snapshots and 0 over-budget warnings:

  • Peak local VRAM snapshot (t = 18.032 s):
    • commit: 14694 MB (UMA window 4095, sparse CPU copy 838, D3D12 heaps 6822, other 2937)
    • video memory: 6177 of a 6901 MB budget (placed texture pages 3546, placed texture pools free 37, arenas 465, sparse tiles 838, GPU-view tiles 0, sparse pools free 57, sparse pools retired 0, committed textures 402, two-pass buffers 0, other 830 — ~86.5% accounted by named owners)
    • non-local: 4740 of a 15556 MB budget (UMA window 4095, sparse staging 64, sparse zero buffer 1, texture upload jobs 195, other 384 — ~91.9% accounted)
  • Final snapshot (t = 58.097 s):
    • commit: 14743 MB (UMA window 4095, sparse CPU copy 838, D3D12 heaps 6835, other 2973)
    • video memory: 6116 of a 6892 MB budget (placed texture pages 3498, placed texture pools free 86, arenas 401, sparse tiles 838, GPU-view tiles 0, sparse pools free 57, sparse pools retired 0, committed textures 402, two-pass buffers 0, other 832)
    • non-local: 4815 of a 15556 MB budget (UMA window 4095, sparse staging 64, sparse zero buffer 1, texture upload jobs 195, other 459)
  • Census line (t = 58.097 s): memory: XCL's own resources (alive): sparse staging 1 of 1 made, 64 MB; sparse zero buffer 1 of 1 made, 1 MB; texture upload jobs 8 of 8 made, 195 MB (all 3 active sites also routed into non-local in both xcl.log and report.json).
  • Beside line (t = 58.100 s): memory: not in the rows: swap chain 3 buffers of 3840x2160, about 94 MB; pipeline builds so far: 4324 finished, 0 failed, 56429 pending (up from 1759 finished, 0 failed, 42106 pending at t = 4.004 s).
  • report.json (memory_by_owner): Absent on baseline 3f39671d, present and populated on 71dad56b. Both memory_by_owner.peak_video (seconds: 18.0317998, video_mb: 6177, video_budget_mb: 6901) and memory_by_owner.last (seconds: 58.0972428, video_mb: 6116, commit_mb: 14743) match the corresponding xcl.log lines exactly, with every segment's parts + other_mb reconciling to the DXGI/process total within 1–2 MB of integer >> 20 truncation.

Limits of coverage

  • Both paired 60 s smokes ran with XCL_PREPARE=0 (XCL_NETWORK=0), bypassing startup prepare_for_launch shader precompilation (reusing the existing local DXIL cache).
  • During this 60 s run of title 29640639, two-pass buffers, GPU-view tiles, and sparse pools retired stayed at 0 MB, and the remaining 10 resource_census sites (upload staging, ExecuteIndirect argument order, copy scratch, fill pattern, timestamp readback, predication, frame dump readback, dispatch chain scratch, sparse readback, sparse readback jobs) were not allocated; those paths were covered only by unit tests / code inspection here rather than non-zero retail smoke traffic.
  • Single-segment iGPU routing (non_local.budget == 0 -> Kind::Video) and Wine commit unknown handling were verified via unit tests (the_rest_is_the_total_less_the_parts), not on iGPU or Wine hosts.
  • hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap skipped as expected without opt-in XCL_HEAP_WINDOWS=1, hle::d3d12x::sparse::tests::early_commit_timing is #[ignore], and the full workspace test suite / visual screenshot capture were not run.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@JJAutoCompare

Copy link
Copy Markdown

Tested

  • Exact head 71dad56b13e366dd36a64b14af8defa448a82ed3 on Intel Arc A770 (16,258 MiB, driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, debug. Built the checked-in tests and a separate test-only probe with rustc --test and lockfile-matched cached dependencies after an interrupted Cargo launch.
  • Ran xcl-stock.exe --exact <filter> --test-threads=1 --nocapture for hle::d3d12x::memory_report::tests::{the_rest_is_the_total_less_the_parts,the_line_beside_other_has_the_swap_chain_and_the_builds,a_snapshot_on_the_device_has_its_budget_and_owners}. Ran xcl-probe.exe --exact hle::d3d12x::bind::probe_two_pass_owner_lifetime_on_arc --test-threads=1 --nocapture. The last stock test and the probe used the Arc mutex with XCL_ADAPTER=A770 and XCL_TWO_PASS_MB=64. All four tests passed, with 0 failed, 0 ignored, and 0 skipped. All native children and the GPU wrapper exited 0.
  • The production two-pass allocator created one 3,211,264-byte committed default-heap UAV. The production snapshot’s two-pass buffers video owner and raw live counter both read 0 before allocation, 3,211,264 bytes while live, held for allocator release, and pooled, and 0 after reuse-pool retrieval and final drop. DXGI local usage went from 3,997,696 to 7,208,960 and back to 3,997,696 bytes. Local other stayed at 3,997,696 bytes. The rendered line and in-memory report record showed 3 MiB while the buffer was held.

Not tested

  • Title rendering or submitted GPU work, allocator vtable routing, age-based eviction, swap chain, full JSON output, retail smoke, the workspace suite, and performance.

AI use

  • T3 Code through the Codex harness, gpt-6.2-sol with high reasoning effort, ran the controls and synthetic probe, checked the raw outputs, and drafted this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants