D3D12.X: a new texture with lazy levels has its tiles mapped by a call #3116
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3116"
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 throny on 2026-11-28T10:11:12Z.
With
XCL_TEXTURE_LEVEL_PAGES=1, world entry on NVIDIA loses the device (0x887a0006, device hung) in a good share of launches. The cause, a reproduction without a title and the remedy were found by psuedo-tty in #2572 (comment): a list that is already submitted and reads a reserved texture created since, on which no tile-mapping call has run yet, takes a GPU page fault. A title makes a streamed texture and names it in a descriptor in one call while lists that read the descriptor are on its queues, and a texture with lazy levels gets its first mapping only with its first texels. This PR is that remedy fornvidia-dev. Part of #2572 / #505.What is in it (one commit)
crates/xcl/src/hle/d3d12x/vram.rs: when a texture is placed with lazy levels,Pages::null_allmaps all its tiles to no memory with one NULL-rangeUpdateTileMappingsand signals the mapping fence, under thePAGESlock; then, outside the lock,wait_new_mappingswaits for that fence value, 250 ms at most (a spin for the first half millisecond, yielding after it). The fence value moves on only when theSignalwas made. A per-device counter and a test hook for it.crates/xcl/src/hle/d3d12x/title_textures.rs: the existing level-pages GPU test also asserts that the placement made that call and that the mapping fence is done when the placement returns.Tested
XCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072, release, on54225f58plus three small local patches (the #684 crash fix, input timing, preparation skip):Error_DMA_PageFault, a read by the graphics engine in the last tile of a live BC1 texture created about 1.8 s before the dump; 2.1–2.6 presents/s in the six that survived;cargo test -p xcl --lib a_placed_texture_gets_the_pages_of_a_level_with_its_texels: passes; with thenull_allcall removed it fails (left: 0, right: 1).cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window(debug): base54225f581901 passed, 6 failed, 48 ignored; this head 1901 passed, 6 failed, 48 ignored; 27 SKIPPED lines on both. The 6 failures are the same on both:placed_title_textures_share_vram_and_preserve_pixelsand threestream_recheck_*tests intitle_textures, andd32s8_targets_take_their_own_size_of_video_memoryandgpu_retire_queue_holds_heap_until_blocked_queue_passes_markinvram.xcllibrary test binary is terminated on the base and on this head alike (exit code 0x7C10003 after "coherent window could not be restored … after CreateCommandQueue"), twice on each tree here; KDenKC sees the same on an RTX 3090 and an RTX 5090 with driver 621.24 and skips the same three. Reported on #3041.Regression run
On a commit of
main, on the base commit (nvidia-dev, which this PR is against) and on this PR's head; same title, 120 s. Themainblock is the run of 2026-11-27 on83b00818on this machine (today's attempt to repeat it on that commit spent its whole start-up limit preparing shaders and showed no frame); the other two are from today.This PR,
fc2e9e94:Not tested
XCL_TEXTURE_LEVEL_PAGES=1is set; whether AMD needs it or pays for it is not measured (psuedo-tty points at #2981 as possibly the same family on AMD).XCL_TEXTURE_LEVEL_PAGESunset) is not changed by this PR; 6 of 6 world entries without level pages were clean here before, which is too few to say the non-lazy branch cannot fault.XCL_TEXTURE_LEVEL_PAGES=1, a handful of launches with and without this commit, counting device removals.AI use
nvidia-dev, wrote the test change and this description, and ran the builds, world entries, suite and smoke runs on my hardware. An independent review by Claude Opus 5.5 led to three changes before this was opened (the wait moved out of the lock, yielding in place of a long spin, and the non-lazy branch left alone). The cause and the remedy are psuedo-tty's (#2572).🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-28T10:38:45Z.
AMD run (listed as untested) on an RX 9070 XT: the extended
a_placed_texture_gets_the_pages_of_a_level_with_its_texelspasses, with its new asserts that the new texture's tiles were mapped by a call that had run when the placement returned. Nothing else invram::testschanges.Tested: at the PR head
fc2e9e9against its merge-base,nvidia-dev54225f5. Debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, RX 9070 XT (RDNA4) driver 32.0.32029.2010.cargo test -p xcl --lib -- hle::d3d12x::vram::tests a_placed_texture_gets_the_pages_of_a_level_with_its_texels --test-threads=1 --nocapture: merge-base 23 passed, 0 failed, 1 ignored; PR the same, no SKIPPED, with no result changes. Same counts withXCL_TEXTURE_LEVEL_PAGES=1set (the test turns level pages on itself throughLEVEL_PAGES_FOR_TEST).EnumAdapters1(0), which is the RX 9070 XT on this PC. So it ran on AMD every time, including a run withXCL_ADAPTER=3060, and the RTX 3060 in the same PC isn't covered.I didn't measure whether AMD needs the mapping call or what it costs, only that the test passes there.
Not tested: the whole suite, a title with
XCL_TEXTURE_LEVEL_PAGES=1, the RTX 3060 for this test, Intel.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-28T10:48:22Z.
@throny, on it. Two parts, both queued now:
XCL_UMA_WINDOWS=16, mixed UMA,XCL_TEXTURE_LEVEL_PAGES=1,XCL_CS_PSO_WAIT_MS=200,XCL_TWO_PASS_MB=3072), 4 launches withfc2e9e94's change and 4 without, alternating, counting device removals and where each launch ends. That also covers a driver other than 621.40.fc2e9e94againstnvidia-dev54225f58. That box has too little RAM for the title, so it's tests only there.We'll post both here as one Tested / Not tested report.
AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-28T11:28:57Z.
A full suite count from a second NVIDIA card (RTX 3060, driver 610.88): the
xcllib binary runs to the end here on both trees, with the same result on the base54225f5and on this head. The 4title_texturesfailures in your run show up here only when the title-run variables from your Tested section are set.Tested:
fc2e9e9and its basenvidia-dev54225f5. RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, 16 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.54225f5fc2e9e9cargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_*setSKIPPEDlinesSKIPPEDwatch::tests::a_thread_in_the_driver_is_seen_until_it_returns(watch.rs:623,unwrap()onErr(Any))a_placed_texture_gets_the_pages_of_a_level_with_its_texelsalonetitle_textures::+vram::withXCL_TEXTURE_LEVEL_PAGES=1placed_title_textures_share_vram_and_preserve_pixels,stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload,stream_recheck_schedule_catches_late_writes_and_resets_milestonescargo test -p xcl --lib -- --test-threads=4withXCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072placed_title_textures_share_vram_and_preserve_pixelsand threestream_recheck_*) plusa_dispatch_with_a_pipeline_still_building_waits_at_the_submitandput_off_dispatches_wait_at_the_submit_and_run_on_the_software_adapter. No termination.So if those variables were set in the shell your suite ran in, they would explain the 4 failures. The
0x7C10003termination did not happen here with or without them.Not tested: world entry with
XCL_TEXTURE_LEVEL_PAGES=1(no title here), so nothing on the device removals this fixes; a release build; the base's termination on your card.AI use: Claude Code (Claude Opus 5.5) ran the suites and wrote this report.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T11:36:29Z.
At head
fc2e9e9, the normal mapping path works in the focused RTX test, but placement can still return a lazy reserved texture before its initial NULL mapping has completed.wait_new_mappingsbreaks after 250 ms with no completion result.null_allalso returnsNoneifSignalfails. In both casesplace_on_pageskeepsbound = trueand returns the successfulCreateReservedResourceHRESULT with the texture pointer. A consumer can then receive the same not-yet-mapped resource that caused the #2572 fault. The PR's own ten-run report says the timeout was reached once. A removed fence'sGetCompletedValuesentinel also needs to be distinguished from a completed value.Suggested resolution: publish the texture in
targetsand return success only after confirmed mapping-fence completion. On a timeout or failed signal, clear the output pointer, return a failure HRESULT, and keep the reserved resource alive until the already-queued mapping call retires or the device is removed. Keep bookkeeping and placement registration consistent on that failure path. A later successful signal on the same private queue can serve as the retirement mark after an earlier signal failure. This avoids trading a GPU fault for a resource-lifetime race.Targeted regression to add
Gate the private mapping queue with a test-controlled fence before lazy placement. Hold it beyond 250 ms, assert that placement cannot return success or a usable texture and that target/page counters are unchanged, then release the gate and verify the retained resource retires. Release the gate even if an assertion fails. Separately inject a failed
Signaland a removed-fence completion value. The existing test checks the normal mapping count and completion at return; it cannot reach these failure paths.Tested: Windows 11 build 26300, RTX 3080 Ti 12 GB / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC. On exact head,
cargo test --offline --locked -j 4 -p xcl --lib a_placed_texture_gets_the_pages_of_a_level_with_its_texels -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. This is normal-path coverage. Not tested: forced timeout, failed signal, full workspace suite, title run.AI use: Codex (GPT-6.2 Sol) traced the placement path and ran the focused test; Codex (GPT-6.2 Astra) independently checked the D3D12 ordering and failure paths.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T12:40:03Z.
Follow-up to my earlier mapping-order review, tested against unchanged head
fc2e9e9.I reproduced the timeout on the RTX 3080 Ti (621.35) by holding the actual tile-mapping queue behind a fence. On the unchanged head plus the regression test, placement returned
S_OKwith a resource pointer after 250 ms while its first NULL mapping had not executed: 0 passed, 1 failed, 0 ignored, 0 skipped. A drop guard opens the gate even if an assertion fails. With the candidate, the same test passed 1/1, returningDXGI_ERROR_WAIT_TIMEOUTand a null pointer. It also injects a failure of the first queueSignal, checks that the unpublished resource stays alive, and verifies idle retirement after a later signal on the same queue. The existing lazy-level GPU test passed.The candidate publishes the target and placement records only after the mapping fence confirms completion. On timeout or
Signalfailure, it retains the resource until a later proven queue mark or device removal, and drops completed references outside the page-map lock. It treatsGetCompletedValue() == UINT64_MAXas device removal, not completion. While an unproven mapping is retained, another lazy placement on that device returns an error without allocating a new reserved resource.Tested: Windows 11 build 26300, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC. Focused
vram,late_release, and existing lazy-texture tests: 28 passed, 0 failed, 1 ignored, 0 GPU skips. The ignored case is the existing mapping-churn benchmark.cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4on cleanfc2e9e9: 1,907 passed, 3 failed, 48 ignored, 26 skip notices; on the candidate: 1,908 passed, 3 failed, 48 ignored, 26 skip notices. All three failure names match:console_mesh_caches_hlsl_compute_pass_in_memory_and_on_diskand twowatch::teststiming cases. The candidate's extra pass is the new regression.git diff --checkpassed.Still to test: a title A/B, AMD, actual device removal, and a clean-commit smoke pair. The 250 ms deadline is inherited from this PR. Returning an error at that deadline prevents premature use, but a real title could encounter a mapping that would complete later; the current runs do not establish the best recovery policy for that case. This is an adoptable candidate, not a merge-readiness claim.
Candidate and regression diff against
fc2e9e9AI use: Codex (GPT-6.2 Astra) wrote the candidate and regression and ran the focused GPU tests; Codex (GPT-6.2 Sol) reviewed the path and ran the paired full workspace suites.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-28T15:05:42Z.
@throny the whole suite of your head on an RTX 3090, against its base on the same machine: no failure the base doesn't have.
Tested:
fc2e9e94and its basenvidia-dev54225f58.XCL_*set.cargo test --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window(those three end the lib test binary on 621.24, at the base too)54225f58fc2e9e94title_textures::tests::a_placed_texture_gets_the_pages_of_a_level_with_its_texels(with your new asserts)placed_title_textures_share_vram_and_preserve_pixelsfails on0x8007000Ein the full run and passes alone;stream_recheck_*fail only on the lock it leaves poisoned;vram::testsfail on0x8007000E;e2etest_title_runs_and_game_folder_is_untouched.Still to come (we'll edit this comment): the in-title part on the RTX 5090: your environment, 4 launches each for the base, this PR and #3124, counting device removals.
Not tested: a title run with
XCL_TEXTURE_LEVEL_PAGES=1(world entry, device removals); a release build; AMD / Intel.AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T15:20:32Z.
Ran the lazy-level tile-mapping GPU test at
fc2e9e94on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The GPU-backed test passes here: a placed texture with lazy levels has its tiles mapped by a call and the mapping fence is done when placement returns. This is a synthetic device test, not a retail-title launch; the PR's 0-of-10 vs 4-of-10 device-loss figures came from a title on an RTX 4080 and are not reproduced here. The thread has runs on RTX 3060, RTX 3090 and AMD; this adds a Blackwell datapoint.
Not tested: a retail title, the device-loss A/B, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T15:33:28Z.
On RTX 5070 12 GB, driver 616.92, all 384 normal lazy placements had a completed mapping fence when checked immediately after placement returned. The production wait counter averaged 199, 205, and 212 µs per placement across three fresh processes. None reached the 250 ms cap.
I used head
fc2e9e94541bf365795d0f674fd7e4cf1700e06ewith a test-only extension toa_placed_texture_gets_the_pages_of_a_level_with_its_texels. Each process created 128 distinct 1024×1024 RGBA8 textures with 11 mip levels throughCreatePlacedResourceX, serially on one device. It kept all 128 resources alive. After each return, the test checked that the NULL-mapping count advanced by one and that the mapping fence had reached its last signalled value. The device's physical texture-page allocation counter stayed unchanged before texel upload. The existing fixture then passed its mip-content GPU readback checks in each process. The adapter name and NVIDIA vendor ID were checked on the DXGI adapter used to create the device. Three focused tests passed, zero skipped.The 128 waits totalled 25,456 / 26,252 / 27,197 µs in the PR's existing wait counter. These are debug-build host wait times on an otherwise ungated queue. They do not establish a safe shorter timeout, measure total placement time, or estimate world-entry device-loss frequency. No retail title or fault injection was used.
AI use: OpenAI Codex (GPT-6) inspected the two related PRs, added the test-only instrumentation, ran the fixture and prepared this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:09:19Z.
Closing this in favour of #3124.
nvidia-devwas merged intomaintoday (#3203), this PR now targetsmainand conflicts with it, and #3124 carries the same NULL mapping with a stricter failure path (it fails the placement instead of handing out a texture whose mapping did not complete), merges cleanly, and did equally well in the title on this card: 10 of 10 world entries without a device removal, the same frame rate (numbers). Two fixes for one hang help nobody; thanks @Prime1997 for taking it further and @KDenKC for the runs on the 3090.AI use: Claude Code (Claude Fable 5.2) wrote this.
Pull request closed