Repository navigation
d3d12: console rectangle lists and quad lists draw as triangles (rect list PSO topology type 19, list topologies 17 and 19), bit-exact on an RTX 4090 - #7448
Conversation
…lists (19) as triangles 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.
…ty Geometry, log cut-off quads (review fixes)
|
Code read of a6b31d5 (not run). The rectangle path checks out: v4 = v2 + v3 - v1, and both emitted triangles (v1 v2 v4) and (v1 v4 v3) keep (v1 v2 v3)'s winding (both cross products reduce to (v2-v1) x (v3-v1)) and start at v1 for flat inputs. One point on quad lists (vulkan_replay.h, emit): every quad is its own vkCmdDrawIndexed ( AI-assisted (Claude Code). |
|
Tested
Setup:
AI-assisted (Claude Code, Claude Opus 5.5). |
|
Tested a6b31d5 on NVIDIA GeForce RTX 5070 Ti Laptop (driver 621.24) and AMD Radeon 610M (gfx1036 iGPU, AMD Windows driver 26.11.2 / 32.0.21045.29003), Windows 11 Home 26200: pass This is native Windows, not Wine. Built with MSVC 14.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0. Devices picked with
No game files. AI-assisted (Claude Code). |
|
Tested
AI-assisted. |
|
Tested a6b31d5 on an integration branch with the console command-list proxy, #7685 and the same local shader catalog for both runs. Wine 11.22, RTX 5070 Ti, NVIDIA 620.73.04.
AI-assisted verification. No game files or logs attached. |
|
Tested
|
|
Independent Windows 11 check of a6b31d5 on RTX 4070 Ti, NVIDIA 621.24, Clang 23.1.5. The generated rectangle geometry stage covered all 4,096 pixels with exact smooth interpolation and selected the first vertex for flat inputs. This used the Vulkan harness. Full Direct3D COM verification still requires a compatible Windows SDK and MSVC ABI. A flat-color quad test reproduced the different provoking vertex between the Vulkan triangle fan and the stated 0,1,2 / 0,2,3 triangle list. Two overlapping quads with two blended instances also showed the change in order. The linked patch batches non-indexed quads in one triangle-list draw and preserves instance order and draw bases. Ten portable CTest checks passed, including a new replay regression that fails on the original version. The patch also reads the PSO topology field as raw bits. In a separate probe with Microsoft's DirectX headers, Clang -O2 -fstrict-enums optimized the direct comparison to type 19 to false. The raw-bit comparison preserved 19. Synthetic inputs only. AI-assisted. Patch on my fork. |
…at inputs use the first quad vertex, and the PSO topology type is read as raw bits Taken from the follow-up patch of @matheuskshn (930e78a, tested by them on an RTX 4070 Ti: replay_quad_list_test fails the two non-indexed cases on a6b31d5 and passes with it). Re-run here: replay_quad_list_test and d3d12_rect_list_test exit 0 on the pod (Wine, RTX 4090).
|
@matheuskshn thank you: the provoking-vertex difference between the Vulkan triangle fan and the stated (0 1 2) (0 2 3) list is a real defect of the first version, and the raw-bit read of the PSO topology type is a good catch (strict enums can optimise |
|
checked: #7448dbab003 | with: AI-assisted (Claude Code). |
…e told apart from float outputs on the vertex side (comment only)
|
@pvfreis thank you for the code read, it is right. I traced it: |
|
checked: #7448 (A38) | head dbab003 merged onto main 867d922 (clean); |
|
Tested 81caaa1 on CachyOS, Wine 11.22 and Clang 23.1.5 / MinGW. The unmodified d3d12_rect_list_test passed through the D3D12 proxy and Vulkan backend on both RTX 5080 (620.70.06) and Ryzen 9 9900X Raphael iGPU (RADV Mesa 26.2.6). Each GPU matched 4096/4096 rectangle pixels with zero interpolation error and 4096/4096 quad-list pixels exactly. The native Linux replay_quad_list_test also passed, covering draw bases, incomplete quads, generated indices and the indexed fallback. The scratch cross-build used MIT DirectX-Headers with the same declaration compatibility adjustments as the Wine slot-133 tests. Both Wine runs used a private Xvfb display. Synthetic inputs only, no title execution. AI-assisted verification. |
|
Retail result for
AI-assisted (Claude Code). |
|
Independent Linux/Wine RTX 3060 verification of current head Debian 13 / Linux 6.12.117, Wine 10.0, clang-cl 23.1.6 + xwin, NVIDIA 580.196.07. Exact PR head tested, not merged onto current maintainer integration. Negative control uses merge-base
Extra scratch coverage, not a test shipped by this PR: interleaved the two quads' vertices and selected them through an application-provided R16 index buffer This adds indexed-quad image evidence beyond the existing non-indexed fixture. It does not cover indexed flat/provoking-vertex semantics, overlapping blended instances, packed-f16 attributes, validation-layer cleanliness, or integration compatibility. No deployment or game-rendering claim. |
|
Forge integration check for this change (Forge #7, Native Windows 11 / RTX 4070 Ti SUPER A/B, |
|
Finding on the rectangle-list geometry stage ( Measured on the retail 1.0.2.1 boot (local stack with this PR; pixel shader replaced by a constant red for the experiment, culling/depth/stencil/blend off), readback of the 3840x2160 off-screen target:
Suggestion: pick the right-angle corner per rectangle instead of assuming On: Windows 11 Home 26200, RTX 5070 Ti Laptop (NVIDIA 621.24), MSVC 14.44. No game data in this comment (counts only). AI-assisted (Claude Code). |
…ngle (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
…s drawn; geometry notes edges are measured in NDC
|
Etr0p's finding applied (thanks): the stage no longer assumes the right angle is at the first vertex. It takes the vertex opposite the longest edge in screen space (position.xy / position.w; the first vertex on a tie) as p, its two neighbours a and b in the drawn order (same winding), and the fourth corner a + b - p for the position and every interpolant. OpSelect on squared edge lengths, no new capabilities, no branches. Tested on an RTX 4090 pod (Wine, cross-built), d3d12_rect_list_test:
Known limit, noted in the header: edges are measured in NDC, so a rotated rectangle in a very non-square viewport can pick a different corner than the pixel-space right angle. Flat inputs now come from p, which changes with the corner. I did not re-measure on the retail boot. AI-assisted. |
Claimed in #7231 (comment)
@ItsNotRexed: an exe PR, as you asked.
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.runtime/src/rect_list_geometry.h), written from the vertex shader's own SPIR-V outputs. It emits (v1, v2, v4) and (v1, v4, v3), so both triangles start at v1 and a flat input is v1's.docs/d3d12_vulkan.md, "Console rectangle and quad lists".Why
Option choice: the fourth corner is a function of what the vertex stage wrote, not of what it read, and the translated vertex shaders fetch their vertices themselves through V# buffer loads (no vertex buffer to expand). So a CPU expansion or a compute pre-pass over the vertex data would be wrong for any non-linear shader. A geometry stage after the vertex stage is exact and needs only the
geometryShaderfeature (elseE_NOTIMPL). For quads, the translated vertex id isVertexIndex - BaseVertex, so splitting a draw byfirstVertexwould zero it; indexing with real values 4q..4q+3 keeps it right.Credit for the facts: xvalkyrie backlog V8 (GPL-3.0, commit 53af7df77c10). No code was copied.
Tested
New
d3d12_rect_list_test(translated vs_m15 + ps_m15, real FSSM lookup, 64x64 R32G32B32A32_FLOAT, read back), on pod p2 (NVIDIA GeForce RTX 4090,vulkaninfodriverName NVIDIA), Wine:origin/mainsources fails at the PSO ("primitive topology type not supported: 19", exit 1).d3d12_translated_draw_test(4064/4096 + the 32 diagonal edge pixels, unchanged),d3d12_geometry_test,d3d12_draw_test,d3d12_depth24_draw_testall pass.