[PR #682] [MERGED] OLD-9940: draw Xbox rectangle and indexed quad lists as triangles #722

Closed
opened 2026-11-26 20:18:50 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/682
Author: @QemmHD
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: qemmhd/old-9940-rectangle-quad-lists


📝 Commits (10+)

  • 21f07a0 d3d12: draw the console's rectangle lists (17, PSO type 19) and quad lists (19) as triangles
  • 0688b83 d3d12: rectangle list stage emits (v1 v2 v4) (v1 v4 v3) with capability Geometry, log cut-off quads (review fixes)
  • abe64d4 d3d12: quad lists draw as triangle-list indices (0 1 2) (0 2 3) so flat inputs use the first quad vertex, and the PSO topology type is read as raw bits
  • e3c22cc d3d12: rect_list_geometry records that packed f16 attributes cannot be told apart from float outputs on the vertex side (comment only)
  • 0bd3c99 d3d12: rectangle list geometry picks the right-angle corner per rectangle (the vertex opposite the longest screen edge) instead of assuming the first; tests for the corner at the second and third vertex and for a non-right triangle
  • ee9db97 d3d12: rect list test: every pixel well inside a non-right triangle is drawn; geometry notes edges are measured in NDC
  • 8311d89 d3d12: the quad list index counts are 32-bit constants, not narrowed from size_t (C4267)
  • 7739895 vulkan_scratch: the chunks can take usage beyond transfer source and destination
  • a9fb805 d3d12: indexed quad lists draw from triangle indices a compute pass expands on the GPU (OLD-9940)
  • 6ce66cf d3d12: GPU test for indexed quad lists: both index sizes, a base vertex, flat inputs, overlapping instances (d3d12_quad_index)

📊 Changes

18 files changed (+2203 additions, -43 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+37 -1)
📝 docs/testing.md (+3 -3)
📝 runtime/CMakeLists.txt (+40 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+79 -23)
➕ runtime/src/quad_index_expand.comp (+44 -0)
➕ runtime/src/quad_index_expand.h (+182 -0)
➕ runtime/src/quad_index_expand_spv.h (+148 -0)
➕ runtime/src/rect_list_geometry.h (+268 -0)
📝 runtime/src/vulkan_backend.h (+34 -3)
📝 runtime/src/vulkan_replay.h (+106 -8)
📝 runtime/src/vulkan_scratch.h (+6 -3)
➕ runtime/test/d3d12_quad_index_test.cpp (+359 -0)
➕ runtime/test/d3d12_rect_list_test.cpp (+421 -0)
➕ runtime/test/replay_quad_list_test.cpp (+406 -0)
➕ runtime/test/shaders/ps_quad_flat.asm (+15 -0)
➕ runtime/test/shaders/vs_quad_inst.asm (+28 -0)
📝 runtime/test/vulkan_scratch_test.cpp (+25 -1)
📝 scripts/run_gpu_tests.py (+2 -1)

📄 Description

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/682 **Author:** [@QemmHD](https://github.com/QemmHD) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `qemmhd/old-9940-rectangle-quad-lists` --- ### 📝 Commits (10+) - [`21f07a0`](https://github.com/ubiquitarianism/leonida/commit/21f07a063ba0000cfeb8717075d28809056b3561) d3d12: draw the console's rectangle lists (17, PSO type 19) and quad lists (19) as triangles - [`0688b83`](https://github.com/ubiquitarianism/leonida/commit/0688b839baf12e7a80795744c908a6ee3e4fdcc1) d3d12: rectangle list stage emits (v1 v2 v4) (v1 v4 v3) with capability Geometry, log cut-off quads (review fixes) - [`abe64d4`](https://github.com/ubiquitarianism/leonida/commit/abe64d495b0a22a78ccf9106f1980c2f550778e0) d3d12: quad lists draw as triangle-list indices (0 1 2) (0 2 3) so flat inputs use the first quad vertex, and the PSO topology type is read as raw bits - [`e3c22cc`](https://github.com/ubiquitarianism/leonida/commit/e3c22cc24693eb654be1bbea7cca32ebc62fd8b7) d3d12: rect_list_geometry records that packed f16 attributes cannot be told apart from float outputs on the vertex side (comment only) - [`0bd3c99`](https://github.com/ubiquitarianism/leonida/commit/0bd3c99d69d5f794eec29695e22ca46812300e4b) d3d12: rectangle list geometry picks the right-angle corner per rectangle (the vertex opposite the longest screen edge) instead of assuming the first; tests for the corner at the second and third vertex and for a non-right triangle - [`ee9db97`](https://github.com/ubiquitarianism/leonida/commit/ee9db97988cb8c8ee36ab835becffb3b9e1d6bae) d3d12: rect list test: every pixel well inside a non-right triangle is drawn; geometry notes edges are measured in NDC - [`8311d89`](https://github.com/ubiquitarianism/leonida/commit/8311d8918c3d6ec5cafbfbb6577aad69c6d1a06b) d3d12: the quad list index counts are 32-bit constants, not narrowed from size_t (C4267) - [`7739895`](https://github.com/ubiquitarianism/leonida/commit/7739895421f52326ab9523690848ec105e99e2e5) vulkan_scratch: the chunks can take usage beyond transfer source and destination - [`a9fb805`](https://github.com/ubiquitarianism/leonida/commit/a9fb8058aa14d7686c6af11d1b14064924fe50d2) d3d12: indexed quad lists draw from triangle indices a compute pass expands on the GPU (OLD-9940) - [`6ce66cf`](https://github.com/ubiquitarianism/leonida/commit/6ce66cf219c9036195f3abe429fa4893867057ca) d3d12: GPU test for indexed quad lists: both index sizes, a base vertex, flat inputs, overlapping instances (d3d12_quad_index) ### 📊 Changes **18 files changed** (+2203 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+37 -1) 📝 `docs/testing.md` (+3 -3) 📝 `runtime/CMakeLists.txt` (+40 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+79 -23) ➕ `runtime/src/quad_index_expand.comp` (+44 -0) ➕ `runtime/src/quad_index_expand.h` (+182 -0) ➕ `runtime/src/quad_index_expand_spv.h` (+148 -0) ➕ `runtime/src/rect_list_geometry.h` (+268 -0) 📝 `runtime/src/vulkan_backend.h` (+34 -3) 📝 `runtime/src/vulkan_replay.h` (+106 -8) 📝 `runtime/src/vulkan_scratch.h` (+6 -3) ➕ `runtime/test/d3d12_quad_index_test.cpp` (+359 -0) ➕ `runtime/test/d3d12_rect_list_test.cpp` (+421 -0) ➕ `runtime/test/replay_quad_list_test.cpp` (+406 -0) ➕ `runtime/test/shaders/ps_quad_flat.asm` (+15 -0) ➕ `runtime/test/shaders/vs_quad_inst.asm` (+28 -0) 📝 `runtime/test/vulkan_scratch_test.cpp` (+25 -1) 📝 `scripts/run_gpu_tests.py` (+2 -1) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:50 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#722
No description provided.