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

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).

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.

7 participants