D3D12.X: title_textures content hash skips remapped textures, double-reads changed textures, and caches failed uploads (#486) #504
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#504
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@mastrr9 on GitHub · 2026-11-24 01:04 UTC · original
Code audit of
crates/xcl/src/hle/d3d12x/title_textures.rsonmain(69f0635, merged via #486) found three follow-up issues in the unchanged-texture skip path:Unmapped/remapped shadowed textures stay skipped when their CPU bytes are unchanged (
title_textures.rs:392-394, 490-492, 508-512, 831-840):Ais shadowed by an overlapping placementB,register()/retire_range()callsvram::unmap_superseded(A), releasingA's unshared VRAM tiles back to the pool, whileLAST_CONTENTstill holdsA -> hash.Bis later released,forget(B)removesB(notA) fromLAST_CONTENT, reactivatesAwithA.pending = true, and callsvram::remap_if_unmapped(A).refresh(), ifA's CPU memory still matches its pre-unmap hash,same_as_last_upload(A, h)returnstrueand skips re-uploadingAinto its freshly remapped VRAM tiles (the existing test at line 1643 didn't catch this because it overwritesold_reswith a new seed0xD4beforerefresh()).to_unmap/to_remapfromLAST_CONTENT.Every changed texture is read and allocated twice (plus TOCTOU between hash and upload) (
title_textures.rs:832, 843, 1050-1066):upload_allcallsread_committed(va, tex.size() as usize)to computecontent_hash, drops thatVec<u8>, and thensubresources(va, &tex)callsread_committeda second time for the exact same memory.LAST_CONTENTstores the hash of snapshot #1 while the GPU receives snapshot #2.mem, hash&mem, and pass&meminto asubresources_from(&mem, &tex)helper (slicing&mem[s * c.slice_bytes..(s + 1) * c.slice_bytes]for 2D/array slices).Failed uploads poison
LAST_CONTENT(title_textures.rs:833, 851-869):same_as_last_uploadinsertshintoLAST_CONTENTbeforeupload_queue()ortexture::upload_batch()runs. Ifupload_queuefails,upload_batchreturnsErr, or an item indexkappears inOk(failed),LAST_CONTENTalready recordedhand suppresses future retries until the memory changes.LAST_CONTENT.get(&res) == Some(&h)before batching, and insert(res, h)only for batch entries that succeeded inupload_batch.Not tested: on Windows yet (static code audit of
69f0635; preparing a clean fix + RTX 5080 test run next).AI use: Audited with Antigravity (Gemini 4 Neon).
github-bot referenced this issue2026-11-26 04:23:53 +00:00
@Grimkaaah on GitHub · 2026-11-24 01:06 UTC · original
PR opened addressing all three follow-ups from the audit (LAST_CONTENT on unmap/remap, single read+hash, remember only after successful upload).
Made with Cursor
@mastrr9 on GitHub · 2026-11-24 01:09 UTC · original
Confirmed bug #1 live on Windows 11 / RTX 5080 (
main7ebf1b8,rustc 1.100.0MSVC):old_res(0xAA), shadows/unmaps it with an overlapping placement, releases the overlapping placement without modifyingold_res's CPU bytes, and runsrefresh()logstitle textures: 1 uploads left out so far – the texture's memory held what it held at its last uploadand reads back[0, 0, 0, ...]instead of0xAA.LAST_CONTENTon unmap/remap, singleread_committed+subresources_from, commit hash only afterupload_batchsucceeds) passingcargo test --workspace -- --test-threads=4: 680 passed, 0 failed, 41 ignored (2 expectedno wave64skips). Waiting to run a cleanscripts/smoke.ps1regression check before opening the PR.AI use: reproduced and verified with Antigravity (Gemini 4 Neon) on NVIDIA GeForce RTX 5080.