shader: rectangle lists whose vertex shader derives corners from SV_VertexID cover half of one rectangle #363

Closed
opened 2026-11-27 14:08:07 +00:00 by github-bot · 2 comments
Owner

@⁠Sheffy007 on GitHub · 2026-11-27 14:07 UTC · original

When Options::rect_list translates a guessed vertex shader for D3D_PRIMITIVE_TOPOLOGY_RECTLIST (drawn as 4-vertex TriangleStrip instances via glue::draw or DrawCall::Rects), fourth-corner reconstruction currently happens only inside Lower::vertex_fetch over fetched VB* attributes.

When a vertex shader computes its corner positions (and any varyings) from SV_VertexID (v0) — either procedurally or by indexing SRVs/CBVs by v0 / 3 and v0 % 3 — two bugs occur:

  1. SV_VertexID is passed straight through as 0..3, so strip vertex 3 runs the program with v0 = 3 instead of extrapolating the missing fourth corner p + q - r opposite the right-angle corner. The second triangle repeats the first, covering only half the rectangle (28 of 64 texels on an 8x8 full-target rectangle in mesh_tests::a_rectangle_of_a_vertex_id_program_covers_half_its_rectangle, or half of a screen-space tile).
  2. Multi-rectangle draws (vertices = 3 * N) pass SV_InstanceID = 0..N-1 while SV_VertexID stays 0..3, so every instance after the first sees v0 = 0..3 again instead of 3 * instance + corner.

Noted as free on #339 (#issuecomment-7218996806), Refs #258.

**@⁠Sheffy007** on GitHub · 2026-11-27 14:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360) When `Options::rect_list` translates a guessed vertex shader for `D3D_PRIMITIVE_TOPOLOGY_RECTLIST` (drawn as 4-vertex `TriangleStrip` instances via `glue::draw` or `DrawCall::Rects`), fourth-corner reconstruction currently happens only inside `Lower::vertex_fetch` over fetched `VB*` attributes. When a vertex shader computes its corner positions (and any varyings) from `SV_VertexID` (`v0`) — either procedurally or by indexing SRVs/CBVs by `v0 / 3` and `v0 % 3` — two bugs occur: 1. `SV_VertexID` is passed straight through as `0..3`, so strip vertex `3` runs the program with `v0 = 3` instead of extrapolating the missing fourth corner `p + q - r` opposite the right-angle corner. The second triangle repeats the first, covering only half the rectangle (`28` of `64` texels on an `8x8` full-target rectangle in `mesh_tests::a_rectangle_of_a_vertex_id_program_covers_half_its_rectangle`, or half of a screen-space tile). 2. Multi-rectangle draws (`vertices = 3 * N`) pass `SV_InstanceID = 0..N-1` while `SV_VertexID` stays `0..3`, so every instance after the first sees `v0 = 0..3` again instead of `3 * instance + corner`. Noted as free on #339 (`#issuecomment-7218996806`), Refs #258.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:08:07 +00:00
Author
Owner

@⁠Sheffy007 on GitHub · 2026-11-27 14:07 UTC · original

/claim

**@⁠Sheffy007** on GitHub · 2026-11-27 14:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360#issuecomment-7220368192) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 14:07 UTC · original

Claimed by @⁠Sheffy007. Open a draft pull request with Refs #360 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-27 14:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360#issuecomment-7220372313) Claimed by @⁠Sheffy007. Open a draft pull request with `Refs #360` in its description within 24 hours, or the claim expires.
This discussion has been locked. Commenting is limited to contributors.
No description provided.