Repository navigation
D3D12.X: count the resources XCL makes for itself, by where it makes them - #2750
joeypercia wants to merge 2 commits into
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
On 51f3149, resource_census::track classifies every UPLOAD/READBACK resource as NonLocal from heap.Type alone. That is wrong for an integrated UMA adapter: Microsoft maps L0 to DXGI LOCAL on UMA, and UPLOAD and READBACK both use L0 there. The new snapshot subtracts these bytes from non_local.usage, so on an integrated GPU it overstates the local other remainder and can report a negative or nonexistent non-local remainder. The new GPU test hardcodes UPLOAD as NonLocal, encoding the same assumption. XCL's existing uma_segment helper already treats an absent non-local segment differently.
Could classification use the resource device's architecture (and the chosen memory pool for custom heaps), so L0 counts as local on UMA and non-local on discrete? Please cover both architectures in a small classifier test and make the GPU assertion follow the actual adapter. This is exact-head source review using the D3D12 memory-pool contract; I did not run the new census test on both adapter types.
|
Thanks, right. A census part in an upload or readback heap now goes where #2697 already puts the coherent window. On an adapter with a non-local budget it's non-local; on an integrated GPU, which has one segment, it's local ( |
51f3149 to
ed8707c
Compare
|
Independent Windows/NVIDIA test of #2750 head Windows 11 build 26300, RTX 3080 Ti (12 GB, NVIDIA driver 621.35), rustc 1.99.1 MSVC. A clean exact-head checkout was used.
Not tested here: an integrated/UMA adapter, a paired retail smoke run, world-load memory growth, or FPS impact. The tests establish the current head's behavior on this discrete adapter; they do not resolve the frame/commit difference in the author's 60-second smoke blocks. AI use: Codex (GPT-6.2 Sol) ran the tests and drafted this report. |
b6d75e3 to
fc3a1ef
Compare
|
I reran the resource-census and memory-report tests at clean head Tested Windows 11 Home build 26200, Ryzen 9 5980HX, AMD driver cargo test --locked -p xcl --lib -j 1 hle::d3d12x::resource_census::tests -- --test-threads=1 --nocapture
cargo test --locked -p xcl --lib -j 1 hle::d3d12x::memory_report::tests -- --test-threads=1 --nocapture
All four commands exited 0, with 0 failures, 0 ignored, and no skip markers. The census fixture checks resource lifetime. The report tests cover synthetic segment and heap-charge cases plus whether a live snapshot includes budgets and expected owners. Not tested No title, full workspace suite, or measured per-heap process commit delta. The tests do not establish the accuracy of every runtime memory attribution. AI use OpenAI Codex (GPT-6.2 Sol) ran the tests, checked the exact revision and backend logs, and drafted this report. |
fc3a1ef to
50cfb32
Compare
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2750 at Setup
Targeted RTX 4060 release unit tests (
|
| Segment / Owner | First (2.0 s) |
Peak | End (59.2 s) |
End share of segment |
|---|---|---|---|---|
| Commit total | 5,108 | 13,980 | 13,979 | 100.0% |
— UMA window |
4,095 | 4,095 | 4,095 | 29.3% |
— sparse CPU copy |
20 | 838 | 838 | 6.0% |
— D3D12 heaps |
122 | 6,670 | 6,670 | 47.7% |
— other |
870 | 2,418 | 2,375 | 17.0% |
| Video memory (local) total | 78 | 6,176 | 6,116 | 100.0% (87.9% of end budget) |
| — DXGI local budget | 7,188 | 7,188 (min 6,959) | 6,959 | — |
— target pages |
0 | 3,575 | 3,540 | 57.9% |
— target pools free |
0 | 71 | 43 | 0.7% |
— arenas |
0 | 465 | 401 | 6.6% |
— sparse tiles |
20 | 838 | 838 | 13.7% |
— sparse pools free |
44 | 58 | 57 | 0.9% |
— sparse pools retired |
0 | 0 | 0 | 0.0% |
— committed textures |
0 | 402 | 402 | 6.6% |
— other |
14 | 832 | 832 | 13.6% |
| Non-local total | 4,139 | 4,650 | 4,650 | 100.0% (29.9% of budget) |
| — DXGI non-local budget | 15,556 | 15,556 | 15,556 | — |
— UMA window |
4,095 | 4,095 | 4,095 | 88.1% |
— sparse staging |
0 | 64 | 64 | 1.4% |
— sparse zero buffer |
0 | 1 | 1 | 0.0% |
— upload staging |
0 | 32 | 32 | 0.7% |
— other |
43 | 457 | 457 | 9.8% |
Key findings on 44a7e6fe (RTX 4060 8 GB)
- Commit
othercut from64.8%to17.0%: AddingD3D12 heaps(6,670 MB,47.7%of commit) brings attributed process commit to 83.0% (11,603 / 13,979 MB, integer>> 20rounding diff1..2 MBacross all29samples; compare9,081 MB/64.8%unattributedotheron PR D3D12.X: a memory line by owner, against DXGI's budget #26978c9433feon the same host/title). - Non-local attribution rises to
90.2%:resource_censusbreaks outsparse staging(64 MB),upload staging(32 MB), andsparse zero buffer(1 MB) cleanly alongsideUMA window(4,095 MB), matching theXCL's own resources (alive):census line (1 of 3 made, 32 MBforupload staging) 1:1 and keepingnon-local otherstrictly positive (43..457 MB, rounding diff1 MBacross all29samples). - Local VRAM accounting stays consistent:
86.3%attributed (5,281 / 6,116 MB,other = 832 MB, rounding diff0..4 MB), peak6,176 / 6,959 MB(88.7%of concurrent DXGI local budget,0/29over-budget samples).
Paired 60 s RTX 4060 smoke (b49be183 vs 44a7e6fe)
Merge-base origin/main (b49be183):
xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB
PR #2750 head (44a7e6fe):
xcl-smoke v1
commit: 44a7e6fe3431b16e26e8f199d958f86648a6bc2c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1579 (PresentX 1579)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13980 MB
Limits of coverage
- Full workspace test suite was not re-run on
44a7e6fe(only targetedresource_census::,memory_report::,sparse::, andtitle_textures::release tests plus paired quiet 60 s smoke). - Discrete NVIDIA 8 GB GPU (
RTX 4060) only — UMA / L0=LOCALiGPU classification (census_kindwhennon_localis absent/zero) and VRAM oversubscription were not exercised on this host. - Default 60 s no-input menu/intro run: only
sparse staging,sparse zero buffer, andupload stagingappeared inXCL's own resources (alive):; other census categories (dispatch_chainscratch, compositor targets, readback/copy staging) stayed0in this window.
AI use
Ran the targeted release unit tests, paired quiet 60 s smoke runs, and log aggregation with assistance from Google Antigravity (Gemini 4 Neon); all numbers and verbatim lines were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.
… 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)
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)
44a7e6f to
d08648b
Compare
… 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)
|
Tested Clean
Three passed, zero failed, ignored, or skipped. Both GPU runs confirmed the Arc backend with Not tested Per-site totals across all hooks, integrated-GPU attribution, full workspace suite and retail smoke. AI use T3 Code / Codex ( |
Stacked on #2697; only the top commit belongs here.
Renamed after review (@throny on #2688): the row
target pagesis nowplaced texture pages, andtarget pools freeis nowplaced texture pools free. It isvram::page_bytes().0, the pages of every placed texture on the shared 64 KiB pages, not only render targets. Log lines and JSON quoted below are from before the rename and keep the old names; the quantity is the same.Counts the D3D12 resources XCL makes for itself, by the place it makes them: how many are alive, how many were made, and their bytes. #2697's memory line then shows each place as a part, and a line of its own lists the counts. Growth that follows the title's submits shows up as one place whose count keeps climbing. That's what @GreemSC's measurements on #2688 needed to tell XCL's own buffers apart from the title's. Part of #2688 (workstream 1, part 2 of the plan there).
What is in it (one commit)
crates/xcl/src/hle/d3d12x/resource_census.rs(new):track(res, site)counts a resource XCL made and gives it a small COM object (IUnknown, a hand-made vtable as innull.rs) as private data (SetPrivateDataInterface).GetResourceAllocationInfo. A resource in an upload or readback heap is in system memory, andmemory_report::census_kindputs it where D3D12.X: a memory line by owner, against DXGI's budget #2697 puts the coherent window: non-local on a card, local on an integrated GPU with one segment (luckyteagirl's review). Everything else counts as video memory.tracked(Option<ID3D12Resource>, site)wraps a creation's result.tracked:list_x.rs: copy scratch, fill pattern, timestamp readback, predication;bind.rs: ExecuteIndirect argument order;present.rs: frame dump readback;real/dispatch_chain.rs: dispatch chain scratch;sparse.rs: staging, zero buffer, readback;gpu/texture.rs: upload staging.memory_report.rs: each place's bytes are a part of the line by owner, so they come out of "other".census_line()givesmemory: XCL's own resources (alive): <place> <alive> of <made> made, <MB> MB; …, logged after it underXCL_ACTIVITY.a_tracked_resource_counts_until_it_is_destroyed:madestays.Without the private data (
SetPrivateDataInterfaceleft out) it fails at its first count.Tested
XCL_ADAPTER=Radeon. Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.8.2502.11. Debug builds for the tests, release for the runs.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4:d08648bc: 1438 passed, 0 failed, 47 ignored; 29SKIPPEDlines, mostly "no wave64".gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, which fails the same way onmainon this iGPU (DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115).... ok), not skipped.Regression run
RTX 4070 Ti (driver 621.40), release builds, 60 s each,
scripts/smoke.ps1 -Game <folder> -Title retail-titleon the newer retail title, with the same settings. Both ran with the NVIDIA shader-heap profile (#2590, 2 GiB) installed on this machine, one after the other.mainb49be183(the base of #2697 and of this) and this PR's head (no uncommitted changes):main:
PR:
Not tested
nvidia-devrun; the lines will go on [OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688.vram,sparsepools: already parts of the line), and the title's own resources (not XCL's to count).GetResourceAllocationInforeturningUINT64_MAX) count as 0.AI use