gpu: pin rectlist placement and winding refusal in rectlist_topology check #1818

Merged
Asimmimx merged 1 commit from upstream-pr/1825 into main 2026-11-24 19:30:53 +00:00
Asimmimx commented 2026-11-24 19:18:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:18:34Z.


Change

tests/rectlist_topology_check.py checked counts and the first rectangle, but not where the rest of the output lands. A hand-applied mutation probe of tools/rectlist_topology.py showed that six single-point mutants passed the existing check:

  • expand_rectangles read the wrong corners for every rectangle after the first. test_expand_rectangles_multiple asserted only len == 12.
  • expand_rectangles(..., validate_winding=True) was called only with a counter-clockwise input. Dropping the validation, or passing require_ccw=False, went undetected.
  • expand_indices was called only with base_vertex=0.
  • rect_raster_oracle was checked only by its foreground count. Flipping either axis moved the quadrant and kept 256 foreground pixels.

The new assertions go into the existing test methods, so the check still runs 14 tests. They check that:

  • rectangle 1 of test_expand_rectangles_multiple expands to [-0.5,-0.5], [0.5,-0.5], [0.5,0.5], [-0.5,-0.5], [0.5,0.5], [-0.5,0.5], with v3 = (-0.5,-0.5) + (0.5,0.5) - (0.5,-0.5);
  • expand_rectangles([v2, v1, v0], validate_winding=True) raises the counter-clockwise precondition error, and the same corners still expand to 6 vertices without the flag;
  • expand_indices(2, base_vertex=8) returns [8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15];
  • in the 32x32 top-right-quadrant oracle, each pixel is foreground exactly when x >= 16 and y < 16 (row 0 is +y and column 0 is -x). Pixel x = 16 has x_ndc = 1/32 and y = 15 has y_ndc = 1/32; x = 15 and y = 16 fall at -1/32.
Mutant Existing check With the new cases
M1 degenerate test abs(area) < tolerance -> <= survived survived (not pinned, see below)
M2 orthogonality dot uses v2 - v0 instead of v2 - v1 killed killed
M3 orthogonality abs(dot) dropped killed killed
M4 expand_rectangles drops its validate_corner_order call survived killed
M5 expand_rectangles validates with require_ccw=False survived killed
M6 triangle 1 emitted as (v0, v3, v2) killed killed
M7 expand_indices ignores base_vertex survived killed
M8 expand_indices stride 3 instead of 4 killed killed
M9 oracle y_ndc not flipped (row 0 = bottom) survived killed
M10 oracle x_ndc flipped survived killed
M11 oracle bounds strict (< instead of <=) survived survived (not pinned, see below)
M12 v0 = vertices[i] instead of vertices[3 * i + 0] survived killed
M13 v3 = v0 + v1 - v2 killed killed
M14 multiple-of-3 refusal dropped killed killed
M15 oracle foreground/background swapped killed killed
M16 CCW refusal area < 0.0 -> area <= 0.0 survived survived (equivalent)

Refs #870

Verification

Based on origin/main at 813045b3c13f7bad20d8577557b621ee869ccbba. Windows 11 Pro 26300.9974, Python 3.12.10 (out/pe-env). No build is needed; I ran no GPU tests and did not run the --draw path, which this change does not touch.

> python -B tests/rectlist_topology_check.py
Ran 14 tests in 0.004s
OK

> python -B tests/docs_links_check.py
Self-test passed.
Checked 18 Markdown files and 369 links.

> python -B tests/bidi_controls_check.py
Self-test passed.
Checked 1320 tracked source, script and build/CI files: no bidirectional controls.

For the mutation table, a local probe script (not committed) applied each mutant to tools/rectlist_topology.py in turn, ran python -B tests/rectlist_topology_check.py, recorded killed or survived from the exit status and restored the file. I ran it against the existing check and again with the new cases.

