Repository navigation
D3D12.X: sampled textures go without their top mips while video memory fills up - #2385
NWProgramming00 wants to merge 3 commits into
Conversation
61b2f2c to
d790a29
Compare
…y fills up When the device's local video memory passes 75 % of its budget, a new sampled title texture gets no pool tiles for its largest mips (the largest side kept: 2048 from 75 %, 1024 from 85 %, 512 from 92 %). Those tiles stay unmapped and every view of the texture is clamped to the first mip that has memory (ResourceMinLODClamp, which counts from the resource's first mip). With lazy levels (XCL_TEXTURE_LEVEL_PAGES=1) those levels never get pages. XCL_TEXTURE_BUDGET=0 turns it off; XCL_TEXTURE_MAX caps every new texture. Part of xcl-dev#1773. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
d790a29 to
005a442
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
…#2404, xcl-dev#2405 Integrates VRAM top-mip pressure shedding (xcl-dev#2385), DXC wanted-compile prioritization & worker headroom (xcl-dev#2423), inline split pipeline foreground path (xcl-dev#2424), ExecuteIndirect split program dispatch (xcl-dev#2404), and hosted view heap exhaustion null-pair fallback (xcl-dev#2405). Assisted-by: Antigravity (Gemini 4 Neon)
|
Two contributors checked independently and found that #640 solves the same problem (for #1773) in a different way: #1607, group D111. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
…#2404, xcl-dev#2405 Integrates VRAM top-mip pressure shedding (xcl-dev#2385), DXC wanted-compile prioritization & worker headroom (xcl-dev#2423), inline split pipeline foreground path (xcl-dev#2424), ExecuteIndirect split program dispatch (xcl-dev#2404), and hosted view heap exhaustion null-pair fallback (xcl-dev#2405). Assisted-by: Antigravity (Gemini 4 Neon)
bmjask
left a comment
There was a problem hiding this comment.
No concrete code defect found, and the mapping/SRV clamping coverage is useful. Before merge, please provide low-VRAM (8-12 GB) title and visual/image validation, since this deliberately changes texture fidelity in the scenario it targets. The disclosed Load/mip-query zeros for skipped mips and discarded CPU detiling should remain explicit. Also reconcile intended coexistence with #640, which targets the same #1773 VRAM-pressure problem, to avoid competing strategies.
…extures) Integrates xcl-dev#2436 cleanly alongside xcl-dev#2385 (top-mip shedding) and xcl-dev#2474 (foreign-thread release_cleanup). Assisted-by: Antigravity (Gemini 4 Neon)
|
CPU coverage on exact head Tested
The 97-line companion commit adds:
Negative controls, restored before the final passing run: limiting the mask to the first slice fails the array cases; replacing the LOD clamp instead of taking its maximum fails the existing-clamp cases. Not tested
The companion commit is authored as RTX 3060 12 GB manual title follow-up, 25 November One manual run on Windows 10 22H2, release head At approximately the same elapsed time (~764 s), XCL's memory lines report the following (MB as logged):
The budget run was closed manually after about 50 min 25 s: exit 0, The black screen remains. The last nonzero presents activity sample is at 501.816 s. Another 582 logged driver calls finish after it; a read-only, non-suspending stack snapshot finds Limits: one run per profile, different cache warm-up and the wanted-limit change, so this does not isolate your patch's effect. No visual correctness or playability established; no image-quality comparison was possible. Raw title logs, stack dumps and proprietary files are not uploaded. |
|
Tested
Not tested
AI use
|
|
Updated independent RTX 3080 Ti check for #2385 head Tested: RTX 3080 Ti / NVIDIA 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC 1.8.2502.11; debug.
I also applied the #2385 PR patch to current main Existing main-side correction for the stale barrier assertiondiff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs
index a3b942d..cec9257 100644
--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -1150,9 +1150,10 @@ mod tests {
return runner::skip_test("no DXC");
}
let text = crate::gpu::dxil::validate::disassemble(&dxil).unwrap();
- let barriers = text.lines().filter(|l| l.contains("call void @dx.op.barrier")).count();
- // the one where the halves take their console lanes, at the start (every lane is there)
- assert_eq!(barriers, 1, "group barriers in the program:\n{text}");
+ let (_, after_entry) = text.split_once("\n br ").unwrap_or_else(|| panic!("expected branch in program:\n{text}"));
+ let divergent_barriers = after_entry.lines().filter(|l| l.contains("call void @dx.op.barrier")).count();
+ // after the entry whole-wave branch, only one half reaches the body so no group barrier may appear there
+ assert_eq!(divergent_barriers, 0, "group barriers after entry branch:\n{text}");
if !gpu() {
return;
}Not tested: a retail title under 8–12 GB memory pressure, visual quality in a title, AMD/Intel, or FPS and memory savings. The new GPU fixture calls mapping/clamp helpers and creates a PC SRV directly; it does not exercise XCL's title SRV hook or prove title draws and dispatches are preserved. Synthetic inputs only. AI use: Codex (GPT-6.2 Sol) reviewed the paths, ran the tests, and drafted this update. |
|
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with the budget (default) and 3 with Setup:
Not tested: the image quality (no frames); AI use: Claude Code (Claude Opus 5.5) ran the title and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Independent dual-PC NVIDIA full-workspace test report on clean head Tested
Not tested
AI use
|
|
On the #1607 hint (group D111): #640 and this PR take different memory, so I think both are needed.
Thanks to everyone who tested it. @Royalflamejlh's runs are the measurement on a card that fills its budget that I could not make on a 16 GB card: about 3 GB less spill into non-local memory, and target pages of 6.2–6.5 GB against 9.6 GB. They also point out that the MB figure in the AI use: Claude Code (Claude Opus 5.5) wrote this. |
…o without their top mips while video memory fills up Taken as it is for a test on a title. The memory line keeps the fork's budget and commit text after the pull request's count of thinned textures. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Textures placed at one title address share their pages, so summing the left-out tiles of each texture counted the same 64 KiB page several times, and counted pages another texture there still has. Each texture now keeps the pages its left-out tiles would have had (keyed as Pages::bind keys them); skipped_textures counts the distinct ones no texture holds now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t its top mip 64x64 samples with trilinear and 16x anisotropic filtering, level of detail -3 to +3, anisotropy 1 to 16 and turned footprints, from two copies of one texture whose mip 0 holds a colour no other mip has: one with mip 0 left out and its view clamped, one with every mip in memory and the same clamp. The pictures are the same to the bit and neither has the colour; without the clamp the samples do reach mip 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@bmjask, thanks for the review. On your four points:
AI use: Claude Code (Claude Opus 5.5) wrote the test and this reply. |
When the device's video memory fills up, new sampled title textures get no memory for their largest mips. Every view of such a texture is clamped to the first mip it has. A texture then gets less sharp up close instead of pushing the card past its budget. Part of #1773.
What it does
QueryVideoMemoryInfo, at most every 100 ms. Past 75 % of the budget, a new sampled texture keeps a largest side of at most:ResourceMinLODClamp= the mips left out, so sampling never reaches them. The clamp counts from the resource's first mip, not the view's; the new GPU test checks this.XCL_TEXTURE_BUDGET=0turns it off.XCL_TEXTURE_MAX=<texels>caps every new sampled texture at that size, whatever the fill. It is meant for tests and measurements.XCL_ACTIVITY'smemory:line gives the textures alive now without their top mips, and the MB of tiles they leave unmapped.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:texture_cap,cap_for_fill,mips_to_skip);top_mip_tiles,top_mip_mask);Pages::bind/bind_rangemap all tiles but the masked ones; the mask is kept forremap_if_unmapped;XCL_TEXTURE_LEVEL_PAGES=1, D3D12.X: video memory use is high, title memory and textures are mirrored into VRAM #1773) the left-out levels never get pages inmap_levels(groups_to_map);clamp_skipped_mips.crates/xcl/src/hle/d3d12x/real.rs:dev_create_srv_xclamps the views of such a texture. When the title passes no description, it builds the default 2D view first.crates/xcl/src/host.rs: the counts on thememory:line. The MB there count each left-out 64 KiB page once, and not while another texture at that address still has it (skipped_textures,skipped_pages; textures placed at one address share pages).vram.rs:the_cap_follows_how_full_video_memory_isandtop_mips_go_until_the_largest_side_fits_and_one_tiled_mip_stays.lazy_levels_never_map_the_top_mips_left_out: with lazy levels, the left-out levels never get pages, the others once.left_out_tiles_name_the_pages_bind_would_give_them: left-out tiles are keyed asPages::bindkeys them, so two textures at one address name the same pages.gpu_a_texture_without_its_top_mip_samples_the_first_it_has, a GPU test. It binds a 512×512 4-mip reserved texture without mip 0 throughPages::bindand uploads every mip. Then it samples through three views:gpu_a_texture_without_its_top_mip_filters_like_the_clamp_alone, a GPU test of the filtered picture. It makes two copies of one 256×256 texture with nine mips, whose mip 0 holds a colour (red) that no other mip has. One copy has mip 0 left out throughPages::bindand its view clamped; the other has every mip in memory and the same clamp. It samples both into 64×64 pictures with trilinear and with 16× anisotropic filtering, over level of detail −3 to +3, anisotropy 1 to 16 and footprints turned 45°.Tested
XCL_ADAPTER=radeon), AMD Ryzen 7 9700X, drivers 32.0.16.2124 (NVIDIA) and 32.0.21042.62 (AMD), Rust 1.100 MSVC, release.bind;cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, against basee44af70on the same machine:e44af70005a442)XCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=allThe +4 are the new tests. The failing tests are the same on base and PR:
fuzz_validate_and_gpu_0..3on NVIDIA (#1905),fuzz_validate_and_gpu_1on RDNA2 (#2115, #2170),offline_compute_pipeline_is_reused_by_a_second_processwith direct DXIL (#1674), anda_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrieron both adapters in both modes (it came with254a058and fails on base too).SKIPPEDlines: 37 on NVIDIA, 19 on the Radeon, the same on base and PR.The suite ran on
005a442.ed214c2after it changes only how thememory:line counts left-out pages (and adds one test); for it I rerancargo test --release -p xcl --lib d3d12x::vram -- --include-ignoredon both adapters: 25 passed, 0 failed on each, the GPU test included.The picture test (
4c4c577, a test only) passes on both adapters: 0 of 4,096 pixels differ with either filter, no red with the clamp, and red without it in 1,240 (trilinear) and 2,529 (anisotropic) pixels on the RTX 5070 Ti, 1,376 and 2,716 on the Radeon. With the clamp taken out ofclamp_skipped_mips, it fails: 1,240 pixels differ, the zeros of the missing mip filtered in.cargo test -p xcl --lib vram::tests -- --test-threads=1: 25 passed, 0 failed, 1 ignored.A retail title, 300 s runs that reach world loading (
XCL_ACTIVITY=1, A pressed at 15–65 s, RTX 5070 Ti; made before the rebase ontoe44af70, on base06c9f55):main06c9f55XCL_TEXTURE_MAX=1024mainrun on the Radeon iGPU reached it too, and the frames then stop at the known wait afterListX #101(Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505). So I do not claim that this PR gets the title further.Regression run
Base (
main), NVIDIA GeForce RTX 5070 Ti:This PR, same card, run right after:
These 60 s runs end in the title's menus, before any texture is left without its top mips (video memory stays far under 75 % of the budget there), so they check that nothing else changed; the 300 s runs above are the ones that reach this code. The machine had 11.6 GB of commit free for both, so XCL gave the title a 512 MB coherent window in both (its own warning) and both have a pause in the menus; a second pair in turn gave 829 (base) and 972 (PR) frames. With more commit free, earlier pairs gave 1,607 (base) and 1,597 (
ed214c2).Not tested
title_memory_budget_mbis 13,824 MB regardless of the adapter's memory #1337, Retail Game potentially overcomitting VRAM - feasibility for 8GB VRAM cards? #320) would settle it.Load,mipsqueries). They are not clamped by a view, and read zero there.AI use
🤖 Generated with Claude Code