D3D12.X: fix title texture skip hash on remap, one read, no poison (#504) #503
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/508"
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 Grimkaaah on 2026-11-24T01:06:53Z.
Summary
LAST_CONTENTfor every texture into_unmap/to_remapso a remapped texture is re-uploaded even when its CPU bytes are unchanged (#504.1).subresources_fromshare the same snapshot (no double-read / TOCTOU) (#504.2).upload_batchsucceeds for that item — a failed upload no longer poisons the skip cache (#504.3).Fixes #504
Test plan
cargo test -p xcl --lib hle::d3d12x::title_textures::tests::last_contentcargo test -p xcl --lib hle::d3d12x::title_textures::tests::a_texture_with_unchanged_memoryImported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T01:10:03Z.
The upload path now reads title memory once. There’s one more full copy of the detiled bytes on each cache miss:
subs.clone()duplicates every subresource’s ownedVec<u8>while the original batch is still live. Couldupload_allpush(r, subs, states)directly into the upload list and append(res_key, h)to a parallel list at the same point? That keeps the failure indices aligned and moves the bytes into the batch once. Batch construction at 61ee2a2 · Subresource definitionTested
On the same commit,
cargo test --offline --locked -p xcl --lib hle::d3d12x::title_textures::tests -- --test-threads=1 --nocapturepassed 9 tests, with 0 failures, 0 ignored and no reported skips. XCL selected the RTX 3080 Ti (621.35). Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, debug.Not tested
Full workspace, retail titles, and the performance impact of removing the copy.
AI use
Codex with GPT-6.2 Astra reviewed the upload path, ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by Abdellah-Khanani on 2026-11-24T01:24:47Z.
Tested on AMD RDNA1: no new failures.
cargo test --workspace --no-fail-fast -- --test-threads=4on this PR's head61ee2a2(on top of currentmain7ebf1b8): 677 passed, 1 failed, 41 ignored. Onmain7ebf1b8alone: 676 passed, 1 failed, 41 ignored.gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction. It fails onmainon this adapter too and is unrelated (#472).last_content_is_not_poisoned_by_a_hash_check_alone,a_texture_with_unchanged_memory_is_left_out_until_it_is_forgottenand the other 7title_texturestests pass. On this adapterplaced_title_textures_share_vram_and_preserve_pixelsis SKIPPED onmain(the driver refuses the reserved cube; see #470), so it does not cover this change here.gpu_geometry_mode_es_gs_strip,gpu_mesh_mode_two_passes(no mesh shaders).upload_batchpushes(k, e)), so thefailed_idxmapping tokeysis right.Tested with Claude Code (Claude Opus 5.5); the run was on my machine.
Imported from ivall/xcl. Originally posted by gta5all on 2026-11-24T01:27:04Z.
Review of
8d09824's diff againstmain(69f0635). The three fixes match #504, and reading the memory once and slicing it gives the same bytes as the old per-sliceread_committedcalls (size()coversarray × slice_bytes, and bytes past the end read as 0 indetile_level/detile_volume). Two things I'd change before it is merged:1. Every batch's detiled data is copied once more.
upload_itemsclones each item'sVec<Subresource>(up toBATCH_BYTES, 256 MiB, per batch) only to drop the two extra tuple fields. That gives back much of what reading once saves. Keepingbatchas the tupleupload_batchtakes, with the keys in a separate vec, avoids the copy:(with
let mut keys = Vec::new();next tolet mut batch = Vec::new();). Smaller point: withXCL_TEXTURE_SKIP_UNCHANGED=0the hash is still computed for every upload.let h = if unchanged_skip() { content_hash(&mem) } else { 0 };only remembers a dummy hash that is never compared.2. No test fails without the fix for #504.1.
last_content_is_not_poisoned_by_a_hash_check_alonechecks the helpers only. The placement test misses the remap case because it writes a new pattern (0xD4) before the refresh that followsdrop(new_res). Restoring the old texture's memory to what it held at its last upload shows the bug: B's0x55write lies insideold_res, so rewriting0xAAgives the bytes ofold_res's last upload while its remapped tiles hold B's data. Without theLAST_CONTENTremoval inforget, this upload is skipped and the assert fails:Also: the multi-line reformatting of the two
Subresource { .. }expressions insubresources_fromis churn CONTRIBUTING asks to leave out. And thePR descriptioncheck fails because the description has no Tested (full GPU suite counts), Regression run (the twoxcl-smokeblocks), Not tested or AI use sections.Static review only: I did not build or run this (no Windows machine here). The diffs above are suggestions to check, not tested code.
Written with Claude Code (Claude Opus 5.5), under human review.
Imported from ivall/xcl. Originally posted by Alpha325 on 2026-11-24T01:36:38Z.
I ran the unchanged-source remap regression suggested in review. I applied the same local test-only edits to base
7ebf1b8and PR head61ee2a2.The fixture uploads a 512×512 RGBA8 texture, then places and uploads a smaller texture over part of its address range. While the old texture is still shadowed, the fixture restores the exact CPU bytes from its first upload. It then releases the overlapping texture, calls
refresh, and compares the old texture’s GPU readback byte for byte.The cache-disabled control isolates the cause: identical CPU bytes do not mean the remapped GPU tiles still contain the old texture. The PR forces the upload and restores the full readback. I’d add this case to
placed_title_textures_share_vram_and_preserve_pixels, since the existing fixture writes a different pattern after remapping.Tested: Radeon RX 9060 XT, driver
32.0.32029.2010, Windows 11, Rust 1.100.0 MSVC x64, release. The PR’s texture test module passed 9/9 with the fixture and no skips. This check covers remap invalidation, not upload-failure handling or snapshot performance.AI use: OpenAI Codex (GPT-6.2 Sol) wrote the local fixture, ran the tests, and drafted this report.
Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T01:57:22Z.
Test report on NVIDIA (the review thread so far has RDNA1 and code audits): PR head
61ee2a2merged ontomain508a0c7(clean merge), release build, RTX 3060 Ti 8 GB (wave32), Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11.Tested
cargo test -p xcl --lib -- --test-threads=1 title_textures xaudio2 acphalon the merge with #468 and #456 also applied (all three touch adjacent paths): 27 passed, 0 failed - including the three newLAST_CONTENTtests (last_content_is_not_poisoned_by_a_hash_check_alone, the unchanged-remap regression, the one-read snapshot).title_texturesGPU tests (gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes,placed_title_textures_share_vram_and_preserve_pixels,transitions_apply_when_their_list_is_submitted) pass serially on this adapter. Under--test-threads=4the same set fails on a poisoned lock on unmodified main too (documented in #516's report) - worth running GPU tests serially when reporting counts.XCL_NETWORK=0 XCL_ACTIVITY=1): the game exited cleanly on its own at t≈34 s during shader warm-up (exit 0x0, no crash, no device removal) - the early-exit behaviour varies run to run on this title; nothing in the log points at the skip path. Not counted as a regression signal either way.Not tested
AI use: GPT-6.2 Astra (API model selector) in DSH ran the builds/tests and wrote this comment; the human contributor reviewed it.
Imported from ivall/xcl. Originally posted by jacksonslab on 2026-11-24T03:23:55Z.
Tested on a retail title (Windows 11, RTX 4070 SUPER 12 GB, i7-14700K). We hit #504.3 independently: with #486's skip-unchanged on, a failed
upload_queue/upload_batchleft the content hash recorded, so the texture was never uploaded again. We had a local fix that only forgot the hash on failure; this PR's version is strictly better (also covers remaps with unchanged bytes and the double read). We've replaced our fix with this PR in our test build;title_texturestests pass.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T02:56:27Z.
Regression run of
61ee2a28on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 92 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T13:53:47Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T03:46:00Z.
I verified the single-snapshot change on a native RTX 5070 by running the same GPU readback assertion against
61ee2a280184ba22995ef306609dc18aa975e981and its immediate parent7ebf1b8044bef8f0ef296eb36e85010cceb4633a.The fixture uses a 64 × 64 R8 texture backed by ordinary memory. On the first call to
upload_all, a one-shot test hook changes the source from A (0x17) to B (0x81) after the hash comparison and before detiling. I then restore A and callupload_allagain. A third call changes the source to C (0x56) as a fresh-upload control. All three calls exercise the production upload path. Each readback follows a fence on the upload queue.7ebf1b8061ee2a28The parent failed the expected-A assertion. The PR passed it. Neither test skipped. On the PR, the hash and uploaded pixels describe the same snapshot, so skipping the second upload preserves the correct texture. This checks #504’s double-read case with a controlled source change. Remapping, failed uploads and retail frame time were outside this test.
AI use: OpenAI Codex with GPT-6.2 Astra adapted the fixture and ran the paired native checks; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:27:34Z.
Follow-up to my snapshot readback on head
61ee2a280184ba22995ef306609dc18aa975e981: a previous successful hash can remain after a later submitted upload returns an outer error. If those submitted bytes reached the texture, restoring the previous source can then incorrectly hit the unchanged-content skip.In a synthetic 64×64 R8 fixture, A uploaded successfully; B was submitted and a real fence completed; a test-only hook then returned an error at the outer wait boundary. After restoring A, the unmodified head recorded one skip and all 4,096 read-back texels remained B. A local candidate cleared hashes for the attempted resources on the outer batch error: the next A refresh recorded zero skips and all 4,096 texels returned to A. Initial A, B, and a fresh C control each matched in both runs.
The injected error occurred after a successful wait on a healthy device to make the landed-copy case deterministic. This is not a reproduced native driver timeout, device loss, or GTA VI symptom. On a real timeout, staging lifetime and device recovery are separate concerns; hash invalidation alone does not establish either. Retail frequency and performance remain unmeasured.
AI use: OpenAI Codex with GPT-6.2 Astra constructed, ran and independently reviewed the synthetic test and candidate; Codex coordinated and prepared this follow-up.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:28:34Z.
Related prior work: #2109 discusses clearing
LAST_CONTENTafter failed batches and preserving retry state, alongside mitigation for repeated waits. That overlaps the hash-invalidation candidate in my previous comment. Its newer uploader also retains timed-out staging resources, so my staging-lifetime caveat applies to the historical #508 head tested here, not automatically to that newer path.The deterministic A→B→A fixture establishes the cache consequence after an injected completion-report error; it does not identify the queue dependency behind a real title timeout. AI use: OpenAI Codex with GPT-6.2 Astra checked the related discussion; Codex coordinated and prepared this correction.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:37:22Z.
Triage (#1607) – head
61ee2a2The code this PR changes is no longer on main. Main commit
e44c9ffclearsLAST_CONTENTon placed-texture unmap and remap (item 1 of #504). Commit73fc616then replaced the whole-texture skip with a page-by-page comparison of written pages. That commit also uploads a texture whole again when its upload failed or when it becomes active again.LAST_CONTENT,same_as_last_uploadand the double read inupload_allare gone fromtitle_textures.rs. Failed batches are retried throughretry_failed. The PR conflicts with main, and a rebase would mean writing it again against the new upload path.Recommendation: close (superseded by main commits
e44c9ffand73fc616).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:38:08Z.
Closing as superseded: this change is already on
main(73fc616f).e44c9ffclears LAST_CONTENT on unmap/remap (#2460);73fc616freplaced LAST_CONTENT with per-page Known/changed in texture_upload.rs (LAST_CONTENT no longer exists on main); a failed upload is retried via stale()/retry_failed, so the PR's remember-only-after-success goal is metTwo 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