D3D12.X: download block-compressed texture mip tails #3550
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3550"
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 BBareth on 2026-11-30T22:48:08Z.
Depends on #3549: with this PR alone the retail title crashes about 160 s in (downloads that now go through reach pages the title has not committed); with #3549 it does not. Runs: https://github.com/xcl-dev/xcl/pull/3550#issuecomment-7364038479
A GPU-written title texture is copied back into the title's memory through a download plan. For a block-compressed texture the plan was refused for the smallest mips: D3D12 returns a 4×4 footprint for the 2×2 and 1×1 mips of a BC3 texture, and the single-footprint query kept an unaligned base offset (
0x555780after mip 6 of a 2048×2048 chain on an RTX 5070 Ti) where the check expected the next 512-byte boundary. Both ended indriver footprint differs from the exact subresource, and reverse layout compared against the logical mip size as well. This change aligns each query base and uses whole-block extents for the copy and the reverse layout. Part of #505.The base alignment is not specific to block compression: it applies to every format, so an uncompressed multi-mip chain whose previous mip ends off a 512-byte boundary, which
mainalso refuses, is downloaded as well. A refused plan is not dropped onmain: it is prepared again at every submit and refused again.What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: the download layout rounds each query base up to the placement alignment and validates, copies and reverse-tiles with dimensions rounded to whole format blocks.gpu_download_publishes_every_bc3_mip(GPU): uploads a pattern to all 12 mips of a 2048×2048 BC3 texture, downloads it through the plan and compares the tiled buffer byte for byte.gpu_download_publishes_every_rgba8_mip(GPU): the same for all 8 mips of a 128×128 RGBA8 texture, whose small mips end off a 512-byte boundary too. It fails with the base alignment taken out (driver footprint differs from the exact subresource).download_layout_accepts_full_bc_blocks_for_small_mips(no GPU): the 4×4 footprints, byte counts and offsets of the two smallest mips, and an unrounded footprint is still refused.README.md: the Textures row names block-compressed mip tails.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on443ad638(on mainff0c364b): 2892 passed, 0 failed, 51 ignored.SKIPPEDon this adapter: 28: 22no wave64; 2no heap windows; 2no d3d12SDKLayers.dll; 1no D3D12 debug layer; 1 cannot disable the driver cache (no Developer Mode).prepare_downloads(not in this PR),main493dbd3dagainst493dbd3dmerged with this PR, two 120 s runs each after a warm-up: onmainno plan was accepted and at least 512 and 256 were refused (all block-compressed, formats 77 and 78, the same textures prepared again at every submit, from about 100 s); with this PR one plan was accepted (a 12-mip format 78 texture) and none refused. No plan for another format was prepared in any of the four runs. Frames shown:main3093 and 3047, with this PR 3142 and 3061; no device removal or crash.driver footprint differs from the exact subresource(on the earlier base9dfbe3ea) and pass with it; the GPU test ran on the RTX 5070 Ti, not skipped.Regression run
Each run follows one warm-up run of the same build; the A button is pressed once at 70 s.
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T06:55:20Z.
Independent Windows GPU check of #3550 head
3b4a7a4against its exactmainparent86e86fc.I ran the same synthetic 60×20 BC1, six-mip test in isolated source trees. It uploads distinct tight bytes to each mip, checks every native GPU readback row, and compares the published tiled allocation against an independently CPU-tiled expected buffer. The unmodified parent fails while planning mip 1 (
driver footprint differs from the exact subresource); the PR head passes all six mip footprints, all 888 payload bytes, and the complete 4,104-byte published allocation, including untouched padding. Mip 1 is a 32×12 driver footprint at offset 1,536.Windows 11 build 26300; RTX 3080 Ti, NVIDIA driver 621.40; Rust 1.99.1 MSVC. With
XCL_REQUIRE_GPU=1, both trees rancargo test --offline --locked -j 3 -p xcl --lib hle::d3d12x::title_textures::tests::gpu_download_publishes_every_nonsquare_bc1_mip -- --exact --nocapture --test-threads=1(separate target directories). Parent: 0 passed, 1 failed, 0 ignored, 0 GPU skips. PR head: 1 passed, 0 failed, 0 ignored, 0 GPU skips. This is focused evidence for the non-square BC1 mip path; I did not run the full workspace suite or a title smoke, so it is not a merge check.AI use: Codex (GPT-6.2 Sol) wrote and ran the synthetic GPU test and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:08:51Z.
merge-check
base:
7d86c5d2b7head:
3b4a7a42dfmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2898 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 (title_textures.rs +102/-11, README). It changes the default path more widely than the title says: every download query base is now rounded up to 512 bytes for all formats (~4231). On main, any multi-mip download whose previous mip ended off a 512-byte boundary was refused and silently skipped (~3902), uncompressed chains included (e.g. RGBA8 mips under 64 px), so this turns on downloads well beyond BC mip tails; the description should say so. Findings: (1) the PR's own smoke shows 2928 / 2921 frames against main's 3058 / 3073, about 4.5 % lower in both rounds, while other PRs on the same base stayed at 3009-3074; downloads that were refused now running (and the fence held until they're written) is a likely cause, so a count of downloads per frame before and after would settle it. This run is also lower than most on this machine today (see performance). (2) The no-GPU test builds its mock driver layout from the same rule the change adds, so only the BC3 GPU test checks real footprints. Fine: rounding to whole blocks fits
xg::element(block sides 1 and 4 only, so BC6 / BC7 are covered), the block-count check is equivalent to the old one, packed mip-tail placement is untouched (tile_level), overflow is checked, and the GPU test usesskip_test.performance: 60 s smoke of a retail title, main
7d86c5d2vs this merge (34f56934): 1663 -> 1448 frames shown (87 %; last presents per 2 s: 60 60 60), peak commit 17153 -> 17512 MB, 0 device removals, 0 crashes. This is 87 % of main's frames, lower than most runs of this title on this machine today (typically 1650-1690); together with the PR's own -4.5 % in two rounds it points at a cost, though one run can't separate it from noise.verdict: not yet: it turns on downloads far beyond BC mip tails (every multi-mip chain main used to skip), and both the PR's smoke runs and this one show fewer frames than main; how many downloads run per frame before and after would show whether that cost is real
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 BBareth on 2026-12-01T08:47:09Z.
Thanks for the check. Both points looked at, head unchanged (
3b4a7a42).Wider than the title: correct, and the description now says so. The base alignment in
prepare_texture_downloadapplies to every format, so an uncompressed multi-mip chain thatmainrefuses for the same reason is downloaded too.Cost: I counted download plans with a local counter in
prepare_downloads(not in the PR):main493dbd3dagainst493dbd3dmerged with this PR, GTA 6, two 120 s runs each after a warm-up, RTX 5070 Ti.main, run 1main, run 2maina refused plan is not dropped: the same block-compressed textures (formats 77 and 78) are prepared again at every submit and refused again, from about 100 s on. The counter logs at powers of two, so the refused numbers are lower bounds.Not covered: the world after 120 s was not counted, and there is no test of an uncompressed multi-mip download. Both are under Not tested now.
AI use: Claude Code, Claude Fable 5.2 added the local counter, ran the four runs and wrote this reply.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:39:37Z.
Follow-up, head
443ad638: the uncompressed case now has a test.gpu_download_publishes_every_rgba8_mipuploads a pattern to all 8 mips of a 128×128 RGBA8 texture, downloads it through the plan and compares the published bytes, like the BC3 test (both now share one helper). With the base alignment taken out it fails withdriver footprint differs from the exact subresource; with it, it passes on the RTX 5070 Ti. The runtime code is unchanged from3b4a7a42.Suite on
443ad638: 2892 passed, 0 failed, 51 ignored, 28 SKIPPED lines. The smoke blocks in the description are rerun on this head.AI use: Claude Code, Claude Fable 5.2 wrote the test and this comment and ran the tests.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:12:42Z.
Triage (#1607) – head
443ad63No open or merged PR makes the same change. #3514 (same author) touches texture-download command objects, not the footprint layout.
No problems found in the diff. Rounding to whole blocks keeps
side1 formats unchanged, and aligning theGetCopyableFootprintsbase matches the 512-byte offsetsvalidate_download_layoutexpects.Note: the new GPU test builds
ReadyDownload { .. }without thepagesfield that #3549 adds, so the second of the two to merge must update it. There is also a double blank line before the new tests.Recommendation: keep open.
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 brainhay5 on 2026-12-01T10:26:36Z.
merge-check claim
head:
443ad63815Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T10:33:30Z.
merge-check claim
head:
443ad63815Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:35:27Z.
merge-check
base:
493dbd3dd0head:
443ad63815merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 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: re-check after my "not yet" on
3b4a7a42; the range-diff and the updated description read. Both points are answered. (1) The description and commit message now say the 512-byte base alignment applies to every format, so any multi-mip chain main refused is downloaded. A new GPU test,gpu_download_publishes_every_rgba8_mip, covers an uncompressed chain and fails without the alignment. (2) The frame cost now has a count behind it. The author counted plans in the retail title (local counter, not in the PR): main refused at least 512 / 256 block-compressed plans, re-preparing the same textures at every submit, while this head accepted one and refused none. Frames went 3093 / 3047 -> 3142 / 3061 in two 120 s runs each, so the lower numbers on the first head look like noise rather than download cost. My own smoke below agrees. Still open, both stated in Not tested: the bytes of the accepted retail download weren't compared, and no uncompressed retail download was seen. Fine: the shared helper keeps the BC3 test as it was, and nothing else changed.performance: 60 s smoke of a retail title, main
493dbd3dvs this merge (d954dc77): 1670 -> 1680 frames shown (100 %; last presents per 2 s: 61 60 60), peak commit 17083 -> 17766 MB, 0 device removals, 0 crashes. In line with the PR's own retail runs (3093 / 3047 -> 3142 / 3061 frames over 120 s); the run is capped at 60 presents per second.verdict: safe to merge
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 brainhay5 on 2026-12-01T11:48:27Z.
merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.
AI use: an agent posted this withdrawal.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:06:47Z.
merge-check
base:
1c8b551475head:
443ad63815merge: clean trial merge into
1c8b551475e1e7bfe48f94448492a4c3544a2e0f(trial-merge commit69e305691b5d63c44e1fd4ad74d9ffb6606f65fb;git diff --checkclean).build:
cargo build --workspace-> ok;cargo build --release -p xcl-> ok.tests:
cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture(43 targets) -> 2912 passed, 0 failed, 51 ignored (+3 new tests vsmain1c8b5514; all 43 targets green includinggpu_two_pass_cache_e2e). All 3 newhle::d3d12x::title_textures::testspassed with 0 skips on RTX 4060:download_layout_accepts_full_bc_blocks_for_small_mips,gpu_download_publishes_every_bc3_mip, andgpu_download_publishes_every_rgba8_mip. 28SKIPPEDlines — all hardware/environment-expected on RTX 4060 (22no wave64, 2no d3d12SDKLayers.dll, 1no D3D12 debug layer, 2no heap windows, 1cannot disable the driver cache (Windows Developer Mode required)).review: read the full merged diff (2 files:
README.md+1/-1,crates/xcl/src/hle/d3d12x/title_textures.rs+115/-11, total +116/-12). Clean and tightly scoped:reverse_layout_subresourceandvalidate_download_layoutround mip(width, height)up to whole format blocks viachecked_next_multiple_of(side)(matchingGetCopyableFootprintsfor small BC mip tails), andprepare_texture_downloadalignsbasetoD3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT(512 bytes) before each single-subresourceGetCopyableFootprintscall (fixing both BC and RGBA8 small-mip chains). The three new unit and GPU round-trip tests verify 12-mip BC3 and 8-mip RGBA8 upload -> download -> publish byte-for-byte. No UB, overflow, or correctness issues found (minor merge-order note: if#3549merges first,ReadyDownloadingpu_download_publishes_every_mipwill need its new field).performance: Tier 3 60 s retail smoke (
title: 29640639) shows no regression vsmain1c8b5514baseline (1462frames,presents per 2 s (last 3): 48 53 59,peak commit: 16043 MB):1620frames (+10.8%),presents per 2 s (last 3): 61 60 60,peak commit: 14963 MB(-6.7%), 0 device removals, 0 crashes.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:11:23Z.
@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 throny on 2026-12-02T17:02:07Z.
Test report for #3550 at head
443ad6381(not a merge check): the retail title crashes about 100 s after the first frame with this PR.Tested
XCL_RESIDENCY_PRIORITY=1.5eaadb54ccrashed in two world runs (cold and warm), each about 100 s after the first frame: an unhandled access violation in the title, a write to address 0. Those are the title's own abort writes, not a device removal.5eaadb54c+ #3550 alone crashed the same way, 102 s after the first frame (first frame at 7.7 s).5eaadb54cwithout it (plus #3633) ran 900 s and 300 s without a crash.Not tested
AI use
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T21:42:22Z.
merge-check
base:
5ad98adbc3head:
443ad63815merge: clean (merge commit 4d1d8b0789971f4d308bac6fe582a8f34472375a;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3008 passed, 0 failed, 52 ignored; SKIPPED: 24 (22 no wave64, 2 no heap windows); failing: none
title run: crashed before the world, 3 of 3 runs: Newer Retail Game, release build of this merge, Series S settings (
XCL_DEVICE_TYPE=lockhart,XCL_COHERENT_MB=512,XCL_UMA_WINDOWS=16,XCL_SPARSE_LAZY=1), scripted A presses, 240 s planned. Each run ended at 86 to 88 s withunhandled exception 0xc0000005 in game_scarlett_master.exe+0x23cf683 (write at address 0x0), the same address every time, before the first 2 s window with 5,000+ draws and dispatches. Main5ad98adbwith the same settings, two runs: no crash (into the world at 94 s and at 80 s).review: the diff reads correctly to me (footprint rounded up to the block size, base aligned to 512, non-BC formats unchanged), but the title runs above show a crash in the title's code that main does not have, matching what was reported here about a crash ~100 s in.
performance: not compared; the PR's runs end in the crash.
verdict: not yet: the retail title crashes at ~87 s in 3 of 3 runs of this merge (write to address 0 at game_scarlett_master.exe+0x23cf683), not on main
hardware / tool and model: RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26300 / Claude Code with Claude Opus 5.5
AI use: Claude Code (Claude Opus 5.5) ran the build, tests and title runs and wrote this; a Claude Sonnet subagent read the diff and I checked its points.
~Tiago
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T01:10:27Z.
Thanks @throny and @tiagonleal. I can reproduce it, and #3549 stops it.
Reproduced (RTX 5070 Ti, 420 s world runs,
XCL_RESIDENCY_PRIORITY=1):c53e9696+ #3550 (443ad638): crashed in 3 of 3 runs, at 161 s, 163 s and 161 s, with the same write to address 0 atgame_scarlett_master.exe+0x23cf683.c53e9696: no crash in 2 of 2 runs (3319 and 3494 frames).Likely cause (inferred from the logs, not proven yet):
write_changed_pagesrefuses an uncommitted page and keeps the fence hidden until the write succeeds, which never happens. The title's wait on that fence then times out, and it aborts with the write to 0.With #3549: main
078358a0+ #3550 (443ad638) + #3549's fix (56c06989, the same runtime code as the update I'm about to push to #3549). 3 of 3 runs went 420 s without a crash: 3510, 3649 and 3956 frames, no device removal. #3549 left out 64 to 128 uncommitted pages per run.So #3550 depends on #3549. I'll mark it in the description, and it shouldn't be merged before #3549.
Not tested: AMD. The combined runs used main
078358a0, notc53e9696.AI use: Claude Code (Claude Opus 5.5) ran the builds and runs, read the logs and wrote this comment.
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T01:24:05Z.
Confirmed on a second card: #3549 + #3550 together run clean on the RTX 4080. Main
078358a05+ #3549c3a91393+ #3550443ad638, one 300 s world run (XCL_RESIDENCY_PRIORITY=1): first frame at 57 s, then 300 s in the world with no crash, no device removal and no Aftermath dump, 2.90 presents/s. #3550 alone crashed here about 100 s in (the same write to 0 you saw). So the dependency holds on NVIDIA Ada too.AI use: Claude Code (Claude Opus 5.5) ran it and wrote this.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T01:50:08Z.
Confirmed with a diagnostic build of main
c53e9696+ #3550 (not for merging) that logs every texture download written and every pagewrite_changed_pagesrefuses:MEM_RESERVEpages (state0x2000, at0x1394578000and0x124e858000): 16 refusals in 32 ms, then none. No later poll reached them.game_scarlett_master.exe+0x23cf683.r8). So nothing was written over the title's data; the title is waiting on a fence that never becomes visible.That is the case #3549 handles (leave settled reserved pages out). With #3549 in the tree, the same pages were left out from 136 s, and 3 of 3 runs went on without a crash.
AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T02:51:53Z.
merge-check
base:
395405e4chead:
443ad63815merge: clean (trial merge of #3549 then this PR into main
395405e4c)build: cargo build --workspace -> ok
tests: cargo test --workspace -- --test-threads=4 -> 3019 passed, 0 failed, 56 ignored; 25 SKIPPED (no wave64 and similar); failing: none
title run: retail title, RTX 4080, main
078358a05+ #3549fc7abe517+ this head, 300 s in the world (run 517), no crash, no device removal, no Aftermath dump, 2.93 presents/s. Without #3549 this head crashes about 100 s in (runs 472, 474, 485; BBareth reproduced it on an RTX 5070 Ti)review: diff read (title_textures.rs download layout, the 512-byte base alignment for every format, the new GPU tests). With #3549 in the tree, a download over uncommitted pages no longer holds its fence back
performance: no measurable cost (2.93 presents/s, as main on this machine)
verdict: safe to merge after #3549 (merged before it, it crashes the retail title; BBareth marks the dependency)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300 / Claude Code with Claude Opus 5.5 (trial suite, world runs, diff review)
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.