D3D12.X: XCL_TEXTURE_DROP_LEVELS leaves large textures' top levels without video memory #2968
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2968"
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 Prime1997 on 2026-11-27T05:42:00Z.
Requested by Prime
With
XCL_TEXTURE_DROP_LEVELS=n(1 to 4; off by default) andXCL_TEXTURE_LEVEL_PAGES=1, a sampled texture with lazy levels whose largest level isXCL_TEXTURE_DROP_MINtexels or more on a side (1024 by default) leaves itsnlargest levels without video memory, and its views sample from the next level down (ResourceMinLODClamp). Textures look softer up close; each dropped level is about three quarters of such a texture's memory. Meant for cards whose video memory a title's world overruns, where the budget overrun costs more than the detail.Part of #2688.
Why
In a retail title's world on an 8 GB card the title's textures held 3.2 GB of level pages and local video memory reached 10.2 GB on a 7.1 GB budget (Series S profile). In runs of the same length with the same settings,
n = 1brought the level pages to 2,286 MB and local video memory to 9,365 MB against 10,229 MB at about 400 s;n = 2(withXCL_TWO_PASS_INDIRECT_MB=8, a local switch) peaked at about 9.0 GB. No view of such a texture was left unclamped, no crash (local branch ofnvidia-devwith #1182, #2921 and #2815 merged in).Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: head4770c0011df4728ce292cdeed226f72eb323bfe4(was8c07f9abb06dddf2aaef505e6fc8e3e8c5b8b3bc). Conflicts were invram.rs, where a placed texture's entry now carries bothmain's texel accounting and this PR'sdroppedcount, and in the level-pages test oftitle_textures.rs, wheremain's additions and this PR's now run one after the other. That test marks the GPU write throughcapture_gpu_writeandpublish_gpu_writes, asmaindoes;note_gpu_writeno longer exists there. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 a_view_of_a_texture_without_its_largest_level_samples_from_the_next integer_rtv_blend_sanitization_clears_uint_sint_and_preserves_float a_placed_texture_gets_the_pages_of_a_level_with_its_texels test_mapping_observation_includes_level_group_ownersgave 4 passed, 0 failed, 0 ignored, no SKIPPED. The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:drop_setting/dropped_levels_for(the switch and which textures it takes),Target::droppedset at placement,map_levelsskips the dropped levels unless a GPU write asks for all of them,has_unmapped_levelsignores them,dropped_levelsfor the views.crates/xcl/src/hle/d3d12x/real.rs:dev_create_srv_xclamps a 2D or 2D-array view of such a texture (clamp_view_to_level); default views are counted, not clamped.a_view_of_a_texture_without_its_largest_level_samples_from_the_next(the clamp), and the level-pages GPU test places a texture with one level dropped: the smaller levels get pages with their texels, the largest none, it has no level still to map, and a GPU write gives it all of them.Tested
cargo test --locked --workspace --no-fail-fast -- --test-threads=4withXCL_DXC_DIRset to DXC 1.9.2609.5: 1825 passed, 8 failed, 48 ignored. The 8 failures are the same tests that fail onnvidia-deva5e2d851itself (1820passed,12failed,48ignored there, same command):async_compute_pso_registers_real_pso_and_not_standin,console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays,hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels,split_compute_prefers_the_offline_whole_pipeline,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.Build and test (Windows, no GPU)has failed on other pull requests againstnvidia-dev(#2905, for one) onhle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view(the WARP device is removed, 0x887a0005). That test passes on the card above, on this branch and ona5e2d851.Regression run
A commit of
main(b49be183, the last one before the shader preparation screen of #2555, which prepares every record before the title and so does not fit a 60 s run):The base of this PR,
nvidia-deva5e2d851:This PR's head:
Not tested
Load(no level of detail) reads zeros there; sampling is clamped.AI use
Claude Code (Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/6B4TykyC4W
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T06:11:11Z.
Review: COMMENTED
An explicit 2D SRV can contain only a mip this option drops. For a valid view with
MostDetailedMip=0andMipLevels=1, the exactclamp_view_to_levelhelper returns the same one-mip view withResourceMinLODClamp=1. Mip 1 is outside that view, so this cannot make sampling fall back to the next resident mip as described. The existing clamp test exposes the full chain and misses this case. Could the implementation keep the necessary level resident when the requested view has no intersection with the retained levels, or define and test an explicit fallback for that view? View clamp · D3D12 view fieldsAI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran an isolated CPU harness around the exact descriptor helper, and drafted this comment. Shader sampling and retail impact were not measured.
Imported from ivall/xcl. Originally posted by vibryxcx on 2026-11-27T06:21:41Z.
AMD data point for the "Not tested" side: on an RX 6800 (RDNA2, driver 32.0.21045.5002, Windows 11 Pro 26200, Rust 1.100.0, debug), this head adds no failure in the texture / vram / view tests.
cargo test -p xcl --lib -- --test-threads=1 title_textures vram dropped level view, run on the base (merge-base withnvidia-dev,a5e2d851) and on this head (8c07f9ab):The one failure is the same on both,
texture_upload::tests::pieces_hold_the_texels_of_their_levels, so it does not come from this PR. The extra pass is this PR's new test. I did not run the title onnvidia-dev: this card has 16 GB, so the over-budget case the switch is for does not happen here, and on this branch the shader cache is cold (about an hour of recompile).Not tested: the switch on the title; RDNA3/4; 8 GB AMD cards.
AI use: Claude Code (Claude Opus 5.5) ran the tests through a local runner and wrote this comment.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T06:27:05Z.
I checked the previously untested
Loadcase on RTX 5070 / NVIDIA 616.92 at head8c07f9abb06dddf2aaef505e6fc8e3e8c5b8b3bc. An instrumented test build extends the existing reserved-texture fixture with native shader readbacks and exposes the existing clamp helper to the test; its implementation is unchanged.For 1024×1024 RGBA8 textures, mip 0 had red value 25 and mip 1 had red value 48. Each shader wrote one half of a 64×64 output:
SampleLevel(0)Loadat mip 0Each value above was observed in all 2,048 pixels of its half; the focused test passed without skips. This supports the stated risk that direct loads can see zero even though sampled reads use the next mip. It covers explicit 2D SRVs and this synthetic fixture; console descriptor dispatch, retail image quality, and actual memory savings were not tested.
AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.
Imported from ivall/xcl. Originally posted by milas6669 on 2026-11-27T09:34:45Z.
RTX 3070 8 GB retail loading test of #2968
On the clean NVIDIA PR head
8c07f9abb06dddf2aaef505e6fc8e3e8c5b8b3bc, dropping one texture level reduced the memory attributed to sampled textures at comparable loading checkpoints. All four Series X runs still exceeded the local video memory budget and reached a host memory guard while displaying loading artwork. PR #2968Tested. RTX 3070 8 GB, NVIDIA 621.40, i9-10900KF, 32 GB RAM, Windows 11 build 26200, Rust 1.100.0 MSVC. Release build with
cargo build --locked --release -p xcl --bin xcl. Two focused checks ran individually withcargo test --locked --release -p xcl --lib <filter> -- --nocapture --test-threads=1. The filters werea_view_of_a_texture_without_its_largest_level_samples_from_the_nextanda_placed_texture_gets_the_pages_of_a_level_with_its_texels. Total 2 passed, 0 failed, 0 ignored, 0 explicit skips.I used the same executable, frozen save, scripted A-button schedule and byte-identical copies of a 1,861-file cache from a 60-second warm-up on this head. The Windows driver cache was retained. Each measured run used the PR’s
scripts/smoke.ps1 -Game <local retail folder> -Seconds 360 -StartupTimeoutSeconds 60 -Xcl <release executable> -OutDir <private output>. Common settings includedXCL_DEVICE_TYPE=anaconda,XCL_NETWORK=0,XCL_PREPARE=0,XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1,XCL_UMA_WINDOWS=16,XCL_COHERENT_MB=1024,XCL_TEXTURE_LEVEL_PAGES=1,XCL_TEXTURE_DROP_MIN=1024andXCL_FRAME_DUMP=30. OnlyXCL_TEXTURE_DROP_LEVELSchanged between settings. The game first registered A at 15, 30, 15 and 15 seconds in run order.Each row uses the first complete two-second activity interval past 32,000 cumulative DirectStorage requests. All memory values are MiB. XCL counts a shared page for each owner in its per-owner columns.
At 34,692 and 34,720 requests the one-level and full-detail runs both used 8,143 MiB locally. The sampled-texture counter was 66 MiB lower with one level dropped. At 32,422 and 32,222 requests it was 49 MiB lower, and local use was 128 MiB lower. The textures with all their pages accounted for roughly 3.2 GiB throughout this checkpoint. That group merits allocation-by-use profiling during loading.
The last complete intervals were at 124, 138, 170 and 160 seconds, with 58,791, 49,851, 87,979 and 76,108 cumulative requests and zero reported storage failures. The first pair stopped below 2 GiB of available system commit. The repeat pair stopped below 2 GiB of available physical RAM. Sampled frames showed startup and loading artwork in all four runs. The logs recorded zero unhandled exceptions and zero device removals through the stops.
Not tested. World-frame rate, world texture quality, longer unguarded runs, other profiles or GPUs, later branch commits, or the additional PRs used in the author's Series S run. The full workspace suite was outside this hardware comparison.
AI use. OpenAI Codex (GPT-6, exact serving variant unavailable) built the PR, ran the tests and wrote the analysis and report.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T09:48:39Z.
I found two boundary cases for
XCL_TEXTURE_DROP_LEVELSon head8c07f9a. Neither is covered by the existing full-chain SRV readback.An explicit 2D SRV with
MostDetailedMip=0, MipLevels=1has only mip 0.clamp_view_to_levelleaves that count at 1 and setsResourceMinLODClamp=1when mip 0 was dropped. The resulting accessible interval is empty: Microsoft's SRV contract gives[ResourceMinLODClamp, MipLevels-1]for this setting. The test-only assertion below fails on this head. To preserve the original view's contents, an incompatible restricted view needs its omitted mip mapped and uploaded, including when the view is created after an earlier upload. Simply omitting the clamp leaves mip 0 without pages; widening only the native view to include mip 1 can provide a sampled fallback, but changes the view's direct-load behavior. A native GPU test should cover a mip-0-only console SRV created both before and after upload, with distinct colors in mips 0 and 1 and a readback through the published descriptor.The requested drop count can land inside a packed mip group.
Target::droppedis set from dimensions and count alone, whilemap_levelsretains any group whose end is past that count. For example, with separate groups for mips 0 and 1 and one packed group for mips 2–10, requesting four dropped levels keeps the packed group and its mip-2/3 texels, yet the SRV clamp hides mips 2 and 3. That loses visible detail without saving their tiles. Use the effective group boundary (2 in this example) for both mapping and the SRV clamp; when all mips share one group, the effective drop is 0. A syntheticLevelstest with a packed tail can check this without relying on a driver's tiling choice.On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, I ran
cargo test --offline --locked -j 4 -p xcl --lib a_view_of_a_texture_without_its_largest_level_samples_from_the_next -- --test-threads=1with the test-only assertion below: 0 passed, 1 failed, 0 ignored, no GPU skip; it fails at “the clamp leaves this view no accessible mip.” This checks the descriptor the helper produces, not GPU pixels. The packed-tail point is a source and tiling-contract analysis, not a native tiling measurement. Neither is a measured retail visual defect or a validated production patch; GPU readback and memory measurements are still needed for fixes.Failing focused assertion for the restricted SRV
AI use: Codex (GPT-6.2 Sol) inspected the production paths and ran the focused assertion; Codex (GPT-6.2 Astra) independently checked the mip-group and descriptor cases.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T12:20:54Z.
Tested PR #2968 (
8c07f9ab) on an 8 GB NVIDIA RTX 3060 Ti (Series S /lockhartprofile,240 sworld runs withXCL_TEXTURE_DROP_LEVELS=1and=2) plus its unit test.Environment
32.0.16.2140)nvidia-devDXIL cache (XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE_GRAPHICS=0,XCL_DRED=1)Unit test
cargo test --locked -p xcl --lib -- a_view_of_a_texture_without_its_largest_level_samples_from_the_next --nocaptureon8c07f9ab:hle::d3d12x::real::pso_blend_and_tsharp_tests::a_view_of_a_texture_without_its_largest_level_samples_from_the_next— ok (1 passed, 0 failed)240 sWorld Runs (XCL_TEXTURE_LEVEL_PAGES=1)PresentX)target pagesa5e2d851(180 s, unset)0x00 / 01861151.36 s3880 MB(pools 3968 MB)8974 MB4677 MB25770 MBa5e2d851(240 s, unset)0xc0000005(188.46 s)2 / 0126.29 s3864 MB(pools 3904 MB)9351 MB4768 MB25909 MB#2968DROP_LEVELS=1(240 s)0xc0000005(240.48 s)2 / 0119.74 s3607 MB(3569 MBat crash;pools 3712 MB)9478 MB5048 MB27718 MB#2968DROP_LEVELS=2(240 s)0x00 / 01937(1 1 1last 3/2s)122.15 s3337 MB(pools 3392 MB)9319 MB5165 MB28274 MBSummary
DROP_LEVELS=1andDROP_LEVELS=2logged activation cleanly (sampled textures of 1024 texels or more on a side leave their 1/2 largest level(s) without video memory and are sampled from the next one).target pagesdropped from3,864–3,880 MBona5e2d851to3,607 MB(DROP_LEVELS=1) and3,337 MB(DROP_LEVELS=2), saving~540 MBin target texture pages at=2.DROP_LEVELS=1still hit an unhandled guest exception (0xc0000005at240.483 sexecuting0x1ffffffff), similar to the240 sa5e2d851baseline crash at188.459 s, whereasDROP_LEVELS=2completed the full 240 s open-world run withexit: 0x0,0crashes, and0device removals.Imported from ivall/xcl. Originally posted by 3L1A5-1 on 2026-11-27T12:49:38Z.
Another 8 GB NVIDIA data point, this time stacked with #2987 (sparse tiles in system memory):
XCL_TEXTURE_DROP_LEVELS=1lowers the total (local + non-local) by ~0.8 GB, which is what matters once local is near budget. One run with the switch, compared with two without.Setup: RTX 2060 SUPER 8 GB (driver 617.14, no ReBAR), i5-9400F, 16 GB RAM, Windows 11 26300, release.
nvidia-deve0821b12+ #2817 + #2921 + #2898 + #2987 + this PR (8c07f9ab, clean merge).XCL_SPARSE_SYSMEM=1,XCL_COHERENT_MB=1024,XCL_TEXTURE_LEVEL_PAGES=1, Series S profile, warm cache, scripted input into the world, 450 s limit.Why the total: dxdiag on this PC shows 8,006 MB dedicated + 8,160 MB shared (half of 16 GB RAM). In my runs of this stack, a Close returns E_OUTOFMEMORY once local + non-local reaches ~14.9–15.0 GB, whichever side the memory is on. So with #2987 moving sparse tiles to non-local, savings like this PR's are the ones that move the end.
XCL_TEXTURE_DROP_LEVELS=1AI use: build, run and log analysis by a Claude Code agent (Claude Sonnet 5.5), this note by Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T22:38:28Z.
merge-check
base:
beeb81be4b(checked against current main: merge conflicts)head:
4770c0011dmerge: conflicts on current main (was clean on
765b2c5b/beeb81be)build: cargo check -p xcl --all-targets -> ok (on
beeb81be)tests: non-GPU lib tests of touched modules (title_textures 7 passed / 1 ignored, vram 41 passed). Full workspace suite and level-pages GPU test not run.
review: with XCL_TEXTURE_DROP_LEVELS enabled, views other than 2D and 2D-array (cube, cube array, 3D) of a texture with dropped levels are neither clamped nor counted (real.rs clamp_view_to_level _ => return None), so they can sample unbacked largest levels; only default (null-desc) views are counted. When enabled, every SRV creation takes the PAGES lock (when off, returns before the lock).
performance: off by default (no cost). In a combined 600 s run with XCL_TEXTURE_DROP_LEVELS=1 + XCL_DEFER_PRIVATE_HOME_TILES=1 (#3123), local video memory dropped 2.3-2.6 GB (11.87-12.16 vs 14.19-14.76 GB), sparse tiles -1.5 GB, peak commit -3.0 GB (32,052 vs 35,016 MB), 0 removals, 0 crashes. Tested in a combined 600 s retail run on main
beeb81be+ 13 PRs (warm cache, defaults) vs baseline: presents/2 s 3.27 vs 3.29, peak commit 35,016 vs 35,767 MB, local video memory 14.19-14.76 vs 14.32-14.95 GB, 0 pipeline waits >= 1 s vs 5, 0 device removals, 0 crashes. Combined result across all 13 PRs, not isolated to this PR.verdict: not yet: needs rebase onto current main; cube/3D views unclamped when enabled; full suite, GPU test, and visual check not run.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:46:01Z.
Review: COMMENTED
Critical review of current head
4770c001. Correctness blockers when the opt-in is enabled:clamp_view_to_levelhandles 2D/2D-array SRVs but leaves cube and 3D views able to sample dropped, unbacked top mips. A restricted 2D SRV exposing only mip 0 can also receiveResourceMinLODClamp=1, leaving an empty accessible interval while mip 0 has no backing. Please handle every view shape that can reference a dropped mip, or keep the referenced mips mapped; add restricted-view and cube/3D GPU readbacks. These cases were detailed in the prior review. The branch also conflicts with main. No local GPU run.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:49:00Z.
Review (head
4770c001, diff read, not a merge-check; draft, conflicting, with CI andPR descriptionred):mapped_level_tiles(soft_key) == Some(all)after the GPU write (title_textures.rs~6968) gets 27 vs 28 on WARP. The panic poisons the test lock and leavesDROP_FOR_TEST/LEVEL_PAGES_FOR_TESTset, which likely explains most of the othertitle_texturesfailures (about 10 PoisonErrors). Main's CI at765b2c5bpassed all 12 tests that fail here.has_unmapped_levels(vram.rs~2849) now ignores dropped levels, so the first full upload records them as sent (title_textures.rs~2858). Whencapture_gpu_writelater maps them, they keep the previous contents of reused pages and never get the title's texels, so aLoador copy reads stale data rather than zeros.real.rs~3325). README doesn't mentionXCL_TEXTURE_DROP_LEVELS/XCL_TEXTURE_DROP_MIN.Targetgainedrecycle(cd1c1d8d), so all three constructions need both fields. The smoke block is on8c07f9ab, not the head.Fine: off by default (one
OnceLockcheck per SRV creation otherwise),clamp_view_to_levelkeeps a coarser clamp a view already had, and themap_levels/has_unmapped_levelsfilters only skip groups made entirely of dropped levels.AI review: Claude Code (Claude Opus 5.5), 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.