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