D3D12.X: keep re-checking small textures in the unwatched upload range #3617
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3617"
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-12-01T21:14:21Z.
Control-hint glyphs lose letters with
XCL_UMA_DRIVER=mixed("B g / K b g" instead of "Bewegen / Kamera bewegen"). Title textures are copies that XCL re-uploads when a write watch reports a change; theGPU_UPLOADrange of the mixed driver has no write watch, so a texture there is uploaded when it is made and after that only by the stream recheck. That recheck fingerprints three 16 KiB slices at five milestones (4 to 400 frames after the upload) and then drops the texture for good, so a small texture the CPU rewrites later, or outside the slices, is never uploaded again. This adds a switch,XCL_UNWATCHED_RECHECK=1(off by default), that keeps such textures under a whole-texture check.Part of #1049 (not shown that the six textures it re-uploads are the glyph atlas itself; the text came out complete in the one run with the switch on).
What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: with the switch, a texture of up to 4 MiB in the committed window that is not fully write-watched stays in the stream recheck after the milestones, is hashed whole every 16 frames (read throughwith_title_bytes), under a frame budget of 8 MiB and 64 textures (longest unchecked first, the first always made); an entry with no baseline yet is hashed under the same budget; entries seeded in one frame are staggered over the 16-frame period by a hash of the resource. A change queues a whole upload as before. A texture that becomes GPU-written is still removed bypublish_submission_effects, as before (the switch does not change that). Watched memory, paged textures, textures over 4 MiB and the switch off are unchanged. Unit teststeady_rechecks_follow_the_milestones_and_keep_to_the_frame_budget(budget, count cap, stagger).README.md: one line for the switch.Tested
RTX 4080 (NVIDIA), Windows 11 Pro, Rust stable-x86_64-pc-windows-msvc, debug.
cargo build --workspace && cargo test --workspace -- --test-threads=4on head4714ed9b(after bmjask's third review): 3007 passed, 0 failed, 52 ignored, 25SKIPPEDlines.The in-world A/B below (402 vs 404) was made on the pre-review commit
e125eda8, before the frame count cap, the stagger and the baseline budget; it was not repeated onc9283790.25
SKIPPEDlines: 22no wave64(RTX 4080 has no wave64), 2no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form,bind::tests::two_pass_binds_set_the_shared_view_heap), 1shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache: Developer Mode required).A/B on the retail title (same build with and without the switch,
XCL_UMA_DRIVER=mixed, 900 s, hint phase, near-white pixels in the left quarter of each 960x540 frame):Switch-on cost at
412e11e9(review point 2): a 900 s warm world run withXCL_UNWATCHED_RECHECK=1(run 492,XCL_RESIDENCY_PRIORITY=1): 3.00 presents/s from 240 s, no device removal, no crash (main on this machine: 3.0-3.2).Regression run
main
817eb1fc9:this PR's head:
Not tested
0x887a0006, Aftermath page fault "Read by Graphics, BC7 128x1024, not placed". Plain main's run 344 lost the device the same way at +90 s, so it is probably the known loss at the world load, but 1 of 2 switch runs ended that way and 0 of 1 without.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T21:34:43Z.
merge-check
base:
f07e426dadhead:
c928379000merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 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: read the whole diff (+153/-11). With
XCL_UNWATCHED_RECHECK=1, a title texture of up to 4 MiB in a committed window that isn't fully write-watched stays in the stream recheck after the milestones and is hashed whole every 16 frames under a per-frame budget; with the switch off nothing changes. Findings: (1) The whole hash at seed time has no cap and is a GPU round trip. Inseed_stream_recheck(title_textures.rs~2468-2478), every whole upload of a kept texture callsstream_fingerprint(.., true)->with_title_bytes, which in theGPU_UPLOADrange goes toread_vram_bytes(uma_driver.rs~658-687): aCopyBufferRegion, a signal, a fence wait with a 5 s timeout and a newlen-sizedVec, one texture at a time, on the submit path beforeupload_all. This applies to every new upload and every re-upload the check itself triggers; the 8 MiB / 64-texture budget only covers the recheck side, so a frame that creates thousands of small textures (world load) gets thousands of synchronous readbacks, and even the budgeted recheck can make up to 64 serial round trips a frame. The description and README ("at most 8 MiB and 64 textures read a frame") leave this out. (2) The switch-on cost isn't measured at the head commit. The description's A/B was made one125eda8, before the cap, the stagger and the baseline budget; both of its smoke blocks run with the switch off, and one of its two switch-on runs lost the device at +95 s. The switch-on smoke below is 60 s on NVIDIA and doesn't cover world load. (3) The tests don't exercise the wiring.steady_recheck()is read once through aOnceLock, so no test runsseed_stream_recheckorrecheck_streamed_unwatched_atwith the switch on: nothing shows a kept entry surviving past the 400-frame milestone, a rewrite after the last milestone being re-queued, or the 4 MiB limit. The new test covers only the helpers (recheck_interval,steady_waiting,steady_base,stream_fingerprint, including a byte changed outside the slices). (4) Kept textures lose the early milestones.first_stage(true)plussteady_baseput the first check 16-31 frames after the upload (later when over budget) instead of 4 / 12 / 40, so streaming writes landing shortly after a small texture is made are caught later with the switch on than without it. (5) A match arm that is effectively dead and can't clean up.Some(e) if e.gpu_written && steady_keeps(..) => {}(~2533) is in practice never reached, sincepublish_submission_effectsremoves the entry; if it were, the entry would never be pruned and would stay due every frame under theTEXTURESlock. Keeping the plain prune would be simpler. Related: a kept texture whosegpu_writtenis later cleared by a download (~4117) isn't re-seeded until its next whole upload, so "for as long as they live" overstates the coverage. (6) README is imprecise: besides the seed-time reads in (1), the first check is 16-31 frames, and with more than about 1024 kept textures the 64-check cap stretches the period to about N/64 frames, with every waiting entry sorted and looked up underTEXTURESeach frame. Fine: the baseline is the hash at the last whole upload (re-seeded beforeupload_all; partial uploads keep it); a detected change re-uploads through the existing pending path at the next submit with main's ordering, and pending entries are skipped, so nothing uploads twice;forget,registerandretire_rangedrop entries, and the committed window is never decommitted, so reading a freed texture can't fault;steady_waitingchecks the oldest first, so nothing starves; with the switch off,steady_keepsreturns early, no new locks are taken, and the milestones and retirement are as on main.performance: 60 s smoke of a retail title, main
f07e426dvs this merge (c9283790): 1672 -> 1683 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17352 -> 17229 MB, 0 device removals, 0 crashes. WithXCL_UMA_DRIVER=mixed XCL_UNWATCHED_RECHECK=1: 1673 frames, peak commit 17700 MB, 0 device removals, 0 crashes, and the log shows the new check running; a 60 s run doesn't reach world load, where finding 1 would cost most.verdict: not yet: with the switch on, every whole upload of a kept texture does a synchronous GPU readback outside the per-frame budget (finding 1), so the cost at world load is unmeasured and the description's "at most 8 MiB and 64 textures read a frame" doesn't hold; and no test runs the new path with the switch on (finding 3). With the switch off nothing changes, the suite passes, and both smoke runs are clean
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 throny on 2026-12-01T22:01:50Z.
Stability follow-up on the switch (pre-review build of this change, RTX 4080, 900 s each, same save and inputs, no draws skipped): runs 405 and 407 with
XCL_UNWATCHED_RECHECK=13.05 and 3.07 presents/s, run 406 without it 2.97; no device removal or crash in any of the three. So with run 403 that is 1 loss in 4 runs with the switch and the same fault plainmainshowed once — not tied to the switch as far as these runs go.AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T00:18:15Z.
merge-check claim
head:
c928379000Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T00:37:01Z.
merge-check
base:
1c8b551475head:
c928379000merge: clean (merged tree 8cc07b4e,
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; failing: none. Base alone, same machine: 2909 passed, 0 failed, 51 ignored. The new test
steady_rechecks_follow_the_milestones_and_keep_to_the_frame_budgetpasses.review: whole diff read (title_textures.rs, README.md), in the merge result. No blocking finding. With the switch off nothing changes:
steady_keepsis false everywhere, so every entry starts at stage 0, is fingerprinted by the three slices and is removed after the last milestone as on main; an entry past the milestones (now due every 16 frames instead of never) cannot exist without the switch. With the switch on: the whole-texture read goes throughwith_title_bytes, which reads aGPU_UPLOADsegment from the GPU's copy and the committed window in place (never decommitted), so the read cannot fault; a frame's steady checks are capped at 8 MiB and 64 textures, oldest first, and one that waits stays due; an unchanged kept entry is rescheduled from the current frame, a changed one restarts with the stagger. Smaller points: (1) the unit test covers the helpers (interval, budget, stagger, whole hash); thatrecheck_streamed_unwatched_atkeeps an entry past the milestones and queues the upload is not tested; (2) a kept texture that is GPU-written and still listed is neither checked nor pruned and stays due every frame (a map lookup a frame; the comment sayspublish_submission_effectsremoves it); (3) as the description says, the text comparison is n = 1 per side and was made on a commit before the budget and stagger. Duplicates: none open; #3537 (same author, closed draft) was the earlier form.performance: off by default: one
OnceLockread per seeded texture and per due check, reasoned, not measured. With the switch on, up to 8 MiB hashed per frame on the submitting thread; the description measured 0.00-0.20 ms per submit on an RTX 4080. No title run in this check.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T11:10:31Z.
merge-check claim withdrawn
head:
c928379000Withdrawn: this PR is labelled needs:amd-test and we have no AMD hardware. Sorry for the noise; the slot is free.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:32Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2360High:
first_stage(true)starts kept entries past all milestones, so a kept texture is first rechecked 16 + stagger (16-31) frames after upload instead of at the 4- and 12-frame milestones it had before. With the switch on, if a texture is uploaded zeroed and the title streams its contents in 5 frames later, the PR used to catch it at frame 4/12 but now waits 16-31 frames plus any budget delay. At the 3.07 presents/s measured in run 404 that's 5-10 s of stale content, the late-streaming case the milestones exist for. Keeping the early milestones for kept entries, then switching to the steady interval, would keep both.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:32Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2533Medium: The new
gpu_written && steady_keepsarm neither checks nor prunes the entry, so a GPU-written kept entry stays in STREAM_RECHECK for good withbase_framefrozen, collected as due and looked up in TEXTURES every frame. Before the PR it was pruned. Ifpublish_submission_effectsremoves the entry andseed_stream_recheckon another submit thread re-inserts it from a todo list built beforegpu_writtenwas set, it now leaks untilforget(). If the download path later clearsgpu_written, the old whole-hash baseline no longer matches and the texture is re-uploaded spuriously. Pruning it as before would fix both.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:32Z.
Review: COMMENTED
Review of
c9283790: 2 finding(s) (1 high, 1 medium), most severe first.crates/xcl/src/hle/d3d12x/title_textures.rs:2360:first_stage(true)starts kept entries past all milestones, so a kept texture is first rechecked 16 + stagger (16-31) frames after upload instead of at the 4- and 12-frame milestones it had before. (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:2533: The newgpu_written && steady_keepsarm neither checks nor prunes the entry, so a GPU-written kept entry stays in STREAM_RECHECK for good withbase_framefrozen, collected as due and looked up in TEXTURES every frame. (inline)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 bmjask on 2026-12-02T16:10:34Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T16:47:03Z.
merge-check
base:
5eaadb54c1head:
c928379000verdict: not yet: the workspace and retail smoke ended early on both builds. The changed GPU_UPLOAD path remains unverified on this host.
Windows / AMD RDNA4 (native D3D12) — workspace suite and retail smoke on
c928379Clean merge onto
mainat5eaadb54(merge commitdb004a531a1a10e335aae3e1541b97092365c789).git diff --checkwas clean.Setup
d3d12SDKLayers.dll, DXC 1.9.2609.5Tested
cargo build --workspacepassed on both builds.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputexited 101 on both.SKIPPEDnoticesmainCounts are partial because two test processes aborted on each build.
main— none observed in the comparable results.steady_rechecks_follow_the_milestones_and_keep_to_the_frame_budgetpassed in isolation.uploads_start_from_each_subresources_statepassed on both builds.Shared failures and process aborts
fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsreported failures on both builds.gpu_compute_e2etest processes exited with0xc0000409on both builds.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedfor title hash2c508222.main0xc0000409XCL_UNWATCHED_RECHECK=00xc0000409XCL_UNWATCHED_RECHECK=10xc0000409Diff review
The isolated test covers scheduling and hashing. With the switch enabled, the initial whole-texture fingerprint runs before the periodic recheck budget applies. Neither merged smoke run logged recheck activity.
Not tested
Tests after the aborts and retail frame performance remain unverified. The smoke runs did not verify mixed
GPU_UPLOADre-upload or its performance.AI use
Codex (GPT-6) ran the builds and tests, reviewed the diff, compared the results with
main, and drafted this report.Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-12-02T17:13:23Z.
Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on
c928379Merged onto
main5eaadb54(clean merge) and compared withmainrun twice on the same machine.Setup
v3.1-83-gcae8353edand DXVKdxgi.dllfrom GE-Proton11-16, DXC 1.9.2609.5x86_64-pc-windows-msvcwithcargo-xwin; test binaries run under WineTested:
cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>main5eaadb54main: none.steady_rechecks_follow_the_milestones_and_keep_to_the_frame_budget).About the failures on
mainand the 31 skipped tests (same for every PR in this batch)main's 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (d3d12_command_list_Reset: Invalid command allocator), and later tests getE_INVALIDARG(0x80070057). Running vkd3d-proton master with its vtable check taken out,hle::d3d12x::sparse::testsgoes from 106 passed / 38 failed to 144 / 0.std::terminate()(Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private), which kills the whole test binary. They are the split-wave64, dispatch-chain and bridged-mask GPU tests,gpu_compute_mode_dispatch_abi,gpu_compute_thread_limits_leave_the_lanes_past_them_out, the twogpu_mesh_mode_*tests, andconsole_wave64_compute_through_the_pso_hook_dispatch_and_read_back, plusserialize_root_signature_strips_console_flags_and_preserves_pc_flags, whose null descriptor vkd3d-proton dereferences. The dxil-spirv ones crash the same way with vkd3d-proton master (f8c1cae8, dxil-spirv93ab44c5).mainwas run twice: same counts, same failure set.SKIPPEDlines (same asmain): no heap windows (2), no D3D12 debug layer (2-3), driver cache control not implemented in vkd3d-proton (1).Not tested: Windows, NVIDIA, a retail title /
scripts/smoke.ps1, a review of the diff. This is a test report, not amerge-check.AI use: omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with
main, and drafted this report. The user asked for it to be posted.Imported from ivall/xcl. Originally posted by throny on 2026-12-02T18:56:42Z.
@Foniass thanks for the review; everything is in
412e11e9(rebased on main817eb1fc):Whole::Unknown. Its first whole hash is taken by the first budgeted check (8 MiB / 64 textures a frame), and until then the three slices are compared as on main. A hash taken by a check stays the baseline for the upload it queues, because it was read before that upload. The reads are still synchronous GPU copies, at most 64 a frame; the README says so now.XCL_UNWATCHED_RECHECK=1gave 3.00 presents/s, no device removal, no crash (main on this machine: 3.0–3.2).seed_stream_recheck_keeping(.., keeps)andkeeps_whole(..)take the switch as an argument. The new teststeady_recheck_keeps_small_unwatched_textures_past_the_milestonesruns the real seed and recheck path. It covers no read at seed, the early milestones, survival past 400 frames, an 8 MiB texture retiring, a rewrite outside the slices being re-queued, and the download re-seed.gpu_writtenre-seeds the texture from the bytes it wrote, with nothing read.Known limits, now in the commit message: a write outside the three slices before a texture's first whole hash is missed, and so is a CPU write, made while the texture was GPU-written, to a subresource a later download didn't cover (main never re-checks those at all).
@stijn-boer the whole suite runs through at this head on an RTX 4080 (3006 passed, 0 failed), and both smoke runs finish (blocks in the description). If it still ends early on your machine, could you post the last lines of the log? Then I can see whether it's this PR.
Could you both re-check
412e11e9? An AMD check would help too (gpu:both).AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:09:41Z.
Review: COMMENTED
Review of
412e11e9: 4 finding(s) (1 high, 3 medium), most severe first.crates/xcl/src/hle/d3d12x/title_textures.rs:2489: A kept texture is seeded asWhole::Unknownand gets its first whole hash only at a later check, after the upload has already read it. (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:2597:steady_waitingremoves deferred kept entries fromcheckentirely and orders bybase_frame, so milestone and Unknown checks of freshly uploaded kept textures wait behind steady polls of older ones and get no slice comparison meanwhile. (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:4209:reseed_downloadeddoesn't checkentry.cpu_backed, so GPU-owned placements (fromregister_gpu_owned) that get downloaded are put under the recheck. (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:4207:publish_downloaddrops the TEXTURES lock beforereseed_downloadedinserts into STREAM_RECHECK, so a concurrentforgetorregisteron the same raw resource pointer can run in between and the stale entry gets inserted afterwards. (inline)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 bmjask on 2026-12-02T19:09:41Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2489High: A kept texture is seeded as
Whole::Unknownand gets its first whole hash only at a later check, after the upload has already read it. So a write landing between the upload's read and that first check, outside the three 16 KiB slices, becomes part of the baseline and is never uploaded. A glyph atlas in GPU_UPLOAD memory goes up whole at frame F, and at F+0.5 the title writes a glyph at offset 100 KiB. At F+1 (or many frames later if the budget defers it), the check hashes the bytes with the glyph, the slices still matchlast_fpsodiffersis false, andst.whole = Hash(cur)becomes the baseline. The PC texture never gets the glyph: the missing-letter bug this switch exists to fix, with a window that grows under budget pressure. Taking the whole hash from the bytes the upload actually read would close it.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:09:41Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2597Medium:
steady_waitingremoves deferred kept entries fromcheckentirely and orders bybase_frame, so milestone and Unknown checks of freshly uploaded kept textures wait behind steady polls of older ones and get no slice comparison meanwhile. The README and the enum comment both say 'its slices compared meanwhile'. With the switch on and enough kept textures that 64 or more steady checks are due every frame, a texture uploaded at frame F loses its Unknown/4-frame milestone check every frame until older entries drain. Streaming mip writes that the switch-off path catches by slices at F+4 then go undetected for many frames. Running milestone checks ahead of steady polls, or falling back to a slice check for deferred entries, would keep the documented behaviour.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:09:41Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 4209Medium:
reseed_downloadeddoesn't checkentry.cpu_backed, so GPU-owned placements (fromregister_gpu_owned) that get downloaded are put under the recheck. When their hash differs, the recheck setse.pending = trueandPENDING += 1on a texture thattexture_needs_upload(false, ..)never selects. Take a small render target or UAV (≤ 4 MiB) in the committed window that is GPU-written and then downloaded (publish_downloadreseeds it) and later touched by the CPU. Itse.pendingstays true for good, PENDING never returns to 0, thedirty_len == 0 && PENDING == 0fast path is off on every later submit, and the recheck skips the entry forever. Skipping entries that aren'tcpu_backedwould fix it.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:09:41Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 4207Medium:
publish_downloaddrops the TEXTURES lock beforereseed_downloadedinserts into STREAM_RECHECK, so a concurrentforgetorregisteron the same raw resource pointer can run in between and the stale entry gets inserted afterwards. Thread A clearsgpu_writtenand drops the table. Thread B releases the resource (forgetremoves the recheck entry) and a new texture is registered at the same address. A then inserts the old resource's console-bytes hash for the new texture, whose first check compares against another texture's hash, giving a spurious upload or a recheck entry on a GPU-owned replacement. Doing the insert while TEXTURES is still held (or re-checking the entry's identity) would close the window.Imported from ivall/xcl. Originally posted by throny on 2026-12-02T21:38:50Z.
Thanks. All four were real; they are fixed in
7783f9b6, which is amended into the PR's single commit. The commit message and README now describe the new behaviour.High: a write between the upload's read and the first whole hash was never uploaded. Fixed. The upload already keeps a hash of each page it read (
Known, written byHashes::noteinfill). The first whole check of aWhole::Unknownentry now compares the texture's pages with those hashes in the same read, throughtexture_upload::differs_from_sent(texture_upload.rs:137) andwhole_check(title_textures.rs:2418). A difference queues the texture, and the hash taken there becomes the baseline of that upload (title_textures.rs:2593,differsjust below line 2648). The texture is not read again at seed time. One case is left: a page the upload read only in part, where row reads of a linear texture end inside a page, has no hash. A write there is still caught only if it falls in the slices. The commit message says so. Tests:bytes_are_compared_with_what_the_last_upload_read(texture_upload.rs:963), and a new part ofsteady_recheck_keeps_small_unwatched_textures_past_the_milestones(title_textures.rs:7042) that writes outside the slices after the upload's read and expects the texture to be queued. That part fails without the fix.Medium: deferred checks of fresh kept textures waited behind steady polls, with no slice comparison. Fixed.
steady_waitingnow sorts checks still at their milestones ahead of the steady polls (title_textures.rs:2392). A deferred check that is at a milestone (at_milestone, line 2405) is still made by its slices, as with the switch off (lines 2615 and 2648). A change there queues the texture and resets its whole hash toUnknown, because the old hash is not a baseline for the upload that follows. A match advances the stage. A deferred steady poll still just waits. Test: the ordering andat_milestonecases added tosteady_rechecks_follow_the_milestones_and_keep_to_the_frame_budget(line 6866).Medium:
reseed_downloadedput GPU-owned placements under the recheck. Fixed.reseed_downloadednow takes the entry and does nothing for one that is notcpu_backedor is paged (title_textures.rs:2539). The test re-seeds the texture withcpu_backedfalse, then withcpu_backedtrue but not kept, and expects no recheck entry in either case.Medium: lock gap in
publish_download. Fixed. The re-seed now runs whileTEXTURESis held, right afterdownload_currentchecks the entry's generation and address (title_textures.rs:4240). A texture that is released or registered at the same address cannot come in between. If a concurrentforgetremoves the recheck entry before the insert, the leftover entry has no texture behind it, and the next recheck prunes it as on main. Aregisterat that address removes it first. No code path locksTEXTURESwhile it holdsSTREAM_RECHECK, so the new lock order (TEXTURESfirst, thenSTREAM_RECHECK) cannot deadlock. This race is not covered by a test.Tested on an RTX 4080 (debug build) with
cargo build --workspace(ok) andcargo test -p xcl --lib title_textures: 67 passed, 0 failed, 1 ignored.cargo test -p xcl --lib texture_upload: 11 passed, 1 failed. The failure isan_upload_reads_pages_kept_apart, which also fails at412e11e9without these changes on this machine. It is not related to this PR. The whole suite was not run.Pushed as
7783f9b6. The whole suite passes there (see the description), and the smoke blocks are updated. @bmjask could you re-check?AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:10:00Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2676High: The first whole-hash check of a
Whole::Unknownentry still takes the current memory as its baseline, and its only guard against writes made after the upload read the texture isdiffers_from_sent, which returns false whenever the upload recorded no page hashes. So such a write is folded into the baseline and never uploaded. That happens whenunmappedlazy levels make the upload calltexture_upload::unknown()(hashes cleared), whenforgottenchanged duringfill, or when the write lands on a partial edge page (hash 0). If the title then writes a glyph outside the three 16 KiB slices before the next frame's check, the slices match,st.whole = Hash(current)becomes the baseline, and the PC texture keeps the old atlas: the failure this PR sets out to fix. Treating 'no page hashes' as 'differs' (forcing one more whole upload) would close it.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:10:00Z.
Review: COMMENTED
Review of
7783f9b6: 3 finding(s) (2 high, 1 medium), most severe first.Re-review at
7783f9b6. From the412e11e9review, the stuck PENDING on GPU-owned textures and the reseed race on reused addresses weren't flagged again. The baseline-after-upload gap is narrowed bydiffers_from_sentbut still open in the case below, and milestone checks can still be starved under sustained streaming. Two new items.crates/xcl/src/hle/d3d12x/title_textures.rs:2676: The first whole-hash check of aWhole::Unknownentry still takes the current memory as its baseline, and its only guard against writes made after the upload read the texture isdiffers_from_sent, which returns false whenever the uplo.... (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:2525: On a whole upload,seed_stream_recheckkeeps an existingWhole::Hash(h)even when the check that took h didn't trigger this upload, so the baseline can be arbitrarily old: from a check 16+ frames ago, areseed_downloaded, or the me.... (inline)crates/xcl/src/hle/d3d12x/title_textures.rs:2556: see below.On lines outside the diff:
crates/xcl/src/hle/d3d12x/title_textures.rs:2556:LAST_RECHECK_FRAME.swaponly stops two calls for the same frame. Since the recheck can now do up to 64 GPU readbacks one after another (each waiting up to 5 s on a fence), passes for frames F and F+1 from two submitting threads can overlap, and both write the same STREAM_RECHECK entries from staleseensnapshots. If thread A is still reading for frame F when B starts F+1, both snapshot entry X and both runst.stage += 1, so X skips a milestone. Or one pass writeswhole: Hash(cur_old)over an entry thatseed_stream_recheck/reseed_downloadedrefreshed in between, replacing the fresh baseline with one read before the upload. Holding a recheck-in-progress flag (or re-validating each entry's generation before writing) would prevent the overlap.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 bmjask on 2026-12-02T22:10:01Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2525High: On a whole upload,
seed_stream_recheckkeeps an existingWhole::Hash(h)even when the check that took h didn't trigger this upload, so the baseline can be arbitrarily old: from a check 16+ frames ago, areseed_downloaded, or the memory at the previouse.src. In an A-B-A sequence, where the title writes C0 -> C1 (uploaded) -> C0 (e.g. an atlas cleared back to its initial state), the steady check sees hash == h(C0) and reports no change, so the PC texture keeps C1 while memory holds C0. Whenrecheck_sourcemovese.srcor a texture is re-queued, the stale h also causes a redundant whole upload. Resetting the baseline to the uploaded content (or to Unknown) on every whole upload would fix both.Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T22:21:52Z.
merge-check
base:
5ad98adbc3head:
7783f9b608verdict: not yet: the focused checks passed, all smoke runs completed, and the library abort affected both trees. This host exposed no GPU_UPLOAD heaps, leaving the changed mixed-UMA path unverified.
Windows / AMD RDNA4 — unwatched texture recheck redo with #3707 and #3455
Both builds include #3707 at
912ff558e932264511f386eb8b7e97cbf7cf46e2and #3455 at1895d9e8ea3c64f7e91f4a0211f2a7aacff5c525. The combined baseline iscfdacf961cf9cced7aba34f4f11e6219ce55df2d, measured in the prior #3613 retest. The PR merged cleanly onto it atdef66c5d589a6df50b1298156e9dee73bf6242c1, with a cleangit diff --checkand its own Cargo target directory.Setup
AMD Radeon RX 9060 XT (32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332, Rust 1.100.0 debug, Agility SDK 1.620.2 with matching debug layer, DXC 1.9.2609.5.
Tested
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputrecorded the following partial counts.SKIPPEDnoticesmain+ #3707 + #3455Both workspace commands exited 101. The library exited
0x80004005on both builds. Both logged the same failures infuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3,gpu_smem_flat_descriptor_windows_and_limits,f32_programs_on_the_gpu,gpu_f32_compares_with_nan,gpu_float_compares_random,gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, and two failures oftwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. The two skip notices were for disabled heap windows. Both debug-layer E2E checks and the texture-state check passed.Three focused checks passed, with 0 failed, 0 ignored, and 0 skip notices using
--test-threads=1 --show-output --nocapture. They cover comparison against the last upload, the check budget, and rechecks beyond the initial milestones.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedand a fresh data root for title hash2c508222. The baseline row is from the prior run under the same setup.main+ #3707 + #34550x00x01, AMD default UMA0x0mixed:0:1280x01,mixed:0:1280x0The baseline and the first pair used
XCL_UMA_DRIVER=mixedwithout ranges, which selected AMD default UMA. The second pair explicitly requestedXCL_UMA_DRIVER=mixed:0:128. Both logs for that pair reported that the adapter exposed noGPU_UPLOADheaps and used a CUSTOM heap instead. The switch-on runs logged zeroXCL_UNWATCHED_RECHECKevents, so the frame and commit differences do not establish an effect from the recheck path.Not tested
Remaining workspace tests after the abort, mixed
GPU_UPLOADre-upload and its startup and frame costs, and repeated performance pairs.AI use
Codex (GPT-6) merged and built the PR, ran the tests and smoke test, compared the results with the combined baseline, and drafted this report.
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T01:43:54Z.
Thanks for the third round. All three points hold; they are fixed in the PR's commit (amended, now
4714ed9bb; not pushed yet when this was written).1. High: first whole check of a
Whole::Unknownentry takes current memory as its baseline. Fixed.texture_upload::differs_from_sentnow answers "may differ": a page the upload kept no hash of (read only in part, or nothing kept becauseunknown()/forget()ran orforgottenmoved duringfill) counts as changed (crates/xcl/src/hle/d3d12x/texture_upload.rs:138-149). Such a first check queues one more whole upload, and the hash it took becomes that upload's baseline (point 2), so this does not loop: the next check compares whole hashes and no longer relies on page hashes. The cost is one extra whole upload (at most 4 MiB) after an upload whose page hashes are incomplete. Tests:bytes_are_compared_with_what_the_last_upload_readnow expects "may differ" for no hashes and for a zero-hash page.steady_recheck_keeps_small_unwatched_textures_past_the_milestones(title_textures.rs:7091) checks that afterforgetthe first check queues the texture, that the upload that follows makes the hash its baseline, and that the next check finds nothing.2. High:
seed_stream_recheckkeeps an oldWhole::Hashon an upload no check queued. Fixed. A newWhole::Queued(h)(title_textures.rs:2331-2334) is what a check that finds a change leaves (:2687-2691). Only that hash carries over into the upload's seed (:2532-2535). Any other whole upload starts fromUnknown, which also covers a movede.src. A check that finds no change turnsQueuedintoHash(:2699). The test reproduces your A-B-A case (:7108): the title writes, an upload it did not queue reads that, then the title writes the old bytes back. The entry isUnknownafter the seed, and the first check queues the texture.3. Medium: overlapping passes write from stale snapshots. Fixed with the re-validation you suggested. When a pass records its results, it skips an entry that no longer equals the snapshot it read (
title_textures.rs:2658-2662). That covers a seed or reseed in between and a pass of another thread's frame. The test (:7120) uses a test-only hook that runs between a pass's reads and its write-back (AFTER_RECHECK_READS,:2340-2344,:2651). It replaces the entry the way a concurrent seed would, and checks that the pass leaves it as it is and queues nothing.Tests (Windows, debug, RTX 4080):
cargo test -p xcl --lib d3d12x::title_texturesgave 67 passed, 0 failed, 1 ignored.cargo test -p xcl --lib d3d12x::texture_uploadgave 10 passed, 0 failed, 0 ignored. There were no SKIPPED notices. The whole suite was not rerun for this amend.On @stijn-boer's "not yet" (merge check on
7783f9b6), the part that concerns this PR:0x80004005and the 9 failures are the same tests with the same counts on both builds (1585 / 9 / 47 each). They come from the base, not this PR.XCL_UNWATCHED_RECHECKline was logged is expected on that host. The switch acts only on textures in aGPU_UPLOADsegment ofXCL_UMA_DRIVER=mixed, the range without write watch. Without ranges,mixedpicked AMD's default UMA. Withmixed:0:128the adapter had noGPU_UPLOADheaps (the log says so; Resizable BAR is probably off), so the window is one CUSTOM heap and nothing is in the unwatched range. On that host the runs count as a regression check with the switch on and off, not as coverage of the recheck. A run that covers it needs an adapter that exposesGPU_UPLOADheaps.Each round has found new points so far. Would the remaining ones block the merge, or can they be follow-ups once this round is in?
Pushed as
4714ed9b. The whole suite passes there (3007 passed, 0 failed), and the smoke block in the description is updated.AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T04:35:52Z.
merge-check
base:
078358a058head:
4714ed9bb4merge: clean
build: ok
tests: 3009 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1679 frames (100 % of main), peak commit 17577 → 18035 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 234 s there, 0 device removals, 0 crashes, 2.9 presents/s; run with
XCL_SKIP_CS=95cc13288a27a96e(the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)verdict: not yet:
PR descriptionis red; otherwise no blocking finding, the suite passes and the smoke run is cleanhardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
In short: The PR adds XCL_UNWATCHED_RECHECK=1 (off by default): small textures in unwatched memory are hashed whole every 16 frames after the usual milestones, and the push to
4714ed9breworks how a check picks its baseline. Reading the code at this head shows the three medium findings from the7783f9b6review are fixed, and the new paths have unit tests (no page hashes, the queued baseline, a pass racing a seed); the default path is unchanged. Nothing blocks merging; the main open point is that the switch-on cost was measured before this push, and the push adds a second whole upload for many kept textures.Medium
412e11e9, the A/B from e125eda8, and the test counts and smoke blocks from7783f9b6. This head adds a path that costs more: differs_from_sent (texture_upload.rs ~137) now counts a page with no hash as changed. An upload keeps no hash for a page it read only in part (Hashes::note ~608), which covers linear textures read in row chunks that end inside a page, small mips whose block rows are under 4 KiB, and pages in padding between levels. So the first check after most outside whole uploads of such a texture queues it once more. That is one extra whole upload per upload, not a loop, because the queued upload takes the check's hash as its baseline. Re-run the switch-on world run at4714ed9bwith the XCL_UNWATCHED_RECHECK "goes up again" count logged, and update the cost and count lines in the description.Nit
Checked and fine
How this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.Written by Claude Code (Claude Opus 5.5) and 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.