Repository navigation
D3D12.X: a same-list write drops a later wait only when its value meets it - #2506
tiagonleal wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
|
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
luckyteagirl
left a comment
There was a problem hiding this comment.
At exact head 46456f0 (base 6d12f58, current main b49be18), the new value-aware wait rule loses the written value across a mid-list split. This is a source-derived review; I did not run a split-enabled title fixture.
split copies written_ranges from the old ListState into the next segment (list_x.rs:2789,2879) but leaves written_values at its default empty value. wait_memory then treats an overlapping prior write with no matching known value as already ordered and returns (:3023–3025). One concrete path is: record Write64(A, 0), issue a wait on unrelated B so try_split_for_wait creates a second segment, then issue Wait64(A, >=, 1) while another queue is expected to raise A. The second segment remembers A's written range but not 0, so it drops a wait that the PR's rule would retain before the split. This is an incomplete case of the bug the PR addresses, rather than a regression newly introduced against main.
Could split carry written_values with written_ranges (keeping the existing invalidation on later overlapping writes)? A split-enabled fixture can inspect the second segment's pending waits after A >= 1, with A >= 0 as the satisfied control.
AI assistance: two GPT-6.2 Sol agents independently checked this path; GPT-6.2 Astra verified the exact-head source and wording.
…dev#2506) (cherry picked from commit 4b5b37a3e1331f63bde73d9d6ab81f9ccf82d1aa)
46456f0 to
a4b66e8
Compare
|
Confirmed. Fixed in a4b66e8 (squashed with the first commit): Run on a4b66e8: |
|
@raylitebull a note for amd-dev carries the first version of this change (a080eb6). Its delta against amd-dev c32c91adiff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs
index 53a6ccc..edc3d50 100644
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -1053,6 +1053,11 @@ impl ListState {
std::mem::take(&mut self.write64_signals)
}
+ /// What a mid-list split's next segment inherits of this list's writes: the ranges and the known values.
+ fn writes_for_split(&self) -> (Vec<(u64, u64)>, Vec<(u64, u64, u64)>) {
+ (self.written_ranges.clone(), self.written_values.clone())
+ }
+
fn has_prior_write(&self, va: u64, size: u64) -> bool {
let end = va.saturating_add(size);
self.written_ranges.iter().any(|&(s, e)| va < e && s < end)
@@ -3293,7 +3298,7 @@ unsafe fn split(list: *mut c_void, dispatch: Option<Deferred>) -> Option<*mut c_
}
None => None,
};
- let (alloc, last_queue, bound_pso, depth_bias, index_buffer, depth_bounds, predication, pred_buf, pred_in_state, active_query, ended_early, written_ranges, bindings) = {
+ let (alloc, last_queue, bound_pso, depth_bias, index_buffer, depth_bounds, predication, pred_buf, pred_in_state, active_query, ended_early, (written_ranges, written_values), bindings) = {
let mut g = LISTS.lock().unwrap();
let s = g.as_mut()?.get_mut(&(list as usize))?;
if s.allocator == 0 {
@@ -3314,7 +3319,7 @@ unsafe fn split(list: *mut c_void, dispatch: Option<Deferred>) -> Option<*mut c_
pred_in_state,
active_query,
ended_early,
- s.written_ranges.clone(),
+ s.writes_for_split(),
s.bindings.clone(),
)
};
@@ -3415,6 +3420,7 @@ unsafe fn split(list: *mut c_void, dispatch: Option<Deferred>) -> Option<*mut c_
depth_bounds,
occlusion: Occlusion { active: None, ended_early },
written_ranges,
+ written_values,
pred_buf: pred_buf.clone(),
pred_in_state: false,
predication,
@@ -6138,6 +6144,25 @@ mod tests {
assert_eq!(kept(&[], &fill), 0);
}
+ #[test]
+ fn a_split_segment_keeps_the_written_value_for_a_later_wait() {
+ let cell = AtomicU64::new(0);
+ let va = &cell as *const AtomicU64 as u64;
+ let (mut a, mut b) = (0usize, 0usize);
+ let (list, next) = ((&mut a as *mut usize).cast::<c_void>(), (&mut b as *mut usize).cast::<c_void>());
+ let ge = D3D12_COMPARISON_FUNC_GREATER_EQUAL.0 as u32;
+ // `Write64(va, 0)`, then a split moves the recording to `next` with what `split` carries over
+ note_write_value(list as usize, va, &[0, 0]);
+ let (written_ranges, written_values) = LISTS.lock().unwrap().as_ref().unwrap()[&(list as usize)].writes_for_split();
+ on_release(list as usize);
+ LISTS.lock().unwrap().as_mut().unwrap().insert(next as usize, ListState { written_ranges, written_values, ..Default::default() });
+ // a wait the written 0 does not meet stays on the segment
+ unsafe { wait64_x(next, va, ge, 1, 0, 0) };
+ let n = LISTS.lock().unwrap().as_ref().unwrap()[&(next as usize)].pending_waits.len();
+ on_release(next as usize);
+ assert_eq!(n, 1, "the wait after the split was dropped");
+ }
+
#[test]
fn execute_with_waits_splits_batches_before_unsatisfied_list() {
// Use synthetic non-zero list pointers distinct from real COM objects.AI use: Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Sonnet 5.5) compared the trees and wrote this; I checked it. |
|
Overlap with #1256 (open): it makes AI-assisted (Claude Code, Claude Opus 5.5): read both diffs and wrote this. |
|
Agreed, and that order works for me. On that branch #1256 records the range with If this one lands first, your offer to record the value on that branch in #1256 covers it. If #1256 lands first, I'll rebase this PR and make that branch call AI use: Claude Code with Claude Fable 5.2 wrote this from the two diffs; I checked it. |
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2506 updated head Setup
Targeted RTX 4060 release unit & GPU tests (
|
|
Independent test report under Wine/Proton (not native Windows) for head Setup
Tests (debug,
Retail title, 300 s (release, from a copy of the same warm-cache snapshot;
Not tested
AI use
|
a4b66e8 to
f024795
Compare
f024795 to
0b7d23c
Compare
0b7d23c to
9953ecd
Compare
…ts it `wait_memory` dropped a `Wait32/64BitValueX` whenever the same open list had already written an overlapping address (`has_prior_write`, since 3dfbcfb). The reason for that drop is that the wait would otherwise be polled before the list is submitted, while the write that satisfies it is still in the unsubmitted list. That only holds when the value the list wrote meets the comparison. A list that resets a counter (`Write64BitValue…X(X, 0)`) and then waits `X >= 1` for another queue to raise it lost its wait: the list ran without waiting for the producer. The list now keeps the value of its last immediate write (`write`) per address. The wait is dropped when that value, masked, meets the comparison (`compare_u64`), or when the last write over the address has no known value (fill, copy, a partial write), as before. Otherwise it is recorded like any other wait. A mid-list `split` carries the written values to the next segment together with the written ranges (`SplitCarry`), so a wait after the split is judged the same way. Tests: `a_wait_after_an_own_write_is_dropped_only_when_the_written_value_meets_it` covers all eight comparison functions, 32 and 64 bit, the Wait32 mask, the last of several writes, and a fill over the value. `a_split_segment_keeps_the_written_value_for_a_later_wait` checks that after a split a list that wrote `X = 0` and then waits `X >= 1` keeps the wait. It exercises what `split` carries to the next segment (`SplitCarry::capture` and `continuation_state`), not `split` itself. With the continuation carrying no values, the split test fails (0 waits kept, 1 expected); with this change both tests pass, 3 of 3 runs.
9953ecd to
9856615
Compare
|
No open or merged PR makes the same change. #592 changes how AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
wait_memorydrops aWait32/64BitValueXwhenever the same open list already wrote an overlapping address (has_prior_write, there since 3dfbcfb). The comment gives the reason: the write is earlier in the same list, and polling the address before that list is submitted would only wait on our own unsubmitted list. That holds only when the value the list wrote meets the wait. A list that resets a counter (Write64BitValue…X(X, 0)) and then waitsX >= 1for another queue to raise it lost the wait, so it ran without waiting for the producer. With this change such a wait is recorded like any other wait. A wait that the list's own last write meets is still dropped, also after a mid-listsplit. Part of #1452.Rebased onto
maind8bd9a38.mainreplaced the written-range list withRecordedWriteProducersand moved the split carry-over intoSplitCarry, so this is a port: the known written values are aListStatefield cleared wherevermainclears the segment's write producers, they travel inSplitCarry, and a wait thatmain'swait_placementwould order inside the segment is kept (recorded here, or split after a Write64) when the list's own known value does not meet the comparison. The split test now goes throughSplitCarry::capture(..).continuation_state(..); it fails when the continuation carries no values. The Write64 fallback has no test of its own.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:ListStatekeeps the value of the list's last immediate write (write:Write32/64BitValue…X) per address (this includes an immediate write into a window the GPU only has a copy of, thenote_immpathmainadded, through the new helpernote_written_value), cleared wherever the segment's write producers are cleared. A later write over it of unknown value (fill,CopyMemoryToMemoryX, timestamp) forgets it.wait_memorydrops the wait when that value, masked, meets the comparison (compare_u64), or when there is no known value for exactly that address and width (fill, copy, partial write), as before. A split carries the written values to the next segment inSplitCarry, so a wait after a split is judged the same way.a_wait_after_an_own_write_is_dropped_only_when_the_written_value_meets_it: the eightD3D12_COMPARISON_FUNCs for 32 and 64 bit, a 64-bit value above 32 bits, theWait32BitValueXmask, the last of two writes, a write to another address, and a fill over the value.a_split_segment_keeps_the_written_value_for_a_later_wait: a list writesX = 0and then waitsX >= 1; after the split the wait is kept. It goes throughSplitCarry::capture(..).continuation_state(..), the carry-over a split uses.A title that writes an address and then waits on it in the same list for a value its own write does not meet now gets that wait (before, it was dropped). If nothing else ever produces the value, the wait behaves like any other wait without a producer: the CPU fallback blocks the submitting thread for up to 2 s, or the GPU bridge waits until the watchdog releases it at 5 s. Before, the list just ran.
Tested
main6d12f58.main6d12f58, with only the drop condition ofmainrestored, fails on its first case:64-bit: wrote 0x0, wait op 7 0x1,left: 0, right: 1(the wait is dropped). The split test fails when the continuation carries no values (checked again on the current code):the wait after the split was dropped,left: 0, right: 1.cargo test -p xcl --lib -- a_wait_after_an_own_write a_split_segment_keeps: 2 passed, 3 of 3 runs.cargo test -p xcl --lib -- hle::d3d12x, 6 runs (earlier head 46456f0, not repeated on a4b66e8): 254 passed, 0 failed, 2 ignored in 5 runs. In 1 runa_dispatch_with_a_pipeline_still_building_waits_at_the_submitfailed (segment count 389, expected 421). The same test failed 1 time in 6 runs onmain6d12f58 (252/253 passed), so it depends on timing and fails without this change too.cargo test --workspace --no-fail-fast -- --test-threads=4, run twice on a4b66e8: 1421 passed, 4 failed, 46 ignored both times. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState: E_OUTOFMEMORY). They failed onmain6d12f58 in earlier runs; I did not run them onmainagain today.SKIPPEDlines on this adapter: 24 GPU tests that need wave32/wave64 forms this adapter does not have ("no wave64"), andheap_window_out_of_memory_falls_back_to_the_switch_form("no heap windows").maind8bd9a38(head98566154):cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run: 2615 passed, 5 failed, 49 ignored (26SKIPPEDlines). The 5 failures are 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) andtest_title_runs_under_the_debug_layer_with_dred, which failed on one check of the test title (a texture in title memory (XG layout, Split wave32 geometry: refuse prefix counts over a mask #44) follows CPU writes: subresource 2 row 0 differs from the title memory). That check is intermittent: the e2e target of this PR's tree run alone 3 times right after gave 5 passed, 0 failed each time. The PR does not touch title textures. Onmaind8bd9a38on this machine: 2613 passed, 5 failed, 49 ignored; the same 4 fuzz tests fail there, and the fifth failure there istest_title_draws_with_a_root_signature_under_the_debug_layer, the same intermittent check. The other results in this section are from the earlier heads named in them.Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e(Newer Retail Game), release builds of both commits in clean trees,maind8bd9a38first, 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 1697 frames and a peak commit of 15496 MB, so differences of a few tens of frames between runs are noise here.main(d8bd9a38):This PR (
98566154):Not tested
split; it checks only the valuessplitcarries over.Overlap: #1256 (records
cpu_writesranges for this drop) and #592 (range tracking) change the same check. Neither looks at the written value. With #1256, its title-memory writes would have no known value here and would still be dropped.AI use
🤖 Generated with Claude Code