Evidence and follow-up

  • M1 and M11 are boundary choices that the docstrings do not specify. M1 is whether an area exactly equal to tolerance counts as degenerate. M11 is whether pixel centers that lie exactly on a rectangle edge are covered; the oracle is inclusive, which is not the D3D top-left rule. Pinning either would fix behavior that may be unintended, so I left both open.
  • M16 is equivalent. An area of exactly 0 is already refused by the degenerate check before the CCW test runs.
  • The assertions are added to existing test methods, so the "14 verification and negative control cases" count in docs/experiments.md stays accurate.
  • The tool is not changed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589533886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1825). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T19:18:34Z. --- ## Change `tests/rectlist_topology_check.py` checked counts and the first rectangle, but not where the rest of the output lands. A hand-applied mutation probe of `tools/rectlist_topology.py` showed that six single-point mutants passed the existing check: - `expand_rectangles` read the wrong corners for every rectangle after the first. `test_expand_rectangles_multiple` asserted only `len == 12`. - `expand_rectangles(..., validate_winding=True)` was called only with a counter-clockwise input. Dropping the validation, or passing `require_ccw=False`, went undetected. - `expand_indices` was called only with `base_vertex=0`. - `rect_raster_oracle` was checked only by its foreground count. Flipping either axis moved the quadrant and kept 256 foreground pixels. The new assertions go into the existing test methods, so the check still runs 14 tests. They check that: - rectangle 1 of `test_expand_rectangles_multiple` expands to `[-0.5,-0.5], [0.5,-0.5], [0.5,0.5], [-0.5,-0.5], [0.5,0.5], [-0.5,0.5]`, with v3 = (-0.5,-0.5) + (0.5,0.5) - (0.5,-0.5); - `expand_rectangles([v2, v1, v0], validate_winding=True)` raises the counter-clockwise precondition error, and the same corners still expand to 6 vertices without the flag; - `expand_indices(2, base_vertex=8)` returns `[8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15]`; - in the 32x32 top-right-quadrant oracle, each pixel is foreground exactly when `x >= 16 and y < 16` (row 0 is +y and column 0 is -x). Pixel x = 16 has x_ndc = 1/32 and y = 15 has y_ndc = 1/32; x = 15 and y = 16 fall at -1/32. | Mutant | Existing check | With the new cases | |---|---|---| | M1 degenerate test `abs(area) < tolerance` -> `<=` | survived | survived (not pinned, see below) | | M2 orthogonality dot uses `v2 - v0` instead of `v2 - v1` | killed | killed | | M3 orthogonality `abs(dot)` dropped | killed | killed | | M4 `expand_rectangles` drops its `validate_corner_order` call | survived | killed | | M5 `expand_rectangles` validates with `require_ccw=False` | survived | killed | | M6 triangle 1 emitted as `(v0, v3, v2)` | killed | killed | | M7 `expand_indices` ignores `base_vertex` | survived | killed | | M8 `expand_indices` stride 3 instead of 4 | killed | killed | | M9 oracle `y_ndc` not flipped (row 0 = bottom) | survived | killed | | M10 oracle `x_ndc` flipped | survived | killed | | M11 oracle bounds strict (`<` instead of `<=`) | survived | survived (not pinned, see below) | | M12 `v0 = vertices[i]` instead of `vertices[3 * i + 0]` | survived | killed | | M13 `v3 = v0 + v1 - v2` | killed | killed | | M14 multiple-of-3 refusal dropped | killed | killed | | M15 oracle foreground/background swapped | killed | killed | | M16 CCW refusal `area < 0.0` -> `area <= 0.0` | survived | survived (equivalent) | Refs #870 ## Verification Based on `origin/main` at `813045b3c13f7bad20d8577557b621ee869ccbba`. Windows 11 Pro 26300.9974, Python 3.12.10 (`out/pe-env`). No build is needed; I ran no GPU tests and did not run the `--draw` path, which this change does not touch. ```text > python -B tests/rectlist_topology_check.py Ran 14 tests in 0.004s OK > python -B tests/docs_links_check.py Self-test passed. Checked 18 Markdown files and 369 links. > python -B tests/bidi_controls_check.py Self-test passed. Checked 1320 tracked source, script and build/CI files: no bidirectional controls. ``` For the mutation table, a local probe script (not committed) applied each mutant to `tools/rectlist_topology.py` in turn, ran `python -B tests/rectlist_topology_check.py`, recorded killed or survived from the exit status and restored the file. I ran it against the existing check and again with the new cases. ## Evidence and follow-up - M1 and M11 are boundary choices that the docstrings do not specify. M1 is whether an area exactly equal to `tolerance` counts as degenerate. M11 is whether pixel centers that lie exactly on a rectangle edge are covered; the oracle is inclusive, which is not the D3D top-left rule. Pinning either would fix behavior that may be unintended, so I left both open. - M16 is equivalent. An area of exactly 0 is already refused by the degenerate check before the CCW test runs. - The assertions are added to existing test methods, so the "14 verification and negative control cases" count in `docs/experiments.md` stays accurate. - The tool is not changed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 20:00:49 +00:00
