Plan dependent GPU fills behind placed copies #344

Manually merged
github merged 7 commits from github-bot/gh-344 into main 2026-11-27 18:48:01 +00:00 AGit
Owner

@⁠TaynanGT on GitHub · 2026-11-27 18:34 UTC · original
TaynanGT:perf/placed-fill-dependencies → main · +1191 −88 · 6 files · 7 commits · merged 2026-11-27 18:42 UTC

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.

**@⁠TaynanGT** on GitHub · 2026-11-27 18:34 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/344) `TaynanGT:perf/placed-fill-dependencies` → `main` · +1191 −88 · 6 files · 7 commits · merged 2026-11-27 18:42 UTC 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.
With `VICTORY_PLACED_ORDER=1`, `cut_for` listed the steps of a submission
that has a copy at its place and planned them to see whether it must be
cut, and `Host::card_steps` then did both again under the submission
lock.

`cut_or_plan` hands the steps and the plan of a submission it does not
cut to `card_steps` (`Preplan`), which takes them if the flights still
write the same ranges and works them out again if not.

(cherry picked from commit ee7eb389fe)
(cherry picked from commit 341d83a11b0107f85ebe3d7d792e512cca3dab4d)
(cherry picked from commit 290cf86ed2cbe23afeed9d0deeb84225f3d2e6f7)
(cherry picked from commit 12ed096844a9bce3cb9ee8082afbac3ecfa7203a)
With `VICTORY_PLACED_ORDER=1` a fill taken to the card that reads bytes
a copy at its place in an earlier list writes refused the submission
(`BEHIND_PLACED`), or had it cut behind the copy's list: our list runs in
front of all of them, so it would read the bytes before the copy.

Such a fill now reads the placed copy's source host copy at the same
offset, which holds those bytes before the copy runs. Only when:

- the fill lies wholly inside the copy's destination;
- the copy reads a host copy on the card, not upload memory;
- nothing ahead of the copy in the submission writes its source (a
  shader write or another placed copy), and no buffer copy of the
  submission does;
- no buffer copy or shader write between the copy and the fill writes
  the fill's bytes;
- a later placed copy that writes the fill's bytes covers all of them
  (the fill then reads that one's source).

Anything else behind a placed copy is refused or cut as before, and so
is every case with the switch off. `Does` gains the shader writes the
lists declare (`GpuWrite`) for these checks.

What stands between the copy and each fill is gathered in one pass over
the steps behind the copy.

(cherry picked from commit 6936fc5834d12ad12aaf9d36d7651cd4e5596ec5)
Retry a blocked submission with eligible fills that read from earlier placed copies. Preserve the original wait if any reader still needs CPU memory. Report which dependencies caused waits in diagnostics builds.
The test covers the tracked copy. Other fixtures can temporarily hold the global mapping write lock, which sends a regular copy down its untracked fallback. Give this test a blocking mapping read while keeping production acquisition nonblocking.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:36:25 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 18:34 UTC · original · edited 2026-11-27 18:38 UTC

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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 18:34 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/344#issuecomment-7225636420) · edited 2026-11-27 18:38 UTC <!-- 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>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 18:38 UTC · original · reviewed

💡 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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 18:38 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/344#pullrequestreview-6092169774) · **reviewed** <!-- 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>
@ -378,0 +533,4 @@
return Some((i, i));
}
if source_pending || touches(written, dst, dst + len) {
pending.push((i, (dst, dst + len)));
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 18:38 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 18:38 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4722707881) **<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 -->
@ -321,0 +392,4 @@
!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),
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 18:38 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 18:38 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/344#discussion_r4722707887) **<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 -->
github manually merged commit 10675b58f5 into main 2026-11-27 18:48:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.