startup: identify a rotated rectangle corner by its diagonal #3142
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3142"
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 lambirou on 2026-11-27T18:01:55Z.
Change
The indexed rectangle stage identified the right-angle corner by testing whether a corner shares an x or a y with each neighbour. A rotated rectangle has no axis-aligned edge, so no corner matched and the stage returned before emitting either triangle: the region the rectangle covered stayed unpainted, bounded by its diagonal. The vertex-stage rectangle expansion has no such restriction (
v0 + v2 - v1), so the two implementations of the same rule disagreed.The corner is now also identified from the shape: the vertex opposite the diagonal (the longest of the three edges), with the two sides required to meet at a right angle (
|dot|^2 <= 1e-6 |pa|^2 |pb|^2) so a shape that is not a rectangle stays undrawn as before. The axis test keeps precedence, so every input it accepted is unchanged. Bothsrc/startup_stubs/indexed_rect_geometry.hand the native rule ofsrc/gfx1013_rect_geometry.cppuse it.tests/startup_rect_geometry.cppdraws one rectangle named by three corners with back-face culling on: the axis order and the swung order keep their result, the same square turned by 15 degrees goes from 32/32 differing pixels to 0/32, and a non-rectangle stays undrawn.tests/startup_rect_gap.cppandtests/startup_rect_gap_check.pyadd the reported synthetic draw: eight 12-byte records (mask at +0, XY at +4), two vertex-buffer views over the same records, an R16 indexed triangle list and a six-vertex rectangle list of the same quad and edge ring, a mask-controlled pixel shader and a constant-colour control, an RGBA8 target, with and without back-face culling. It also pins the bound vertex and index bytes, the.iarequest and the two generated fetch loads.Refs #3131. Target main.
Verification
Windows 11 build 26300 (26H2), MSVC 19.44.35228, Windows SDK/DXC 10.0.26100.0, base
63a30dc1. Commite387d855.startup_rect_geometry: 2/2, WARP (Microsoft Basic Render Driver 10.0.26100.10068) and AMD Radeon RX 9060 XT (driver 32.0.32029.2010). Rotated case: 32/32 differing pixels before the fix, 0/32 after; axis and swung orders unchanged; the non-rectangle refusal is kept.startup_rect_gap: 2/2, but the runtime draw reported the Microsoft Basic Render Driver in both backends, so both pictures are WARP results. The reported diagonal gap does not reproduce for the described input (details indocs/experiments/startup-rect-gap.md).docs_links_check: 98 files and 589 links.The D3D12 debug layer is unavailable on this host (
D3D12GetDebugInterfacefails), so the fixtures printdebug_layer=unavailableand no debug-layer verdict is claimed.Evidence and follow-up
All inputs are source-built gfx1013 bytecode and synthetic vertex/index data; no game files or captures. The fix addresses a real cause of a sharply bounded missing region in an indexed rectangle pass, but the exact #3131 draw is not reproduced by the described 12-byte-stride triangle input. Open candidates are recorded in the note: a vertex view that declares fewer bytes than the indices name, a translated non-indexed indirect rectangle list that keeps the three-vertices-per-rectangle count, and the rectangle stage's flat
FPARAMtaking the first vertex's value for both triangles instead of each provoking vertex.Review update (2026-11-27,
04c82a48)tedin7's blocking compile failure is fixed.
src/gfx1013_rect_geometry.cppnow writes the binary32 value of1e-6as the exact hexadecimal double0x3EB0C6F7A0000000; LLVM IR accepts it andgfx1013-container-rectpublishes the native pair again.native_rectangle_pso_warppasses in dev and release.Added
native_rectangle_geometry_warpfor the coverage gap. It compiles a native VS/PS/GS pair whose VS exports onlySV_Position, then runs the standalonestartup_rect_geometryfixture with--native-vs,--native-psand--native-gs. The native GS draws the independentaxis,swungandrotatedscenes with back-face culling on; all three read back 0 of 32 pixels differing from the literal rectangle model. The HLSL and native implementations are now pinned by readback, not only by compiling the IR.Verification at
04c82a48:Both presets: 6/6 passed. The native readback is WARP-only; the standalone HLSL geometry test also passes on the RX 9060 XT. The debug layer remains unavailable (
D3D12GetDebugInterfacefails).docs_links_checkpasses with 98 files and 589 links.Review update (2026-11-27,
24bf6c99)pigalot's non-rectangle finding is addressed. The fixture now has a fourth scene,
skewed: the top-left corner is moved a quarter of the way toward the top-right, so the triangle has no axis corner and no right angle. The stage must leave the target clear. The same scene runs through the HLSL and native geometry stages, so it pins the right-angle guard in both copies.Debug and Release:
native_rectangle_geometry_warp,startup_rect_geometry_warpandstartup_rect_geometry_hardwareall pass;skewedreports 0 of 32 pixels differing. The experiment note records the new case. CI is running on24bf6c99.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T20:46:20Z.
Review: COMMENTED
Review of
e387d855(comment only). I ran the PR's tests and the neighbouring native rectangle test on this exact head on Windows Server 2025 (D3D12 WARP, MSVC 14.44.35207), dev and release.Blocking: the native rectangle path no longer compiles.
native_rectangle_pso_warppasses on main and fails on this head in both presets.compile_dxilrefuses the rectangle pair:LLVM IR only accepts a decimal
floatconstant that is exactly representable in binary32, and 1e-6 is not. That is why the rest of the file andgfx1013_direct_compute.inlonly use exact values such as3.906250e-03. The new tolerance innative_rectangle_geometry(src/gfx1013_rect_geometry.cpp) should be written as the hex double of the rounded float,0x3EB0C6F7A0000000, or replaced by an exact power of two such as 2^-20, written in full as9.5367431640625e-07. As it stands, every native graphics pair that uses the rectangle stage is refused, not only the rotated case.Coverage gap in the native path. The rotated case is drawn and read back only through the HLSL stage in
indexed_rect_geometry.h(startup_rect_geometry_*,startup_rect_gap_*, all passing here). The IR copy ingfx1013_rect_geometry.cppis checked only bynative_rectangle_pso_warp, which builds a PSO but draws nothing. That test caught the constant above, but it would not catch a wrong corner choice. A readback of the rotated rectangle through the native pair, even an IR-level evaluation like thenative_*_irchecks, would pin the two implementations to the same rule.Logic, which reads correctly to me:
across > side_bfails whenp == a.Results on
e387d855, dev and release:startup_rect_geometry_warpand_hardware: passed.startup_rect_gap_warpand_hardware: passed.startup_stream_draw_warpand_hardware: passed.native_rectangle_pso_warp: failed, as above. It passes on main.The PR does not touch any file that
cpp-migrationchanges. I did not run thecpp-migrationmerge leg, because the head itself fails a native test.Merge: I am leaving the merge to R0Y00. Besides the blocker above, #3131 comes from a rendering problem seen while running a title, and we cannot check the title-level claim ourselves.
Commands:
cmake --build --preset <dev|release> --target startup_rect_geometry startup_stream_consumer compile_dxil native_recording_checkctest --preset <dev|release> -R '^startup_rect_(geometry|gap)|^native_rectangle_pso|^startup_stream_draw|^startup_indexed_rect'git diff origin/main...pull/3142/head(read)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T21:04:09Z.
@tedin7 thanks, the compile failure was real. Fixed on
04c82a48:src/gfx1013_rect_geometry.cppnow writes the binary32 value of1e-6as0x3EB0C6F7A0000000, sogfx1013-container-rectaccepts the IR again.I also addressed the coverage gap with a real native readback.
native_rectangle_geometry_warpcompiles a native VS/PS/GS pair whose VS exports onlySV_Position, then runs the standalone geometry fixture with--native-vs/--native-ps/--native-gs. The native GS draws the independentaxis,swungandrotatedscenes with back-face culling on, and all three read back 0 of 32 pixels differing from the literal rectangle model. The HLSL and native rules are now pinned by readback, not only by PSO creation.At
04c82a48, dev and release each pass 6/6:native_rectangle_pso_warp,native_rectangle_geometry_warp,startup_rect_geometry_{warp,hardware}andstartup_rect_gap_{warp,hardware}.docs_links_checkpasses with 98 files and 589 links. The native readback is WARP-only; the standalone HLSL test still passes on the RX 9060 XT. CI is running on the new head. The debug layer is unavailable here (D3D12GetDebugInterfacefails).Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T21:07:29Z.
Windows checks #8349 completed successfully on
04c82a48.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T21:07:35Z.
@tedin7 the compile blocker and the native readback gap are addressed on
04c82a48; Windows checks #8349 is green. Could you take another look when you have a moment?Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:01:41Z.
Review: CHANGES_REQUESTED
Independently reviewed
04c82a48integrated overmaind474a393(tree170f7e5d). The merge is clean andgit diff --cached --check origin/mainis clean.Earlier blocking review (tedin7 on
e387d855).0x3EB0C6F7A0000000is the exact double of(float)1e-6(checked withstruct.pack('>d', struct.unpack('<f', struct.pack('<f', 1e-6))[0])), andnative_rectangle_pso_warppasses in both presets.native_rectangle_geometry_warpdraws the three scenes through the native GS, and disabling the fallback ingfx1013_rect_geometry.cppfails it (mutants below).What I traced. In both copies the fallback runs only when no axis corner matched, so every input the old rule accepted keeps its corner. It picks the vertex opposite the strictly longest edge, provided
dot(pa, pb)^2 <= 1e-6 |pa|^2 |pb|^2. A zero-length side failsacross > side, and NaN fails the ordered compares. TheRASTERIZERsubobject'swholesize equalssizeof(RasterLayoutStream), becauseD3D12_RASTERIZER_DESCis 44 bytes after the 4-byte tag; thestatic_assertpins the offset.What I ran. I built
startup_rect_geometry startup_stream_consumer compile_dxil native_recording_checkindevandrelease, then ran:/O2, with no skips.startup_rect_geometry_hardwareruns on the RTX 5090 with the debug layer on.axis,swungandrotatedeach give 0 of 32 differing pixels.startup_rect_gap_hardwarereports the Basic Render Driver, so it is a second WARP result.Mutants. Each mutant was applied alone, the one target rebuilt, and the source restored afterwards (
git diff --quietclean).if (corner == 3)→if (false))startup_rect_geometry_warprotated: pixel (0, 0) is ffff0000, expected ff0000ff, 30 of 32 differgeometric[i]→false)native_rectangle_geometry_warpFinding.
startup_rect_geometry.cpphas onlyaxis,swungandrotated.swungis undrawn because of its winding, not because of the new rule. So nothing pins the guard that stops the fallback from drawing arbitrary triangles, in either copy.rotatedrecords with a skewed triangle. The middle corner moved a quarter of the way toward the third, so there is no axis corner and no right angle, and I setcovered = false.rotated: pixel (1, 0) is ff0000ff, expected ffff0000, 24 of 32 differ.covered = false.native_rectangle_geometry_warpruns the same scenes, so one scene would pin both copies.Non-blocking. The longest-edge survivor is equivalent for any true rectangle. It only matters for a degenerate input where two corners coincide, so a zero-length-side scene would pin it.
Verdict: changes requested on
04c82a48for finding 1. The rest reads correctly and passes here. tedin7 asked to leave the merge to R0Y00, and I would leave it there too.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP 10.0.26100.9818, Windows 11 build 26200, MSVC 14.52.37025, Windows SDK 10.0.28000.0 DXC, debug layer on.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on04c82a48.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T22:08:47Z.
Review update (2026-11-27,
24bf6c99)pigalot's non-rectangle finding is addressed. The fixture now has a fourth scene,
skewed: the top-left corner is moved a quarter of the way toward the top-right, so the triangle has no axis corner and no right angle. The stage must leave the target clear. The same scene runs through the HLSL and native geometry stages, so it pins the right-angle guard in both copies.Debug and Release:
native_rectangle_geometry_warp,startup_rect_geometry_warpandstartup_rect_geometry_hardwareall pass;skewedreports 0 of 32 pixels differing. The experiment note records the new case. CI is running on24bf6c99.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T22:19:23Z.
@pigalot the skewed non-rectangle scene is added on
24bf6c99; Debug and Release both pass the HLSL and native rectangle fixtures. Could you take another look?Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:30:42Z.
Review: APPROVED
Retested
24bf6c99integrated overmainb66cdce6(tree13266b11). The merge is clean andgit diff --cached --check origin/mainis clean.Earlier finding (my changes-requested review on
04c82a48).startup_rect_geometry.cppadds a fourth scene,skewed, withcovered = false. Its top-left corner moves to x = -0.5, so the three records have no axis corner and no right angle. This is the case my probe used. The same scene runs through the HLSL stage and the native geometry stage.What I ran. I built
startup_rect_geometry startup_stream_consumer compile_dxil native_recording_checkindevandrelease, then ran:All 10 WARP and 6 hardware tests pass in Debug and Release
/O2, with no skips. On the RTX 5090,startup_rect_geometry_hardwarereports 0 of 32 differing pixels for each ofaxis,swung,rotatedandskewed.Mutants. Each was applied alone, the one target rebuilt in
dev, the test run, and the source restored afterwards (git diff --quietclean).if (corner == 3)→if (false))startup_rect_geometry_warpskewed: pixel (2, 0) is ff0000ff, expected ffff0000(survived on04c82a48)geometric[i]→false)native_rectangle_geometry_warpskewed: pixel (2, 0) is ff0000ff, expected ffff0000(survived on04c82a48)Non-blocking, unchanged. The longest-edge survivor is equivalent for any true rectangle. It matters only for a degenerate input where two corners coincide.
Verdict: approve on
24bf6c99. This supersedes my changes-requested review on04c82a48. tedin7 left the merge to R0Y00 because the title-level claim cannot be checked here, and I am leaving it there too.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 with the debug layer enabled, and WARP 10.0.26100.9818, on Windows 11 25H2 build 26200.9974, MSVC 19.52.37029.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on24bf6c99.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T22:59:30Z.
Review: APPROVED
Independently retested
24bf6c99integrated overmain4b0350ea(clean treeed3e7b27). The native and HLSL rules preserve the axis-aligned selection and use the shape check for a rotated right-angle corner. The added skewed input remained clear. I rebuiltstartup_rect_geometry startup_stream_consumer d3d12_xs_shim compile_dxil native_recording_checkand ranctest --test-dir <build> --no-tests=error -j1 -V -R '^(startup_rect_(geometry|gap)_(warp|hardware)|startup_stream_draw_(warp|hardware)|native_rectangle_(geometry|pso)_warp|native_direct_container)$'. Debug and Release /O2 each passed 9/9 with no skips. The rectangle-geometry fixture matched all 32 pixels in each axis, swung, rotated and skewed scene on WARP and RTX 4060 Laptop. The gap fixture logged Microsoft Basic Render Driver even in its hardware-labelled run, so both of those readbacks are WARP evidence. Windows 11 26200.9974, WARP 10.0.26100.9818 and NVIDIA driver 32.0.16.1656. The standalone geometry fixture enabled the debug layer. Docs link check and hosted Windows passed. This validates the isolated rectangle behavior. The original executable's draw described in #3131 remains unreproduced by the fixture. GitHub marked that issue completed before this merge.