Deferred buffer copies expose later bytes across submissions and within one command list #844

Closed
opened 2026-11-28 14:28:47 +00:00 by github-bot · 2 comments
Owner

@⁠thegonsalez1 on GitHub · 2026-11-28 07:36 UTC · original

On 63b902fe1720, a GPU read can see a later CPU-source copy to the same destination. This reproduces across submissions and between two reads in a single command list. All inputs are synthetic. The adapter was an RTX 5060 8 GB on Windows 11, driver 621.40, using a release MSVC build.

Reproduction Expected Observed on main
Three submissions, 256 bytes each, one-sided D3D12 L0 backing Each read returns its submission’s payload The first byte of each of the first two reads matched the third submission in every round. 36 of 54 readbacks were wrong across three fresh processes.
Same test with two-sided L0 backing Same three payloads 0 of 54 wrong. Refusing new snapshot allocations after the spare-pool lookup brought the failure back in 36 of 54.
One list, two guest CopyBufferRegion calls, each followed by GPU readback, 8 MiB + 256 bytes per copy First read 0x21, second 0x51 throughout Both began with 0x51. The second read matched in full. This also happened with two-sided backing and successful snapshots. The 256-byte command-position control returned both expected values.

The cross-submission test holds the direct queue on a fence until all three submissions return. A five-second watchdog fails the test if submitting waits for the queue. The single-list test needs no fence gate. It checks the selected copy path and the bytes across both readback ranges.

Step::Copy changes guest memory while preparing the submission. On a one-sided shadow a refresh can overwrite the mapping an earlier GPU command will read. Two-sided shadows normally preserve a submission’s input, but when send::take returns None, card_before reads from reusable staging. Within a single list both deferred writes run before the upload prelude and native list, so a submission-owned snapshot can contain only the second value. Deferred execution · Upload prelude

An earlier PC-memory failure was mentioned in closed PR #119. I reproduced these cases on Foxhound 3d52ac8a978b and with PR #60 applied to main and enabled. That PR’s own copy-queue readback and retirement test passed. PRs #34, #194 and #641 also retained these failures in the same hardware tests. With three submissions in flight, the owned upload buffers peaked at 24 MiB for 256-byte copies and 48 MiB for the 8 MiB + 256-byte workload.

Reproduce on Windows

Save the test-only diff below as copy-ordering-reproducer.patch and apply it to 63b902fe1720 with git apply. Run the commands in a fresh PowerShell with the project’s Rust/MSVC prerequisites.

$env:VICTORY_RELAY = '2'
$env:VICTORY_RELAY_COPY = '1'
function Run-CopyTest($name) {
    cargo test --locked --release -p victory-gpu --lib "host::upcheck::tests::$name" -- --exact --ignored --nocapture --test-threads=1
}
Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory'
Run-CopyTest 'two_public_copies_in_the_same_list'

$env:VICTORY_CARD_ALL = '1'
$env:VICTORY_CARD_BUFFERS_MB = '0'
Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory'
Run-CopyTest 'two_public_copies_in_the_same_list'

$env:COPY_PROBE_REFUSE_FRESH_UPLOAD = '1'
Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory'

The refusal switch exists only in the test build and leaves the spare pool available. For the small single-list control, set COPY_PROBE_BYTES=256 and COPY_PROBE_PLACED=1 before running that test.

OpenAI Codex provided AI assistance by preparing the reproducer, running the hardware tests, and drafting this report.

Test-only regression patch
diff --git a/crates/victory-gpu/src/host/send.rs b/crates/victory-gpu/src/host/send.rs
index 68e9967..e0d627c 100644
--- a/crates/victory-gpu/src/host/send.rs
+++ b/crates/victory-gpu/src/host/send.rs
@@ -143,6 +143,11 @@ fn memory(host: &Host, size: u64) -> Option<Memory> {
             return Some(spare.swap_remove(i));
         }
     }
+    #[cfg(test)]
+    if std::env::var_os("COPY_PROBE_REFUSE_FRESH_UPLOAD").is_some() {
+        eprintln!("synthetic fresh snapshot allocation refusal: {size} bytes");
+        return None;
+    }
     // By doubles, so that the next of about this size finds it: what
     // submissions send differs from frame to frame.
     let size = size.max(8 << 20).next_power_of_two();