tedin7 commented 2026-11-24 20:00:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:29:17Z.

Review: COMMENTED


Reviewed at commit f7226c220d993501b58bf15f47394657c6e3a646 (no P1/P2 defects found).

Verification

  • Linux checks:
    • git diff --check origin/main...HEAD: pass
    • python -B tests/bidi_controls_check.py: pass (Checked 1320 tracked source, script and build/CI files: no bidirectional controls.)
    • python -B tests/rectlist_topology_check.py: pass (Ran 14 tests in 0.014s, OK)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev):
      • Build (cmake --build --preset dev --target rectlist_draw_check -- -j 8): 0.10s
      • Test (ctest --preset dev -R '^(rectlist_draw_warp|rectlist_topology)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (0.32s: rectlist_topology 0.13s, rectlist_draw_warp 0.24s)
    • Release /O2 (--preset release):
      • Build (cmake --build --preset release --target rectlist_draw_check -- -j 8): 0.10s
      • Test (ctest --preset release -R '^(rectlist_draw_warp|rectlist_topology)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (0.34s: rectlist_topology 0.14s, rectlist_draw_warp 0.26s)
  • Local mutation checks (python -B tests/rectlist_topology_check.py on mutated tools/rectlist_topology.py, then restored cleanly):
    • Disabled if validate_winding: in expand_rectangles -> failed as expected (rc=1)
    • Dropped base_vertex offset in expand_indices -> failed as expected (rc=1)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045938394 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1825#pullrequestreview-6045938394). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:29:17Z. **Review:** COMMENTED --- Reviewed at commit `f7226c220d993501b58bf15f47394657c6e3a646` (no P1/P2 defects found). ### Verification - **Linux checks**: - `git diff --check origin/main...HEAD`: pass - `python -B tests/bidi_controls_check.py`: pass (`Checked 1320 tracked source, script and build/CI files: no bidirectional controls.`) - `python -B tests/rectlist_topology_check.py`: pass (`Ran 14 tests in 0.014s`, OK) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target rectlist_draw_check -- -j 8`): `0.10s` - Test (`ctest --preset dev -R '^(rectlist_draw_warp|rectlist_topology)$' --parallel 6 --no-tests=error --output-on-failure`): **2/2 passed** (`0.32s`: `rectlist_topology` `0.13s`, `rectlist_draw_warp` `0.24s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target rectlist_draw_check -- -j 8`): `0.10s` - Test (`ctest --preset release -R '^(rectlist_draw_warp|rectlist_topology)$' --parallel 6 --no-tests=error --output-on-failure`): **2/2 passed** (`0.34s`: `rectlist_topology` `0.14s`, `rectlist_draw_warp` `0.26s`) - **Local mutation checks** (`python -B tests/rectlist_topology_check.py` on mutated `tools/rectlist_topology.py`, then restored cleanly): - Disabled `if validate_winding:` in `expand_rectangles` -> failed as expected (`rc=1`) - Dropped `base_vertex` offset in `expand_indices` -> failed as expected (`rc=1`) AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1818
No description provided.