Plan dependent GPU fills behind placed copies #344

Merged
TaynanGT merged 7 commits from upstream-pr/344 into main 2026-11-27 18:42:08 +00:00
TaynanGT commented 2026-11-27 18:34:33 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T18:34:33Z.


Reuse the card-step plan while pending writes and the placed-copy mode still match. Use the recorded source of an earlier placed copy when it covers a GPU fill. If the first plan leaves another eligible fill behind, retry with that fill included. The regular wait still handles pending CPU readers and changes to the mapping.

Enable the path with VICTORY_PLACED_FILL_REDIRECT=1 and VICTORY_PLACED_ORDER=1.

This builds on Petr Seifert's work in #322 and #285. Windows workspace tests, both Clippy configurations, and the D3D12 copy test passed. The GPU test completed 48 of 48 copies on the card.

A local RTX 4090 comparison used the Series S profile, 4K output, DLSS Quality, and 2× frame generation. Across two 15-second windows per mode, rendered FPS rose from 14.83 to 16.52. The median of the two frame-time medians fell from 66.5 ms to 58.2 ms.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5531440934 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T18:34:33Z. --- Reuse the card-step plan while pending writes and the placed-copy mode still match. Use the recorded source of an earlier placed copy when it covers a GPU fill. If the first plan leaves another eligible fill behind, retry with that fill included. The regular wait still handles pending CPU readers and changes to the mapping. Enable the path with `VICTORY_PLACED_FILL_REDIRECT=1` and `VICTORY_PLACED_ORDER=1`. This builds on Petr Seifert's work in #322 and #285. Windows workspace tests, both Clippy configurations, and the D3D12 copy test passed. The GPU test completed 48 of 48 copies on the card. A local RTX 4090 comparison used the Series S profile, 4K output, DLSS Quality, and 2× frame generation. Across two 15-second windows per mode, rendered FPS rose from 14.83 to 16.52. The median of the two frame-time medians fell from 66.5 ms to 58.2 ms.
chatgpt-codex-connector[bot] commented 2026-11-27 18:34:45 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T18:34:45Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T18:38:37.702577Z 15aaa84 PR opened
🔒 Security Review ✅ Completed 2026-11-27T18:37:34.137568Z 15aaa84 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7225636420 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#issuecomment-7225636420). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T18:34:45Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"15aaa8413ed92f5489987f07d7cbf18c0bd5a329","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":"15aaa8413ed92f5489987f07d7cbf18c0bd5a329","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} --> <!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"15aaa8413ed92f5489987f07d7cbf18c0bd5a329","mergeGateEnabled":false,"pullRequestNumber":344,"repository":"TaynanGT/Vice-Tay","status":"completed"} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-27T18:38:37.702577Z">2026-11-27T18:38:37.702577Z</relative-time> | `15aaa84` | PR opened | | 🔒 **Security Review** | ✅ **Completed** <relative-time datetime="2026-11-27T18:37:34.137568Z">2026-11-27T18:37:34.137568Z</relative-time> | `15aaa84` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-27 18:38:35 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T18:38:35Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15aaa8413e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6092169774 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#pullrequestreview-6092169774). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T18:38:35Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `15aaa8413e` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot] commented 2026-11-27 18:38:35 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T18:38:35Z.

Code review location: crates/victory-gpu/src/host/card_steps.rs; line 536

@@ -370,11 +505,158 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u
         if writes {
             copies.push(out.len());
         }
-        out.push((i, level));
+        out.push(Planned {
+            index: i,
+            level,
+            redirect: redirects[i],
+        });
     }
     Ok(out)
 }
 
