D3D12.X: hash only written pages of title textures (#2395) #2474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2484"
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 ChalanaGimhanaX on 2026-11-25T20:01:27Z.
Track per-page content hashes for write-watched title textures instead of hashing the entire texture on every dirty hit. When
refresh_oncecollects overlapping dirty pages for a previously uploaded texture with matching(src, size, page_size),upload_allreads and hashes only those deduplicated dirty pages (outsideLAST_CONTENT), returns the changed page indices (ready for #2396), and still forces a full baseline upload on first upload, pending uploads, or #504 GPU-view remaps.Fixes #2395. Part of #2390, #582, and #1833.
What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: replacedLAST_CONTENT's whole-texture hash with per-pagePageHashes, passed dirty pages fromrefresh_oncethroughUpload, invalidatedLAST_CONTENToutsideTEXTURESonrecheck_gpu_view_sourcesremaps, implementedchanged_pages_with/changed_pages_since_last_upload(documenting theExecuteCommandLists/GetWriteWatch(WRITE_WATCH_FLAG_RESET)synchronization contract), and added 6 unit tests (including aGetWriteWatch(RESET)post-reset interleaving test) alongside updating the existing unchanged-upload test.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release build.cargo test --release -p xcl --lib hle::d3d12x::title_textures::tests -- --test-threads=1(1c9e839): 25 passed, 0 failed.cargo build --release --workspace+cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture(1c9e839): 1423 passed, 0 failed, 46 ignored.SKIPPEDGPU/adapter tests (26): 21 no wave64, 3 refused f16 forms (#1426), 1no heap windows, 1pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode required for driver cache disable).cargo test --release -p xcl --test e2e -- --test-threads=1(1c9e839): 4 passed, 0 failed.Regression run
main (
6d051da):this PR (
1c9e839):Not tested
AI use
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:16:30Z.
Review: COMMENTED
Nonblocking validation gap: GetWriteWatch(RESET) captures/reset dirty pages at title_textures.rs:751-767, and the new fast path hashes only those captured pages at :905-946. A CPU write to another texture page after reset but before upload_all can miss this submission and be caught only on the next refresh, adding a frame/submission of staleness. Please either document the synchronization guarantee that excludes this or add an interleaving regression test.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T20:24:13Z.
Independent AMD RDNA4 (native wave64) test report on exact head
b6b5b9c85ffe47aec7b701de1f938f664c3229d7(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1420 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests and all 5 newtitle_texturesdirty-page hashing tests ran and passed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by ChalanaGimhanaX on 2026-11-25T20:31:41Z.
Thanks for the review, @bmjask — addressed in
1c9e839:changed_pages_with):refresh_onceruns insideExecuteCommandLists, so any CPU write ordered before that GPU submission is already captured beforeGetWriteWatch(WRITE_WATCH_FLAG_RESET)runs. A concurrent write to another page afterWRITE_WATCH_FLAG_RESETis not ordered before the current submission (and onmainalready waited for the next refresh whenever no other page of that texture was dirty); because it happens after the reset, the OS write watch keeps that page dirty and the fast path leaves its stored hash untouched, so the nextrefresh_onceis guaranteed to detect and upload it.post_reset_write_to_unchecked_page_is_caught_on_next_refreshusing a realMEM_WRITE_WATCHallocation andtake_written(GetWriteWatch(WRITE_WATCH_FLAG_RESET)), verifying that a write to page 4 landing after reset while pass 1 checks unchanged page 1 stays dirty and is detected on pass 2 (Some(vec![4])).Re-ran the full release suite (
1423 passed, 0 failed, 46 ignored,title_textures::tests25/25,e2e4/4) and a fresh 60s smoke run on1c9e839(1409frames,0crashes/removals).AI use: Antigravity (Gemini 4 Neon) added the doc comment and interleaving test, ran the tests and smoke check, and drafted this reply.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T20:34:29Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:49:59Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-26T05:32:41Z.
Found while building on this PR, one case where the skip leaves out an upload it needs (no benchmarks): a placed texture superseded by a placement over a different range is unmapped (
title_textures.rs:407,:544on1c9e8396), and when that placement is released it is uncovered, remapped and made pending again (:271,:564). The remap gives it other tiles for the pages it had given back, but itsLAST_CONTENTentry survives (it is dropped only inregister,:342, andforget,:553), so its next upload compares the full hash with the old one (:957-:979), finds the memory unchanged and is left out (:1253): the texture then reads whatever the new tiles hold.Steps that show it on this PR's head with an RTX 5070 Ti (test
an_uncovered_texture_on_other_tiles_is_uploaded_again, a harness modelled onplaced_title_textures_share_vram_and_preserve_pixels): place a 256 KiB texture A atva, write it, refresh (uploaded); place a 256 KiB texture atva - 192 KiB(A is unmapped, its last three pages go back); wait 2.1 s and place a texture elsewhere; release the second one (A is remapped: 3 of its 4 tiles are new); refresh: A is left out as unchanged (UNCHANGED+1, no upload of it); A's subresource 0 then reads 0 in 195,840 of its 262,144 bytes, the three new tiles.Suggested fix: drop the hashes where the tiles go, one line
LAST_CONTENT.lock().unwrap().remove(&(r.as_raw() as usize));next tosuper::vram::unmap_superseded(r)in each of the two loops (:407,:544), so the first upload after the remap is a full one. With it, the same test passes on the same card (same remap,uploaded 2, left out as unchanged 0, A reads its bytes); the rest of the suite was not run on it.AI use: Claude Code (Claude Opus 5.5) found this, wrote and ran the test, and drafted this comment.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T15:18:14Z.
Independent RTX 3080 Ti follow-up on PR head
1c9e839, building on Kalmarv's remap report. I reproduced the different-range case in the existing placed-texture GPU test: after restoring the original CPU bytes and uncovering the old texture, its readback differed in 1,045,504 of 1,048,576 bytes. Adding the two suggested hash invalidations atunmap_supersededmade that assertion pass.There is a related exact-range path those two lines do not cover. Exact-range siblings share tiles and are shadowed without
unmap_superseded. After the newer sibling overwrites the tiles, releasing it and restoring the older sibling's original CPU bytes left 262,144 of 262,144 bytes wrong on this GPU. The older entry was reactivated withpending=false; clearing its hash only in the unmap loops could not schedule an upload. A local candidate that also marks each reactivated CPU-owned texture pending and clears its old hash before remapping passed both GPU readback assertions. This forces a fresh upload even if no write-watch page was captured after reactivation.Windows 11 build 26300; RTX 3080 Ti (driver 621.35); Ryzen 7 9800X3D; rustc 1.99.1 MSVC; DXC 1.8.2502.11.
cargo test --offline --locked -p xcl --lib placed_title_textures_share_vram_and_preserve_pixels -- --nocapture --test-threads=1: stock assertion 0 passed, 1 failed; different-range check with the two unmap invalidations 1 passed before adding the exact-range assertion; with both assertions and the candidate below 1 passed, 0 failed, 0 ignored, no GPU skip.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4on the final local candidate: 1,422 passed, 1 failed, 46 ignored across 37 targets, including 25 explicit GPU skip notices (21 no wave64, 3 refused per-lane forms, 1 no heap windows). The sole failure wasconsole_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled yet); I reproduced it with the same focused command on untouched PR head. No retail title run or AMD/Intel test was performed.Exact local candidate diff (not committed)
AI use: Codex (GPT-6.2 Sol) traced the lifecycle, wrote and ran the local candidate and regression assertions, and drafted this report.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T17:27:21Z.
Triage note: this no longer merges with current
main(mergeable=false,DIRTY), so it can't be built or tested as it stands.If it's still wanted, a rebase would make it testable again. It's directly relevant to something we're measuring on an RTX 5070 Ti: the title-texture write-watch scan is the present-path cost we see (about 2.1 M dirty pages and up to ~6 s of scan time across a run), so "hash only written pages" is the right shape of fix.
If it has been superseded by other work, saying so is enough and it can be closed.
AI use: an agent posted this triage note.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:09:44Z.
Triage (#1607) – head
1c9e839Main now does what this PR adds: commit
73fc616f(D3D12.X: what changed of a texture goes up, through lists and buffers that are kept) moved uploads totexture_upload.rs, wherePages.hashesholds a hash per 4 KiB page and only the dirty pages are read and compared (changed). It goes further than this PR: it uploads only the changed parts, while this PR still uploads the whole texture.LAST_CONTENT/same_as_last_upload, which this diff replaces, are no longer on main, so the PR also conflicts.Recommendation: close (superseded by main commit
73fc616f).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:53:23Z.
Closing as superseded: this change is already on
main(73fc616f).73fc616ftexture_upload.rs keeps per-page hashes (Known/changed, only the write-watched pages are compared); PR's PageHashes/changed_pages_since_last_upload is the same proposalTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed