D3D12.X: page_owners counts the pages a lazy texture holds by level #3309
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3309"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-29T06:54:51Z.
The activity line "target pages by owner: … N sampled textures with pages by level hold M MB" summed
Target::used. A texture with lazy levels leaves that empty: it holds its pages by group inLevels::group_tiles(map_levels), so the line always said 0 MB for them. Now both are counted. This is a diagnostics-only change to the line added in #2896.No issue.
Seen in two runs of a retail title on this machine, on a development build (main plus other changes) with
XCL_TEXTURE_LEVEL_PAGES=1, which gives sampled textures pages by level. Without this fix (xcl.log):With it (same run setup, a later run):
What is in it
crates/xcl/src/hle/d3d12x/vram.rs:held_pages(&Target)countsused,used_extraand the level groups' pages;page_ownersuses it. Testpage_owners_counts_the_pages_a_texture_holds_by_levelfails without the change (checked by leaving out the level groups).Tested
cargo build --release -p xcl)494aa53dd1c45fb8f0487baa468ac1eec2eea909:cargo build --workspaceok;cargo test --workspace -- --test-threads=4: 2609 passed, 0 failed, 49 ignoredSKIPPEDlines on this adapter (no wave64 on NVIDIA, no heap windows, no D3D12 debug layer):SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsSKIPPED hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)SKIPPED the title under the debug layer (dred: false): no d3d12SDKLayers.dllSKIPPED the title under the debug layer (dred: true): no d3d12SDKLayers.dllSKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))Regression run
scripts/smoke.ps1 -Game <title folder> -Seconds 60 -StartupTimeoutSeconds 900withXCL_DEVICE_TYPE=lockhart XCL_PREPARE=0(Series S mode as in the contributor's runs; no startup shader preparation, so pipelines are built in game) (smoke.ps1 setsXCL_NETWORK=0); same retail title, same settings for both runs. Both stay on the title's first screens (about 660 draws per 2 s) for the 60 s.main:
this PR's head:
Not tested
XCL_TEXTURE_LEVEL_PAGES=1, so no texture there holds its pages by level and the value on the activity line is not exercised by them.page_owners()itself has no test (it reads the global page registry); the test coversheld_pages, the count it now sums.AI use
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T07:54:50Z.
Checked the live
page_owners()line on494aa53dwith an RTX 5070, driver 616.92 andXCL_TEXTURE_LEVEL_PAGES=1. Each fresh process placed two lazy 1024×1024 RGBA8 textures with 11 mips. For each texture, mapping mip 10 acquired one packed-tail tile. Requesting mips 9 and 10 again acquired none and preserved that tile identity. Mapping mip 0 then added 64 tiles. I waited for the D3D12 mapping fence and compared the live report with the pool/tile IDs held by each resource.The two owner counts sum to 130 × 64 KiB (8.125 MiB) in every case. Unique backing was 4.0625, 4.625 and 8.125 MiB respectively; the diagnostic truncates to whole MiB. This explains why complete and partial sharing can print the same total. The registry showed zero idle pages throughout. Three tests passed with zero skips. These are XCL mapping identities and accounting, not a measurement of DXGI residency, title behavior or texture contents.
AI disclosure: OpenAI Codex prepared and ran the fixture and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:57:57Z.
Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s
scripts/smoke.ps1run of a retail title against main on the same machine. The 4fuzz_validate_and_gpu_*failures happen on main on this machine too.Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T21:20:55Z.
merge-check
base:
ff0c364b3dhead:
494aa53dd1merge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; SKIPPED: 24 lines (22 "no wave64", 2 "no heap windows", one of them the opt-in
XCL_HEAP_WINDOWS=1one); failing: none. The new testpage_owners_counts_the_pages_a_texture_holds_by_levelpasses, and with the level groups left out ofheld_pages(+ 0 * by_level) it fails ("pages by level count", left 0, right 3), so it tests the change.review: whole diff read (+31/-1,
vram.rs).held_pagesadds the pages inLevels::group_tilestousedandused_extra. That is the same set the existing test helpertarget_page_keystreats as a texture's pages, andmap_levelsis where a lazy texture's pages go (group_tiles[k].0/.1.extend), so the count is right. A page shared by several textures still counts once for each of them; the line already says so ("a shared page counts for each"), and the "MB of pages in all" total is unchanged, so nothing is counted twice that the line does not announce. Eachused_extraentry is one page, solen()is the right count.page_ownersalready held thePAGESlock for the whole walk; the change only adds a walk over each lazy texture's groups under that lock, once per activity line. It is diagnostics only: no behaviour or allocation changes.performance:
scripts/smoke.ps1, 60 s of a retail title, release, after one warm-up run of the base: 1696 frames, 18399 MB peak commit against 1696 frames, 18303 MB on the base (warm-up: 1689, 16791 MB). No device removal, no crash. The smoke does not setXCL_TEXTURE_LEVEL_PAGES=1, so it has no lazy textures and the line reads the same on both (0 sampled textures by level). The changed path was run in world runs withXCL_TEXTURE_LEVEL_PAGES=1(release, 16 UMA windows, RAM guard; all of them, base included, were stopped by the RAM guard at 70-96 s, about world entry, so they say nothing about frame time). At the last line before the stop, base: "88364 sampled textures with pages by level hold 0 MB" and "85813 ... hold 0 MB" (2 runs); this PR: "78099 sampled textures with pages by level hold 3212 MB" (1 run that got that far), with 5663 MB of target pages in all. The textures with all their pages (3353 MB) plus those by level (3212 MB) come to more than the 5663 MB in all, as expected when shared pages count for each owner. Commit and video at that point were within the run-to-run spread of the base.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests, smoke and world runs, reviewed the diff against the merged source and wrote this)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:58:11Z.
merge-check
base:
d0832e614fhead:
494aa53dd1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (vram.rs, +31/-1). Diagnostics only:
page_owners()is only logged (host.rs ~230) and drives no decision, and for textures that get all their pages at onceheld_pagesreturns the same count as before. No blocking findings. Lazy textures are inserted with emptyused/used_extra(~2378), so the new count can't double-count. Theremap_if_unmappedfallback moves group pages intousedonly when the group counts differ, whichtake_level_tilesprevents, andforget_pages,unmap_levelsandrelease_held_unmapsall take the group pages away, so no release path leaves them counted. Nits: the testpage_owners_counts_the_pages_a_texture_holds_by_level(~4139) only callsheld_pages(the PR says so);held_pagesrepeats the union in the test-onlytarget_page_keys(a copy that doesn't allocate is reasonable). Already on main, not from this PR: pages waiting inheld_unmapsare counted in neither column. No smoke run: nothing on the default path changes.performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: safe to merge (diagnostics only)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.