+/// A placed copy whose bytes still depend on a flight does not update
+/// title memory during CPU preparation. Any CPU reader of its destination
+/// must wait, even if another fill was redirected to the card.
+/// A CPU upload source blocked directly by a flight cannot be promoted.
+fn remaining_cpu_reader(
+    does: &[Does],
+    chosen: &[Planned],
+    written: &[(usize, usize)],
+    readers_before_copy: bool,
+    mut stop: impl FnMut(usize) -> bool,
+) -> Option<(usize, usize)> {
+    let mut pending = Vec::new();
+    for (i, step) in does.iter().enumerate() {
+        if let Does::Placed { dst, src, len, from_cpu } = *step {
+            let source_pending = touches(written, src, src + len);
+            if from_cpu && source_pending {
+                return Some((i, i));
+            }
+            if source_pending || touches(written, dst, dst + len) {
+                pending.push((i, (dst, dst + len)));

P2 Badge Propagate pending dependencies through card-sourced placed copies

With fill redirection enabled, a chain of card-sourced placed copies can leave a CPU fill reading stale bytes. For example, let flights write [100,116) and [200,204), followed by a placed copy 100→200 of 16 bytes, a redirected fill of [200,204), a placed copy 204→400 of 4 bytes, and a fill of [400,404). The planner accepts this sequence and leaves the last fill on the CPU: only the first copy is added to pending, and card-sourced copies are not treated as CPU readers. However, Step::Placed preparation in host.rs considers the second copy free against the flight ranges, so its prepare(true) copies the still-stale title bytes at 204 into 400 before the final fill reads them. The previous planner refused the first redirected fill and waited instead. Propagate pending destinations through subsequent placed copies, or refuse this dependency chain before accepting the plan.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4722707881 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4722707881). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T18:38:35Z. **Code review location:** `crates/victory-gpu/src/host/card_steps.rs`; line 536 ~~~~diff @@ -370,11 +505,158 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u if writes { copies.push(out.len()); } - out.push((i, level)); + out.push(Planned { + index: i, + level, + redirect: redirects[i], + }); } Ok(out) } +/// A placed copy whose bytes still depend on a flight does not update +/// title memory during CPU preparation. Any CPU reader of its destination +/// must wait, even if another fill was redirected to the card. +/// A CPU upload source blocked directly by a flight cannot be promoted. +fn remaining_cpu_reader( + does: &[Does], + chosen: &[Planned], + written: &[(usize, usize)], + readers_before_copy: bool, + mut stop: impl FnMut(usize) -> bool, +) -> Option<(usize, usize)> { + let mut pending = Vec::new(); + for (i, step) in does.iter().enumerate() { + if let Does::Placed { dst, src, len, from_cpu } = *step { + let source_pending = touches(written, src, src + len); + if from_cpu && source_pending { + return Some((i, i)); + } + if source_pending || touches(written, dst, dst + len) { + pending.push((i, (dst, dst + len))); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Propagate pending dependencies through card-sourced placed copies** With fill redirection enabled, a chain of card-sourced placed copies can leave a CPU fill reading stale bytes. For example, let flights write `[100,116)` and `[200,204)`, followed by a placed copy `100→200` of 16 bytes, a redirected fill of `[200,204)`, a placed copy `204→400` of 4 bytes, and a fill of `[400,404)`. The planner accepts this sequence and leaves the last fill on the CPU: only the first copy is added to `pending`, and card-sourced copies are not treated as CPU readers. However, `Step::Placed` preparation in `host.rs` considers the second copy free against the flight ranges, so its `prepare(true)` copies the still-stale title bytes at 204 into 400 before the final fill reads them. The previous planner refused the first redirected fill and waited instead. Propagate pending destinations through subsequent placed copies, or refuse this dependency chain before accepting the plan. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-27 18:38:35 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T18:38:35Z.

Code review location: crates/victory-gpu/src/host/card_steps.rs; line 395

@@ -306,18 +363,88 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u
     // A copy at its place in a list comes after what is done in front of all
     // of them: as it should after the steps ahead of it, but not after those
     // behind it that read or write its bytes.
+    //
+    // Under `by_order` (`VICTORY_PLACED_ORDER=1`), a taken `Fill` behind a
+    // card-sourced placed copy `P` whose source lies wholly inside `P`'s
+    // destination can read `P`'s source host copy at the matching offset in
+    // the front list instead of refusing the whole submission — provided no
+    // earlier placed copy or copy anywhere in the submission writes `P`'s
+    // source, and no intervening step overwrites the fill's bytes.
+    let mut redirects = vec![None; does.len()];
     for (p, d) in does.iter().enumerate() {
-        if let Does::Placed { dst, src, len } = *d
+        if let Does::Placed { dst, src, len, from_cpu } = *d
             && (touched(&read, (dst, dst + len)) || touched(&written, (dst, dst + len)) || touched(&written, (src, src + len)))
         {
             let (to, from) = ((dst, dst + len), (src, src + len));
             let in_the_way = |i: usize| {
                 reads_writes(&does[i]).is_some_and(|(r, w)| meet(r, to) || w.0 < w.1 && (meet(w, to) || meet(w, from)))
             };
-            let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i));
-            *behind = found.map(|i| (p, i));
-            if !by_order || found.is_some() {
-                return Err(BEHIND_PLACED);
+            if !by_order || !redirect_fills {
+                let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i));
+                if !by_order || found.is_some() {
+                    let cause = if by_order { "redirect_disabled" } else { "ordering_disabled" };
+                    return Err(behind.refuse(found.map(|i| (p, i)), cause));
+                }
+                behind.steps = None;
+                continue;
+            }
+            let src_clean = || {
+                !does.iter().enumerate().any(|(k, step)| match *step {
+                    Does::Copy { dst: cd, len: cl, .. } => meet((cd, cd + cl), from),
+                    Does::Placed { dst: pd, len: pl, .. } if k < p => meet((pd, pd + pl), from),
+                    Does::GpuWrite { from: gf, to: gt } if k < p => meet((gf, gt), from),

P2 Badge Account for picked-view shader writes before redirecting fills

When a shader before the placed copy writes its source through a dynamically picked UAV, this check can incorrectly declare the source clean and redirect a later fill to its pre-dispatch contents. These writes do not necessarily produce Step::GpuWrite: draw.rs:1861–1862 records picked::runs_in(list), which only sets a list-use key, and the known picked-write ranges are declared submission-wide by picked::declare in host.rs:7449, after card-step planning. Thus, with picked writes and fill redirection enabled, an earlier dispatch can update a previously shader-written source buffer, the placed copy correctly copies that updated GPU value, but its redirected fill reads the old value in the front list. The old planner refused this dependent fill rather than hoisting it. Include picked-write hazards in the planner, or conservatively refuse redirection when an earlier picked-view shader could modify the source or intervening destination.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4722707887 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4722707887). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T18:38:35Z. **Code review location:** `crates/victory-gpu/src/host/card_steps.rs`; line 395 ~~~~diff @@ -306,18 +363,88 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u // A copy at its place in a list comes after what is done in front of all // of them: as it should after the steps ahead of it, but not after those // behind it that read or write its bytes. + // + // Under `by_order` (`VICTORY_PLACED_ORDER=1`), a taken `Fill` behind a + // card-sourced placed copy `P` whose source lies wholly inside `P`'s + // destination can read `P`'s source host copy at the matching offset in + // the front list instead of refusing the whole submission — provided no + // earlier placed copy or copy anywhere in the submission writes `P`'s + // source, and no intervening step overwrites the fill's bytes. + let mut redirects = vec![None; does.len()]; for (p, d) in does.iter().enumerate() { - if let Does::Placed { dst, src, len } = *d + if let Does::Placed { dst, src, len, from_cpu } = *d && (touched(&read, (dst, dst + len)) || touched(&written, (dst, dst + len)) || touched(&written, (src, src + len))) { let (to, from) = ((dst, dst + len), (src, src + len)); let in_the_way = |i: usize| { reads_writes(&does[i]).is_some_and(|(r, w)| meet(r, to) || w.0 < w.1 && (meet(w, to) || meet(w, from))) }; - let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i)); - *behind = found.map(|i| (p, i)); - if !by_order || found.is_some() { - return Err(BEHIND_PLACED); + if !by_order || !redirect_fills { + let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i)); + if !by_order || found.is_some() { + let cause = if by_order { "redirect_disabled" } else { "ordering_disabled" }; + return Err(behind.refuse(found.map(|i| (p, i)), cause)); + } + behind.steps = None; + continue; + } + let src_clean = || { + !does.iter().enumerate().any(|(k, step)| match *step { + Does::Copy { dst: cd, len: cl, .. } => meet((cd, cd + cl), from), + Does::Placed { dst: pd, len: pl, .. } if k < p => meet((pd, pd + pl), from), + Does::GpuWrite { from: gf, to: gt } if k < p => meet((gf, gt), from), ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Account for picked-view shader writes before redirecting fills** When a shader before the placed copy writes its source through a dynamically picked UAV, this check can incorrectly declare the source clean and redirect a later fill to its pre-dispatch contents. These writes do not necessarily produce `Step::GpuWrite`: `draw.rs:1861–1862` records `picked::runs_in(list)`, which only sets a list-use key, and the known picked-write ranges are declared submission-wide by `picked::declare` in `host.rs:7449`, after card-step planning. Thus, with picked writes and fill redirection enabled, an earlier dispatch can update a previously shader-written source buffer, the placed copy correctly copies that updated GPU value, but its redirected fill reads the old value in the front list. The old planner refused this dependent fill rather than hoisting it. Include picked-write hazards in the planner, or conservatively refuse redirection when an earlier picked-view shader could modify the source or intervening destination. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
TaynanGT commented 2026-11-29 19:06:56 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:06:56Z.

Code review location: crates/victory-gpu/src/host/card_steps.rs; line 536

@@ -370,11 +505,158 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u
         if writes {
             copies.push(out.len());
         }
-        out.push((i, level));
+        out.push(Planned {
+            index: i,
+            level,
+            redirect: redirects[i],
+        });
     }
     Ok(out)
 }
 
