gpu: lower primitive topology 0x11 (rectangle list) to triangle list (Refs #870) #1061
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1068"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T00:12:11Z.
This pull request implements lowering of primitive topology
0x11(VGT_PRIMITIVE_TYPE_RECTLIST) to standard Direct3D 12 triangle lists (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST), addressing point 5 of the #870 checkpoint.Interface & Provenance
VGT_PRIMITIVE_TYPE_RECTLIST = 0x11(17 decimal), taking 3 vertices per primitive(v_0, v_1, v_2).0x1through0xa, and0x21..0x48). Passing raw0x11causes D3D12 debug layer validation error and driver rejection.Implementation
tools/rectlist_topology.py:derive_fourth_vertex: computesv_3 = v_0 + v_2 - v_1for positions and linearly interpolates vertex attributes.expand_rectangles: lowersNrectangles (3Nvertices) into2Ntriangles (6Nvertices) forming counter-clockwise triangles(v_0, v_1, v_2)and(v_0, v_2, v_3).expand_indices: generates index buffer sequences[0, 1, 2, 0, 2, 3]for indexed rectangle draws.rect_raster_oracle: reference rasterizer comparing point-in-rectangle coverage against analytically derived triangles.Verification
tests/rectlist_topology_check.py:[-1, 1] \times [-1, 1]).Tested Commands & Results
Refs #870.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:14:47Z.
Review: CHANGES_REQUESTED
This is a useful CPU geometry prototype. The current expansion preserves the sign of the first triangle, so the same positions with v0 and v2 exchanged produce clockwise output. Please document and validate corner order as a defined input precondition, or state that winding follows input order. Before we can accept this as desktop topology lowering, please exercise the emitted triangles in a source-built WARP draw with culling enabled, distinct interpolated attributes and coverage against a separate expected rectangle. The reversed-winding and wrong-corner mutants should both fail GPU readback. Keep the runtime hook for a follow-up.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:50:06Z.
Review: APPROVED
I kept your rebased branch and added a check that feeds the GPU renderer the actual Python expansion. Windows Release passes the Python suite plus RTX 4060 Laptop and WARP draws. Each adapter had zero positive mismatches and detected the reversed-winding and wrong-corner controls (900 and 435). Mutating only the Python output also failed WARP with 282 mismatches. The runtime hook remains separate.
Candidate:
cbf3c8bb84Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T00:27:19Z.
Thanks for the review and guidance, @R0Y00! I've updated the branch (
85ce3705) addressing all requested points:Corner Order Precondition & Winding Preservation:
tools/rectlist_topology.py:(v_0, v_1, v_2)wherev_0andv_1are adjacent corners andv_2is diagonally opposite tov_1.(v_0, v_1, v_2)and Triangle 1(v_0, v_2, v_3)possess identical signed 2D area: So the winding order of both lowered triangles strictly follows the input winding.validate_corner_ordervalidating non-collinearity, CCW winding, and optional edge orthogonality.Source-Built D3D12 WARP Draw Fixture with Culling Enabled:
tests/rectlist_draw_check.cppandtests/rectlist_quad.hlsl, registeringrectlist_draw_warpandrectlist_draw_hardwarein CMake.CullMode = D3D12_CULL_MODE_BACKandFrontCounterClockwise = TRUE.v_0, v_1, v_2have distinct RGBA colors, withv_3color derived identically to positions.[-0.46, 0.46]^2are compared against bilinear analytical interpolation, and pixels outside[-0.54, 0.54]^2must be clear color (0).Mutant Controls against GPU Readback:
v_0andv_2flips winding to clockwise. The GPU hardware rasterizer discards all back-facing triangles underD3D12_CULL_MODE_BACK, leaving the buffer completely clear (900 culled mismatches against expected rectangle).v_3 = v_0 + v_2): distorts Triangle 1 and leaves the top-left quadrant unrendered (435 mismatches against expected rectangle).0x11fails pipeline creation with0x80070057(E_INVALIDARG).Runtime Hook:
Verification (Windows 11 x64, RX 6600M & WARP):
AI-assisted.