Repository navigation
D3D12.X: land a list's sparse GPU writes in chunks the CPU changed - #3162
Closed
tiagonleal wants to merge 1 commit into
Closed
tiagonleal wants to merge 1 commit into
tiagonleal wants to merge 1 commit into
Conversation
Since 04de323 a sparse copy-back skips every 64-byte chunk whose hash no longer matches the last upload, so a newer CPU store is not overwritten. After a list executes, though, the copy-back ranges are the list's recorded GPU writes (`sparse_writes`), and those bytes are newer than any CPU store made before the work ran. When the CPU had written other bytes of the same chunk, the whole GPU write was dropped. The e2e title hits this (xcl-dev#3093): its CPU thread stores the Wait32/64 cells at +0x300/+0x308, the list then writes +0x310, and +0x310 read back 0. Scratch logging showed the copy-back range was only the 4 written bytes and that the chunk's sent hash matched neither the CPU nor the GPU view, so recovering the uploaded bytes from the hash is not possible; the written range itself is what tells the bytes apart. `land_page` now takes `gpu_wrote`. For the post-execute copy-back (true) the written bytes land in a changed chunk as well, and the chunk keeps its old hash, so the next look uploads the CPU's bytes together with the GPU's. Map-time copy-back (`readback_now`, whole spans) passes false and keeps the CPU-wins rule. No new memory; the dirty-chunk branch costs one extra copy of bytes already being copied for clean chunks. Measured (RTX 5070 Ti, debug): e2e 2 passed / 3 failed before ("post-Wait32/64 write failed (0x0)"), 5 passed after; d3d12x::sparse unit tests 84 passed, 1 ignored. New test gpu_write_lands_next_to_cpu_writes_in_one_chunk fails without the change ("GPU write lost").
Contributor
Author
|
Closing as a duplicate: #3149 (KOLESNiii) fixes the same copy-back case and was merged into AI use: Claude Code wrote this comment (Claude Fable 5.2). |
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3093 (group 1). On
maine429936cthe threee2etitle tests fail on NVIDIA and AMD withpost-Wait32/64 write failed (0x0). Since 04de323 a sparse copy-back skips every 64-byte chunk whose hash no longer matches the last upload, so that a newer CPU store is not overwritten. After a list executes, though, the copy-back ranges are that list's recorded GPU writes, and those bytes are newer than any CPU store made before the list ran. When the CPU had written other bytes of the same chunk, the GPU's write was dropped. The test title does exactly this: its CPU thread stores the wait cells at+0x300and+0x308, the list writes+0x310, and+0x310read back 0.The issue suggested rebuilding the uploaded bytes from the chunk's hash and merging byte by byte. That does not work here: logging showed the copy-back range was only the 4 written bytes and the chunk's sent hash matched neither the CPU's view nor the GPU's. The written range itself is what tells the two apart.
What is in it
sparse.rs:land_pageandreadback_rangestakegpu_wrote. The copy-back after a list executes (readback_after_execute) passes true: the written bytes land in a chunk the CPU changed as well, and the chunk keeps its old hash, so the next look uploads the CPU's bytes together with the GPU's. The Map-time copy-back (readback_now, whole spans) passes false and keeps the CPU-wins rule of 04de323.gpu_write_lands_next_to_cpu_writes_in_one_chunk: two CPU cells and one GPU cell in one chunk, all three present after the copy-back, and the chunk still uploads next.Tested
cargo test -p xcl --test e2e -- --test-threads=1: 2 passed, 3 failed onmaine429936c; 5 passed, 0 failed with this change.cargo test -p xcl --lib d3d12x::sparse: 84 passed, 0 failed, 1 ignored, including 04de323'sdirty_chunks_survive_gpu_copy_back_and_upload_nextandclean_chunks_take_gpu_copy_back_bytes.cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run on headb673f36d: 2126 passed, 10 failed, 48 ignored (25SKIPPEDlines). All 10 failures also fail onmaine429936con this machine (2122 passed, 13 failed, 48 ignored): the 4gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_*(Recompiler: LDS ds_sub_u32 hides its negation from the driver (RTX 50 refuses it) #1919 fixes them) and 6 of the 9 in main e429936 on NVIDIA: 3 e2e title tests and 6 split-wave64 GPU tests fail since #2959 #3093. Fixed againstmain:test_title_draws_with_a_root_signature_under_the_debug_layer,test_title_runs_and_game_folder_is_untouched,test_title_runs_under_the_debug_layer_with_dred.Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e(Newer Retail Game), release builds of both commits in clean trees,maine429936cfirst, one run each, in one queue with this account's other PRs. Both runs hadXCL_PREPARE=0and the same warm DXIL cache. A warm-up run ofmaincame before them and is not shown. A second run ofmainat the end of the queue showed 374 frames and a peak commit of 14157 MB, so differences of a few tens of frames between runs are noise here.main(e429936c):This PR (
b673f36d):Not tested
land_pagealready relies on the title's fence discipline for this window.AI use
🤖 Generated with Claude Code