GPU: leave rectangle vertex components past the stride alone #66

Manually merged
github merged 1 commit from gh-pr/66/head into gh-pr/66/base 2026-11-26 03:49:00 +00:00
Owner

@⁠AndyLatimer on GitHub · 2026-11-24 00:07 UTC · original
AndyLatimer:fix/gpu-rect-element-past-stride → main · +21 −2 · 1 files · 1 commits · merged 2026-11-24 00:40 UTC

expand_rects (crates/victory-gpu/src/primitive.rs) turns each console rectangle into two host triangles and makes the fourth corner as v0 + v2 - v1, element by element. Each vertex is a stride-byte slice, but nothing checked that an element's components fit inside it. An input layout may place an element so that it reaches past the stride (into the next vertex's bytes), and the bound stride is only known at draw time. Then &v(i)[at..] or the component index went past the slice and the expansion panicked at submission (in the deferred host work of a rect-list draw).

Examples that panicked:

  • R32G32B32A32_FLOAT at offset 4 with an 8-byte stride (component 1 starts at byte 8).
  • R8G8B8A8_UNORM at offset 8 with an 8-byte stride (the element starts at the stride).

Now only the components fully inside the vertex are computed. The rest keep the first vertex's bytes, as inputs in formats components does not know already do (documented with the existing shortcut note). draw.rs is unchanged.

Testing

  • cargo test --workspace: 225 passed, 3 ignored (need external files). Includes 1 new regression test, elements_past_the_stride_are_left_alone, which panics on the old code.
  • cargo clippy --workspace --all-targets: 0 warnings.
  • cargo xtask policy: pass (148 files).
  • rustfmt --check on the changed file: clean.
  • Tested with a synthetic unit test only (not run against a title).

🤖 Generated with Claude Code

**@⁠AndyLatimer** on GitHub · 2026-11-24 00:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/66) `AndyLatimer:fix/gpu-rect-element-past-stride` → `main` · +21 −2 · 1 files · 1 commits · merged 2026-11-24 00:40 UTC `expand_rects` (`crates/victory-gpu/src/primitive.rs`) turns each console rectangle into two host triangles and makes the fourth corner as `v0 + v2 - v1`, element by element. Each vertex is a `stride`-byte slice, but nothing checked that an element's components fit inside it. An input layout may place an element so that it reaches past the stride (into the next vertex's bytes), and the bound stride is only known at draw time. Then `&v(i)[at..]` or the component index went past the slice and the expansion panicked at submission (in the deferred host work of a rect-list draw). Examples that panicked: - `R32G32B32A32_FLOAT` at offset 4 with an 8-byte stride (component 1 starts at byte 8). - `R8G8B8A8_UNORM` at offset 8 with an 8-byte stride (the element starts at the stride). Now only the components fully inside the vertex are computed. The rest keep the first vertex's bytes, as inputs in formats `components` does not know already do (documented with the existing shortcut note). `draw.rs` is unchanged. ## Testing - `cargo test --workspace`: 225 passed, 3 ignored (need external files). Includes 1 new regression test, `elements_past_the_stride_are_left_alone`, which panics on the old code. - `cargo clippy --workspace --all-targets`: 0 warnings. - `cargo xtask policy`: pass (148 files). - `rustfmt --check` on the changed file: clean. - Tested with a synthetic unit test only (not run against a title). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Expanding a rectangle list makes the fourth corner from the other three,
element by element. An element that reaches past the vertex stride (the
input layout allows it to overlap the next vertex) was read and written
past the vertex's bytes, which panicked at submission. Only the
components inside the vertex are computed now; the rest keep the first
vertex's bytes, as unknown formats already do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:58 +00:00
github manually merged commit f3c7f0f2ad into gh-pr/66/base 2026-11-26 03:49:00 +00:00
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 00:19 UTC · original

Verified f3c7f0f2a on Windows 11 (x86_64-pc-windows-gnullvm, rustc 1.100.0, applied cleanly to main@35b054ec0): pass.

  • cargo xtask policy: 150 files ok
  • cargo test -p victory-gpu: 40 passed, 0 failed (including the new rectangle vertex stride test in primitive.rs + host D3D12 tests on Intel Iris Xe).

AI-assisted.

**@⁠lordon1a** on GitHub · 2026-11-24 00:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/66#issuecomment-7117955674) Verified `f3c7f0f2a` on Windows 11 (`x86_64-pc-windows-gnullvm`, `rustc 1.100.0`, applied cleanly to `main@35b054ec0`): **pass**. - `cargo xtask policy`: 150 files ok - `cargo test -p victory-gpu`: **40 passed, 0 failed** (including the new rectangle vertex stride test in `primitive.rs` + host D3D12 tests on Intel Iris Xe). AI-assisted.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:57 UTC · original

Tested f3c7f0f under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.

  • victory_gpu: 35 passed, 2 failed — the two environment-only failures on this base (argument_clamp_builds, and #128's buffer_data_reaches_the_host_texture).
  • The diff adds no test, so this only shows nothing else broke; a synthetic rectangle with stride < vertex size would cover the "leave components alone" path.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/66#issuecomment-7118611601) Tested `f3c7f0f` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**. - `victory_gpu`: **35 passed, 2 failed** — the two environment-only failures on this base (`argument_clamp_builds`, and #128's `buffer_data_reaches_the_host_texture`). - The diff adds no test, so this only shows nothing else broke; a synthetic rectangle with `stride < vertex size` would cover the "leave components alone" path. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!66
No description provided.