d3d12: console rectangle lists and quad lists draw as triangles (PSO topology type 19; retail boot CreatePipelineState 50,470 of 50,470) #7
Loading…
Reference in a new issue
No description provided.
Delete branch "tedin9/leonida:rect-list-geometry"
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?
Upstream GitHub PR: ItsNotRexed/Leonida#7448 (same change, rebased onto forge/main).
What
The console's rectangle-list topology (PSO topology type 19,
IASetPrimitiveTopology(17)) and quad-list topology (IASetPrimitiveTopology(19)) draw as triangles on Vulkan. A generated geometry stage adds each rectangle's fourth corner (v2 + v3 - v1, for the position and every interpolant); non-indexed quad lists draw from a shared triangle-list index buffer(0 1 2) (0 2 3)so flat inputs use the first quad vertex. The PSO topology type is read as raw bits, so the console's out-of-range value 19 survives strict-enum optimisation. The quad-list batching and the raw-bit read come from a follow-up patch by @matheuskshn (GitHub 930e78a2).Why
Without it
CreatePipelineStaterefuses the type-19 pipelines of the retail boot ("primitive topology type not supported: 19").Evidence
CreatePipelineState4 failed / 50,466 ok before, 50,470 ok, 0 failed with this change.d3d12_rect_list4096/4096 pixels, quad list exact.097e9f46e, runtime built fresh on RunPod, Wine 11, RTX 4090):replay_quad_list_testexit 0,d3d12_rect_list_testexit 0 ("rect list: 4096 of 4096 pixels on the colour plane (worst error 0), all four quadrants; quad list: 4096 of 4096 pixels exact"). Negative control (production files reverted) failsd3d12_rect_listat line 141 on the GitHub PR.Known limit
The fourth corner is computed with float add/sub on every vec4 float vertex output. An attribute the translator exports as two packed f16 halves would get a wrong corner; nothing on the vertex side tells them apart (recorded in a comment at
rect_list_geometry.h).Not verified
Native Windows on this exact branch, and the draws' pixel output on the title (frames stay black for other reasons, see slot 133).
AI-assisted.
Lowering checks out (replay_quad_list passes, generated stage passes spirv-val). Changes requested:
Forge integration finding applied (thanks akimfomin): the rectangle geometry module is now created with device_.shader_modules().acquire(words) instead of a direct vkCreateShaderModule, so modules_ releases it through ShaderModuleCache like the other stages. Pushed
5e2b95145on rect-list-geometry, after merging current forge/main (b5163905e, which has the cache) into the branch; the merge was clean.Evidence: I did not add a test. shader_module_cache_test covers the cache with fake create/destroy functions; the leak was in the device code's choice of creation call, which needs a real Vulkan device to observe, and akimfomin's Windows A/B (two PSOs sharing one module, zero left after release) is the measurement for it. I did not re-run it here.
AI-assisted.
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.