diff --git a/crates/victory-gpu/src/host/upcheck.rs b/crates/victory-gpu/src/host/upcheck.rs
index 63e8cd4..c16d769 100644
--- a/crates/victory-gpu/src/host/upcheck.rs
+++ b/crates/victory-gpu/src/host/upcheck.rs
@@ -913,19 +913,146 @@ mod tests {
         assert!(first <= 6 && back[first..].iter().all(|b| *b), "{back:?}");
     }
 
-    /// The title copies another value to the same bytes in each of three
-    /// submissions, and each has a draw (a copy here) that reads them. The
-    /// card is busy meanwhile, so all three are prepared before the first
-    /// runs: each must read its own.
-    fn each_reads_its_own(len: usize, resource: usize, carded: bool) {
-        let Some(host) = host() else {
-            return;
-        };
+    /// Hold the direct queue until all CPU submissions return. Release it
+    /// even if preparation blocks or unwinds, so a failure can be reported.
+    fn while_queue_waits(host: &Host, submit: impl FnOnce()) -> bool {
+        // SAFETY: a fresh fence for this round, kept alive until signalled.
+        let gate: ID3D12Fence = unsafe { host.device.CreateFence(0, D3D12_FENCE_FLAG_NONE) }.unwrap();
+        std::thread::scope(|threads| {
+            let (ready, release) = std::sync::mpsc::channel();
+            let fence = &gate;
+            let watchdog = threads.spawn(move || {
+                let submitted = release.recv_timeout(std::time::Duration::from_secs(5)).is_ok();
+                // SAFETY: only this thread signals the gate.
+                unsafe { fence.Signal(1) }.unwrap();
+                submitted
+            });
+            // SAFETY: a GPU-side wait on a live fence. The watchdog can
+            // release it independently of this thread and the host queue.
+            unsafe { host.queue.Wait(&gate, 1) }.unwrap();
+            submit();
+            let _ = ready.send(());
+            watchdog.join().unwrap()
+        })
+    }
+
+    /// Two CPU-owned copies and their GPU reads in the same public list.
+    #[test]
+    #[ignore = "synthetic ordering probe in its own process"]
+    fn two_public_copies_in_the_same_list() {
+        use crate::object::{S_OK, This, guid, slot};
+        let host = host().expect("D3D12 host");
+        let size: usize = std::env::var("COPY_PROBE_BYTES")
+            .map_or((8 << 20) + 256, |v| v.parse().expect("copy size in bytes"));
+        let placed = std::env::var("COPY_PROBE_PLACED").as_deref() == Ok("1");
+        let null = std::ptr::null();
+        let alloc_id = guid(
+            0x6102dee4,
+            0xaf59,
+            0x4b09,
+            [0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24],
+        );
+        let list_id = guid(
+            0x5b160d0f,
+            0xac1b,
+            0x4185,
+            [0x8b, 0xa8, 0xb3, 0xae, 0x42, 0xa5, 0xa4, 0x55],
+        );
+        let (mut allocator, mut list) = (null, null);
+        assert_eq!(
+            crate::list::create_allocator(null, 0, &alloc_id, &mut allocator),
+            S_OK
+        );
+        assert_eq!(
+            crate::list::create_list(null, 0, 0, allocator, null, &list_id, &mut list),
+            S_OK
+        );
+        let source = crate::resource::test_buffer((2 * size) as u64);
+        let destination = crate::resource::test_buffer((size + 8192).max(256 << 10) as u64);
+        let (src, _) = crate::resource::buffer_bytes(source).unwrap();
+        let (dst, width) = crate::resource::buffer_bytes(destination).unwrap();
+        let shadow = crate::shadow::find(dst as u64, width).unwrap();
+        let (output, mapped) = host.shared_buffer((2 * size) as u64).unwrap();
+        let init = host.new_list().unwrap();
+        shadow.refresh(&init, dst as u64, width);
+        init.close();
+        host.execute_own(&init);
+        settle_now(WHY_SYNC);
+        let copy = slot::<extern "system" fn(This, This, u64, This, u64, u64)>(list, 0x78);
+        for v in 0..2 {
+            // SAFETY: live, disjoint and in bounds. Both initializations precede submission.
+            unsafe {
+                std::ptr::write_bytes(src.add(v * size), 0x21 + 0x30 * v as u8, size);
+            }
+            copy(
+                list,
+                destination,
+                8192,
+                source,
+                (v * size) as u64,
+                size as u64,
+            );
+            let native = crate::list::host_list(list).unwrap();
+            read_out(native, &shadow, 8192, size, (&output, (v * size) as u64));
+        }
+        let native = crate::list::host_list(list).unwrap();
+        {
+            let d = native.deferred();
+            assert_eq!(
+                d.copies
+                    .iter()
+                    .filter(|s| matches!(s, Step::Placed(_)))
+                    .count(),
+                if placed { 2 } else { 0 }
+            );
+            assert_eq!(
+                d.copies
+                    .iter()
+                    .filter(|s| matches!(s, Step::Copy(..)))
+                    .count(),
+                if placed { 0 } else { 2 }
+            );
+        }
+        assert_eq!(
+            slot::<extern "system" fn(This) -> i32>(list, 0x48)(list),
+            S_OK
+        );
+        host.execute_own(native);
+        settle_now(WHY_SYNC);
+        // SAFETY: both device copies completed and the mapping is live.
+        let bytes = unsafe { std::slice::from_raw_parts(mapped, 2 * size) };
+        eprintln!(
+            "SAME_LIST size={size} placed={placed} paired={} first={:#04x} second={:#04x}",
+            shadow.carded(),
+            bytes[0],
+            bytes[size]
+        );
+        let first = bytes[..size].iter().position(|&v| v != 0x21);
+        let second = bytes[size..].iter().position(|&v| v != 0x51);
+        for object in [list, allocator, source, destination] {
+            slot::<extern "system" fn(This) -> u32>(object, 0x10)(object);
+        }
+        assert_eq!(
+            (first, second),
+            (None, None),
+            "first wrong byte offsets in the two GPU reads"
+        );
+    }
+
+    /// Each submission copies a distinct payload to the same bytes and
+    /// then reads it. All three are prepared before the GPU may read any.
+    fn each_reads_its_own(len: usize, resource: usize, pc_memory: bool) {
+        let host = host().expect("this opt-in test requires a D3D12 host");
         let (title, start, shadow) = title_of(resource, true, len);
-        assert_eq!(shadow.carded(), carded, "where the copy is");
-        let slow = Slow::new(host);
+        let carded = !pc_memory || std::env::var_os("VICTORY_CARD_ALL").is_some_and(|v| v == "1");
+        assert_eq!(shadow.carded(), carded, "whether the copy has two sides");
+        if pc_memory {
+            let mut heap = D3D12_HEAP_PROPERTIES::default();
+            // SAFETY: a live committed resource and a valid output.
+            unsafe { shadow.buffer.GetHeapProperties(Some(&mut heap), None) }.unwrap();
+            assert_eq!(heap.MemoryPoolPreference, D3D12_MEMORY_POOL_L0, "use VICTORY_CARD_BUFFERS_MB=0 with two sides");
+        }
         let (out, out_data) = host.shared_buffer(1 << 16).unwrap();
-        let mut lists = Vec::new();
         const AT: usize = 8192;
         // All there once.
         let all = host.new_list().unwrap();
@@ -933,40 +1060,42 @@ mod tests {
         all.close();
         host.execute_own(&all);
         settle_now(WHY_SYNC);
-        lists.push(all);
         let mut wrong = Vec::new();
         for round in 0..6u8 {
-            for v in 0..3u8 {
-                title[65_536 + usize::from(v) * 256..][..256].fill(round * 16 + v + 1);
-            }
-            let busy = host.new_list().unwrap();
-            slow.record(&busy, 40);
-            busy.close();
-            host.execute_own(&busy);
-            lists.push(busy);
+            let mut lists = Vec::with_capacity(3);
             for v in 0..3usize {
+                let source = 65_536 + v * 256;
+                for (offset, byte) in title[source..source + 256].iter_mut().enumerate() {
+                    *byte = (round * 16 + v as u8 + 1).wrapping_add(offset as u8);
+                }
                 let list = host.new_list().unwrap();
-                list.defer_copy((start + AT) as *mut u8, (start + 65_536 + v * 256) as *const u8, 256);
+                list.defer_copy((start + AT) as *mut u8, (start + source) as *const u8, 256);
                 shadow.refresh(&list, (start + AT) as u64, 256);
                 // SAFETY: an open list; live buffers.
                 unsafe {
                     list.list.CopyBufferRegion(&out, (v * 256) as u64, &shadow.buffer, AT as u64, 256);
                 }
                 list.close();
-                host.execute_own(&list);
                 lists.push(list);
             }
+            let mut asynchronous = true;
+            let submitted = while_queue_waits(host, || {
+                for list in &lists {
+                    asynchronous &= host.execute_own(list) != 0;
+                }
+            });
             settle_now(WHY_SYNC);
+            assert!(submitted && asynchronous, "all three submissions must return with the direct queue gated");
             // SAFETY: a mapping of 64 KiB; the copies into it have run.
             let read = unsafe { std::slice::from_raw_parts(out_data, 768) };
-            for v in 0..3u8 {
-                let got = read[usize::from(v) * 256];
-                if got != round * 16 + v + 1 {
-                    wrong.push((round, v, got - round * 16));
+            for (v, bytes) in read.chunks_exact(256).enumerate() {
+                let first = round * 16 + v as u8 + 1;
+                if let Some((offset, &got)) = bytes.iter().enumerate().find(|&(i, &b)| b != first.wrapping_add(i as u8)) {
+                    wrong.push((round, v, offset, first.wrapping_add(offset as u8), got));
                 }
             }
         }
-        eprintln!("read another submission's value (round, submission, whose + 1): {wrong:?}");
+        eprintln!("wrong copies (round, submission, offset, expected, observed): {wrong:?}");
         let stale = STALE.lock().unwrap_or_else(|e| e.into_inner());
         let found = stale.get(&shadow.span()).map_or(0, |s| s.words);
         eprintln!("the check at sends found {found} words");
@@ -979,13 +1108,13 @@ mod tests {
     #[test]
     #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 and a process of its own"]
     fn each_submission_reads_its_own_copy_on_the_card() {
-        each_reads_its_own(LEN, 0x7777, true);
+        each_reads_its_own(LEN, 0x7777, false);
     }
 
     #[test]
-    #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 and a process of its own"]
+    #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 in its own process; with VICTORY_CARD_ALL=1 also set VICTORY_CARD_BUFFERS_MB=0"]
     fn each_submission_reads_its_own_copy_in_pc_memory() {
-        each_reads_its_own(256 << 10, 0x8888, std::env::var_os("VICTORY_CARD_ALL").is_some_and(|v| v == "1"));
+        each_reads_its_own(256 << 10, 0x8888, true);
     }
 
     /// What a draw of `list` reads at `at`: comes to `out`.
**@⁠thegonsalez1** on GitHub · 2026-11-28 07:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/844) On `63b902fe1720`, a GPU read can see a later CPU-source copy to the same destination. This reproduces across submissions and between two reads in a single command list. All inputs are synthetic. The adapter was an RTX 5060 8 GB on Windows 11, driver 621.40, using a release MSVC build. | Reproduction | Expected | Observed on main | | --- | --- | --- | | Three submissions, 256 bytes each, one-sided D3D12 L0 backing | Each read returns its submission’s payload | The first byte of each of the first two reads matched the third submission in every round. 36 of 54 readbacks were wrong across three fresh processes. | | Same test with two-sided L0 backing | Same three payloads | 0 of 54 wrong. Refusing new snapshot allocations after the spare-pool lookup brought the failure back in 36 of 54. | | One list, two guest `CopyBufferRegion` calls, each followed by GPU readback, 8 MiB + 256 bytes per copy | First read `0x21`, second `0x51` throughout | Both began with `0x51`. The second read matched in full. This also happened with two-sided backing and successful snapshots. The 256-byte command-position control returned both expected values. | The cross-submission test holds the direct queue on a fence until all three submissions return. A five-second watchdog fails the test if submitting waits for the queue. The single-list test needs no fence gate. It checks the selected copy path and the bytes across both readback ranges. `Step::Copy` changes guest memory while preparing the submission. On a one-sided shadow a refresh can overwrite the mapping an earlier GPU command will read. Two-sided shadows normally preserve a submission’s input, but when `send::take` returns `None`, `card_before` reads from reusable staging. Within a single list both deferred writes run before the upload prelude and native list, so a submission-owned snapshot can contain only the second value. [Deferred execution](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/63b902fe1720a5188ee79d94a88c8de0470f6349/crates/victory-gpu/src/host.rs#L8107) · [Upload prelude](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/63b902fe1720a5188ee79d94a88c8de0470f6349/crates/victory-gpu/src/host.rs#L4822) An earlier PC-memory failure was mentioned in [closed PR #119](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/119). I reproduced these cases on Foxhound `3d52ac8a978b` and with [PR #60](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/60) applied to main and enabled. That PR’s own copy-queue readback and retirement test passed. PRs #34, #194 and #641 also retained these failures in the same hardware tests. With three submissions in flight, the owned upload buffers peaked at 24 MiB for 256-byte copies and 48 MiB for the 8 MiB + 256-byte workload. ### Reproduce on Windows Save the test-only diff below as `copy-ordering-reproducer.patch` and apply it to `63b902fe1720` with `git apply`. Run the commands in a fresh PowerShell with the project’s Rust/MSVC prerequisites. ```powershell $env:VICTORY_RELAY = '2' $env:VICTORY_RELAY_COPY = '1' function Run-CopyTest($name) { cargo test --locked --release -p victory-gpu --lib "host::upcheck::tests::$name" -- --exact --ignored --nocapture --test-threads=1 } Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory' Run-CopyTest 'two_public_copies_in_the_same_list' $env:VICTORY_CARD_ALL = '1' $env:VICTORY_CARD_BUFFERS_MB = '0' Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory' Run-CopyTest 'two_public_copies_in_the_same_list' $env:COPY_PROBE_REFUSE_FRESH_UPLOAD = '1' Run-CopyTest 'each_submission_reads_its_own_copy_in_pc_memory' ``` The refusal switch exists only in the test build and leaves the spare pool available. For the small single-list control, set `COPY_PROBE_BYTES=256` and `COPY_PROBE_PLACED=1` before running that test. OpenAI Codex provided AI assistance by preparing the reproducer, running the hardware tests, and drafting this report. <details> <summary>Test-only regression patch</summary> ```diff diff --git a/crates/victory-gpu/src/host/send.rs b/crates/victory-gpu/src/host/send.rs index 68e9967..e0d627c 100644 --- a/crates/victory-gpu/src/host/send.rs +++ b/crates/victory-gpu/src/host/send.rs @@ -143,6 +143,11 @@ fn memory(host: &Host, size: u64) -> Option<Memory> { return Some(spare.swap_remove(i)); } } + #[cfg(test)] + if std::env::var_os("COPY_PROBE_REFUSE_FRESH_UPLOAD").is_some() { + eprintln!("synthetic fresh snapshot allocation refusal: {size} bytes"); + return None; + } // By doubles, so that the next of about this size finds it: what // submissions send differs from frame to frame. let size = size.max(8 << 20).next_power_of_two(); diff --git a/crates/victory-gpu/src/host/upcheck.rs b/crates/victory-gpu/src/host/upcheck.rs index 63e8cd4..c16d769 100644 --- a/crates/victory-gpu/src/host/upcheck.rs +++ b/crates/victory-gpu/src/host/upcheck.rs @@ -913,19 +913,146 @@ mod tests { assert!(first <= 6 && back[first..].iter().all(|b| *b), "{back:?}"); } - /// The title copies another value to the same bytes in each of three - /// submissions, and each has a draw (a copy here) that reads them. The - /// card is busy meanwhile, so all three are prepared before the first - /// runs: each must read its own. - fn each_reads_its_own(len: usize, resource: usize, carded: bool) { - let Some(host) = host() else { - return; - }; + /// Hold the direct queue until all CPU submissions return. Release it + /// even if preparation blocks or unwinds, so a failure can be reported. + fn while_queue_waits(host: &Host, submit: impl FnOnce()) -> bool { + // SAFETY: a fresh fence for this round, kept alive until signalled. + let gate: ID3D12Fence = unsafe { host.device.CreateFence(0, D3D12_FENCE_FLAG_NONE) }.unwrap(); + std::thread::scope(|threads| { + let (ready, release) = std::sync::mpsc::channel(); + let fence = &gate; + let watchdog = threads.spawn(move || { + let submitted = release.recv_timeout(std::time::Duration::from_secs(5)).is_ok(); + // SAFETY: only this thread signals the gate. + unsafe { fence.Signal(1) }.unwrap(); + submitted + }); + // SAFETY: a GPU-side wait on a live fence. The watchdog can + // release it independently of this thread and the host queue. + unsafe { host.queue.Wait(&gate, 1) }.unwrap(); + submit(); + let _ = ready.send(()); + watchdog.join().unwrap() + }) + } + + /// Two CPU-owned copies and their GPU reads in the same public list. + #[test] + #[ignore = "synthetic ordering probe in its own process"] + fn two_public_copies_in_the_same_list() { + use crate::object::{S_OK, This, guid, slot}; + let host = host().expect("D3D12 host"); + let size: usize = std::env::var("COPY_PROBE_BYTES") + .map_or((8 << 20) + 256, |v| v.parse().expect("copy size in bytes")); + let placed = std::env::var("COPY_PROBE_PLACED").as_deref() == Ok("1"); + let null = std::ptr::null(); + let alloc_id = guid( + 0x6102dee4, + 0xaf59, + 0x4b09, + [0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24], + ); + let list_id = guid( + 0x5b160d0f, + 0xac1b, + 0x4185, + [0x8b, 0xa8, 0xb3, 0xae, 0x42, 0xa5, 0xa4, 0x55], + ); + let (mut allocator, mut list) = (null, null); + assert_eq!( + crate::list::create_allocator(null, 0, &alloc_id, &mut allocator), + S_OK + ); + assert_eq!( + crate::list::create_list(null, 0, 0, allocator, null, &list_id, &mut list), + S_OK + ); + let source = crate::resource::test_buffer((2 * size) as u64); + let destination = crate::resource::test_buffer((size + 8192).max(256 << 10) as u64); + let (src, _) = crate::resource::buffer_bytes(source).unwrap(); + let (dst, width) = crate::resource::buffer_bytes(destination).unwrap(); + let shadow = crate::shadow::find(dst as u64, width).unwrap(); + let (output, mapped) = host.shared_buffer((2 * size) as u64).unwrap(); + let init = host.new_list().unwrap(); + shadow.refresh(&init, dst as u64, width); + init.close(); + host.execute_own(&init); + settle_now(WHY_SYNC); + let copy = slot::<extern "system" fn(This, This, u64, This, u64, u64)>(list, 0x78); + for v in 0..2 { + // SAFETY: live, disjoint and in bounds. Both initializations precede submission. + unsafe { + std::ptr::write_bytes(src.add(v * size), 0x21 + 0x30 * v as u8, size); + } + copy( + list, + destination, + 8192, + source, + (v * size) as u64, + size as u64, + ); + let native = crate::list::host_list(list).unwrap(); + read_out(native, &shadow, 8192, size, (&output, (v * size) as u64)); + } + let native = crate::list::host_list(list).unwrap(); + { + let d = native.deferred(); + assert_eq!( + d.copies + .iter() + .filter(|s| matches!(s, Step::Placed(_))) + .count(), + if placed { 2 } else { 0 } + ); + assert_eq!( + d.copies + .iter() + .filter(|s| matches!(s, Step::Copy(..))) + .count(), + if placed { 0 } else { 2 } + ); + } + assert_eq!( + slot::<extern "system" fn(This) -> i32>(list, 0x48)(list), + S_OK + ); + host.execute_own(native); + settle_now(WHY_SYNC); + // SAFETY: both device copies completed and the mapping is live. + let bytes = unsafe { std::slice::from_raw_parts(mapped, 2 * size) }; + eprintln!( + "SAME_LIST size={size} placed={placed} paired={} first={:#04x} second={:#04x}", + shadow.carded(), + bytes[0], + bytes[size] + ); + let first = bytes[..size].iter().position(|&v| v != 0x21); + let second = bytes[size..].iter().position(|&v| v != 0x51); + for object in [list, allocator, source, destination] { + slot::<extern "system" fn(This) -> u32>(object, 0x10)(object); + } + assert_eq!( + (first, second), + (None, None), + "first wrong byte offsets in the two GPU reads" + ); + } + + /// Each submission copies a distinct payload to the same bytes and + /// then reads it. All three are prepared before the GPU may read any. + fn each_reads_its_own(len: usize, resource: usize, pc_memory: bool) { + let host = host().expect("this opt-in test requires a D3D12 host"); let (title, start, shadow) = title_of(resource, true, len); - assert_eq!(shadow.carded(), carded, "where the copy is"); - let slow = Slow::new(host); + let carded = !pc_memory || std::env::var_os("VICTORY_CARD_ALL").is_some_and(|v| v == "1"); + assert_eq!(shadow.carded(), carded, "whether the copy has two sides"); + if pc_memory { + let mut heap = D3D12_HEAP_PROPERTIES::default(); + // SAFETY: a live committed resource and a valid output. + unsafe { shadow.buffer.GetHeapProperties(Some(&mut heap), None) }.unwrap(); + assert_eq!(heap.MemoryPoolPreference, D3D12_MEMORY_POOL_L0, "use VICTORY_CARD_BUFFERS_MB=0 with two sides"); + } let (out, out_data) = host.shared_buffer(1 << 16).unwrap(); - let mut lists = Vec::new(); const AT: usize = 8192; // All there once. let all = host.new_list().unwrap(); @@ -933,40 +1060,42 @@ mod tests { all.close(); host.execute_own(&all); settle_now(WHY_SYNC); - lists.push(all); let mut wrong = Vec::new(); for round in 0..6u8 { - for v in 0..3u8 { - title[65_536 + usize::from(v) * 256..][..256].fill(round * 16 + v + 1); - } - let busy = host.new_list().unwrap(); - slow.record(&busy, 40); - busy.close(); - host.execute_own(&busy); - lists.push(busy); + let mut lists = Vec::with_capacity(3); for v in 0..3usize { + let source = 65_536 + v * 256; + for (offset, byte) in title[source..source + 256].iter_mut().enumerate() { + *byte = (round * 16 + v as u8 + 1).wrapping_add(offset as u8); + } let list = host.new_list().unwrap(); - list.defer_copy((start + AT) as *mut u8, (start + 65_536 + v * 256) as *const u8, 256); + list.defer_copy((start + AT) as *mut u8, (start + source) as *const u8, 256); shadow.refresh(&list, (start + AT) as u64, 256); // SAFETY: an open list; live buffers. unsafe { list.list.CopyBufferRegion(&out, (v * 256) as u64, &shadow.buffer, AT as u64, 256); } list.close(); - host.execute_own(&list); lists.push(list); } + let mut asynchronous = true; + let submitted = while_queue_waits(host, || { + for list in &lists { + asynchronous &= host.execute_own(list) != 0; + } + }); settle_now(WHY_SYNC); + assert!(submitted && asynchronous, "all three submissions must return with the direct queue gated"); // SAFETY: a mapping of 64 KiB; the copies into it have run. let read = unsafe { std::slice::from_raw_parts(out_data, 768) }; - for v in 0..3u8 { - let got = read[usize::from(v) * 256]; - if got != round * 16 + v + 1 { - wrong.push((round, v, got - round * 16)); + for (v, bytes) in read.chunks_exact(256).enumerate() { + let first = round * 16 + v as u8 + 1; + if let Some((offset, &got)) = bytes.iter().enumerate().find(|&(i, &b)| b != first.wrapping_add(i as u8)) { + wrong.push((round, v, offset, first.wrapping_add(offset as u8), got)); } } } - eprintln!("read another submission's value (round, submission, whose + 1): {wrong:?}"); + eprintln!("wrong copies (round, submission, offset, expected, observed): {wrong:?}"); let stale = STALE.lock().unwrap_or_else(|e| e.into_inner()); let found = stale.get(&shadow.span()).map_or(0, |s| s.words); eprintln!("the check at sends found {found} words"); @@ -979,13 +1108,13 @@ mod tests { #[test] #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 and a process of its own"] fn each_submission_reads_its_own_copy_on_the_card() { - each_reads_its_own(LEN, 0x7777, true); + each_reads_its_own(LEN, 0x7777, false); } #[test] - #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 and a process of its own"] + #[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 in its own process; with VICTORY_CARD_ALL=1 also set VICTORY_CARD_BUFFERS_MB=0"] fn each_submission_reads_its_own_copy_in_pc_memory() { - each_reads_its_own(256 << 10, 0x8888, std::env::var_os("VICTORY_CARD_ALL").is_some_and(|v| v == "1")); + each_reads_its_own(256 << 10, 0x8888, true); } /// What a draw of `list` reads at `at`: comes to `out`. ``` </details>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:28:47 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 07:36 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-28 07:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/844#issuecomment-7236049061) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 19:48 UTC · original

Closing this one because it was reported on a build from before v2026.11.28.03 (more than 4 releases ago) and has had no activity since v2026.11.29.01. A lot has changed since then.

If it still happens on the latest release, please open a new issue with the play log and crashes.log from that run. Thanks for reporting!

**@⁠trustno1-coder** on GitHub · 2026-11-29 19:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/844#issuecomment-7261576355) Closing this one because it was reported on a build from before v2026.11.28.03 (more than 4 releases ago) and has had no activity since v2026.11.29.01. A lot has changed since then. If it still happens on the [latest release](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/latest), please open a new issue with the play log and crashes.log from that run. Thanks for reporting!
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#844
No description provided.