Repository navigation
gpu: settle reader before readback and serialize Gate tests - #81
Conversation
In raw_views_a_submission_in_flight_may_read_stay_until_it_has_run, gpu_caught_up checks only the D3D12 GPU fence value and returns without draining when the fence has already advanced, racing against xtp-gpu-finisher copying dst back to title memory. Settle reader explicitly before asserting on dst.words(). Also serialize the Gate::close tests in descriptor/host.rs and resource/pool.rs with host::submissions::serial(), matching host::submissions and draw.rs.
fogydes
left a comment
There was a problem hiding this comment.
Reviewed exact head 988e9a6 with a separate read-only source review. No blocking correctness finding in this test-only change.
reader.settle() waits for CPU write-back as well as GPU completion before the old-window read. The Gate still encloses the in-flight descriptor replacement, so the retirement, reuse and data assertions retain their purpose. The five added guards use the existing submission-test isolation mechanism and cover the whole gated interval.
All current-head required CI checks are green, including strict GPU diagnostics and the workspace test job (633 GPU tests passed, 14 ignored). I did not repeat local builds or the author's stress measurements: the local memory guard stopped validation before Cargo. This addresses the test's premature read; it is not evidence of a production raw-view defect or a complete resolution of #54.
Nonblocking follow-up: the existing Gate test in texture.rs around line 5031 still lacks the same serial guard. A deterministic CPU-finisher negative control would strengthen the timing regression.
AI assistance: Codex coordinated the independent review and checked the final diff and merge gates.
What and why
descriptor::host::tests::raw_views_a_submission_in_flight_may_read_stay_until_it_has_runcalledgpu_caught_up(host)aftergate.open()and then asserted ondst.words()[..64].gpu_caught_uploops onwhile host.completed() < ticket, which checks the D3D12 GPU fence value (ID3D12Fence::GetCompletedValue). When the GPU finishesreaderand advances the fence beforegpu_caught_upenters its loop, the loop runs zero times and returns beforextp-gpu-finisherfinishesHost::completewrite-back intodst, leaving the0xdead_beefsentinel in title memory (crates/xtp-gpu/src/descriptor/host.rs:6603).Settling
reader(reader.settle()) waits for both the GPU fence andtimeline.finishwrite-back before readingdst.words(), without touching the heap, whilecompleted_untilstill verifies that host completion returns both retired raw views to the pool.In addition, the four
Gate::closetests incrates/xtp-gpu/src/descriptor/host.rsandreserved_textures_map_and_give_back_their_tilesincrates/xtp-gpu/src/resource/pool.rsheld the shared host queue withouthost::submissions::serial(), unlikehost::submissionsanddraw.rs. Serializing them prevents holding the queue concurrently with tests waiting under the host submission lock.Fixes part of #54 (
raw_views_a_submission_in_flight_may_read_stay_until_it_has_run; other tests tracked in #54 are unchanged).Depends on: none
Area
xtp-gpuunit tests (descriptor::host,resource::pool,host::submissionsdoc comment).Tests
cargo xtask pr-checkpasses on my machine (ranfmt,clippyplain +--all-features,xtask policy,xtask conventions, and repeatedxtp-gpuWARP + hardware runs; the 17 inline-ray tests requiring Windows SDKdxcwere skipped locally becausedxcis not installed on this machine)Measured on Windows 11 Pro build 26300.10075, NVIDIA GeForce RTX 3050 Ti Laptop GPU (driver
32.0.16.2140),rustc 1.100.0(stable-x86_64-pc-windows-gnu; MSVClink.exenot installed locally):main9b822f5): 30 parallel WARP runs (XTP_TEST_ADAPTER=warp,--test-threads=8, skipping the 17 DXC-only RT tests): 29 passed, 1 failed (run 29) indescriptor::host::tests::raw_views_a_submission_in_flight_may_read_stay_until_it_has_runatcrates/xtp-gpu/src/descriptor/host.rs:6603(assertion left == right failed: the old window, untouched,left: [3735928559, ...]=0xdead_beef).XTP_TEST_ADAPTER=warp,XTP_REQUIRE_GPU=1,--test-threads=8, skipping DXC-only RT tests): 40/40 passed (604 passed, 0 failed per run).XTP_TEST_ADAPTER=hardware,XTP_REQUIRE_GPU=1,--test-threads=8) of all 5 modified tests together withhost::submissions::: 10/10 passed (25 passed, 0 failed per run).cargo fmt --all --check,cargo clippy -p xtp-gpu --no-deps --all-targets --locked(both plain and--all-features, zero warnings in touched files; Rust 1.100 flags pre-existing untouchedfetch_update/texture.rs:937),cargo xtask policy, andcargo xtask conventions(commits, title, and PR body) all passed.dxcunavailable) andXTP_D3D12_DEBUG=1(Graphics Tools /d3d12SDKLayers.dllnot installed on this machine).Provenance
AI assistance: Antigravity assisted with investigating the failure, implementing the fix, and running the verification checks; I reviewed and verified every changed line and measurement.
Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above