Skip to content

TEST-362: mesh pass coverage comparator fixes + synthetic MS/PS acceptance slice - #4809

Open
Idealism3937 wants to merge 2 commits into
ItsNotRexed:mainfrom
Idealism3937:test-362
Open

Idealism3937 wants to merge 2 commits into
ItsNotRexed:mainfrom
Idealism3937:test-362

Conversation

@Idealism3937

@Idealism3937 Idealism3937 commented Nov 23, 2026 •

Copy link
Copy Markdown

TEST-362 (workflow: #1889). Replaces #4770: this branch is based on its 1fc8fc75 by @illusionart453-max (Chris) and retains that commit and attribution. #4770 can be closed if this lands.

Depends on: #4770

What changed:

  • VKH_COVERAGE_MASK in vk_harness writes a stencil mask (one byte/pixel), so a fragment writing (-1,-1,-1,-1) still counts as covered. ps_coverage_clear proves it on the GPU.
  • mesh_pass_coverage.py uses that mask, snaps CPU-projected vertices to the 8-bit subpixel grid (ties to even), streams the coverage/raw readbacks and keeps the CPU mask in a bytearray.
  • New ms_coverage.asm: a 4-dword V# at heap 0x1000 points at six synthetic vertices at 0x2000; ps_texture_sample reads an 8-dword T# at 0x100. One 64x64 draw, with the same two triangles projected on the CPU.
  • run_gpu_tests.py builds the PSV0 fixture and runs both the textured and clear-colour regressions; docs/testing.md documents it.

Verification:

  • CPU: python -I tests/test_mesh_pass_coverage.py -v -> 5 tests OK; 512x512 peak 591,276 bytes traced (target <= 2 MB).
  • GPU: python -I scripts/run_gpu_tests.py --build runtime/build --filter ms_coverage --require-pass -> texture: IoU 1.000000, missing 0, extra 0; clear-colour: IoU 1.000000, missing 0, extra 0. The mask is 2704/4096 bytes set, matching the 52x52 CPU projection; the first covered raw pixel is (1,0,0,1).
  • RTX 3060, NVIDIA 617.14, Vulkan 1.4.351, Windows 11 x64; LEONIDA_VK_DEVICE=3060; CMake with VS 18 / MSVC 19.51.
  • Regression: the full ms_ suite is 6/7 pass, 1 SKIP (ms_w64x_ballot, no 64-wide subgroup).
  • git diff --check clean. No game files, archives, executables, game shaders, textures or logs.

Limits: this is the synthetic no-game slice. The real game drawable plus its carved MS/PS, and the pass-by-pass chain, are the coordinator's follow-up and need a package. AI-assisted.

illusionart453-max and others added 2 commits November 22, 2026 23:00
Based on ItsNotRexed#4770's 1fc8fc7 by @illusionart453-max (commit retained).

- VKH_COVERAGE_MASK reads a stencil mask, so a fragment writing (-1,-1,-1,-1) is still covered; ps_coverage_clear regression.
- CPU projection snaps vertices to the 8-bit subpixel grid, ties to even; Kev-Ball 4.5009765625 and CuteBooty half-tie cases.
- Coverage and raw readbacks are streamed; CPU mask is a bytearray. 512x512 peak 591,276 bytes traced.
- ms_coverage fetches six synthetic vertices through a 4-dword V# at 0x1000 and samples an 8-dword T# at 0x100; 52x52 mask, IoU 1.0 on RTX 3060 / NVIDIA 617.14 / Vulkan 1.4.351.
- Docs describe the no-game fixture and leave the game-drawable pass chain as the coordinator's follow-up.

AI-assisted.
@Atomic258

Copy link
Copy Markdown
Contributor

Verified d0b5d21c7983fd9e748c8e0b957fdb3befaab5af on Windows 11, RTX 5090 driver 617.42, Vulkan SDK 1.4.363.0, MSVC 14.44/Ninja, Python 3.15.2.

  • cmake --build runtime/build --target vk_compute_test vk_store_test vk_harness: passed.
  • python -I tests/test_mesh_pass_coverage.py -v: 5/5 passed, including the 512×512 memory check.
  • python -I scripts/run_gpu_tests.py --build runtime/build --filter ms_ --require-pass --llvm-mc C:/msys64/ucrt64/bin/llvm-mc.exe: 10/10 shaders translated and validated; 6/7 GPU checks passed, with ms_w64x_ballot skipped (no 64-wide subgroup). Both coverage cases had IoU 1.000000, zero missing and zero extra pixels.
  • Red control: rebuilt with only runtime/test/vk_harness.cpp from 1fc8fc75, then ran the same GPU command with --filter ms_coverage. Both cases reported “vk_harness wrote no coverage mask” and the runner exited 1. Restored and rebuilt the head harness; worktree clean.

AI-assisted (Devin); no game files.

@Kev-Ball

Copy link
Copy Markdown

I tested the integration with #4815’s real one-meshlet draw. I used its drawable selector, translated mesh shader, CPU camera and projection at 83e08db2, then drew with this PR’s vk_harness and compared its stencil readback with this PR’s rasterizer at d0b5d21c. This used the constant-colour fixture PS from #4815.

Across 48 poses at 128×128, the 8-bit CPU mask matched the GPU stencil at every pixel. On this fixture the independently decoded colour coverage also matched the stencil on every draw. One pose distinguishes the subpixel fix from disabling it: yaw −128°, pitch 13°, 1,403 covered GPU pixels. I repeated the draw and ran the comparator CLI twice on the same readback:

Subpixel bits IoU Missing Extra Exit
0 0.999287 0 1 1
8 1.000000 0 0 0

That pose is a reproducible integration check for #4815 when switching to the shared comparator. RTX 3080 Ti (8 subpixel precision bits), driver 620.73.04, CachyOS, own 1.0.2.1 copy. Aggregate counts only. AI-assisted.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At d0b5d21, the ms_coverage branch labels UNSUPPORTED draws SKIP but sets ok_all=False. When both draws are unsupported this reports failure and exits 1 even without --require-pass. Please propagate the suite’s skip sentinel and cover both-unsupported and mixed outcomes. Found by source inspection. Five comparator tests passed, and independent synthetic CPU checks confirmed IoU threshold and mask-length behavior. AI-assisted.

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows CPU review, AI-assisted, with uv CPython 3.12.13. All five comparator tests and all three synthetic shader validations passed. Independently decoded vertices yielded 2,704 covered pixels with no shared-edge overlap. The stencil mask also gave the same coverage with red, black, and clear-colored readback.

Three adjacent test failures are new versus #4770 at 1fc8fc75:

  • test_run_gpu_tests.py (40/41) and test_run_gpu_tests_paths.py (19/20) both still treat every DRAWN_WITH value as a string. The cs_bench_mix no-runnable-filter path passes the new tuple to splitext at line 1485, and the dependency-path test passes it directly to its path join. Please normalize the partner list consistently in both paths.
  • test_text_write_line_endings.py (2/3) flags the fixture triangle JSON open at line 118. Set newline="\n".

The textured acceptance case also needs an independent color assertion. With only vk_harness mocked, I kept the exact 2,704-pixel stencil mask and replaced the expected covered red with transparent black. The runner still exited 0 at IoU 1.0. A wrong clear-color pixel in its separate case correctly failed. Keep coverage independent of RGBA and assert the expected textured RGBA on covered pixels. CPU/stub evidence only.

lunarminus added a commit to lunarminus/Leonida that referenced this pull request Nov 23, 2026
…iser); NaN is a wrong colour

