GPU: honor command-list 64-bit memory waits without blocking submissions (#700) #1388

Open
github-bot wants to merge 1 commit from github-bot/gh-1388 into main AGit
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:41 UTC · original
wbkepler:gpu/cmdlist-memory-wait → main · +1118 −105 · 5 files · 1 commits · open

Summary

Rebased cleanly onto upstream/main (ffe310e):

  • Implements 64-bit command-list memory waits (wait_value64, slot 72) with full 64-bit D3D12_COMPARISON_FUNC evaluation, Acquire/Release memory ordering, and segmented HostList/CpuOp execution.
  • Pre-wait segments execute immediately while unsatisfied waits defer only the post-wait tail (and subsequent submissions/signals on that queue) to a lazily spawned victory-gpu-wait scheduler so submitting CPU threads never deadlock on consumer-first submission orders.
  • Preserves graphics state across segments via draw::State::rebind_segment, clears fresh_tables per segment, and ties upload/HostList/dynamic-slot lifetimes to Arc-retained segments.
  • Adds 3 deterministic tests in queue::tests covering full 64-bit comparison ops, both producer-first and consumer-first 2-queue ordering (#700), and mid-list pre-wait work preservation.

Verification

  • cargo clippy -p victory-gpu --all-targets & -p victory --features diagnostics --all-targets — passed
  • cargo test -p victory-gpu — passed
  • VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib queue — passed
  • cargo xtask policy — passed
**@⁠wbkepler** on GitHub · 2026-11-24 17:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1388) `wbkepler:gpu/cmdlist-memory-wait` → `main` · +1118 −105 · 5 files · 1 commits · open ## Summary Rebased cleanly onto `upstream/main` (`ffe310e`): - Implements 64-bit command-list memory waits (`wait_value64`, slot 72) with full 64-bit `D3D12_COMPARISON_FUNC` evaluation, `Acquire`/`Release` memory ordering, and segmented `HostList`/`CpuOp` execution. - Pre-wait segments execute immediately while unsatisfied waits defer only the post-wait tail (and subsequent submissions/signals on that queue) to a lazily spawned `victory-gpu-wait` scheduler so submitting CPU threads never deadlock on consumer-first submission orders. - Preserves graphics state across segments via `draw::State::rebind_segment`, clears `fresh_tables` per segment, and ties upload/`HostList`/dynamic-slot lifetimes to `Arc`-retained segments. - Adds 3 deterministic tests in `queue::tests` covering full 64-bit comparison ops, both producer-first and consumer-first 2-queue ordering (#700), and mid-list pre-wait work preservation. ## Verification - `cargo clippy -p victory-gpu --all-targets` & `-p victory --features diagnostics --all-targets` — passed - `cargo test -p victory-gpu` — passed - `VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib queue` — passed - `cargo xtask policy` — passed
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:00 +00:00
Author
Owner

@⁠HenriqueSBueno on GitHub · 2026-11-24 19:22 UTC · original

Field data for this PR from a retail run (RTX 3080, Series S profile, main @⁠ffe310e + #189 + #89 + this PR, diag build).

I added a counter at the point where this PR defers a list tail behind an unsatisfied 64-bit memory wait, and a queue-level ID3D12CommandQueue::Wait implemented as the same kind of wait on the fence's value (GREATER_EQUAL) through this PR's pending stream:

wait kind times it held work back in ~5 min
command-list 64-bit memory wait (this PR) 32+ (counter logged at powers of two; last line held=32)
queue fence wait (Queue::Wait) 0

So on this title the producer/consumer ordering goes through command-list memory waits, not queue fence waits. Without this PR those consumers ran before their producers. That matches #700 and the "GPU waits on itself in the wrong order" explanation for the black world.

This run did not light the world by itself: the stack is plain main without translator changes (603 shaders refused, so the lighting compute passes are still dropped), and the GPU was removed at ~300 s after reaching the world. The next step on our side is to combine this PR with our translator changes. Background and the related hypotheses are in #1317 (H-6.14, H-6.7).

AI-assisted (Claude Code)

**@⁠HenriqueSBueno** on GitHub · 2026-11-24 19:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1388#issuecomment-7142011114) Field data for this PR from a retail run (RTX 3080, Series S profile, `main` @⁠ffe310e + #189 + #89 + this PR, diag build). I added a counter at the point where this PR defers a list tail behind an unsatisfied 64-bit memory wait, and a queue-level `ID3D12CommandQueue::Wait` implemented as the same kind of wait on the fence's value (GREATER_EQUAL) through this PR's pending stream: | wait kind | times it held work back in ~5 min | |---|---| | command-list 64-bit memory wait (this PR) | 32+ (counter logged at powers of two; last line `held=32`) | | queue fence wait (`Queue::Wait`) | 0 | So on this title the producer/consumer ordering goes through command-list memory waits, not queue fence waits. Without this PR those consumers ran before their producers. That matches #700 and the "GPU waits on itself in the wrong order" explanation for the black world. This run did not light the world by itself: the stack is plain `main` without translator changes (603 shaders refused, so the lighting compute passes are still dropped), and the GPU was removed at ~300 s after reaching the world. The next step on our side is to combine this PR with our translator changes. Background and the related hypotheses are in #1317 (H-6.14, H-6.7). AI-assisted (Claude Code)
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-24 20:55 UTC · original

Tested in the title on a 6 GB / 16 GB laptop (RTX 3050, diag build, title 1.0.2.1, story load). Full table: #700.

  • On main ffe310e + #208 + the wave64 stack + #452 + #579 + #431, this PR (9d84135, clean merge) lost the device in 2 of 2 runs without DRED: at 2:46 and 3:29, 0x887A0007, after submissions of 29 and 3 lists. The same tree without it ran 7:26 and 8:21 (2 runs) to a title stop, with no removal.
  • A run with VICTORY_D3D12_DRED=1 did not reproduce it (9:29, no removal), so it looks timing-dependent, and I have no DRED breadcrumbs for it.
  • World frames are about twice as long: 5.8 s against 2.6–3.0 s on the same tree.
  • Each unmet wait makes a new HostList through host.new_list() (two allocators, two lists). This title records thousands of waits per load, so reusing segment lists might be where the time goes. Not measured separately.

AI use: Claude Code (Claude Opus 5.5) ran the title on my machine and drafted this; results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-24 20:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/1388#issuecomment-7144240798) Tested in the title on a 6 GB / 16 GB laptop (RTX 3050, diag build, title 1.0.2.1, story load). Full table: https://git.gtahub.st/github/Marvisak--VIctory/issues/700. - On `main` `ffe310e` + #208 + the wave64 stack + #452 + #579 + #431, this PR (`9d84135`, clean merge) **lost the device in 2 of 2 runs** without DRED: at 2:46 and 3:29, `0x887A0007`, after submissions of 29 and 3 lists. The same tree without it ran 7:26 and 8:21 (2 runs) to a title stop, with no removal. - A run with `VICTORY_D3D12_DRED=1` did not reproduce it (9:29, no removal), so it looks timing-dependent, and I have no DRED breadcrumbs for it. - **World frames are about twice as long:** 5.8 s against 2.6–3.0 s on the same tree. - Each unmet wait makes a new `HostList` through `host.new_list()` (two allocators, two lists). This title records thousands of waits per load, so reusing segment lists might be where the time goes. Not measured separately. AI use: Claude Code (Claude Opus 5.5) ran the title on my machine and drafted this; results are from the runs described.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-25 01:14 UTC · original

Rebased onto main 42363ab6 and ran it on AMD. It conflicted in 9 places; four of them needed more than picking a side. #700 is still open on main (wait_value is still the empty stub), so this seemed worth carrying forward.

What the rebase had to change

  • list.rs uploads. Main replaced the Vec<u8> upload blocks with Upload (VirtualAlloc'd, not Clone), so Arc<Vec<Vec<u8>>> plus Arc::make_mut no longer works. Uploads are now Vec<Arc<Upload>> (pub(crate) type Uploads).
    • A snapshot clones the Arcs, and reset just clears the list's own Vec.
    • A pending wait keeps the blocks it recorded against alive.
  • draw.rs dynamic slots. This PR moves them from State to the host list segment (keep_dynamic). Main has since added two more users of State::dynamic: root views (root_view, ROOT_VIEW_RUN) and clear_unordered. Both now call list.keep_dynamic(..).
  • Two follow-ons of that move:
    • rebind_segment now also resets root_run and root_slots. Otherwise a new segment keeps handing out slots from a run the sealed segment owns, and those slots are freed when that segment retires.
    • Deferred::drop gives slots of our own view heap (memory::OURS) back to memory::heap(), as main's old State::drop did. descriptor::release_dynamic doesn't know that heap.
  • Other conflicts:
    • list.rs create_list keeps main's initial set_pipeline.
    • reset keeps pipeline::bound.
    • external.rs uses the now Arc-returning host_list (made pub(crate)).
    • host.rs keeps main's frame dump and then calls notify_memory_waiters, after the submitted lock is dropped.
    • draw.rs keeps main's diagnostics lines.

Results on 42363ab6 + this, RX 6750 XT (RDNA2), Windows 11, Rust 1.98.1 MSVC:

  • The wait tests, including command_list_memory_wait_orders_producer_and_consumer_both_ways and mid_list_memory_wait_preserves_pre_wait_work_and_releases_post_wait_tail (the producer-first and consumer-first cases from #700): 8 passed.
  • victory-gpu: 144 passed, 0 failed, twice. Main alone: 141.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

Not covered: how this interacts with #1828 (asynchronous submissions). Both rework host.rs submission, so whichever lands second will need a rebase. Not tested with the title.

The rebase on top of a plain git merge -X theirs of this PR into 42363ab6 (what differs from taking this PR's side of every conflict)
--- a/crates/victory-gpu/src/draw.rs
+++ b/crates/victory-gpu/src/draw.rs
@@ -96,6 +96,19 @@
     root_run: (usize, u32, u32),
 }
 
+/// The key of our own view heap (`crate::memory::heap`) among the title's.
+const MEMORY_HEAP: usize = crate::memory::OURS;
+
+/// Dynamic slots taken at a time for root views.
+const ROOT_VIEW_RUN: u32 = 256;
+
+/// Dynamic slots taken for root views ([`State::root_view`]) since the last
+/// call.
+pub(crate) fn take_root_view_slots() -> u64 {
+    ROOT_VIEW_SLOTS.swap(0, Ordering::Relaxed)
+}
+static ROOT_VIEW_SLOTS: AtomicU64 = AtomicU64::new(0);
+
 /// Draws recorded on the host GPU since the last frame line.
 static DRAWN: AtomicU64 = AtomicU64::new(0);
 
@@ -211,8 +224,11 @@
         self.host_pipeline = 0;
         self.host_roots = [0; 2];
         self.host_heaps = [0; 2];
-        // Fresh tables point at CBV scratch owned by the sealed segment.
+        // Fresh tables point at CBV scratch owned by the sealed segment, and
+        // root views at dynamic slots it holds.
         self.fresh_tables.clear();
+        self.root_run = Default::default();
+        self.root_slots.clear();
         if self.topology != 0 {
             self.set_topology(list, self.topology);
         }
@@ -468,10 +484,8 @@
             return false;
         };
         if p.compute || p.mesh != mesh {
-            once!(
-                mesh,
-                "a draw or mesh dispatch with another kind of pipeline"
-            );
+            once!(mesh, "a draw or mesh dispatch with another kind of pipeline");
+            not_run("another kind of pipeline");
             return false;
         }
         if !self.bind(list, p, false) {
@@ -825,7 +839,8 @@
                 once!("no dynamic slots for root views: dropped");
                 return None;
             };
-            self.dynamic.push((key, first, ROOT_VIEW_RUN));
+            // The host list segment holds them until it has run.
+            list.keep_dynamic(key, first, ROOT_VIEW_RUN);
             self.root_run = (key, first, first + ROOT_VIEW_RUN);
         }
         let index = self.root_run.1;
@@ -887,8 +902,7 @@
         let Some(slot) = visible.dynamic(1) else {
             return;
         };
-        self.dynamic
-            .push((std::ptr::from_ref(heap) as usize, slot, 1));
+        list.keep_dynamic(std::ptr::from_ref(heap) as usize, slot, 1);
         visible.make_at(slot, &view);
         let at = host.cpu_view();
         let Some(resource) = crate::descriptor::host::make_view(&view, at) else {
@@ -1617,10 +1631,15 @@
             crate::indirect::done(list, &args.buffer);
             #[cfg(feature = "diagnostics")]
             match crate::pipeline::host_pipeline(self.pipeline as This) {
-                None => crate::pipeline::note_drop(self.pipeline as This),
+                None => {
+                    crate::pipeline::note_drop(self.pipeline as This);
+                    list.note_op(|| format!("DROPPED indirect kind {kind} (no host pipeline) {}", crate::pipeline::shaders_of(pipeline)));
+                }
                 Some(p) => why(&format!(
-                    "prepare failed (compute {}, mesh {})",
-                    p.compute, p.mesh
+                    "prepare failed (compute {}, mesh {}): {}",
+                    p.compute,
+                    p.mesh,
+                    NOT_RUN.with(|w| w.replace(""))
                 )),
             }
             return false;
@@ -1769,10 +1788,10 @@
         crate::resource::host_resource(r).map(|t| {
             // SAFETY: a live resource.
             let d = unsafe { t.GetDesc() };
-            format!(
-                "{}x{} f{} flags {:#x}",
-                d.Width, d.Height, d.Format.0, d.Flags.0
-            )
+            // Its console memory: another view of it (a placed one) is
+            // another host texture.
+            let at = crate::resource::texture_memory(r).map_or(0, |(p, _)| p as u64);
+            format!("{}x{} f{} flags {:#x} mem {at:#x}", d.Width, d.Height, d.Format.0, d.Flags.0)
         })
     };
     // Small buffers (exposure, counters): their title memory now, as floats.
--- a/crates/victory-gpu/src/external.rs
+++ b/crates/victory-gpu/src/external.rs
@@ -26,7 +26,7 @@
 ) -> Option<(ID3D12Resource, u32)> {
     let host = crate::list::host_list(list)?;
     let texture = crate::resource::host_resource(resource)?.clone();
-    crate::list::ensure_state(host, resource, state);
+    crate::list::ensure_state(&host, resource, state);
     let state = crate::host::legal_state(&texture, state);
     Some((texture, state))
 }
--- a/crates/victory-gpu/src/host.rs
+++ b/crates/victory-gpu/src/host.rs
@@ -693,7 +693,11 @@
 impl Drop for Deferred {
     fn drop(&mut self) {
         for &(heap, first, n) in &self.dynamic {
-            crate::descriptor::release_dynamic(heap, first, n);
+            // Our own view heap (root views of title memory) has its own slots.
+            match (heap, crate::memory::heap()) {
+                (crate::memory::OURS, Some(ours)) => ours.release(first, n),
+                _ => crate::descriptor::release_dynamic(heap, first, n),
+            }
         }
     }
 }
@@ -1021,7 +1025,23 @@
         // The submission has run and the next waits for our lock.
         release_retired();
         self.log_messages();
+        #[cfg(feature = "diagnostics")]
+        let sub = *submitted;
         drop(submitted);
+        // A listed frame: what this submission's lists drew, as it is now
+        // (the dumps submit lists of their own).
+        #[cfg(feature = "diagnostics")]
+        if traced {
+            let mut targets: Vec<(usize, String)> = Vec::new();
+            for r in runs {
+                for t in r.targets.lock().unwrap_or_else(|e| e.into_inner()).iter() {
+                    if !targets.iter().any(|x| x.0 == t.0) {
+                        targets.push(t.clone());
+                    }
+                }
+            }
+            crate::capture::dump_submission(sub, &targets);
+        }
         crate::queue::notify_memory_waiters();
     }
 
