Skip to content

fix(shaders): reject a NaN mesh frame and let ms_wave_info_s3 run at 32 lanes - #6192

Open
vA7md wants to merge 2 commits into
ItsNotRexed:mainfrom
vA7md:fix/mesh-w64x-nan-and-subgroup-gate
Open

vA7md wants to merge 2 commits into
ItsNotRexed:mainfrom
vA7md:fix/mesh-w64x-nan-and-subgroup-gate

Conversation

@vA7md

@vA7md vA7md commented Nov 23, 2026

Copy link
Copy Markdown

Fixes #5262. Fixes #5273.

Both are in mesh_w64x_test in runtime/test/shaders/check.py, which serves two meshes: ms_w64x_ballot and ms_wave_info_s3.

#5262: a NaN frame read as success

The comparison was abs(p[i] - want) > 1e-3. Every comparison against NaN is false, so a frame entirely of NaNs produced wrong == 0 and the check returned the empty success string. A single NaN channel was enough, because that channel's comparison simply never counted as wrong.

It now uses math.isclose(..., abs_tol=1e-3) and negates it, so a NaN channel counts as a mismatch. math.isclose is false for NaN, and not False is True. This is the same fix #1100 made in scripts/run_gpu_tests.py; the standalone path had its own copy of the comparison, which is why it stayed.

Reproduced and fixed with a synthetic harness writing a full 64x64 frame of NaNs:

  • before: '' (success)
  • after: 4096 of 4096 pixels differ (blue nan at pixel 0, want 0.5)

#5273: a valid 32-wide draw skipped

The 64-wide subgroup gate applied to both meshes:

if not W64_EMULATED and 64 not in [...subgroup widths...]:
    return None   # skip

Only ms_w64x_ballot needs 64 lanes; its ballot is taken across both halves. ms_wave_info_s3 is valid at a 32-wide subgroup, and the skip made the standalone checker report it as untested there while the main runner checked it. The gate now applies to name == "ms_w64x_ballot" only.

Against a harness reporting subgroup 32..32:

Shader before after
ms_w64x_ballot None (skip) None (skip, still)
ms_wave_info_s3 None (skip) '' (passes)

The ballot mesh keeps its width requirement, which is the behaviour the reviewer asked to retain on #5264.

Tests

Five cases added to tests/test_run_gpu_pixel_checks.py (MeshW64xChecks), using a synthetic vk_harness written into a temporary directory, so no GPU and no game data are involved:

  • an all-NaN frame fails;
  • one NaN channel fails;
  • the expected frame still passes;
  • ms_w64x_ballot still skips on a 32..32 device;
  • ms_wave_info_s3 passes on a 32..32 device.

Mutation-checked: reverting the four comparisons to abs(...) > 1e-3 fails test_a_nan_frame_fails and test_one_nan_channel_fails, and reverting the gate to apply to both meshes fails test_the_wave_info_mesh_runs_on_a_32_wide_subgroup. So none of the new cases passes vacuously.

Tested

CPU only, no GPU, no game files.

  • python -I tests/test_run_gpu_pixel_checks.py — Ran 16 tests, OK
  • python -I tests/test_shader_checks.py — Ran 82 tests, OK
  • python -m compileall -q runtime/test/shaders/check.py — passes

Note for whoever lands this: #6030 also edits check.py, but only by adding ms_wave0_alloc_rounds to two name lists; it does not touch mesh_w64x_test, so the two should merge cleanly either way round.

AI-assisted.

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.

Standalone ms_wave_info_s3 skips a valid 32-wide subgroup draw Standalone mesh shader checks accept NaN pixel readbacks

1 participant