Repository navigation
Conversation
…ts (RT-RECT-LIST-CORNER) Select the right-angle corner in post-divide NDC (x/w, y/w) via the minimum signed edge dot product (law-of-cosines equivalent to opposite the longest side, without float32 squared-length tie-break loss on thin axis-aligned strips or pre-divide overflow/distortion when w is large or differs across vertices). Compute the fourth corner bit-exact whenever either non-corner vertex matches the corner (zero ULP drift on axis-aligned grid coordinates and constant/flat attributes) and extrapolate linearly in NDC and 1/w when w differs with positive 1/w4. Adds self-contained GPU regression test d3d12_rect_list_corner_test covering w != 1, large w = 1e20, differing w, 5000:1 thin strips, near-square, rotated 45-degree rectangles, bit-exact non-dyadic constant attributes, and degenerate triangles.
|
Independent Linux/Wine + NVIDIA check at head
AI-assisted. |
|
Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked. Reading (marked):
Limits: one machine, one run for the PR, one run for each main witness. AI-assisted (Claude Code, Claude Opus 5.5) |
|
Review of head 4283e3f (read against main 43a9d56, which contains ec91d69). The game run is in my RUN above. I suggest splitting this PR into two: Ready to merge on its own: picking the corner in NDC with the dot product (I checked that it matches "longest side" through the law of cosines) and copying the vertices bit for bit. Both look sound to me. Needs a source or a separate PR:
Minor points:
AI-assisted (Claude Code, Claude Opus 5.5) |
…ry (RT-RECT-LIST-CORNER) Addresses review feedback on ProjectLeonida#2478: - Drop the unmeasured NDC + 1/w differing-w fourth-corner extrapolation and w4=1 fallback, keeping the documented clip-space other_a + other_b - corner rule (with bit-exact component selection) uniformly for Position and all attributes. - Restore the original range-based corners loop so rect_list_geometry.h merges cleanly with ProjectLeonida#1970. - Update d3d12_rect_list_corner_test cases and header comment to match.
|
@MoonEyes Thanks for the thorough review and testing! Addressed all four points in
Re-tested on RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341,
AI-assisted (Antigravity, Gemini). |
|
Reviewed at head Verification
Notes (non-blocking)
Approve. AI-assisted review + local MSVC/dual-GPU verification. |
tiguan26
left a comment
There was a problem hiding this comment.
Approving. Merged onto current main (431ceba) with no conflicts, cross-built (clang-cl 19 + xwin) and ran under Wine 11.22 on llvmpipe: d3d12_rect_list_corner passes, and so does the existing d3d12_rect_list (the console's rectangle and quad lists through the translated vs_m15 / ps_m15), so the rewrite keeps the real translated draws right. As a negative check I built the new test against main's rect_list_geometry.h: it fails, starting with the w=1e20 case drawing the wrong colour (corner v2: pixel (0,0) got 0.5,0.125,0.25,0.5).
I checked the math rather than the comment. With s_k the dot of the two edges at vertex k as the code forms them, the law of cosines gives s_k = c_k^2 - (a^2 + b^2 + c^2)/2, where c_k is the side opposite k: the sum term is the same for all three vertices, so the largest s_k is exactly the vertex opposite the longest side, as the comment says, without the old squared-length comparisons' tie losses. The unordered compares send NaN (w == 0) to v1 as documented. exact_fourth is right per component: if a component of one non-corner vertex equals the corner's bits, a + b - c is exactly the other vertex's value, so returning it bit for bit only removes rounding. The other_a / other_b picks give (v2, v3), (v1, v3), (v1, v2) for corners v1, v2, v3, and the emitted triangles are unchanged. The new opcode numbers (OpBitcast 124, OpFDiv 136, OpIEqual 170, OpFUnordGreaterThanEqual 191) are right.
One thing worth stating in the docs line, not a blocker: the corner is now chosen in post-divide NDC rather than clip-space x/y. That only changes the choice when the three w differ, which a screen-space rectangle shouldn't have, but it is a behaviour change for such input.
AI-assisted (Claude Code, Claude Opus 5.5).
|
On main, each 5,000:1 strip missed 2,048 of 4,096 pixels. Each differing- Captured geometry modules matched the corresponding main and merged emitters byte for byte. The CPU topology/statistics control also passed on both. Khronos synchronization validation was active: zero validation errors or sync hazards across the four hardware runs. Synthetic only. AI-assisted. |
timbot103
left a comment
There was a problem hiding this comment.
Static audit of 220aa322e only. No builds, tests, or GPU runs were performed for this review. The emitted vertex order preserves the first vertex for flat shading and keeps the documented homogeneous fourth-corner reconstruction.
runtime/src/rect_list_geometry.h:225divides by W before enforcing the fallback indocs/d3d12_vulkan.md:3113. Clip-space(x, y, w)values(1/8, 1/4, 0),(-1/2, 0, 1), and(0, 1/2, 1)yield(-Inf, -Inf, +Inf)on IEEE division and select v3. Base selects v1 and emits no geometry below NDC Y = 0. Please guard signed zero before dividing and add a mixed-W coverage case. The all-zero-W fixture atruntime/test/d3d12_rect_list_corner_test.cpp:276cannot distinguish the corner choices, and the collinear fixture selects the middle vertex, so the general degenerate-fallback wording also needs qualification.runtime/src/rect_list_geometry.h:231can overflow the products even with finite NDC. With clip-space XY(1, 1),(0, 0),(1, -1)and commonw = 2^-65, separate float32 operations can produce(-Inf, NaN, -Inf)and pick v1 over the right angle at v2. A common power-of-two scale on projected XY before forming the edges would preserve the ordering and keep the products finite for this case.
AI-assisted.
|
@timbot103 I reproduced both corner-selection issues on the current head The local correction selects v1 for zero or non-finite W or non-finite projection. For large finite projected coordinates it scales both axes by the same power of two before calculating the edge dot products. The correction is still local because GitHub rejected the push under its commit-email protection. The new D3D12 raster assertions still need a CTest run with Windows SDK 10.0.26100 or newer. AI-assisted. Codex (GPT-6). |
|
I also ran the D3D12 raster fixture on RTX 5070 (610.88) with Khronos validation. I used the same extended fixture in both builds, with the pinned Agility SDK headers and a static CRT on Windows 10/MSVC 19.29.
The permanent raster case checks positive zero. Negative zero and the large finite-NDC inputs were checked by capturing geometry-stage output in the separate probe above. The correction is still local. AI-assisted. Codex (GPT-6). |
|
Pushed the corner-selection fix from the checks above as
AI-assisted (Antigravity, Gemini). |
|
Verified by OreoFR — READY
AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
Fixes the rectangle-list fourth-corner selection and reconstruction in
runtime/src/rect_list_geometry.hfor packageRT-RECT-LIST-CORNER(#2464 Part B; builds on @kevincommits's numerical analysis in #1608 (comment)).Root cause removed
rect_list_geometry()picked the corner opposite the longest edge using pre-divide clip-space squared lengthsdx^2 + dy^2. That failed on:dx^2 + dy^2 == dx^2in float32 breaks the tie-break and flips the rectangle);w(e.g.,w = 1e20, wheredx^2 + dy^2overflows to+Inf);wacross vertices (where pre-divide distances pick the wrong corner).Computing post-divide NDC
(x/w, y/w)and selecting the vertex with the minimum signed incident-edge dot product (equivalently maxdot(e_in, e_out), unordered>=soNaN/w == 0deterministically falls back tov1) is algebraically identical to opposite-the-longest-side by the law of cosines for all triangles (including rotated rectangles, near-square, obtuse/acute, and degenerate) while keeping exact0.0dot product at any axis-aligned right angle.(((v0 + v1) + v2) - corner) - cornerwith direct(other_a, other_b, corner)selection and per-component bit-equality checks (OpBitcast+OpIEqual), preserving axis-aligned coordinates and constant/flat attributes bit-exact (0 ULP drift) while keeping the documented clip-spaceother_a + other_b - cornerrule uniformly forPositionand all interpolants (docs/d3d12_vulkan.md).for (const Corners& c : corners)loop header intact (git merge-treewith runtime: preamble-only flat scan, safe type lookups, and portable CPU test for rect_list_geometry #1970 is conflict-free).Testing
main(ec91d695c):d3d12_rect_list_corner_testfails on 7 corner-rule cases (w=1e20 corner v2: 2080/4096 off plane;differing w=(1.875,1,1) corner v0&w=(1,1,1.875) corner v2: 2080/4096 missed each;thin strip 5000:1 corner v2&v1: 2048/4096 missed each;flat non-dyadic exact: 4096/4096 pixels drifted;differing w=(1.875,1,1) flat color: 2080/4096 missed).220aa322e):ctest -R "^(d3d12_rect_list_corner|indirect_topology_and_stats)$": 2/2 passed (d3d12_rect_list_corner_test: all 17 cases passed, 0.27 s).python -I tests/test_ctest_registration.py -v: 6/6 passed.python -I scripts/check_no_game_data.py ...andgit diff --check: clean.VK_LAYER_KHRONOS_validationnot installed locally;d3d12_rect_list_corner_testis self-contained withoutllvm-mcand skips with 77 whengeometryShaderor Vulkan is unavailable).AI-assisted (Antigravity, Gemini).