--- a/crates/victory-gpu/src/list.rs
+++ b/crates/victory-gpu/src/list.rs
@@ -104,7 +104,7 @@
     #[cfg(windows)]
     Host {
         list: Arc<crate::host::HostList>,
-        uploads: Arc<Vec<Vec<u8>>>,
+        uploads: Uploads,
     },
     Cpu(Vec<CpuOp>),
     Wait(MemoryWait),
@@ -207,7 +207,7 @@
     /// [`allocate_upload`], kept until the list is reset; the host list
     /// segments the calls record into (decision 0007, split at 64-bit memory
     /// waits), and the draw state the title set.
-    uploads: Mutex<Arc<Vec<Vec<u8>>>>,
+    uploads: Mutex<Uploads>,
     #[cfg(windows)]
     host: Mutex<Option<Arc<crate::host::HostList>>>,
     #[cfg(windows)]
@@ -233,7 +233,7 @@
 /// The current open host list segment behind a title list, if there is a
 /// host GPU.
 #[cfg(windows)]
-fn host_list(this: This) -> Option<Arc<crate::host::HostList>> {
+pub(crate) fn host_list(this: This) -> Option<Arc<crate::host::HostList>> {
     if this.is_null() {
         return None;
     }
@@ -363,7 +363,7 @@
         compute_root_headers: [0; 128],
         pipeline_shadow: [0; 8],
         newer: [0; 256],
-        uploads: Mutex::new(Arc::new(Vec::new())),
+        uploads: Mutex::new(Vec::new()),
         #[cfg(windows)]
         host: Mutex::new(crate::host::host().and_then(|h| match h.new_list() {
             Ok(list) => Some(Arc::new(list)),
@@ -375,7 +375,11 @@
         #[cfg(windows)]
         segments: Mutex::new(Vec::new()),
         #[cfg(windows)]
-        state: Default::default(),
+        state: {
+            let mut state = crate::draw::State::default();
+            state.set_pipeline(pipeline);
+            std::sync::Mutex::new(state)
+        },
         cpu_segments: Mutex::new(vec![(Vec::new(), None)]),
     });
     let hr = object::hand_out(LIST, list, iid, &LIST_IIDS, out);
@@ -421,13 +425,8 @@
     // SAFETY: the title passes one of our lists.
     let list = unsafe { &*this.cast::<List>() };
     {
-        let mut uploads = list.uploads.lock().unwrap_or_else(|e| e.into_inner());
-        if let Some(v) = Arc::get_mut(&mut *uploads) {
-            v.clear();
-        } else {
-            // A pending wait still references the old upload buffers; detach cleanly.
-            *uploads = Arc::new(Vec::new());
-        }
+        // A pending wait's snapshot keeps its own references to the blocks.
+        list.uploads.lock().unwrap_or_else(|e| e.into_inner()).clear();
     }
     {
         let mut cpu = list.cpu_segments.lock().unwrap_or_else(|e| e.into_inner());
@@ -461,8 +460,7 @@
             .unwrap_or_else(|e| e.into_inner())
             .reset(pipeline);
     }
-    #[cfg(not(windows))]
-    let _ = pipeline;
+    crate::pipeline::bound(pipeline);
     S_OK
 }
 
@@ -1109,9 +1107,7 @@
     let at = unsafe { start.add(start.align_offset(align)) };
     // SAFETY: the title passes one of our lists.
     let uploads = unsafe { &(*this.cast::<List>()).uploads };
-    // Moving the vector keeps its heap block where it is.
-    let mut guard = uploads.lock().unwrap_or_else(|e| e.into_inner());
-    Arc::make_mut(&mut *guard).push(block);
+    uploads.lock().unwrap_or_else(|e| e.into_inner()).push(Arc::new(block));
     at
 }
 
@@ -1120,7 +1116,11 @@
 /// find title memory by address (`crate::memory`; the console's GPU
 /// addresses have 40 bits), and is a buffer of its own to the host copies
 /// (`crate::shadow`), so its copy is exactly it.
-struct Upload {
+/// Upload blocks a list's commands read, shared with the snapshots of its
+/// segments a pending wait holds.
+pub(crate) type Uploads = Vec<Arc<Upload>>;
+
+pub(crate) struct Upload {
     #[cfg(windows)]
     at: usize,
     #[cfg(windows)]
--- a/crates/victory-gpu/src/queue.rs
+++ b/crates/victory-gpu/src/queue.rs
@@ -33,7 +33,7 @@
 }
 
 #[cfg(windows)]
-type HostSegment = (Arc<crate::host::HostList>, Arc<Vec<Vec<u8>>>);
+type HostSegment = (Arc<crate::host::HostList>, crate::list::Uploads);
 
 /// One queued item on a guest command queue waiting behind an unsatisfied
 /// 64-bit command-list memory wait.

Unit tests only, no game files. AI-assisted (Claude rebased it; I ran it on my machine).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-25 01:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1388#issuecomment-7149341382) Rebased onto main 42363ab6 and ran it on AMD. It conflicted in 9 places; four of them needed more than picking a side. #700 is still open on main (`wait_value` is still the empty stub), so this seemed worth carrying forward. **What the rebase had to change** - **`list.rs` uploads.** Main replaced the `Vec<u8>` upload blocks with `Upload` (VirtualAlloc'd, not `Clone`), so `Arc<Vec<Vec<u8>>>` plus `Arc::make_mut` no longer works. Uploads are now `Vec<Arc<Upload>>` (`pub(crate) type Uploads`). - A snapshot clones the `Arc`s, and reset just clears the list's own `Vec`. - A pending wait keeps the blocks it recorded against alive. - **`draw.rs` dynamic slots.** This PR moves them from `State` to the host list segment (`keep_dynamic`). Main has since added two more users of `State::dynamic`: root views (`root_view`, `ROOT_VIEW_RUN`) and `clear_unordered`. Both now call `list.keep_dynamic(..)`. - **Two follow-ons of that move:** - `rebind_segment` now also resets `root_run` and `root_slots`. Otherwise a new segment keeps handing out slots from a run the sealed segment owns, and those slots are freed when that segment retires. - `Deferred::drop` gives slots of our own view heap (`memory::OURS`) back to `memory::heap()`, as main's old `State::drop` did. `descriptor::release_dynamic` doesn't know that heap. - **Other conflicts:** - `list.rs` `create_list` keeps main's initial `set_pipeline`. - `reset` keeps `pipeline::bound`. - `external.rs` uses the now `Arc`-returning `host_list` (made `pub(crate)`). - `host.rs` keeps main's frame dump and then calls `notify_memory_waiters`, after the `submitted` lock is dropped. - `draw.rs` keeps main's diagnostics lines. **Results** on 42363ab6 + this, RX 6750 XT (RDNA2), Windows 11, Rust 1.98.1 MSVC: - The wait tests, including `command_list_memory_wait_orders_producer_and_consumer_both_ways` and `mid_list_memory_wait_preserves_pre_wait_work_and_releases_post_wait_tail` (the producer-first and consumer-first cases from #700): 8 passed. - victory-gpu: 144 passed, 0 failed, twice. Main alone: 141. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. **Not covered:** how this interacts with #1828 (asynchronous submissions). Both rework `host.rs` submission, so whichever lands second will need a rebase. Not tested with the title. <details><summary>The rebase on top of a plain <code>git merge -X theirs</code> of this PR into 42363ab6 (what differs from taking this PR's side of every conflict)</summary> ```diff --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -96,6 +96,19 @@ root_run: (usize, u32, u32), } +/// The key of our own view heap (`crate::memory::heap`) among the title's. +const MEMORY_HEAP: usize = crate::memory::OURS; + +/// Dynamic slots taken at a time for root views. +const ROOT_VIEW_RUN: u32 = 256; + +/// Dynamic slots taken for root views ([`State::root_view`]) since the last +/// call. +pub(crate) fn take_root_view_slots() -> u64 { + ROOT_VIEW_SLOTS.swap(0, Ordering::Relaxed) +} +static ROOT_VIEW_SLOTS: AtomicU64 = AtomicU64::new(0); + /// Draws recorded on the host GPU since the last frame line. static DRAWN: AtomicU64 = AtomicU64::new(0); @@ -211,8 +224,11 @@ self.host_pipeline = 0; self.host_roots = [0; 2]; self.host_heaps = [0; 2]; - // Fresh tables point at CBV scratch owned by the sealed segment. + // Fresh tables point at CBV scratch owned by the sealed segment, and + // root views at dynamic slots it holds. self.fresh_tables.clear(); + self.root_run = Default::default(); + self.root_slots.clear(); if self.topology != 0 { self.set_topology(list, self.topology); } @@ -468,10 +484,8 @@ return false; }; if p.compute || p.mesh != mesh { - once!( - mesh, - "a draw or mesh dispatch with another kind of pipeline" - ); + once!(mesh, "a draw or mesh dispatch with another kind of pipeline"); + not_run("another kind of pipeline"); return false; } if !self.bind(list, p, false) { @@ -825,7 +839,8 @@ once!("no dynamic slots for root views: dropped"); return None; }; - self.dynamic.push((key, first, ROOT_VIEW_RUN)); + // The host list segment holds them until it has run. + list.keep_dynamic(key, first, ROOT_VIEW_RUN); self.root_run = (key, first, first + ROOT_VIEW_RUN); } let index = self.root_run.1; @@ -887,8 +902,7 @@ let Some(slot) = visible.dynamic(1) else { return; }; - self.dynamic - .push((std::ptr::from_ref(heap) as usize, slot, 1)); + list.keep_dynamic(std::ptr::from_ref(heap) as usize, slot, 1); visible.make_at(slot, &view); let at = host.cpu_view(); let Some(resource) = crate::descriptor::host::make_view(&view, at) else { @@ -1617,10 +1631,15 @@ crate::indirect::done(list, &args.buffer); #[cfg(feature = "diagnostics")] match crate::pipeline::host_pipeline(self.pipeline as This) { - None => crate::pipeline::note_drop(self.pipeline as This), + None => { + crate::pipeline::note_drop(self.pipeline as This); + list.note_op(|| format!("DROPPED indirect kind {kind} (no host pipeline) {}", crate::pipeline::shaders_of(pipeline))); + } Some(p) => why(&format!( - "prepare failed (compute {}, mesh {})", - p.compute, p.mesh + "prepare failed (compute {}, mesh {}): {}", + p.compute, + p.mesh, + NOT_RUN.with(|w| w.replace("")) )), } return false; @@ -1769,10 +1788,10 @@ crate::resource::host_resource(r).map(|t| { // SAFETY: a live resource. let d = unsafe { t.GetDesc() }; - format!( - "{}x{} f{} flags {:#x}", - d.Width, d.Height, d.Format.0, d.Flags.0 - ) + // Its console memory: another view of it (a placed one) is + // another host texture. + let at = crate::resource::texture_memory(r).map_or(0, |(p, _)| p as u64); + format!("{}x{} f{} flags {:#x} mem {at:#x}", d.Width, d.Height, d.Format.0, d.Flags.0) }) }; // Small buffers (exposure, counters): their title memory now, as floats. --- a/crates/victory-gpu/src/external.rs +++ b/crates/victory-gpu/src/external.rs @@ -26,7 +26,7 @@ ) -> Option<(ID3D12Resource, u32)> { let host = crate::list::host_list(list)?; let texture = crate::resource::host_resource(resource)?.clone(); - crate::list::ensure_state(host, resource, state); + crate::list::ensure_state(&host, resource, state); let state = crate::host::legal_state(&texture, state); Some((texture, state)) } --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -693,7 +693,11 @@ impl Drop for Deferred { fn drop(&mut self) { for &(heap, first, n) in &self.dynamic { - crate::descriptor::release_dynamic(heap, first, n); + // Our own view heap (root views of title memory) has its own slots. + match (heap, crate::memory::heap()) { + (crate::memory::OURS, Some(ours)) => ours.release(first, n), + _ => crate::descriptor::release_dynamic(heap, first, n), + } } } } @@ -1021,7 +1025,23 @@ // The submission has run and the next waits for our lock. release_retired(); self.log_messages(); + #[cfg(feature = "diagnostics")] + let sub = *submitted; drop(submitted); + // A listed frame: what this submission's lists drew, as it is now + // (the dumps submit lists of their own). + #[cfg(feature = "diagnostics")] + if traced { + let mut targets: Vec<(usize, String)> = Vec::new(); + for r in runs { + for t in r.targets.lock().unwrap_or_else(|e| e.into_inner()).iter() { + if !targets.iter().any(|x| x.0 == t.0) { + targets.push(t.clone()); + } + } + } + crate::capture::dump_submission(sub, &targets); + } crate::queue::notify_memory_waiters(); } --- a/crates/victory-gpu/src/list.rs +++ b/crates/victory-gpu/src/list.rs @@ -104,7 +104,7 @@ #[cfg(windows)] Host { list: Arc<crate::host::HostList>, - uploads: Arc<Vec<Vec<u8>>>, + uploads: Uploads, }, Cpu(Vec<CpuOp>), Wait(MemoryWait), @@ -207,7 +207,7 @@ /// [`allocate_upload`], kept until the list is reset; the host list /// segments the calls record into (decision 0007, split at 64-bit memory /// waits), and the draw state the title set. - uploads: Mutex<Arc<Vec<Vec<u8>>>>, + uploads: Mutex<Uploads>, #[cfg(windows)] host: Mutex<Option<Arc<crate::host::HostList>>>, #[cfg(windows)] @@ -233,7 +233,7 @@ /// The current open host list segment behind a title list, if there is a /// host GPU. #[cfg(windows)] -fn host_list(this: This) -> Option<Arc<crate::host::HostList>> { +pub(crate) fn host_list(this: This) -> Option<Arc<crate::host::HostList>> { if this.is_null() { return None; } @@ -363,7 +363,7 @@ compute_root_headers: [0; 128], pipeline_shadow: [0; 8], newer: [0; 256], - uploads: Mutex::new(Arc::new(Vec::new())), + uploads: Mutex::new(Vec::new()), #[cfg(windows)] host: Mutex::new(crate::host::host().and_then(|h| match h.new_list() { Ok(list) => Some(Arc::new(list)), @@ -375,7 +375,11 @@ #[cfg(windows)] segments: Mutex::new(Vec::new()), #[cfg(windows)] - state: Default::default(), + state: { + let mut state = crate::draw::State::default(); + state.set_pipeline(pipeline); + std::sync::Mutex::new(state) + }, cpu_segments: Mutex::new(vec![(Vec::new(), None)]), }); let hr = object::hand_out(LIST, list, iid, &LIST_IIDS, out); @@ -421,13 +425,8 @@ // SAFETY: the title passes one of our lists. let list = unsafe { &*this.cast::<List>() }; { - let mut uploads = list.uploads.lock().unwrap_or_else(|e| e.into_inner()); - if let Some(v) = Arc::get_mut(&mut *uploads) { - v.clear(); - } else { - // A pending wait still references the old upload buffers; detach cleanly. - *uploads = Arc::new(Vec::new()); - } + // A pending wait's snapshot keeps its own references to the blocks. + list.uploads.lock().unwrap_or_else(|e| e.into_inner()).clear(); } { let mut cpu = list.cpu_segments.lock().unwrap_or_else(|e| e.into_inner()); @@ -461,8 +460,7 @@ .unwrap_or_else(|e| e.into_inner()) .reset(pipeline); } - #[cfg(not(windows))] - let _ = pipeline; + crate::pipeline::bound(pipeline); S_OK } @@ -1109,9 +1107,7 @@ let at = unsafe { start.add(start.align_offset(align)) }; // SAFETY: the title passes one of our lists. let uploads = unsafe { &(*this.cast::<List>()).uploads }; - // Moving the vector keeps its heap block where it is. - let mut guard = uploads.lock().unwrap_or_else(|e| e.into_inner()); - Arc::make_mut(&mut *guard).push(block); + uploads.lock().unwrap_or_else(|e| e.into_inner()).push(Arc::new(block)); at } @@ -1120,7 +1116,11 @@ /// find title memory by address (`crate::memory`; the console's GPU /// addresses have 40 bits), and is a buffer of its own to the host copies /// (`crate::shadow`), so its copy is exactly it. -struct Upload { +/// Upload blocks a list's commands read, shared with the snapshots of its +/// segments a pending wait holds. +pub(crate) type Uploads = Vec<Arc<Upload>>; + +pub(crate) struct Upload { #[cfg(windows)] at: usize, #[cfg(windows)] --- a/crates/victory-gpu/src/queue.rs +++ b/crates/victory-gpu/src/queue.rs @@ -33,7 +33,7 @@ } #[cfg(windows)] -type HostSegment = (Arc<crate::host::HostList>, Arc<Vec<Vec<u8>>>); +type HostSegment = (Arc<crate::host::HostList>, crate::list::Uploads); /// One queued item on a guest command queue waiting behind an unsatisfied /// 64-bit command-list memory wait. ``` </details> Unit tests only, no game files. AI-assisted (Claude rebased it; I ran it on my machine).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:25 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs, crates/victory-gpu/src/list.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1388#issuecomment-7149523234) <!-- victory-triage v1 head=9d84135faadd235e00835a8d1d25fca05865c5b3 verdict=needs-rebase at=2026-11-25T01:24:59Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/draw.rs`, `crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/list.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/queue.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1388/head:github-bot/gh-1388'
git switch 'github-bot/gh-1388'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1388'
git switch 'github-bot/gh-1388'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1388'
git switch 'github-bot/gh-1388'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1388'
git switch 'main'
git merge --squash 'github-bot/gh-1388'
git switch 'main'
git merge --ff-only 'github-bot/gh-1388'
git switch 'main'
git merge 'github-bot/gh-1388'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!1388
No description provided.