D3D12.X: add gpu::texture::download and title_textures read-back helpers #3675
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3675"
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 iggyvilla on 2026-12-02T06:33:51Z.
Preparation for fault-driven texture copy-back (#2663, split out of #3601 per review so each PR stays under ~400 lines): adds
gpu::texture::downloadandtitle_texturesread-back/re-tile helpers with unit and GPU round-trip tests. Not yet called at runtime (zero behavior change).TL;DR — Before vs After
origin/amd-dev41aa60ce)effdc0a8)+384 / -1across 2 files (245 runtime + 139 test lines)1,654/15,902 MB(0crashes)1,639/16,271 MB(0crashes)What is in it
crates/xcl/src/gpu/texture.rs: addsdownload()to copy every subresource of a single-plane, single-sample 1D/2D/3D texture to linear rows via a readback buffer (refuses multi-plane and MSAA textures cleanly; retains submitted objects if fence wait fails).crates/xcl/src/hle/d3d12x/title_textures.rs: addswrite_subresources,write_writable(writes only changed, committed, writable 4 KiB pages),read_back,download_and_write_after,read_back_after,copy_back_range, and exposessubresource_count, plus 3 unit/GPU tests (written_subresources_skip_a_page_the_title_unmapped,written_subresources_round_trip,read_back_writes_what_the_gpu_holds_into_the_title_memory).Tested
32.0.21045.29003), AMD Ryzen 7 5700X, Windows 11 x64,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke.cargo test -p xcl --lib -- written_subresources read_back_writes_what_the_gpu_holds --test-threads=1: 3 passed, 0 failed, 0 ignored, 0 skipped.cargo test --workspace --no-fail-fast -- --test-threads=4: 2,958 passed, 16 failed, 49 ignored. All 16 failures reproduce identically on cleanorigin/amd-dev41aa60ce(2,954 passed, 17 failed, 49 ignored).SKIPPED(7): 4×f16_programs_on_the_gpu, 2× heap-window tests, 1×pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off).Regression run
Base (
main, required bypr_check.py):Base (
origin/amd-devmerge base):PR head (
effdc0a8):Not tested
AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T06:38:36Z.
Review (head
effdc0a8, diff read, not a merge-check):amd-dev. The base already reads textures back (TextureDownloadPlan/PendingDownload,title_textures.rs~4590), reverse-tiles them (reverse_layout_subresource, ~4390) and writes changed pages (changed_page_runs/write_changed_pages, ~4940 / ~4966). The page-run loop inwrite_subresources(~4237) andwrite_writable(~4259) do the same jobs but behave differently on a page they cannot write, so there would be two reverse paths to keep in step. Reusing the existing helpers, or saying in the description why they cannot be, would help (this part of my split suggestion on #3601 did not account for them).write_writable(~4276) skips changed pages that are read-only, guard or uncommitted, andwrite_subresourcesstill returnsOk(bytes), so the caller cannot tell "nothing changed" from "every changed page was protected" and the title memory can hold part GPU texels and part stale bytes. The base'swrite_changed_pagesrefuses instead, so its publish is retried; the new GPU test asserts the skip-and-succeed behaviour.download_and_write_after(~4309),read_back_after(~4334, with a 200 mstry_lockspin) andcopy_back_range(~4354) are #3601's fault-handler entry points, with no caller and no test here.download_and_write_afteralso queuesnative_queue_waitfor a title fence on the shared per-device upload queue (~4323), so every upload sent after it waits for the title's signal; that choice belongs with its caller.Fine: nothing calls the new code yet;
downloadgets footprints for all subresources in D3D12 order, copies the unpadded rows with depth slicesNumRows × RowPitchapart, moves the texture toCOPY_SOURCEand back from one state or one per subresource, keeps its objects alive when the fence wait fails, and refuses planar and MSAA textures; the description says it is split out of #3601.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T12:47:21Z.
merge-check
base:
41aa60ce84head:
effdc0a876merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2964 passed, 9 failed, 49 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 amd-dev); failing: gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_fract_f32_edges, hle::d3d12x::sparse::tests::private_physical_pages_reach_the_gpu_on_mapping, hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, hle::d3d12x::title_textures::tests::remapped_pages_are_compared_with_what_they_held, hle::d3d12x::title_textures::tests::stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, hle::d3d12x::title_textures::tests::stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, hle::d3d12x::title_textures::tests::stream_recheck_schedule_catches_late_writes_and_resets_milestones (the same tests fail on amd-dev
41aa60cealone on this card, so none is from this PR)review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3675#issuecomment-7337243400 and its findings stand. Most serious: it duplicates read-back helpers already on
amd-dev, andwrite_writable(~4259) skips protected pages whilewrite_subresourcesstill returnsOk, so a partial write looks like success.performance: 60 s smoke of a retail title, amd-dev
41aa60cevs this merge (effdc0a8): 1671 -> 1674 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 16722 -> 16481 MB, 0 device removals, 0 crashes.verdict: not yet: it duplicates read-back helpers already on
amd-dev, andwrite_writable(~4259) skips protected pages whilewrite_subresourcesstill returnsOk, so a partial write looks like success (see the review)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.
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.