shader: read computed buffer descriptors in guessed vertex shaders #133

Manually merged
github merged 1 commit from github-bot/gh-133 into main 2026-11-26 19:08:28 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 18:24 UTC · original
Olima34:fix/native-vertex-computed-buffers → main · +102 −2 · 4 files · 2 commits · merged 2026-11-26 19:02 UTC

The tester log in #123 shows four guessed vertex shaders refused with "a buffer descriptor built around a computed address". The translator allowed such descriptors (read through the title-memory page table) only in pixel and compute shaders.

Why it is safe. The Metal host already gives the page table to the vertex stage of a guessed pipeline. For a draw, memory_args in native/host.rs puts the table's address in the vertex shader's root arguments when its memory flag is set, as it does for the pixel shader. bind_root_render in victory-metal/src/gfx.rs sends those arguments to the vertex stage, binds the heap to both stages and makes the heap views and pool buffers resident for Vertex | Fragment. shaders::unsupported already accepts the page table for guessed graphics at any stage. So the only block was in the translator.

What. resource::track_graphics now allows computed buffers in vertex shaders as well as pixel and compute shaders (mesh shaders unchanged). The refusal text is unchanged; a vertex shader translated without zero_copy_memory is still refused. docs/native-host.md: "Computed pixel buffers" becomes "Computed pixel and vertex buffers" and says how the host binds the table for both stages.

Tests.

  • gfx_refusal_tests::guessed_vertex_computed_buffer_loads_use_title_memory: a hand-assembled guessed vertex shader with a computed buffer load translates. Refused on main.
  • addr_tests::guessed_vertex_buffer_reads_the_pool: a GPU draw whose vertex shader reads its triangle's positions from title memory through a computed descriptor must cover the whole 8×8 target. Fails on main (translation refused), and also fails if the positions in memory are zeros, so the draw checks that the vertex stage really reads title memory.

cargo test -p victory-shader -p victory-gpu -p victory-metal on arm64 (248, 186 and the Metal tests), Windows clippy and cargo xtask policy pass. Not checked: the four shaders from #123 themselves; they may meet another refusal after this one.

**@⁠Olima34** on GitHub · 2026-11-26 18:24 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/133) `Olima34:fix/native-vertex-computed-buffers` → `main` · +102 −2 · 4 files · 2 commits · merged 2026-11-26 19:02 UTC The tester log in #123 shows four guessed vertex shaders refused with "a buffer descriptor built around a computed address". The translator allowed such descriptors (read through the title-memory page table) only in pixel and compute shaders. **Why it is safe.** The Metal host already gives the page table to the vertex stage of a guessed pipeline. For a draw, `memory_args` in `native/host.rs` puts the table's address in the vertex shader's root arguments when its `memory` flag is set, as it does for the pixel shader. `bind_root_render` in `victory-metal/src/gfx.rs` sends those arguments to the vertex stage, binds the heap to both stages and makes the heap views and pool buffers resident for `Vertex | Fragment`. `shaders::unsupported` already accepts the page table for guessed graphics at any stage. So the only block was in the translator. **What.** `resource::track_graphics` now allows computed buffers in vertex shaders as well as pixel and compute shaders (mesh shaders unchanged). The refusal text is unchanged; a vertex shader translated without `zero_copy_memory` is still refused. docs/native-host.md: "Computed pixel buffers" becomes "Computed pixel and vertex buffers" and says how the host binds the table for both stages. **Tests.** - `gfx_refusal_tests::guessed_vertex_computed_buffer_loads_use_title_memory`: a hand-assembled guessed vertex shader with a computed buffer load translates. Refused on main. - `addr_tests::guessed_vertex_buffer_reads_the_pool`: a GPU draw whose vertex shader reads its triangle's positions from title memory through a computed descriptor must cover the whole 8×8 target. Fails on main (translation refused), and also fails if the positions in memory are zeros, so the draw checks that the vertex stage really reads title memory. `cargo test -p victory-shader -p victory-gpu -p victory-metal` on arm64 (248, 186 and the Metal tests), Windows clippy and `cargo xtask policy` pass. Not checked: the four shaders from #123 themselves; they may meet another refusal after this one.
A guessed vertex shader's buffer descriptor built around a computed
address was refused ("a buffer descriptor built around a computed
address"); the tester log in #123 shows four such shaders. The Metal
host already binds the page table for the vertex stage: memory_args
gives each stage's root arguments the table's address, and the heap
and pool buffers are made resident for both render stages. So the
resource tracker now allows computed buffers in vertex shaders too.

Tests: a guessed vertex shader with a computed buffer load translates
(gfx_refusal_tests), and a draw whose vertex shader reads its positions
from title memory through such a descriptor covers the target
(addr_tests::guessed_vertex_buffer_reads_the_pool). Both fail without
the change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:25:34 +00:00
github manually merged commit 1f73805307 into main 2026-11-26 19:08:28 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 19:02 UTC · original · approved these changes

Reviewed and tested together with the other open PRs. I merged main into the branch and resolved the conflict in docs/native-host.md: I kept main's newer text for that bullet and added this PR's vertex-shader wording. Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 19:02 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/133#pullrequestreview-6079286787) · **approved these changes** Reviewed and tested together with the other open PRs. I merged main into the branch and resolved the conflict in docs/native-host.md: I kept main's newer text for that bullet and added this PR's vertex-shader wording. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.