Repository navigation
Conversation
|
I checked head One lifetime case needs a regression before this leaves draft. Suggested recovery and regressionKeep the complete recording dependency set held when a submitted queue has no completion proof: scratch and upload sources, record buffer, allocator backing, and UMA constants. A replacement fence signal on that same queue, issued after the failed marking attempt, can establish a new ordered completion point; release only after it and every other queue mark for the recording complete. If a replacement mark cannot be established, retain the complete set without recycling it. A later proved mark should drain the retained set; the current process-global A regression can block a queue behind an unsignaled gate, inject a failed completion mark after submission, reset the recording, and assert that none of the three allocations is reusable. Include two queues: completion on only one must not release the recording; completion on both may release it once. The focused commands were |
Copy proven UPLOAD inputs into recording-owned scratch and retain sources through submission completion. Bound both inputs before recording and quarantine unmarked staged resources. Thirteen targeted tests passed without skips; full workspace and paired clean-head title runs remain pending. Assisted-by: Codex (GPT-6)
95ff502 to
a54edd3
Compare
|
I tested the rebased indirect caller at The fixture registered a real native compute/mesh PSO pair as a two-pass pipeline and used the production signature-creation hook to create the DispatchMesh signature and its companion Dispatch signature. The UPLOAD argument buffer held two records starting at byte 16 (16-byte stride, one group then two). A separate UPLOAD count buffer supplied the count at byte 8. The preceding words were zero. The native compute pass wrote each group's ID to the record buffer; the mesh pass read it to distinguish the left and right halves of a 4×4 target.
All four fresh processes logged the production two-pass ExecuteIndirect path. Every pixel matched after a completion fence; zero skips. This exercises the rebased exact/native pipeline route, both checked nonzero offsets, GPU argument rewriting and real indirect command consumption. The PSO pair was synthetic, batching was disabled, and the inputs stayed alive through submission. The test does not cover pending asynchronous PSO resolution, retention after early release, or retail rendering. AI use: OpenAI Codex adapted the native geometry fixture, ran the four controls, and wrote this report. |
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree. |
|
Follow-up to my earlier lifetime review on head The remaining memory failure mode is retention after a transient fence error. I made an uncommitted candidate that retries completion marking once in the same ordered queue turn and on the same On the untouched PR head, the new transient- The full Uncommitted candidate diff and focused regressionsdiff --git a/crates/xcl/src/hle/d3d12x/alloc_pool.rs b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
index b1159583..afbd0583 100644
--- a/crates/xcl/src/hle/d3d12x/alloc_pool.rs
+++ b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
@@ -687,8 +687,8 @@ impl PendingSubmit {
fn finish_with_queue_ops(
self,
key: usize,
- create: impl FnOnce() -> Option<ID3D12Fence>,
- signal: impl FnOnce(&ID3D12Fence, u64) -> bool,
+ create: impl FnMut() -> Option<ID3D12Fence>,
+ signal: impl FnMut(&ID3D12Fence, u64) -> bool,
) -> bool {
self.finish_with_queue_ops_marked(key, create, signal).is_ok()
}
@@ -696,8 +696,8 @@ impl PendingSubmit {
fn finish_with_queue_ops_marked(
self,
key: usize,
- create: impl FnOnce() -> Option<ID3D12Fence>,
- signal: impl FnOnce(&ID3D12Fence, u64) -> bool,
+ create: impl FnMut() -> Option<ID3D12Fence>,
+ signal: impl FnMut(&ID3D12Fence, u64) -> bool,
) -> Result<Option<SubmissionReceipt>, ()> {
if self.entries.is_empty() {
return Ok(None);
@@ -709,8 +709,8 @@ impl PendingSubmit {
fn finish_with_queue_ops_receipted(
self,
key: usize,
- create: impl FnOnce() -> Option<ID3D12Fence>,
- signal: impl FnOnce(&ID3D12Fence, u64) -> bool,
+ create: impl FnMut() -> Option<ID3D12Fence>,
+ signal: impl FnMut(&ID3D12Fence, u64) -> bool,
) -> Option<SubmissionReceipt> {
// `begin_submit` intentionally does not initialize allocator state when swapping is off;
// a requested receipt still needs the shared queue-generation marker namespace.
@@ -723,46 +723,73 @@ impl PendingSubmit {
fn finish_with_queue_ops_inner(
mut self,
key: usize,
- create: impl FnOnce() -> Option<ID3D12Fence>,
- signal: impl FnOnce(&ID3D12Fence, u64) -> bool,
+ mut create: impl FnMut() -> Option<ID3D12Fence>,
+ mut signal: impl FnMut(&ID3D12Fence, u64) -> bool,
) -> Option<SubmissionReceipt> {
let marker = {
let g = lock_for_submit();
let s = g.as_ref()?;
s.fences.get(&key).cloned()
};
+ let mut recovered = false;
let marker = match marker {
Some(marker) => marker,
None => {
- let fence = create()?;
- let made = Arc::new(QueueFence::new(fence));
- let mut g = lock_for_submit();
- let s = g.as_mut()?;
- let (marker, unused) = match s.fences.entry(key) {
- Entry::Occupied(entry) => (Arc::clone(entry.get()), Some(made)),
- Entry::Vacant(entry) => {
- let marker = Arc::clone(&made);
- entry.insert(made);
- (marker, None)
+ let mut created = create();
+ let mut nested = None;
+ if created.is_none() {
+ recovered = true;
+ nested = {
+ let g = lock_for_submit();
+ g.as_ref()?.fences.get(&key).cloned()
+ };
+ if nested.is_none() {
+ created = create();
}
- };
- drop(g);
- drop(unused);
- marker
+ }
+ if let Some(marker) = nested {
+ marker
+ } else {
+ let made = Arc::new(QueueFence::new(created?));
+ let mut g = lock_for_submit();
+ let s = g.as_mut()?;
+ let (marker, unused) = match s.fences.entry(key) {
+ Entry::Occupied(entry) => (Arc::clone(entry.get()), Some(made)),
+ Entry::Vacant(entry) => {
+ let marker = Arc::clone(&made);
+ entry.insert(made);
+ (marker, None)
+ }
+ };
+ drop(g);
+ drop(unused);
+ marker
+ }
}
};
// Reserve before entering the driver. The queue lease excludes another thread, while an
// atomic reservation lets intentional same-thread re-entry take a distinct later value.
- // A failed Signal burns its value; its submit remains pinned and a gap is harmless.
- let Ok(value) = marker.next_value.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |v| v.checked_add(1)) else {
- return None;
- };
- let value = value + 1;
- SUBMIT.signal_attempts.fetch_add(1, Ordering::Relaxed);
- if !signal(&marker.fence, value) {
+ // A failed Signal burns its value; a second failure leaves the submit pinned.
+ let value = loop {
+ let Ok(value) = marker.next_value.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |v| v.checked_add(1)) else {
+ return None;
+ };
+ let value = value + 1;
+ SUBMIT.signal_attempts.fetch_add(1, Ordering::Relaxed);
+ if signal(&marker.fence, value) {
+ break value;
+ }
SUBMIT.signal_failures.fetch_add(1, Ordering::Relaxed);
- return None;
- }
+ if recovered {
+ return None;
+ }
+ recovered = true;
+ let g = lock_for_submit();
+ let s = g.as_ref()?;
+ if s.fences.get(&key).is_none_or(|current| !Arc::ptr_eq(current, &marker)) {
+ return None;
+ }
+ };
let fence = marker.fence.clone();
let mut g = lock_for_submit();
let s = g.as_mut()?;
@@ -1818,6 +1845,156 @@ mod tests {
assert_eq!(object.refs.get(), 0);
}
+ fn assert_submit_pin_during_driver_callback(alloc: usize) {
+ let started = std::time::Instant::now();
+ let state = loop {
+ if let Ok(state) = STATE.try_lock() { break state; }
+ assert!(started.elapsed() < std::time::Duration::from_secs(1), "driver callback could not reenter allocator state");
+ std::thread::yield_now();
+ };
+ assert_eq!(state.as_ref().unwrap().backings[&alloc].submit_pins, 1);
+ }
+
+ #[test]
+ fn a_transient_signal_failure_marks_the_original_submit() {
+ let (alloc, list, queue) = (0x7ffe_6b90usize, 0x7ffe_6b91usize, 0x7ffe_6b92usize);
+ created_on(list, alloc, D3D12_COMMAND_LIST_TYPE_DIRECT.0);
+ let (mock, completed) = submission_receipt_for_test(0, 0);
+ let fence = mock.marker.fence.clone();
+ let pending = begin_submit(&[list as *mut c_void]).unwrap().execution_possible();
+ let mut attempts = Vec::new();
+ let marked = pending.finish_with_queue_ops_marked(queue, || Some(fence.clone()), |_, value| {
+ assert_submit_pin_during_driver_callback(alloc);
+ attempts.push(value);
+ attempts.len() == 2
+ });
+ assert_eq!(attempts, [1, 2], "retry must reserve a distinct ordered value");
+ let receipt = marked.expect("a transient failure should be recovered").unwrap();
+ assert_eq!(receipt.value, 2);
+ assert_eq!(STATE.lock().unwrap().as_ref().unwrap().backings[&alloc].submit_pins, 0);
+ assert!(!receipt.is_complete());
+ completed.store(2, Ordering::Release);
+ assert!(receipt.is_complete());
+
+ let removed = {
+ let mut g = STATE.lock().unwrap();
+ let s = g.as_mut().unwrap();
+ s.of_list.remove(&list);
+ s.list_lifetimes.remove(&list);
+ s.recordings.remove(&list);
+ s.last_submit.remove(&list);
+ s.cur.remove(&alloc);
+ s.types.remove(&alloc);
+ (s.backings.remove(&alloc), s.fences.remove(&queue))
+ };
+ drop(removed);
+ }
+
+ #[test]
+ fn a_transient_fence_creation_failure_marks_the_original_submit() {
+ let (alloc, list, queue) = (0x7ffe_6ba0usize, 0x7ffe_6ba1usize, 0x7ffe_6ba2usize);
+ created_on(list, alloc, D3D12_COMMAND_LIST_TYPE_DIRECT.0);
+ let (mock, _) = submission_receipt_for_test(0, 0);
+ let fence = mock.marker.fence.clone();
+ let pending = begin_submit(&[list as *mut c_void]).unwrap().execution_possible();
+ let mut creates = 0;
+ let marked = pending.finish_with_queue_ops_marked(queue, || {
+ assert_submit_pin_during_driver_callback(alloc);
+ creates += 1;
+ (creates == 2).then(|| fence.clone())
+ }, |_, value| value == 1);
+ assert_eq!(creates, 2);
+ assert_eq!(marked.unwrap().unwrap().value, 1);
+ assert_eq!(STATE.lock().unwrap().as_ref().unwrap().backings[&alloc].submit_pins, 0);
+
+ let removed = {
+ let mut g = STATE.lock().unwrap();
+ let s = g.as_mut().unwrap();
+ s.of_list.remove(&list);
+ s.list_lifetimes.remove(&list);
+ s.recordings.remove(&list);
+ s.last_submit.remove(&list);
+ s.cur.remove(&alloc);
+ s.types.remove(&alloc);
+ (s.backings.remove(&alloc), s.fences.remove(&queue))
+ };
+ drop(removed);
+ }
+
+ #[test]
+ fn a_nested_marker_after_failed_creation_marks_without_another_create() {
+ let (alloc, list, queue) = (0x7ffe_6bc0usize, 0x7ffe_6bc1usize, 0x7ffe_6bc2usize);
+ created_on(list, alloc, D3D12_COMMAND_LIST_TYPE_DIRECT.0);
+ let (mock, _) = submission_receipt_for_test(0, 0);
+ let fence = mock.marker.fence.clone();
+ let pending = begin_submit(&[list as *mut c_void]).unwrap().execution_possible();
+ let mut creates = 0;
+ let marked = pending.finish_with_queue_ops_marked(queue, || {
+ assert_submit_pin_during_driver_callback(alloc);
+ creates += 1;
+ assert_eq!(creates, 1, "reuse the marker installed during the first CreateFence");
+ STATE.lock().unwrap().as_mut().unwrap().fences.insert(
+ queue, Arc::new(QueueFence::new(fence.clone())),
+ );
+ None
+ }, |actual, value| {
+ assert_eq!(actual.as_raw(), fence.as_raw());
+ value == 1
+ });
+ assert_eq!(creates, 1);
+ assert_eq!(marked.unwrap().unwrap().value, 1);
+ assert_eq!(STATE.lock().unwrap().as_ref().unwrap().backings[&alloc].submit_pins, 0);
+
+ let removed = {
+ let mut g = STATE.lock().unwrap();
+ let s = g.as_mut().unwrap();
+ s.of_list.remove(&list);
+ s.list_lifetimes.remove(&list);
+ s.recordings.remove(&list);
+ s.last_submit.remove(&list);
+ s.cur.remove(&alloc);
+ s.types.remove(&alloc);
+ (s.backings.remove(&alloc), s.fences.remove(&queue))
+ };
+ drop(removed);
+ }
+
+ #[test]
+ fn a_replaced_fence_marker_cannot_recover_a_failed_signal() {
+ let (alloc, list, queue) = (0x7ffe_6bb0usize, 0x7ffe_6bb1usize, 0x7ffe_6bb2usize);
+ created_on(list, alloc, D3D12_COMMAND_LIST_TYPE_DIRECT.0);
+ let (old, _) = submission_receipt_for_test(0, 0);
+ let (new, _) = submission_receipt_for_test(0, 0);
+ let old_fence = old.marker.fence.clone();
+ let new_fence = new.marker.fence.clone();
+ let pending = begin_submit(&[list as *mut c_void]).unwrap().execution_possible();
+ let mut signals = 0;
+ let marked = pending.finish_with_queue_ops_marked(queue, || Some(old_fence.clone()), |_, value| {
+ signals += 1;
+ assert_eq!(value, 1);
+ STATE.lock().unwrap().as_mut().unwrap().fences.insert(
+ queue, Arc::new(QueueFence::new(new_fence.clone())),
+ );
+ false
+ });
+ assert!(marked.is_err());
+ assert_eq!(signals, 1, "a changed queue generation must prevent a retry");
+ assert_eq!(STATE.lock().unwrap().as_ref().unwrap().backings[&alloc].submit_pins, 1);
+
+ let removed = {
+ let mut g = STATE.lock().unwrap();
+ let s = g.as_mut().unwrap();
+ s.of_list.remove(&list);
+ s.list_lifetimes.remove(&list);
+ s.recordings.remove(&list);
+ s.submit_pins.retain(|&(p, _), _| p != list);
+ s.cur.remove(&alloc);
+ s.types.remove(&alloc);
+ (s.backings.remove(&alloc), s.fences.remove(&queue))
+ };
+ drop(removed);
+ }
+
#[test]
fn submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker() {
use std::cell::Cell;
@@ -1874,13 +2051,15 @@ mod tests {
let failed_list = 0x7ffe_6b05usize;
let failed = begin_submit(&[failed_list as *mut c_void]).unwrap().execution_possible();
+ let mut failed_values = Vec::new();
assert!(!failed.finish_with_queue_ops(first_queue, || unreachable!(), |_, value| {
- assert_eq!(value, 2);
+ failed_values.push(value);
false
}));
+ assert_eq!(failed_values, [2, 3], "both failed Signals burn distinct values");
let retried = begin_submit(&[failed_list as *mut c_void]).unwrap().execution_possible();
assert!(retried.finish_with_queue_ops(first_queue, || unreachable!(), |_, value| {
- assert_eq!(value, 3, "a failed Signal leaves a gap instead of colliding with a retry");
+ assert_eq!(value, 4, "failed Signals leave a gap instead of colliding with a later submit");
true
}));
{
@@ -1888,18 +2067,18 @@ mod tests {
let s = g.as_ref().unwrap();
let lifetime = s.list_lifetimes[&failed_list];
assert_eq!(s.submit_pins.get(&(failed_list, lifetime)), Some(&1), "the failed submit stays pinned");
- assert_eq!(s.last_submit[&failed_list].value, 3);
+ assert_eq!(s.last_submit[&failed_list].value, 4);
}
let (outer_list, inner_list) = (0x7ffe_6b06usize, 0x7ffe_6b07usize);
let outer = begin_submit(&[outer_list as *mut c_void]).unwrap().execution_possible();
- let inner = begin_submit(&[inner_list as *mut c_void]).unwrap().execution_possible();
+ let mut inner = Some(begin_submit(&[inner_list as *mut c_void]).unwrap().execution_possible());
assert!(super::super::queue_submit::with(first_queue, || {
outer.finish_with_queue_ops(first_queue, || unreachable!(), |_, outer_value| {
- assert_eq!(outer_value, 4);
+ assert_eq!(outer_value, 5);
assert!(super::super::queue_submit::with(first_queue, || {
- inner.finish_with_queue_ops(first_queue, || unreachable!(), |_, inner_value| {
- assert_eq!(inner_value, 5, "same-thread re-entry reserves a distinct value");
+ inner.take().unwrap().finish_with_queue_ops(first_queue, || unreachable!(), |_, inner_value| {
+ assert_eq!(inner_value, 6, "same-thread re-entry reserves a distinct value");
true
})
}));
@@ -1909,7 +2088,7 @@ mod tests {
{
let g = STATE.lock().unwrap();
let s = g.as_ref().unwrap();
- assert_eq!((s.last_submit[&outer_list].value, s.last_submit[&inner_list].value), (4, 5));
+ assert_eq!((s.last_submit[&outer_list].value, s.last_submit[&inner_list].value), (5, 6));
}
let (reused_list, reused_queue) = (0x7ffe_6b03usize, 0x7ffe_6b04usize);
@@ -2026,12 +2205,14 @@ mod tests {
assert!(second_receipt.is_complete());
let failed = begin_submit(&[failed_list as *mut c_void]).unwrap().execution_possible();
+ let mut failed_values = Vec::new();
assert!(failed
.finish_with_queue_ops_receipted(queue, || unreachable!(), |_, value| {
- assert_eq!(value, 1);
+ failed_values.push(value);
false
})
.is_none());
+ assert_eq!(failed_values, [1, 2]);
let (marker, submit, second_submit) = {
let mut g = STATE.lock().unwrap();
let s = g.as_mut().unwrap();AI use: Codex (GPT-6.2 Sol) investigated, wrote the candidate and regressions, and ran the checks; Codex (GPT-6.2 Astra) independently reviewed the low-level lifetime and retry paths. |
|
merge-check |
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head a54edd37. The current begin_submit/backing pin corrects the earlier premature allocator-reuse concern for tracked direct recordings; the follow-up review confirms that correction. I found no new source-level blocker in that ownership route. The critical unverified cases are an ExecuteIndirect count/argument buffer rewritten during recording, failed fence creation or Signal, and allocator reset before submission. Please keep exact-head GPU fixtures for those paths and report retained bytes after a transient failure, since deliberate retention is the remaining memory cost. No local Windows run.
|
Review (head a54edd3, diff read, not a merge-check; draft, so not built or run):
Fine: the copy is recorded on the GPU, so it reads the upload buffer at execution time as native ExecuteIndirect does; an upload buffer's GENERIC_READ already allows copying from it; the source buffers are held until the fence completes or the allocator is reset; the copies and the doubled rewritten arguments use separate scratch spans. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
Enable standalone UPLOAD-heap arguments/counts for two-pass indirect mesh draws on
nvidia-dev. The existing path only accepts console UMA inputs.Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: heada54edd3735b9268fcc70dd537239b4c9983fd2aa(was95ff502bb2badc516b71836ed9c9c3578b36c567). The one conflict was inexecute_indirect_classified(bind.rs): this PR's checked offsets are kept, onmain'sdispatches,args_off_titleanddraw_pipeline(pso, bound_unbuilt), and the new test'sFakeAdoptedListgainedmain'slast_psofield. That port needs a review. The widerindirecttest filter is not counted: on this PC it ends in an access violation on plainmain765b2c5btoo (3 of 3 runs), wheredispatch_chain::tests::failed_binding_keeps_indirect_commands_until_allocator_resetalso fails alone withadopted class. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 gpu_upload_indirect_preparation_uses_its_recording_arena_and_sources gpu_upload_indirect_staging_keeps_inputs_counts_and_canaries indirect_known_console_ranges_never_fall_back_to_the_pc_buffer indirect_upload_layout_bounds_both_inputs_and_outputs indirect_upload_source_classification_and_failed_submit_retention invalid_indirect_count_records_no_gpu_workgave 6 passed, 0 failed, 0 ignored, no SKIPPED. The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.What is in it
e429936cstill skips two-pass mesh ExecuteIndirect; D3D12.X: repack root-changing ExecuteIndirect commands on the GPU #869 and draft D3D12.X: two-pass ExecuteIndirect uses plain signatures, with Wine's barrier #3012 address different ordinary-signature paths.Tested
cargo test --locked -p xcl --lib --target-dir <isolated-target> --no-run: passed.cargo test --locked -p xcl --lib --target-dir <isolated-target> hle::d3d12x::bind::tests::<test> -- --exact --nocapture --test-threads=1: 13 passed, 0 failed, 0 ignored; no SKIPPED messages (1,811 filtered per invocation).indirect_upload_layout_bounds_both_inputs_and_outputs,indirect_known_console_ranges_never_fall_back_to_the_pc_buffer,indirect_upload_source_classification_and_failed_submit_retention,invalid_indirect_count_records_no_gpu_work,gpu_upload_indirect_staging_keeps_inputs_counts_and_canaries,gpu_upload_indirect_preparation_uses_its_recording_arena_and_sources.Regression run
Pending paired clean-head main/PR title runs; no smoke block claimed. Draft until required validation is complete.
Not tested
AI use
Codex (GPT-6) reviewed the related work and actual main source, implemented the bounded NVIDIA adaptation, ran the targeted tests and prepared this PR.
Optional temporary Discord for coordinating contributor work, testing and comparing results: https://discord.gg/6B4TykyC4W