PingasMech found two faults in the saved-draw check (ItsNotRexed#4815): an unsnapped CPU rasteriser fails correct
draws whose edges sit between two 1/256-pixel steps (IoU 0.79 on a 16x16 draw), and a NaN channel
passed the colour test because abs(NaN - x) > 1e-6 is false.

The branch now sits on ItsNotRexed#4809. GPU coverage is vk_harness's VKH_COVERAGE_MASK stencil readback, so a
covered pixel counts whatever its colour. CPU coverage is mesh_pass_coverage.rasterize with the vertices
snapped to the subpixel grid (--subpixel-bits, default 8, recorded in manifest.json). The silhouette band,
the colour check (math.isclose, so NaN fails) and the negative controls stay in ms_pass.

On the Radeon 760M the real draw is still exact in both poses, natively and emulated, and the three
controls still fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzPoR7BgcXfXLLrqxDrn7Y
@lunarminus

Copy link
Copy Markdown

Small CI item at d0b5d21c: python -I tests/test_tool_stdout_encoding.py fails, ['tools/mesh_pass_coverage.py'] != []. Every CLI tool's __main__ block now starts by setting errors="replace" on stdout (#1406; see e.g. the end of tools/first_light.py), and mesh_pass_coverage.py doesn't yet:

if __name__ == "__main__":
    try:  # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
        sys.stdout.reconfigure(errors="replace")
    except (AttributeError, ValueError, OSError):
        pass
    ...

(It also needs import sys.) I've stacked the TEST-362 game-drawable slice (#4815) on this PR. It uses rasterize() and VKH_COVERAGE_MASK on a real mesh-shader draw, and both work there: IoU 1.0000 on the Radeon 760M.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

FAIL, reproduced against main 3faac55: merges cleanly and the new test_mesh_pass_coverage.py passes 5/5, but the tuple value your d0b5d21 adds to DRAWN_WITH breaks the pre-existing consumer — python -I tests/test_run_gpu_tests.py fails with TypeError: expected str, bytes or os.PathLike object, not tuple at scripts/run_gpu_tests.py:1485 (the splitext filter added by acbb574 on main), where the same suite is green on main. Please flatten tuple values there (or keep one partner per key), and pin newline="\n" on the new ms_coverage.triangles.json write. Heads-up: #4815 contains these commits and evolves the comparator — one fix, then rebase the other; as-is neither head is clean against test_run_gpu_tests.py. No CI checks on the branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@lunarminus

Copy link
Copy Markdown

At d0b5d21c, two CPU tests fail because DRAWN_WITH["ms_coverage"] is now a tuple, and only with_draw_shaders was taught that. memorypressure found it on #4815, which is stacked on this branch. main passes both tests.

  • python -I tests/test_run_gpu_tests.py: FAILED (errors=1), TypeError: expected str, bytes or os.PathLike object, not tuple at scripts/run_gpu_tests.py:1485 (the partners set for a filter that matches only partners).
  • python -I tests/test_run_gpu_tests_paths.py: FAILED (errors=1), TypeError: unsupported operand type(s) for /: 'PosixPath' and 'tuple' at test_every_shader_named_exists (line 48).

This fix makes both OK here, and tests/test_mesh_pass_coverage.py stays OK:

diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 0caecbaf..7ed96b89 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -1482,7 +1482,8 @@ def run_suite(a, work: str) -> int:
 
     if a.filter and not results:   # the filter matched only inputs/partners: say so rather than "0/0 passed"
         names = [os.path.splitext(f)[0] for f in asm_files]
-        partners = {os.path.splitext(f)[0] for f in DRAWN_WITH.values()} | set(TEXTURE_MIP_DEPENDENCIES)
+        partners = {os.path.splitext(f)[0] for v in DRAWN_WITH.values()
+                    for f in (v if isinstance(v, (list, tuple)) else (v,))} | set(TEXTURE_MIP_DEPENDENCIES)
         shown = ", ".join(names[:5]) + (", ..." if len(names) > 5 else "")
         role = "partners built for other tests" if partners.issuperset(names) else "inputs without a GPU test row"
         hint = ("; cs_bench_* shaders are benchmark inputs, run them with the benchmark tool"
diff --git a/tests/test_run_gpu_tests_paths.py b/tests/test_run_gpu_tests_paths.py
index 7400a7be..30effc35 100644
--- a/tests/test_run_gpu_tests_paths.py
+++ b/tests/test_run_gpu_tests_paths.py
@@ -45,7 +45,8 @@ class DrawShaders(unittest.TestCase):
             # the clip cases (#193) are variants of vs_clip.asm with different signatures, not files of their own
             source = "vs_clip" if name in run_gpu_tests.CLIP_CASES else name
             self.assertTrue((shaders / f"{source}.asm").is_file(), name)
-            self.assertTrue((shaders / extra).is_file(), extra)
+            for partner in (extra if isinstance(extra, (list, tuple)) else (extra,)):
+                self.assertTrue((shaders / partner).is_file(), partner)
 
 
 class FilterSelection(unittest.TestCase):

A minor one, also from memorypressure: ms_coverage.triangles.json (scripts/run_gpu_tests.py:118) could pin newline="\n" like its neighbour at :156.

I've put the same fix on top of #4815 so it's green meanwhile. I'll drop that commit once it's in this branch. AI-assisted (Claude Code).

lunarminus added a commit to lunarminus/Leonida that referenced this pull request Nov 23, 2026
…s DRAWN_WITH has one (stacked fix)

ItsNotRexed#4809 made DRAWN_WITH["ms_coverage"] a tuple; with_draw_shaders handles that, but the partners set of
an inputs-only --filter (scripts/run_gpu_tests.py) and test_every_shader_named_exists
(tests/test_run_gpu_tests_paths.py) still take one file name, so tests/test_run_gpu_tests.py and
tests/test_run_gpu_tests_paths.py each fail with a TypeError (found by memorypressure on ItsNotRexed#4815). Both now
iterate a tuple. The same diff is offered on ItsNotRexed#4809; this commit goes away when that branch has it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzPoR7BgcXfXLLrqxDrn7Y
@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested d0b5d21 at the stack head (1fc8fc7 from #4770, which is closed, is an ancestor of the head). On an AMD Radeon 610M (RADV, subgroup 32..64), Linux: ms_coverage passes with the mesh fixtures running (texture and clear-colour, IoU 1.000000, missing 0, extra 0 each), ps_coverage_clear passes 4096/4096 pixels exact, and tests/test_mesh_pass_coverage.py passes (5 tests). A nonexistent device name fails ms_coverage with "no Vulkan physical device matches". On an Intel UHD 630 (Mesa 25.2.8 ANV, Ubuntu 24.04), the same tests pass 5 of 5 and ps_coverage_clear passes 4096/4096, but both ms_coverage rows skip with "unsupported: no VK_EXT_mesh_shader", so the mesh result is not confirmed on that GPU. The RTX 3060 result in the PR body was not reproduced.

AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested d0b5d21 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_mesh_pass_coverage.py -> OK
  • New coverage tool; verifies.

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants