[PR #207] [CLOSED] d3d12: draw the console rectangle lists and quad lists (topologies 17 and 19) as triangles #259

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/207
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9940


📝 Commits (6)

  • 49d6959 d3d12: draw the console's rectangle lists (17, PSO type 19) and quad lists (19) as triangles
  • 464632f d3d12: rectangle list stage emits (v1 v2 v4) (v1 v4 v3) with capability Geometry, log cut-off quads (review fixes)
  • 1b276a9 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
  • 7de73af d3d12: rect_list_geometry records that packed f16 attributes cannot be told apart from float outputs on the vertex side (comment only)
  • 7589af0 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
  • 21dc388 d3d12: rect list test: every pixel well inside a non-right triangle is drawn; geometry notes edges are measured in NDC

📊 Changes

8 files changed (+923 additions, -11 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+12 -1)
📝 runtime/CMakeLists.txt (+15 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+52 -9)
➕ runtime/src/rect_list_geometry.h (+268 -0)
📝 runtime/src/vulkan_backend.h (+8 -0)
📝 runtime/src/vulkan_replay.h (+37 -1)
➕ runtime/test/d3d12_rect_list_test.cpp (+421 -0)
➕ runtime/test/replay_quad_list_test.cpp (+110 -0)

📄 Description

Carried over from old PR 9940 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9940, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
tedin7: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Rebased cleanly on current main; supersedes #7448 closed during org migration.

What

The console's rectangle list (IASetPrimitiveTopology(17), PSO topology type 19) and quad list (IASetPrimitiveTopology(19)) are accepted and drawn as triangles, instead of refusing the PSO (type 19, E_INVALIDARG) or silently drawing a plain triangle list. This is a 3D-rendering and PSO blocker: a PSO of type 19 fails creation today.

  • Rectangle list: three corners; the fourth is v2 + v3 - v1 for the position and every interpolant. The right-angle corner is the vertex opposite the longest screen edge. A type-19 PSO becomes a triangle-list pipeline plus a small generated geometry stage (runtime/src/rect_list_geometry.h) written from the vertex shader's own SPIR-V outputs. It emits (v1 v2 v4) (v1 v4 v3).
  • Quad list: drawn as triangle-list indices (0 1 2) (0 2 3) per quad, so flat inputs use the first quad vertex. Indexed draws read the application's index buffer; non-indexed draws read a shared index buffer (16384 quads per draw, more is cut off with a log line).
  • Docs: docs/d3d12_vulkan.md, "Console rectangle and quad lists".

Why

The fourth corner is a function of what the vertex stage wrote, and the translated vertex shaders fetch vertices themselves through V# loads, so a CPU or compute expansion of vertex data would be wrong for non-linear shaders. A geometry stage after the vertex stage is exact and needs only the geometryShader feature. Facts credited to the xvalkyrie backlog V8 (GPL-3.0, commit 53af7df77c10); no code copied.

Tested

Run on this base (current main, native g++ on the build host):

  • replay_quad_list_test (quad list is one triangle-list indexed draw, topology, index buffer, count 64): exit 0; the layer logs "a non-indexed quad list of 3 quads draws only the first 2" as designed.
  • Negative control: the same test against origin/main's runtime/src does not compile (quad_indices / quad-list topology do not exist), so it fails on main and passes with the change.
  • rect_list_geometry.h compiles standalone with g++ -std=c++20.

NOT run on this base (be aware): d3d12_rect_list_test (the GPU test, Windows exe through Wine) and the compile of shims/d3d12_vulkan_device.cpp. The GPU pods are off and this host has no unpacked Windows SDK; mingw headers are too old to syntax-check the Windows code. The earlier version of this PR (#7448, older base) measured on an RTX 4090 under Wine: rectangle list 4096 of 4096 pixels on the colour plane (worst error 0); quad list 4096 of 4096 bit-exact; it failed at the PSO on main ("primitive topology type not supported: 19"). The cherry-picks onto current main applied with no conflicts and the merge with the latest main is clean, but the GPU result on this base has not been reproduced. Please run d3d12_rect_list in CI/maintainer hardware before merging.


🔄 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/207 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9940` --- ### 📝 Commits (6) - [`49d6959`](https://github.com/ubiquitarianism/leonida/commit/49d6959790489d3c6bd6aee2323196a7cb570a73) d3d12: draw the console's rectangle lists (17, PSO type 19) and quad lists (19) as triangles - [`464632f`](https://github.com/ubiquitarianism/leonida/commit/464632f8ceb4e90ef260aca934ed2c82c9546ac1) d3d12: rectangle list stage emits (v1 v2 v4) (v1 v4 v3) with capability Geometry, log cut-off quads (review fixes) - [`1b276a9`](https://github.com/ubiquitarianism/leonida/commit/1b276a9e1be6719b23f80d4410862e51bf2a914f) 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 - [`7de73af`](https://github.com/ubiquitarianism/leonida/commit/7de73af8fcc879af7a21e1addf8e67b0028cb487) d3d12: rect_list_geometry records that packed f16 attributes cannot be told apart from float outputs on the vertex side (comment only) - [`7589af0`](https://github.com/ubiquitarianism/leonida/commit/7589af0406837ef2548cdee94d45f799de320303) 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 - [`21dc388`](https://github.com/ubiquitarianism/leonida/commit/21dc3889280dba49916f63342dab72750d3ee4b9) d3d12: rect list test: every pixel well inside a non-right triangle is drawn; geometry notes edges are measured in NDC ### 📊 Changes **8 files changed** (+923 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+12 -1) 📝 `runtime/CMakeLists.txt` (+15 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+52 -9) ➕ `runtime/src/rect_list_geometry.h` (+268 -0) 📝 `runtime/src/vulkan_backend.h` (+8 -0) 📝 `runtime/src/vulkan_replay.h` (+37 -1) ➕ `runtime/test/d3d12_rect_list_test.cpp` (+421 -0) ➕ `runtime/test/replay_quad_list_test.cpp` (+110 -0) </details> ### 📄 Description > Carried over from **old PR 9940** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9940`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `tedin7`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Rebased cleanly on current main; supersedes `#7448` closed during org migration. ## What The console's rectangle list (`IASetPrimitiveTopology(17)`, PSO topology type 19) and quad list (`IASetPrimitiveTopology(19)`) are accepted and drawn as triangles, instead of refusing the PSO (type 19, `E_INVALIDARG`) or silently drawing a plain triangle list. This is a 3D-rendering and PSO blocker: a PSO of type 19 fails creation today. - Rectangle list: three corners; the fourth is v2 + v3 - v1 for the position and every interpolant. The right-angle corner is the vertex opposite the longest screen edge. A type-19 PSO becomes a triangle-list pipeline plus a small generated geometry stage (`runtime/src/rect_list_geometry.h`) written from the vertex shader's own SPIR-V outputs. It emits (v1 v2 v4) (v1 v4 v3). - Quad list: drawn as triangle-list indices (0 1 2) (0 2 3) per quad, so flat inputs use the first quad vertex. Indexed draws read the application's index buffer; non-indexed draws read a shared index buffer (16384 quads per draw, more is cut off with a log line). - Docs: `docs/d3d12_vulkan.md`, "Console rectangle and quad lists". ## Why The fourth corner is a function of what the vertex stage wrote, and the translated vertex shaders fetch vertices themselves through V# loads, so a CPU or compute expansion of vertex data would be wrong for non-linear shaders. A geometry stage after the vertex stage is exact and needs only the geometryShader feature. Facts credited to the xvalkyrie backlog V8 (GPL-3.0, commit 53af7df77c10); no code copied. ## Tested Run on this base (current main, native g++ on the build host): - `replay_quad_list_test` (quad list is one triangle-list indexed draw, topology, index buffer, count 64): exit 0; the layer logs "a non-indexed quad list of 3 quads draws only the first 2" as designed. - Negative control: the same test against origin/main's `runtime/src` does not compile (`quad_indices` / quad-list topology do not exist), so it fails on main and passes with the change. - `rect_list_geometry.h` compiles standalone with g++ -std=c++20. NOT run on this base (be aware): `d3d12_rect_list_test` (the GPU test, Windows exe through Wine) and the compile of `shims/d3d12_vulkan_device.cpp`. The GPU pods are off and this host has no unpacked Windows SDK; mingw headers are too old to syntax-check the Windows code. The earlier version of this PR (`#7448`, older base) measured on an RTX 4090 under Wine: rectangle list 4096 of 4096 pixels on the colour plane (worst error 0); quad list 4096 of 4096 bit-exact; it failed at the PSO on main ("primitive topology type not supported: 19"). The cherry-picks onto current main applied with no conflicts and the merge with the latest main is clean, but the GPU result on this base has not been reproduced. Please run `d3d12_rect_list` in CI/maintainer hardware before merging. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:18 +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#259
No description provided.