D3D12.X: map lazy texture levels when title_textures::register fails #3276
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3276"
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 Kalmarv on 2026-11-29T03:22:33Z.
Map all lazy-level tiles in
CreatePlacedResourceXwhenXCL_TEXTURE_LEVEL_PAGES=1placed a sampled texture on shared pages buttitle_textures::registerreturnedErr(_).Previously,
vram::place_pagesplaced a single-slice non-MSAA sampled 2D texture withlazy = true(zero tiles mapped initially, deferring tile mapping totitle_textures's CPU-upload path). Iftitle_textures::registerthen rejected the texture (for example, console float formats116/117mapped toR16G16B16A16_FLOAT, multi-plane sampled descriptors, or unsupported layouts), the resource was never entered intitle_textures, sovram::map_levelswas never called for it and its reserved tiles stayed unmapped (NULL) permanently.What is in it
crates/xcl/src/hle/d3d12x/device_x.rs:create_placed_resource_x, whentitle_textures::registerreturnsErr(e)for a texture thatvram::place_pagesplaced undervram::level_pages(), callvram::map_levels(r, None)so all of its levels are backed by the shared 64 KiB pages atvawhile still logging the rate-limited warning.lazy_placed_texture_maps_levels_when_title_textures_register_failsverifying withXCL_TEXTURE_LEVEL_PAGES=1that a console format116texture rejected bytitle_textures::registergets its lazy tiles mapped (!has_unmapped_levels,mapped_level_tiles > 0), while a tracked format28control texture stays lazy (mapped_level_tiles == Some(0)).Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release forxcl-smoke.cargo test -p xcl --lib -- hle::d3d12x::device_x::tests:: --nocapture): failed before the fix (untracked lazy texture must not remain with unmapped levels), passed after rebase ontoorigin/main(21 passed, 0 failed,0.25s, runs on WARP with0skips).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::): 2662 passed, 0 failed, 49 ignored, 9 filtered across 41 test binaries.SKIPPEDGPU tests on this wave32 adapter (26 total across--nocaptureworkspace baseline): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426f16/cvt-f16 refusals, 2no heap windows(opt-inXCL_HEAP_WINDOWS=1).ea3b5e4d) 150 s regression run below (0device removals,0crashes,1541frames vs1695onmain,33556 MBpeak commit vs31546 MBonmain).Regression run
Not tested
XCL_TEXTURE_LEVEL_PAGES=1(ea3b5e4dsmoke is a default-config regression check; lazy-level fallback behavior is verified by theXCL_TEXTURE_LEVEL_PAGES=1WARP test).uma_driver::tests::(skipped locally due to pre-existing0x7C10003exit on NVIDIA) andtest_title_runs_and_game_folder_is_untouched.AI use
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T07:55:37Z.
merge-check
base:
d8bd9a3820head:
43f61224dcmerge: clean (local merge 3407dfad213d48bb7e03907ed7259a167b0323d5;
git diff --checkclean)build:
cargo build --workspace-> ok; clean release builds of base and merge -> oktests:
cargo test --workspace --no-fail-fast -- --test-threads=4-> 2,619 passed, 0 failed, 49 ignored on both the base and merge retry; 26 explicit GPU skips on each (21 no wave64, 3 unsupported per-lane operations, 2 no heap windows). The first merged-tree suite run exited with 0xc0000005 during concurrent library tests; the same command passed on retry. The focused PR test passed on the RTX 3080 Ti after locally replacing its WARP adapter selection (1 passed, 0 failed, 0 ignored, 0 skips); that test-only edit was removed before the smoke runs.review: The normal format-116 fallback maps its lazy tiles, while format 28 remains lazy. One allocation-failure path still returns
S_OKwith an unmapped, untracked texture:map_levelsskips a group when its backing heap cannot be allocated, and the new caller discards that result. A local test-only heap-allocation failure reproduced the unmapped-level assertion on the unmodified PR head. The candidate below returnedE_OUTOFMEMORYwith a null output; both focused normal and injected tests passed (1/0/0 each). The child test should also remove inheritedXCL_VRAM_ARENAS, which otherwise disables the placement it asserts. GPU readback of a multi-mip fallback texture remains untested.performance: With
XCL_TEXTURE_LEVEL_PAGES=1and matched 60 s guarded runs, base/merge showed 1,645/1,664 frames and 15,014/14,985 MB peak commit, with no crash or device removal. Both logs confirmed the opt-in and recorded four registration-rejection warnings; the smoke did not establish which resources received lazy tile mappings or reach world load. These menu-phase differences do not establish a frame-time or memory improvement.verdict: not yet: return a failure and null resource if the fallback cannot map every lazy level, and cover that allocation-failure path with a regression.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11 / Codex (GPT-6.2 Sol) ran and reviewed the tests and candidate; Codex (GPT-6.2 Astra) reviewed the allocation path.
Candidate diff for the allocation-failure path
This is a local candidate on the PR head, not a pushed commit. The test hook forces the same
alloc_pool_heapfailure that a failedCreateHeapreaches. Without the runtime change, the injected test fails because an unregistered texture still has unmapped levels; with it, both the injected and normal focused runs pass.Generated opt-in smoke blocks
Both blocks came from
scripts/smoke.ps1 -Seconds 60on clean release trees withXCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE=0, the same adapter, a fresh cache per tree, and the script's network-off setting. A 16 GiB process-tree commit cap, 8 GiB system-commit headroom floor, and 210 s launcher timeout guarded each run; no guard stopped either run.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:39:04Z.
Review (head
5b2ad07c, diff read, not a merge-check: thePR descriptioncheck fails, so not built or run here yet):map_levelscan't get pages, the new branch (device_x.rs~1292-1299) returnsE_OUTOFMEMORYand a null resource. The non-lazy path handles the same failure by releasing the reserved resource and falling back to a committed one with S_OK (place_on_pages->place_pagesreturns None). Console titles don't expect CreatePlacedResourceX to fail, so this probably turns a blank texture (main: no tiles mapped, reads return 0) into a crash. Falling back to a committed resource would match the other path.b161ba8b, not the head5b2ad07c, which is whyPR descriptionfails. The description is also out of date: it doesn't mention the E_OUTOFMEMORY path, the second test child or thevram.rshook.Co-Authored-By: Claude Opus 5.5trailer isn't mentioned.Fine: it's off by default (
XCL_TEXTURE_LEVEL_PAGES=1; thevram.rshook is test-only), the level pages are freed through the release hook (forget_pages), so the failure path neither leaks nor maps twice, and the test fails without the fix in both children, runs on WARP and clearsXCL_VRAM_ARENAS.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T16:35:32Z.
Test report (not a merge-check:
PR descriptionred)base:
b2b1f109d2head:
5b2ad07c8amerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 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: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3276#issuecomment-7300952336, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed); the findings in my review stand
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.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:14:52Z.
Code review location:
crates/xcl/src/hle/d3d12x/device_x.rs; line 1299When the level pages can't be mapped (alloc_pool_heap/CreateHeap fails or take_batch returns None under VRAM pressure), this returns E_OUTOFMEMORY from CreatePlacedResourceX. Titles usually treat that as fatal, and before this PR the call returned S_OK. Every other place_on_pages bind failure falls back to
small_tex::place/dev_create_committed_resource(~1270-1276). This one should drop the reserved resource and take the committed path too. The early return also skips both the warning and thehr < 0log at ~1320, so the failure isn't logged at all.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:14:52Z.
Code review location:
crates/xcl/src/hle/d3d12x/device_x.rs; line 1296Not certain about this one:
map_levelsreturns without mapping whent.mappedis false, buthas_unmapped_levelsignoresmapped. If another thread places an overlapping texture between place_pages and here (hold_unmapsets mapped=false), this texture is destroyed with E_OUTOFMEMORY even though nothing failed to allocate.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:14:52Z.
Review: COMMENTED
Review of
5b2ad07c: 3 finding(s). 2 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/vram.rs:2506: The levels are only mapped at creation. If the texture is later superseded (unmap_placed holds an unmap, and release_held_unmaps unmaps the tiles) and then remapped viaplacements::map_again,remap_if_unmappedtakes its lazy branch, which only sets mapped=true. title_textures never tracks this texture, so no upload callsmap_levelsagain, and it's back to 0 tiles and reading zeros, which is the bug this PR fixes.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:38:54Z.
Closing: returns
E_OUTOFMEMORYfromCreatePlacedResourceXwhere the console does not fail, risking a crash instead of committed fallback.Pull request closed