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

Closed
opened 2026-11-27 14:07:20 +00:00 by Sheffy007 · 2 comments
Sheffy007 commented 2026-11-27 14:07:20 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T14:07:20Z.


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 #338 (#issuecomment-7218996806), Refs #258.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6648034059 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T14:07:20Z. --- 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 #338 (`#issuecomment-7218996806`), Refs #258.
Sheffy007 commented 2026-11-27 14:07:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T14:07:21Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7220368192 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360#issuecomment-7220368192). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T14:07:21Z. --- /claim
github-actions[bot] commented 2026-11-27 14:07:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T14:07:32Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7220372313 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/360#issuecomment-7220372313). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T14:07:32Z. --- Claimed by @Sheffy007. Open a draft pull request with `Refs #360` in its description within 24 hours, or the claim expires.
Sign in to join this conversation.
No labels
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.

Reference
LakshanSivakumar/Native-Victory-macOS#360
No description provided.