D3D12.X: sampled textures go without their top mips while video memory fills up #2385
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2385
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2385"
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?
@NWProgramming00 on GitHub · 2026-11-25 17:37 UTC · original
NWProgramming00:vram/budget-top-mips→main· +726 −14 · 3 files · 3 commits · openWhen 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, #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(#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
Load,mipsqueries). They are not clamped by a view, and read zero there.AI use
🤖 Generated with Claude Code
@emirduran707 on GitHub · 2026-11-25 18:34 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
61b2f2c8d5200eb2c8bd1f2506af89595e46d122(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1266 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::vram::tests::the_cap_follows_how_full_video_memory_is.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release; 16 GB VRAM so this run does not hit the high-fill mip-skipping threshold)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 19:27 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
@throny on GitHub · 2026-11-25 20:28 UTC · original
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.
@oni-swr on GitHub · 2026-11-25 21:11 UTC · original
Tested
XCL_ADAPTER=radeon.005a4427d2926f29d96ea28bf6747dc70321806c. Baselineorigin/mainwas6d12f58a229bc73889878a448c64dc3af25eeba0.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,342 passed, 2 failed, 46 ignored, 18SKIPPEDnotices (exit 101). One failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, also failed on baseline. The other,gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, passed on baseline.cargo test -p xcl --lib gpu_a_texture_without_its_top_mip_samples_the_first_it_has -- --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 skipped; ran on the RX 7800 XT.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,422 passed, 1 failed, 46 ignored, 25SKIPPEDnotices (exit 101).Not tested
AI use
@anes66 on GitHub · 2026-11-25 21:02 UTC · original · edited 2026-11-25 22:01 UTC
CPU coverage on exact head
005a442on native Windows, with an optional test-only companion commit: bb26dd5.Tested
the_cap_follows_how_full_video_memory_is,top_mips_go_until_the_largest_side_fits_and_one_tiled_mip_staysandlazy_levels_never_map_the_top_mips_left_out: 3 passed, 0 failed, 0 ignored, 0 skipped.bb26dd5, those three plus the three newcpu_*tests: 6 passed, 0 failed, 0 ignored, 0 skipped. Command:cargo test --locked -p xcl --lib -j2 -- --nocapture --test-threads=1 hle::d3d12x::vram::tests::cpu_ the_cap_follows_how_full_video_memory_is top_mips_go_until_the_largest_side_fits_and_one_tiled_mip_stays lazy_levels_never_map_the_top_mips_left_out.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
anes66; please preserve its author if you carry the tests into your branch. The runtime change remains yours.RTX 3060 12 GB manual title follow-up, 25 November
One manual run on Windows 10 22H2, release head
f169760(main6d12f58+ XG ABI fix #1435 + your exact head005a442+ test-only commits).XCL_TEXTURE_BUDGET=1, no forcedXCL_TEXTURE_MAX,XCL_PSO_TRACE=1. Both huge-compile worker limits were set to 1; the earlier comparison run set onlyXCL_HUGE_PSO_CONCURRENCY=1, leaving the wanted limit at its default 2. Existing saves/caches were retained.At approximately the same elapsed time (~764 s), XCL's memory lines report the following (MB as logged):
6d12f58+ #1435 (5cb01ab)f169760)The budget run was closed manually after about 50 min 25 s: exit 0,
crash: null, no device-removal or0x8007000Emessage. Final local video memory was 11,057 MB; the policy reported top mips omitted for 2,685 textures / 4,765 MB of tiles. The latter is the policy's tile counter, not a claim of that much net VRAM saved. Sampled peak private bytes were 28,367 MiB, peak working set 16,909 MiB, and minimum available physical memory 2,532 MiB.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
pso_async::resolve_waitunderlist_x::record_deferredand another thread insidenvgpucomp64. Driver work continues, but no new frames arrive before closure at 3,021 s. Final report: 2,065 translated pipelines, 40 translation errors, 283 DXIL compilations / 0 compilation failures.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.
@thehollowedone on GitHub · 2026-11-25 22:15 UTC · original · edited 2026-11-26 08:40 UTC
Updated independent RTX 3080 Ti check for #2385 head
4c4c577, superseding my earlier005a442report. This run used a clean disposable clone of the author's branch;git rev-parse HEADmatched the linked commit.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.
KACHE_CACHE_DIRandXCL_DXIL_CACHEpointed to writable folders under that checkout'starget.cargo build --offline --locked --workspace: passed.cargo test --offline --locked -p xcl --lib gpu_a_texture_without_its_top_mip_filters_like_the_clamp_alone -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 skipped on the named GPU. The omitted-mip and fully backed, equally clamped textures differed at 0/4,096 pixels for trilinear filtering and 0/4,096 for 16× anisotropic filtering. Unclamped poison-mip controls showed 1,240 and 2,529 red pixels respectively.cargo test --offline --locked -p xcl --lib left_out_tiles_name_the_pages_bind_would_give_them -- --nocapture --test-threads=1: 1/0/0. The oldergpu_a_texture_without_its_top_mip_samples_the_first_it_hasGPU test also passed 1/0/0, with no skips.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet: 1,345 passed, 1 failed, 46 ignored across 24 targets, with 25 GPUSKIPPEDnotices. The sole failure wasa_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, reproduced alone at 0/1/0. This head still expects exactly one barrier in the entire DXIL program; currentmainalready contains commitc828d8c, which checks only the divergent block after the entry branch.I also applied the #2385 PR patch to current main
b49be18locally. That uncommitted integration tree built and its workspace suite reported 1,441 passed, 0 failed, 47 ignored across 37 targets, with 25 GPU skip notices. This is a merge-path check, not an exact-head or retail smoke result. Rebasing the PR onto currentmainwould bring in the existing barrier assertion correction; the PR description now has smoke blocks naming4c4c577.Existing main-side correction for the stale barrier assertion
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.
@Royalflamejlh on GitHub · 2026-11-26 01:56 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with the budget (default) and 3 with
XCL_TEXTURE_BUDGET=0, in turn: on this 12 GB card the budget switched on at 46 to 51 s, and no run in either tree had a device removal or a driver message. At 118 s, 11,651 to 12,155 live textures were without their top mips. Target pages were 6.2 to 6.5 GB against 9.6 GB without it, and non-local video memory 4.4 to 4.5 GB against 7.5 to 7.6 GB. XCL's MB figure for the tiles left unmapped (12.2 to 12.9 GB) is a sum per texture, and textures at the same address share tiles, so it is larger than what was saved. The last present came at 70 to 92 s with it and 76 to 82 s without. So on this 12 GB card these runs show no failure that the budget avoided.Setup:
e44af706(the commit this head is based on) + #684e56dbc3+ #2385005a442(9f73b329), the same build both ways, in turn. RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-protonv3.1-90-g30b0eb9bwith the relaxed-vtable patch from #175 and a local dxil-spirv patch, release, Series X profile, 120 s, A pressed when ready at 16.3 to 18.2 s (one run without the budget also pressed at 10.3 s),XCL_PSO_PRELOAD=0,WINEDEBUG=err+all,fixme-all. Memory figures are XCL's ownmemory:lines.XCL_TEXTURE_BUDGET=0(3 runs)video memory is filling upNot tested: the image quality (no frames);
XCL_TEXTURE_LEVEL_PAGES=1andXCL_TEXTURE_MAX; the suite; Windows; AMD and Intel.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.
@itsSio on GitHub · 2026-11-26 04:45 UTC · original
Independent dual-PC NVIDIA full-workspace test report on clean head
005a4427d2926f29d96ea28bf6747dc70321806c.Tested
32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1343 passed, 1 failed, 46 ignored (all 4 newvram::testspass, including GPUgpu_a_texture_without_its_top_mip_samples_the_first_it_has; the sole failure isgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrieratlower_dxil.rs:1155, which also reproduces identically on the PR's bare basee44af7062dc610a9f889de2dcf11450e3e4884b3without this PR and passes on newermainafterc828d8c0/#2420)SKIPPED: 26 (wave64-only GPU tests,#1426wave32 f16/cvt refusals,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record)32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1343 passed, 1 failed, 46 ignored (all 4 newvram::testspass; same pre-existing base failure inlower_dxil.rs:1155)SKIPPED: 29 (same 26 as Machine 1 plus 3 requiringd3d12SDKLayers.dll)Not tested
scripts/smoke.ps1runs--release)AI use
Ran via Samaritan:
e44af706.@bmjask on GitHub · 2026-11-25 20:32 UTC · original · reviewed
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.
@NWProgramming00 on GitHub · 2026-11-26 06:34 UTC · original
On the #1607 hint (group D111): #640 and this PR take different memory, so I think both are needed.
XCL_PAGE_BUDGET_MB): it evicts whole textures that were not used for a while. They are unmapped, then mapped and uploaded again before the next work that uses them. It goes after pages of textures the title no longer uses, which stay mapped while the title recycles that memory.vram.rs(take_tilethere,bind_rangehere). Whichever lands second has to be rebased onto the other, but the two do not need a shared mechanism.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
memory:line is a per-texture sum, which is larger than what was saved when textures share an address. I will make it count each left-out page once.AI use: Claude Code (Claude Opus 5.5) wrote this.
xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590@NWProgramming00 on GitHub · 2026-11-26 08:32 UTC · original
@bmjask, thanks for the review. On your four points:
4c4c577addsgpu_a_texture_without_its_top_mip_filters_like_the_clamp_alone. Two copies of one 256×256 texture have a red mip 0 that no other mip has: one without mip 0 in memory and its view clamped, one with every mip in memory and the same clamp. It samples both into 64×64 pictures with trilinear and 16× anisotropic filtering, LOD −3 to +3, anisotropy 1 to 16, and footprints along and across the axes.clamp_skipped_mips, it fails.Loadand mip queries read zero from the left-out mips, and the title's uploads into them are still detiled.bind_rangeand caps the pools; whichever lands second needs a rebase.AI use: Claude Code (Claude Opus 5.5) wrote the test and this reply.
title_memory_budget_mbis 13,824 MB regardless of the adapter's memory #1337View 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.