+/// A placed copy whose bytes still depend on a flight does not update
+/// title memory during CPU preparation. Any CPU reader of its destination
+/// must wait, even if another fill was redirected to the card.
+/// A CPU upload source blocked directly by a flight cannot be promoted.
+fn remaining_cpu_reader(
+    does: &[Does],
+    chosen: &[Planned],
+    written: &[(usize, usize)],
+    readers_before_copy: bool,
+    mut stop: impl FnMut(usize) -> bool,
+) -> Option<(usize, usize)> {
+    let mut pending = Vec::new();
+    for (i, step) in does.iter().enumerate() {
+        if let Does::Placed { dst, src, len, from_cpu } = *step {
+            let source_pending = touches(written, src, src + len);
+            if from_cpu && source_pending {
+                return Some((i, i));
+            }
+            if source_pending || touches(written, dst, dst + len) {
+                pending.push((i, (dst, dst + len)));

The pending destination must propagate through chained placed copies, including card-sourced copies. A regression should exercise this exact chain and verify the final CPU reader waits or obtains the correct GPU value. Until that dependency is established, the conservative refusal is preferable.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732744924 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4732744924). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:06:56Z. **Code review location:** `crates/victory-gpu/src/host/card_steps.rs`; line 536 ~~~~diff @@ -370,11 +505,158 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u if writes { copies.push(out.len()); } - out.push((i, level)); + out.push(Planned { + index: i, + level, + redirect: redirects[i], + }); } Ok(out) } +/// A placed copy whose bytes still depend on a flight does not update +/// title memory during CPU preparation. Any CPU reader of its destination +/// must wait, even if another fill was redirected to the card. +/// A CPU upload source blocked directly by a flight cannot be promoted. +fn remaining_cpu_reader( + does: &[Does], + chosen: &[Planned], + written: &[(usize, usize)], + readers_before_copy: bool, + mut stop: impl FnMut(usize) -> bool, +) -> Option<(usize, usize)> { + let mut pending = Vec::new(); + for (i, step) in does.iter().enumerate() { + if let Does::Placed { dst, src, len, from_cpu } = *step { + let source_pending = touches(written, src, src + len); + if from_cpu && source_pending { + return Some((i, i)); + } + if source_pending || touches(written, dst, dst + len) { + pending.push((i, (dst, dst + len))); ~~~~ --- The pending destination must propagate through chained placed copies, including card-sourced copies. A regression should exercise this exact chain and verify the final CPU reader waits or obtains the correct GPU value. Until that dependency is established, the conservative refusal is preferable.
TaynanGT commented 2026-11-29 19:06:57 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:06:57Z.

Code review location: crates/victory-gpu/src/host/card_steps.rs; line 395

@@ -306,18 +363,88 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u
     // A copy at its place in a list comes after what is done in front of all
     // of them: as it should after the steps ahead of it, but not after those
     // behind it that read or write its bytes.
+    //
+    // Under `by_order` (`VICTORY_PLACED_ORDER=1`), a taken `Fill` behind a
+    // card-sourced placed copy `P` whose source lies wholly inside `P`'s
+    // destination can read `P`'s source host copy at the matching offset in
+    // the front list instead of refusing the whole submission — provided no
+    // earlier placed copy or copy anywhere in the submission writes `P`'s
+    // source, and no intervening step overwrites the fill's bytes.
+    let mut redirects = vec![None; does.len()];
     for (p, d) in does.iter().enumerate() {
-        if let Does::Placed { dst, src, len } = *d
+        if let Does::Placed { dst, src, len, from_cpu } = *d
             && (touched(&read, (dst, dst + len)) || touched(&written, (dst, dst + len)) || touched(&written, (src, src + len)))
         {
             let (to, from) = ((dst, dst + len), (src, src + len));
             let in_the_way = |i: usize| {
                 reads_writes(&does[i]).is_some_and(|(r, w)| meet(r, to) || w.0 < w.1 && (meet(w, to) || meet(w, from)))
             };
-            let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i));
-            *behind = found.map(|i| (p, i));
-            if !by_order || found.is_some() {
-                return Err(BEHIND_PLACED);
+            if !by_order || !redirect_fills {
+                let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i));
+                if !by_order || found.is_some() {
+                    let cause = if by_order { "redirect_disabled" } else { "ordering_disabled" };
+                    return Err(behind.refuse(found.map(|i| (p, i)), cause));
+                }
+                behind.steps = None;
+                continue;
+            }
+            let src_clean = || {
+                !does.iter().enumerate().any(|(k, step)| match *step {
+                    Does::Copy { dst: cd, len: cl, .. } => meet((cd, cd + cl), from),
+                    Does::Placed { dst: pd, len: pl, .. } if k < p => meet((pd, pd + pl), from),
+                    Does::GpuWrite { from: gf, to: gt } if k < p => meet((gf, gt), from),

Dynamic picked UAV writes need to be included in the hazard analysis before any fill is hoisted. If the planner cannot establish the affected ranges at that point, it should decline redirection rather than assume the source is clean. A regression with a preceding picked-view dispatch is needed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732745016 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4732745016). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:06:57Z. **Code review location:** `crates/victory-gpu/src/host/card_steps.rs`; line 395 ~~~~diff @@ -306,18 +363,88 @@ fn plan(does: &[Does], stage: u32, by_order: bool, behind: &mut Option<(usize, u // A copy at its place in a list comes after what is done in front of all // of them: as it should after the steps ahead of it, but not after those // behind it that read or write its bytes. + // + // Under `by_order` (`VICTORY_PLACED_ORDER=1`), a taken `Fill` behind a + // card-sourced placed copy `P` whose source lies wholly inside `P`'s + // destination can read `P`'s source host copy at the matching offset in + // the front list instead of refusing the whole submission — provided no + // earlier placed copy or copy anywhere in the submission writes `P`'s + // source, and no intervening step overwrites the fill's bytes. + let mut redirects = vec![None; does.len()]; for (p, d) in does.iter().enumerate() { - if let Does::Placed { dst, src, len } = *d + if let Does::Placed { dst, src, len, from_cpu } = *d && (touched(&read, (dst, dst + len)) || touched(&written, (dst, dst + len)) || touched(&written, (src, src + len))) { let (to, from) = ((dst, dst + len), (src, src + len)); let in_the_way = |i: usize| { reads_writes(&does[i]).is_some_and(|(r, w)| meet(r, to) || w.0 < w.1 && (meet(w, to) || meet(w, from))) }; - let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i)); - *behind = found.map(|i| (p, i)); - if !by_order || found.is_some() { - return Err(BEHIND_PLACED); + if !by_order || !redirect_fills { + let found = (p + 1..does.len()).find(|&i| taken[i] && in_the_way(i)); + if !by_order || found.is_some() { + let cause = if by_order { "redirect_disabled" } else { "ordering_disabled" }; + return Err(behind.refuse(found.map(|i| (p, i)), cause)); + } + behind.steps = None; + continue; + } + let src_clean = || { + !does.iter().enumerate().any(|(k, step)| match *step { + Does::Copy { dst: cd, len: cl, .. } => meet((cd, cd + cl), from), + Does::Placed { dst: pd, len: pl, .. } if k < p => meet((pd, pd + pl), from), + Does::GpuWrite { from: gf, to: gt } if k < p => meet((gf, gt), from), ~~~~ --- Dynamic picked UAV writes need to be included in the hazard analysis before any fill is hoisted. If the planner cannot establish the affected ranges at that point, it should decline redirection rather than assume the source is clean. A regression with a preceding picked-view dispatch is needed.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
TaynanGT/Vice-Tay!344
No description provided.