Card steps: a read of memory a texture copy-back writes can be done on the card from a buffer's host copy that never gets the texels #320

Open
opened 2026-11-26 16:22:30 +00:00 by github-bot · 2 comments
Owner

@⁠Coderlord on GitHub · 2026-11-26 16:22 UTC · original

What. crates/victory-gpu/src/host/card_steps.rs, writers() lists what the flights in the air write: their declared shader writes (flight.back, each with the host copy it goes through), their read-backs (deferred().backs, no host copy) and the copies card steps did. It does not list the texture copy-backs (Flight::texture_back_ranges, from crate::texback), although late counts them as written (line.written takes them in).

So take_steps() sees a copy or fill out of such a range as asked for (copy_blocked / read_blocked read line.written), but holder() finds no writer there and falls back to crate::shadow::find. Where a title buffer's host copy spans that memory, the step is then done on the card out of that host copy, which never receives the texels: they reach title memory on the CPU when the flight lands. Without card steps the submission waited for the flight, and the CPU copy read the texels.

When. VICTORY_CARD_STEPS=1 or 2 (scripts/play.ps1 sets 2) with texture copy-back on, which it is by default.

Fix. List them as writers without a host copy, so holder() refuses the step and the submission waits as before:

// in writers(), Late::Run(flight), after the read-backs:
out.extend(flight.texture_back_ranges.iter().map(|&(from, to)| Writer {
    shadow: None,
    from,
    to,
    copy: false,
}));

(Here we also gave such writers their own refusal reason, "a texture copied back is written there", to count them, and a unit test: holder refuses a range a texture writer meets.)

Evidence. Code reading (checked against c9c932c) and the unit test above. In 8 minutes of the first gameplay scene on an RTX 5080 (card steps at 2: about 2,700 fills and 6 buffer copies a frame done on the card), the new reason never showed up among the five longest waits of the per-frame reports, so that scene does not hit it. I can't tell whether it plays a part in #13 or #124 (wrong meshes or black geometry with card steps on).

Found while porting your card steps (cc03ecb, 007fe55, 3e64a64) onto a tree with fxceless's fill_ahead. Thank you for them.

Found, written and tested with Claude Code.

**@⁠Coderlord** on GitHub · 2026-11-26 16:22 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/320) **What.** `crates/victory-gpu/src/host/card_steps.rs`, `writers()` lists what the flights in the air write: their declared shader writes (`flight.back`, each with the host copy it goes through), their read-backs (`deferred().backs`, no host copy) and the copies card steps did. It does not list the texture copy-backs (`Flight::texture_back_ranges`, from `crate::texback`), although `late` counts them as written (`line.written` takes them in). So `take_steps()` sees a copy or fill out of such a range as asked for (`copy_blocked` / `read_blocked` read `line.written`), but `holder()` finds no writer there and falls back to `crate::shadow::find`. Where a title buffer's host copy spans that memory, the step is then done on the card out of that host copy, which never receives the texels: they reach title memory on the CPU when the flight lands. Without card steps the submission waited for the flight, and the CPU copy read the texels. **When.** `VICTORY_CARD_STEPS=1` or `2` (`scripts/play.ps1` sets 2) with texture copy-back on, which it is by default. **Fix.** List them as writers without a host copy, so `holder()` refuses the step and the submission waits as before: ```rust // in writers(), Late::Run(flight), after the read-backs: out.extend(flight.texture_back_ranges.iter().map(|&(from, to)| Writer { shadow: None, from, to, copy: false, })); ``` (Here we also gave such writers their own refusal reason, "a texture copied back is written there", to count them, and a unit test: `holder` refuses a range a texture writer meets.) **Evidence.** Code reading (checked against `c9c932c`) and the unit test above. In 8 minutes of the first gameplay scene on an RTX 5080 (card steps at 2: about 2,700 fills and 6 buffer copies a frame done on the card), the new reason never showed up among the five longest waits of the per-frame reports, so that scene does not hit it. I can't tell whether it plays a part in #13 or #124 (wrong meshes or black geometry with card steps on). Found while porting your card steps (`cc03ecb`, `007fe55`, `3e64a64`) onto a tree with fxceless's `fill_ahead`. Thank you for them. Found, written and tested with Claude Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:22:30 +00:00
Author
Owner

