d3d12: draw the console rectangle lists and quad lists (topologies 17 and 19) as triangles #207

Closed
github-bot wants to merge 6 commits from gh-pr/207/head into gh-pr/207/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:43 UTC · original
ubiquitarianism:old-pr/9940 → main · +923 −11 · 8 files · 6 commits · closed without merging

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.

**@⁠Andretuta** on GitHub · 2026-11-24 02:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207) `ubiquitarianism:old-pr/9940` → `main` · +923 −11 · 8 files · 6 commits · closed without merging > 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.
A rectangle list is three corners; the fourth is v2 + v3 - v1 for the position and every interpolant, after the vertex stage. A quad list is four vertices per quad. Vulkan has neither. A PSO with topology type 19 was refused (E_INVALIDARG) and the two list topologies drew as a plain triangle list.

Rectangle list: the PSO becomes a triangle-list pipeline with a generated geometry stage (src/rect_list_geometry.h), built from the vertex shader's own SPIR-V outputs, that emits the strip v1 v2 v3 v4. Quad list: one triangle fan per quad (0 1 2, 0 2 3), drawn with the index values 4q..4q+3 so the translated vertex id (VertexIndex - BaseVertex) is right; non-indexed draws read a shared 0, 1, 2, ... buffer reserved in the arena.

Facts from xvalkyrie (GPL-3.0, commit 53af7df77c10); no code copied.
Taken from the follow-up patch of @matheuskshn (930e78a2, tested by them on an RTX 4070 Ti: replay_quad_list_test fails the two non-indexed cases on a6b31d51 and passes with it). Re-run here: replay_quad_list_test and d3d12_rect_list_test exit 0 on the pod (Wine, RTX 4090).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:48:44 +00:00
github-bot closed this pull request 2026-11-26 08:48:44 +00:00
Author
Owner

@⁠Sigtryggur-Mani-Gudmundsson on GitHub · 2026-11-24 04:28 UTC · original

I tested the indexed quad path at 21dc3889 on an RTX 4070 Ti with Khronos synchronization validation. A flat red quad came back black in all 4,096 pixels. Two overlapping instances left red on top where the explicit triangle-list reference was green. The non-indexed controls matched both references.

This follow-up to tedin7’s PR extends the triangle pattern credited to matheuskshn to GPU-resident 16- and 32-bit application indices. A single instanced draw keeps the base vertex and first instance. Out-of-view indices read zero. All eight 64 × 64 frames matched the reference after applying the patch. Five failed on this PR head. replay_quad_list, vulkan_scratch and vk_command_replay passed. Large-draw performance, the Windows D3D12 front end and retail startup remain unmeasured.

Patch, GPU fixture, full results and reproduction commands.

