OLD-9940: draw Xbox rectangle and indexed quad lists as triangles #682

Merged
QemmHD merged 13 commits from upstream-pr/682 into main 2026-11-25 02:33:48 +00:00
QemmHD commented 2026-11-24 11:50:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T11:50:07Z.


Claimed in #14 as OLD-9940. Follow-up to #207. This branch carries tedin7's six original patches onto current main and keeps their authorship.

What and why

The Xbox rectangle-list pipeline uses topology type 19. The Vulkan backend currently rejects it. This adds the rectangle geometry stage and draws quad lists as triangles.

The first indexed quad implementation used a triangle fan per quad. That picks the wrong vertex for flat attributes and changes draw order when instances overlap. This branch expands indices on the GPU and issues a single instanced triangle-list draw. Flat attributes come from the quad's first vertex and instance order is preserved.

Shader-addressable standalone buffers now round their Vulkan backing size to a four-byte word for 16-bit index loads. D3D resource sizes and index-view bounds stay the same.

Tested

  • Windows 11 x64, MSVC 14.44 RelWithDebInfo, RTX 4070 SUPER, NVIDIA 621.24, on main 21625bca8.
  • d3d12_rect_list, d3d12_quad_index, replay_quad_list, vulkan_scratch, and d3d12_xmem_placed: 5/5 passed.
  • GPU-assisted Vulkan validation: all seven quad frames matched all 4,096 pixels, including the standalone 16-bit upload index case. No validation errors were reported in that run.
  • The prepared-draw bounds guard passes the unchanged replay_query_predication fixture and the replay and GPU quad tests. GPU validation remained clean.
  • Repository game-data scan, git diff --check, and local merge check passed.

Live game coverage for this branch is pending. AI-assisted: yes (Claude Code and Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5471566185 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/682). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T11:50:07Z. --- Claimed in #14 as [OLD-9940](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127552942). Follow-up to #207. This branch carries tedin7's six original patches onto current `main` and keeps their authorship. ### What and why The Xbox rectangle-list pipeline uses topology type 19. The Vulkan backend currently rejects it. This adds the rectangle geometry stage and draws quad lists as triangles. The first indexed quad implementation used a triangle fan per quad. That picks the wrong vertex for flat attributes and changes draw order when instances overlap. This branch expands indices on the GPU and issues a single instanced triangle-list draw. Flat attributes come from the quad's first vertex and instance order is preserved. Shader-addressable standalone buffers now round their Vulkan backing size to a four-byte word for 16-bit index loads. D3D resource sizes and index-view bounds stay the same. ### Tested - Windows 11 x64, MSVC 14.44 RelWithDebInfo, RTX 4070 SUPER, NVIDIA 621.24, on `main` `21625bca8`. - `d3d12_rect_list`, `d3d12_quad_index`, `replay_quad_list`, `vulkan_scratch`, and `d3d12_xmem_placed`: 5/5 passed. - GPU-assisted Vulkan validation: all seven quad frames matched all 4,096 pixels, including the standalone 16-bit upload index case. No validation errors were reported in that run. - The prepared-draw bounds guard passes the unchanged `replay_query_predication` fixture and the replay and GPU quad tests. GPU validation remained clean. - Repository game-data scan, `git diff --check`, and local merge check passed. Live game coverage for this branch is pending. AI-assisted: yes (Claude Code and Codex).
towade commented 2026-11-24 15:25:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by towade on 2026-11-24T15:25:42Z.


@QemmHD, a heads-up for when this meets #511 (LEONIDA_LAZY_PSO): the two merge without a textual conflict, but in the merged d3d12_vulkan_device.cpp, #511's stage.words = {}; (end of the stage loop) runs before this PR's if (rect_list) block. That block calls leonida::rect_list_geometry(vs_stage.words, why), so it would get empty words. The clear is outside #511's lazy branch, so this happens with LEONIDA_LAZY_PSO unset too, and every rectangle-list PSO would return E_NOTIMPL ("cannot be drawn as a rectangle list").

Building the rectangle-list stage before the clear, or keeping the vertex stage's words until after it, would avoid it. The same word-lifetime problem was found for #207 on #511.

Found by reading the merged source (git merge-tree of both heads, 6aa8eb11c and 88658f1b3). I have not built or run the combination yet.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7136009416 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/682#issuecomment-7136009416). Originally posted by [towade](https://github.com/towade) on 2026-11-24T15:25:42Z. --- @QemmHD, a heads-up for when this meets #511 (`LEONIDA_LAZY_PSO`): the two merge without a textual conflict, but in the merged `d3d12_vulkan_device.cpp`, #511's `stage.words = {};` (end of the stage loop) runs before this PR's `if (rect_list)` block. That block calls `leonida::rect_list_geometry(vs_stage.words, why)`, so it would get empty words. The clear is outside #511's lazy branch, so this happens with `LEONIDA_LAZY_PSO` unset too, and every rectangle-list PSO would return `E_NOTIMPL` ("cannot be drawn as a rectangle list"). Building the rectangle-list stage before the clear, or keeping the vertex stage's words until after it, would avoid it. The same word-lifetime problem was found for #207 on #511. Found by reading the merged source (`git merge-tree` of both heads, `6aa8eb11c` and `88658f1b3`). I have not built or run the combination yet. AI-assisted (Claude Code).
Dezmonius commented 2026-11-24 15:36:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Dezmonius on 2026-11-24T15:36:22Z.


Native Windows follow-up to the #511 integration warning. I applied the #511 diff at 88658f1b to #682 at 6aa8eb11. Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Khronos Vulkan validation 1.4.369.

  • Plain combination: with LEONIDA_LAZY_PSO=0 and =1, d3d12_rect_list failed on the same message: the vertex shader is not a SPIR-V module. Indexed quad and replay tests passed in both modes.
  • Local ordering-only control: retained vs_stage.words when rect_list is set and released it immediately after rect_list_geometry. Both modes passed all three tests with validation enabled. The three rectangle colour-plane cases matched 4,096/4,096 pixels each, and all seven indexed-quad frames matched 4,096/4,096 pixels each.

This checks the combined revisions with synthetic fixtures only. No game files or retail boot. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7136308990 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/682#issuecomment-7136308990). Originally posted by [Dezmonius](https://github.com/Dezmonius) on 2026-11-24T15:36:22Z. --- Native Windows follow-up to [the #511 integration warning](https://github.com/ubiquitarianism/leonida/pull/682#issuecomment-7136009416). I applied the #511 diff at `88658f1b` to #682 at `6aa8eb11`. Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Khronos Vulkan validation 1.4.369. - Plain combination: with `LEONIDA_LAZY_PSO=0` and `=1`, `d3d12_rect_list` failed on the same message: `the vertex shader is not a SPIR-V module`. Indexed quad and replay tests passed in both modes. - Local ordering-only control: retained `vs_stage.words` when `rect_list` is set and released it immediately after `rect_list_geometry`. Both modes passed all three tests with validation enabled. The three rectangle colour-plane cases matched 4,096/4,096 pixels each, and all seven indexed-quad frames matched 4,096/4,096 pixels each. This checks the combined revisions with synthetic fixtures only. No game files or retail boot. AI-assisted (Codex).
Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!682
No description provided.