GPU: a buffer view off its copy's elements gets a copy of its own instead of a null slot #362

Open
github-bot wants to merge 2 commits from github-bot/gh-362 into main AGit
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 23:56 UTC · original
RenzoWit35:fix/62-misaligned-typed-views → main · +210 −8 · 2 files · 2 commits · open

Refs #62 (the refused typed views reported in its comments). It does not close #62: see the note below.

What

A typed shader view of buffer memory names its first element in its own elements, so on the host copy of the memory it is in it can only begin where offset % element == 0. The console lets a view begin anywhere. buffer_srv refused the rest ("buffer view not on an element of its host copy") and left the slot null, so shaders read zeros. The report in #62 counted 100–121 such views per run, all R32G32B32_FLOAT (12-byte elements), 264–792 bytes, 4 or 16 bytes off.

  • shadow::exact(start, len): a host copy of exactly the title memory one view reads, so the view begins at element 0. Kept in its own map, handed out under its lock, and let go with the idle windows in let_go_idle (same criteria: no list, no slot, idle).
  • descriptor::host::off_element: the one decision. A view that is no raw window, has a known element size, and does not begin on an element of its copy. buffer_srv makes such a view on its own copy at element 0. buffer_copy names the same copy for the view, so the heap pass and readable() bring it up to date, and the slot shows the copy that gets refreshed.
  • Structured views that cannot be raw windows and are off their stride are covered by the same path.
  • Unordered views keep the refusal: a second copy that shaders write would diverge from the first.

shortcut: within one submission, what shaders write to the other copy of the same memory reaches the view's copy only through title memory, after the submission (the same as any other copy). Before, these views read zeros.

Note on #62

A commenter on #62 ported the same idea locally on 4e17478: the refusals went to 0, but the missing cell walls were still missing in that run. So this is a correctness fix for what those views read, not a fix for the walls.

Tests

  • views_off_their_copys_elements_are_told_apart (pure): typed 12-byte elements 4 and 16 bytes in need their own copy; 0 and 24 do not; a structured view that is a raw window does not; one that is not and is off its stride does; an unknown format does not.
  • a_typed_view_off_its_copys_elements_gets_its_own_copy (needs a host device, skips without one): 22 R32G32B32_FLOAT elements (264 bytes) from element 1, 4 bytes into a registered buffer, get a slot on a copy of exactly that range, and buffer_copy names that copy. A view of the same memory on an element keeps the buffer's own copy. With the fix switched off it fails: the view is left null.
  • a_views_own_copy_holds_exactly_its_bytes (needs a host device): after update, the copy holds the title's bytes for the range, and the same range asked for again is the same copy.

On Windows 11, MSVC Rust 1.98.1, on top of main (2119b0e): cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, cargo test --workspace --locked, and cargo xtask policy all pass. Not run in the title.

🤖 Generated with Claude Code

**@⁠RenzoWit35** on GitHub · 2026-11-24 23:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/362) `RenzoWit35:fix/62-misaligned-typed-views` → `main` · +210 −8 · 2 files · 2 commits · open Refs #62 (the refused typed views reported in its comments). It does not close #62: see the note below. ## What A typed shader view of buffer memory names its first element in its own elements, so on the host copy of the memory it is in it can only begin where `offset % element == 0`. The console lets a view begin anywhere. `buffer_srv` refused the rest (`"buffer view not on an element of its host copy"`) and left the slot null, so shaders read zeros. The report in #62 counted 100–121 such views per run, all `R32G32B32_FLOAT` (12-byte elements), 264–792 bytes, 4 or 16 bytes off. - **`shadow::exact(start, len)`**: a host copy of exactly the title memory one view reads, so the view begins at element 0. Kept in its own map, handed out under its lock, and let go with the idle windows in `let_go_idle` (same criteria: no list, no slot, idle). - **`descriptor::host::off_element`**: the one decision. A view that is no raw window, has a known element size, and does not begin on an element of its copy. `buffer_srv` makes such a view on its own copy at element 0. `buffer_copy` names the same copy for the view, so the heap pass and `readable()` bring it up to date, and the slot shows the copy that gets refreshed. - Structured views that cannot be raw windows and are off their stride are covered by the same path. - **Unordered views keep the refusal**: a second copy that shaders write would diverge from the first. `shortcut:` within one submission, what shaders write to the other copy of the same memory reaches the view's copy only through title memory, after the submission (the same as any other copy). Before, these views read zeros. ## Note on #62 A commenter on #62 ported the same idea locally on 4e17478: the refusals went to 0, but the missing cell walls were still missing in that run. So this is a correctness fix for what those views read, not a fix for the walls. ## Tests - `views_off_their_copys_elements_are_told_apart` (pure): typed 12-byte elements 4 and 16 bytes in need their own copy; 0 and 24 do not; a structured view that is a raw window does not; one that is not and is off its stride does; an unknown format does not. - `a_typed_view_off_its_copys_elements_gets_its_own_copy` (needs a host device, skips without one): 22 `R32G32B32_FLOAT` elements (264 bytes) from element 1, 4 bytes into a registered buffer, get a slot on a copy of exactly that range, and `buffer_copy` names that copy. A view of the same memory on an element keeps the buffer's own copy. With the fix switched off it fails: the view is left null. - `a_views_own_copy_holds_exactly_its_bytes` (needs a host device): after `update`, the copy holds the title's bytes for the range, and the same range asked for again is the same copy. On Windows 11, MSVC Rust 1.98.1, on top of `main` (2119b0e): `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, `cargo test --workspace --locked`, and `cargo xtask policy` all pass. Not run in the title. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A typed (or structured, not raw-windowed) shader view of buffer memory
names its first element in its own elements, so on the host copy of the
memory it is in it can begin only where offset % element == 0. The
console lets it begin anywhere: on the test runs reported in #62, 100-121
R32G32B32_FLOAT views of 264-792 bytes a run began 4 or 16 bytes off and
were left null, and shaders read zeros through them.

Such a view is now made on a copy of exactly its range
(shadow::exact), where it begins at element 0. buffer_copy names the
same copy for the view, so the heap pass and the draws bring it up to
date; copies nothing holds go with the idle windows. off_element() is
the one decision both use. Unordered views keep the refusal: a second
copy written by shaders would diverge from the first.

shortcut: within one submission, writes shaders make to the other copy
of the same memory reach the view's copy only through title memory,
after the submission.

As reported in #62, this alone did not bring back the missing cell
walls in that run; it fixes what those views read.

Tests: which views need their own copy (pure); a typed view 4 bytes off
its buffer's copy gets a slot on its own copy, the one buffer_copy names,
while a view on an element keeps the buffer's copy (fails on main: left
null); a view's own copy holds exactly its bytes once updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One conflict, in shadow::let_go_idle: main now derives the idle time from
available RAM and returns early when there are no window copies; this
branch sweeps the per-view copies (EXACT) with the same rule. Both are
kept: the RAM-based idle time is asked once, only when a map has copies,
and applies to both maps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:41:41 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/shadow.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/362/head:github-bot/gh-362'
git switch 'github-bot/gh-362'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-362'
git switch 'github-bot/gh-362'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-362'
git switch 'github-bot/gh-362'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-362'
git switch 'main'
git merge --squash 'github-bot/gh-362'
git switch 'main'
git merge --ff-only 'github-bot/gh-362'
git switch 'main'
git merge 'github-bot/gh-362'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.