**@⁠Sigtryggur-Mani-Gudmundsson** on GitHub · 2026-11-24 04:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7122054510) I tested the indexed quad path at `21dc3889` on an RTX 4070 Ti with Khronos synchronization validation. A flat red quad came back black in all 4,096 pixels. Two overlapping instances left red on top where the explicit triangle-list reference was green. The non-indexed controls matched both references. This follow-up to tedin7’s PR extends the triangle pattern credited to matheuskshn to GPU-resident 16- and 32-bit application indices. A single instanced draw keeps the base vertex and first instance. Out-of-view indices read zero. All eight 64 × 64 frames matched the reference after applying the patch. Five failed on this PR head. `replay_quad_list`, `vulkan_scratch` and `vk_command_replay` passed. Large-draw performance, the Windows D3D12 front end and retail startup remain unmeasured. [Patch, GPU fixture, full results and reproduction commands](https://github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches/tree/be306ce247d476860efbae1824fdd33acdbd6340/tests/indexed-quads).
Author
Owner

@⁠VibeClauding on GitHub · 2026-11-24 07:46 UTC · original

Windows test report, since this PR's CI was cancelled: head 21dc38892 merged onto main 8f481cf16 (no conflicts), MSVC, Windows 11, RTX 3070 (driver 610.88).

  • d3d12_rect_list passes under LEONIDA_VK_VALIDATION=1, 0 validation errors: rect list 4096/4096 pixels (worst error 0), right angle at the second and third vertex 4096/4096 each, non-right triangle 2156 pixels drawn, quad list 4096/4096 exact.
  • replay_quad_list passes.
  • Full ctest: 304/305. The one failure, d3d12_execute_indirect_validation, fails the same way on unchanged main here (#337 / #306).

The PR's own tests draw non-indexed quads only, so they neither confirm nor rule out the indexed-quad failure reported above. The rectangle-list path (PSO topology type 19, the four PSOs the retail boot refuses per #432) works on this Windows/NVIDIA stack. AI-assisted.

**@⁠VibeClauding** on GitHub · 2026-11-24 07:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7125363885) Windows test report, since this PR's CI was cancelled: head `21dc38892` merged onto `main` `8f481cf16` (no conflicts), MSVC, Windows 11, RTX 3070 (driver 610.88). - `d3d12_rect_list` passes under `LEONIDA_VK_VALIDATION=1`, 0 validation errors: rect list 4096/4096 pixels (worst error 0), right angle at the second and third vertex 4096/4096 each, non-right triangle 2156 pixels drawn, quad list 4096/4096 exact. - `replay_quad_list` passes. - Full `ctest`: 304/305. The one failure, `d3d12_execute_indirect_validation`, fails the same way on unchanged `main` here (#337 / #306). The PR's own tests draw non-indexed quads only, so they neither confirm nor rule out the indexed-quad failure reported above. The rectangle-list path (PSO topology type 19, the four PSOs the retail boot refuses per #432) works on this Windows/NVIDIA stack. AI-assisted.
Author
Owner

@⁠Mumogg on GitHub · 2026-11-24 10:03 UTC · original

Tested this on the retail boot, merged at 21dc38892 on top of main d7576d56a with my stacked pull requests #375 to #432, #602, #387, and #445, #360, #219. Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8, own 1.0.2.1 copy, network off, 120 s allowed, one run each. The merge was clean.

--run, 120 s without #207 with #207
CreatePipelineState ok / failed 50,466 / 4 (primitive topology type not supported: 19) 50,470 / 0
PresentX ok 177,572 46,467
DrawInstanced 177,571 (one per present) 139,350 (three per present)
How it ends still running, killed by the timeout still running, killed by the timeout

So the four pipelines that failed are created and the title now draws with them. The picture is still black: with LEONIDA_CAPTURE (8 frames, one every 5,000 presents) every captured frame is uniformly (0, 0, 0). I have not established why, so I am not attributing it to this pull request; it was black before it too.

AI-assisted.

**@⁠Mumogg** on GitHub · 2026-11-24 10:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7128252784) Tested this on the retail boot, merged at `21dc38892` on top of `main` `d7576d56a` with my stacked pull requests #375 to #432, #602, #387, and #445, #360, #219. Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8, own 1.0.2.1 copy, network off, 120 s allowed, one run each. The merge was clean. | `--run`, 120 s | without #207 | with #207 | |---|---|---| | `CreatePipelineState` ok / failed | 50,466 / 4 (`primitive topology type not supported: 19`) | 50,470 / 0 | | `PresentX` ok | 177,572 | 46,467 | | `DrawInstanced` | 177,571 (one per present) | 139,350 (three per present) | | How it ends | still running, killed by the timeout | still running, killed by the timeout | So the four pipelines that failed are created and the title now draws with them. **The picture is still black**: with `LEONIDA_CAPTURE` (8 frames, one every 5,000 presents) every captured frame is uniformly (0, 0, 0). I have not established why, so I am not attributing it to this pull request; it was black before it too. AI-assisted.
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 14:11 UTC · original

Check on a second NVIDIA machine (Windows 11, RTX 5070, driver 617.14, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy): this pull request merged on top of main 21625bca8 + #641 + #427 + #727 + #602 + #387 + #357 + #432, which reaches the frame loop, keeps it there: 473,041 PresentX ok and 18,985,555 D3D12 calls in 200 s, no exception, merged without conflicts. Without lazy PSOs only. I did not check whether the rectangle-list pipelines are created on this stack, so this says nothing about the draw itself.

AI-assisted: yes (Claude Code, Sonnet 5.5)

**@⁠DesertGamer** on GitHub · 2026-11-24 14:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7133984487) Check on a second NVIDIA machine (Windows 11, RTX 5070, driver 617.14, `LEONIDA_D3D12=vulkan`, own 1.0.2.1 copy): this pull request merged on top of `main` 21625bca8 + #641 + #427 + #727 + #602 + #387 + #357 + #432, which reaches the frame loop, keeps it there: 473,041 `PresentX ok` and 18,985,555 D3D12 calls in 200 s, no exception, merged without conflicts. Without lazy PSOs only. I did not check whether the rectangle-list pipelines are created on this stack, so this says nothing about the draw itself. AI-assisted: yes (Claude Code, Sonnet 5.5)
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 17:21 UTC · original

Regression check on Windows 10 Pro 22H2 (19045), RTX 5060 Ti (621.01), VS 2022 RelWithDebInfo, LEONIDA_VK_VALIDATION=1, merged onto main 32950551e without conflicts, targets rebuilt: replay_quad_list_test passes; d3d12_draw_test and d3d12_mesh_test exit 0 with 0 VUID lines. I could not run d3d12_rect_list_test: its target needs the translated M1.5 fixtures and there is no llvm-mc here, so this says nothing about the rectangle path itself. Synthetic tests, no game files. AI-assisted (Claude Code); I read the code diff.

**@⁠Snooozs** on GitHub · 2026-11-24 17:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7139063792) Regression check on Windows 10 Pro 22H2 (19045), RTX 5060 Ti (621.01), VS 2022 RelWithDebInfo, `LEONIDA_VK_VALIDATION=1`, merged onto `main` 32950551e without conflicts, targets rebuilt: `replay_quad_list_test` passes; `d3d12_draw_test` and `d3d12_mesh_test` exit 0 with 0 VUID lines. I could not run `d3d12_rect_list_test`: its target needs the translated M1.5 fixtures and there is no llvm-mc here, so this says nothing about the rectangle path itself. Synthetic tests, no game files. AI-assisted (Claude Code); I read the code diff.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:19 UTC · original

This carry-over of old upstream PR 9940 has been taken over in #682, so I'm closing this draft as #17 describes. The branch old-pr/9940 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/207#issuecomment-7141930060) This carry-over of old upstream PR 9940 has been taken over in #682, so I'm closing this draft as #17 describes. The branch `old-pr/9940` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.