@⁠battledogegames-design on GitHub · 2026-11-26 18:54 UTC · original

@⁠Coderlord, thanks for identifying the missing texture copy-back writer. I independently reproduced the source-selection failure on Windows at 2de998014dc85ad68cd6422a250400c7084ace57. An isolated harness compiled the production writers(), meet() and holder() functions with a synthetic flight and Shadow lookup. With a texture write pending at [104,112), baseline selected a Shadow containing 0x11223344 for that exact read. The existing no-host-copy refusal test still passed.

With your no-Shadow writer rule, the same harness passed 3/3 serially and 3/3 under the default parallel runner. Across all 528 nonempty intervals in a 32-byte Shadow, baseline refused zero. The correction refused exactly the 308 intersections and accepted all 220 disjoint intervals, including both touching boundaries. A copy destination checked by the same selector can therefore cause a conservative refusal even when its source is clear. These are selector decisions; GPU wait frequency and duration remain unmeasured.

The target-crate and WARP runs were blocked obtaining locked zlib-rs 0.6.8. No GPU corruption or rendering effect was observed. #339 changes in-place eligibility later in holder(); it leaves the missing writer unaddressed.

Synthetic harness, raw Windows logs, and reproduction commands: issue320-evidence.zip

AI-assisted with Astra 6.2.

**@⁠battledogegames-design** on GitHub · 2026-11-26 18:54 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/320#issuecomment-7200985362) @⁠Coderlord, thanks for identifying the missing texture copy-back writer. I independently reproduced the source-selection failure on Windows at `2de998014dc85ad68cd6422a250400c7084ace57`. An isolated harness compiled the production `writers()`, `meet()` and `holder()` functions with a synthetic flight and Shadow lookup. With a texture write pending at `[104,112)`, baseline selected a Shadow containing `0x11223344` for that exact read. The existing no-host-copy refusal test still passed. With your no-Shadow writer rule, the same harness passed 3/3 serially and 3/3 under the default parallel runner. Across all 528 nonempty intervals in a 32-byte Shadow, baseline refused zero. The correction refused exactly the 308 intersections and accepted all 220 disjoint intervals, including both touching boundaries. A copy destination checked by the same selector can therefore cause a conservative refusal even when its source is clear. These are selector decisions; GPU wait frequency and duration remain unmeasured. The target-crate and WARP runs were blocked obtaining locked `zlib-rs 0.6.8`. No GPU corruption or rendering effect was observed. #339 changes in-place eligibility later in `holder()`; it leaves the missing writer unaddressed. Synthetic harness, raw Windows logs, and reproduction commands: [issue320-evidence.zip](https://github.com/user-attachments/files/35478474/issue320-evidence.zip) AI-assisted with Astra 6.2.
Author
Owner

@⁠rafaconvaitis on GitHub · 2026-11-26 20:00 UTC · original

I confirmed the same missing writer in Cool Fox c3e5c375 and tested a port of your guard on Windows. The regression test passed. It exercises a pending texture destination against an intersecting Stage 1 upload fill, an intersecting Stage 2 buffer copy, and adjacent or disjoint reads. The adjacent and disjoint reads remain eligible for the card path.

At the boat bridge on an RTX 4070, my earlier Stage 1 diagnostics measured a 13.8 ms median flight wait and repeatedly named a buffer copy as the reason the plan was refused. I am checking Stage 2 with the overlap guard in place. That timing measures the separate Stage 1 refusal. It does not establish how often this texture-readback overlap occurs in the boat scene.

**@⁠rafaconvaitis** on GitHub · 2026-11-26 20:00 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/320#issuecomment-7202202319) I confirmed the same missing writer in Cool Fox `c3e5c375` and tested a port of your guard on Windows. The regression test passed. It exercises a pending texture destination against an intersecting Stage 1 upload fill, an intersecting Stage 2 buffer copy, and adjacent or disjoint reads. The adjacent and disjoint reads remain eligible for the card path. At the boat bridge on an RTX 4070, my earlier Stage 1 diagnostics measured a 13.8 ms median flight wait and repeatedly named a buffer copy as the reason the plan was refused. I am checking Stage 2 with the overlap guard in place. That timing measures the separate Stage 1 refusal. It does not establish how often this texture-readback overlap occurs in the boat scene.
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/avatarmanz--VIctory-7900XTX#320
No description provided.