D3D12.X: hash only written pages of title textures (#2395) #2484
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2484
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@ChalanaGimhanaX on GitHub · 2026-11-25 20:01 UTC · original
ChalanaGimhanaX:d3d12x/title-texture-page-hashes→main· +446 −50 · 1 files · 1 commits · openTrack 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
@emirduran707 on GitHub · 2026-11-25 20:24 UTC · original
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
@ChalanaGimhanaX on GitHub · 2026-11-25 20:31 UTC · original
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.
@DavidM1911 on GitHub · 2026-11-25 20:34 UTC · original
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!
@DavidM1911 on GitHub · 2026-11-26 01:49 UTC · original
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
@Kalmarv on GitHub · 2026-11-26 05:32 UTC · original · edited 2026-11-26 05:34 UTC
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.
@bmjask on GitHub · 2026-11-25 20:16 UTC · original · reviewed
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.
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.