Skip to content

Detect unwritten and partial mesh compute sweep headers - #5651

Open
kacper-serewis wants to merge 3 commits into
ItsNotRexed:mainfrom
kacper-serewis:mesh-header-readback
Open

kacper-serewis wants to merge 3 commits into
ItsNotRexed:mainfrom
kacper-serewis:mesh-header-readback

Conversation

@kacper-serewis

@kacper-serewis kacper-serewis commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: #5072
Depends on: #4628

Tracker item ASSET-481, second claim in #5581 (comment). Review the final commit atop 5f6bb48.

Seed both count words in each workgroup slot. The collector reports untouched headers and each direction of partial write, excludes those slots from geometry statistics, and still accepts explicitly written zero counts. The fallback vertex shader clips incomplete slots. Rerun the compute sweep with the rebuilt runner and regenerated vertex shaders in a fresh output directory to measure header writes.

AI-assisted. Native Windows, NVIDIA GeForce RTX 5070, driver 616.56. One private cached compute shader explicitly wrote both zeros in all four slots. Synthetic skip-write, vertex-only zero, primitive-only zero and explicit-zero controls returned their expected raw count pairs in all four slots each. The generated vertex shader passed spirv-val. All 20 ms_sweep and 12 mesh_compute_vs CPU tests passed.

@mrbean56

Copy link
Copy Markdown

Built and tested ce561c110a on Linux (Debian 13), Python 3.13.5, RADV NAVI32 available but not needed.

  • cmake -S runtime -B /tmp/b5651 -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja vk_ms_sweep: builds clean; the executable prints usage and exits 2 with no arguments, as the header comment says.
  • pytest tests/test_ms_sweep.py -q: 20 passed. Two mutations of compare_images (coverage-difference inversion, tolerance comparison flipped) each fail 7 tests, so the comparison the report is built on is pinned, not just the sampling.
  • The mesh_compute_vs.py change is the interesting one: requiring both header sentinels (vcount/pcount != 0xffffffff) before drawing closes a real race — the fallback vertex shader could otherwise draw garbage slots before the mesh compute shader writes them. That path is shared with the runtime fallback, so it would be good to say in the PR body that the runtime's own use was considered (the extra two loads per invocation are negligible).
  • The heap warning added to ps_sweep.py is honest and matches the hang you documented. Nothing else to flag; the 64x64 + tolerance comparison is the right cheap proxy for "the two paths agree".

No GPU run of the sweep itself; no game data. AI-assisted.

@cynbun

cynbun commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested ce561c11 on RTX 5080, NVIDIA 615.78.08, Linux under Wine 11.20 (not a native Windows run): pass

The runtime was cross-built with clang-cl and xwin (vk_ms_sweep.exe, RelWithDebInfo). I also built vk_ms_sweep natively on Linux from the same head.

Python

  • test_ms_sweep.py: 20 OK.
  • test_mesh_compute_vs.py: 12 OK.
  • test_ps_sweep.py: 13 OK.
  • pytest tests/test_mesh_compute.py: 22 passed.
  • With 5f6bb485's tools/ms_sweep.py and tools/mesh_compute_vs.py, the new test_missing_header_words fails.

Synthetic end-to-end run of the runner, collector and fallback VS

The slot writer is a hand-written GLSL compute shader for the test's LAY slot layout (192-byte slots, 4 vertices, 3 primitives). It writes through the output address in push dwords 36..37. Its five workgroups:

  1. write nothing;
  2. a triangle with only the vertex count (3);
  3. a triangle with only the primitive count (1);
  4. explicit zero counts;
  5. one complete triangle.

Each triangle sits in its own quadrant. The VS is this head's mesh_compute_vs.vs_spvasm(LAY) (spirv-val clean). Command: vk_ms_sweep compute cs.spv ps.spv vs.spv out.raw 64 64 5 192 3. Results:

  • Under Wine (vk_ms_sweep.exe) the run exits 0. The output is byte-identical to the native Linux build's.
  • Headers: (ffffffff,ffffffff), (3,ffffffff), (ffffffff,1), (0,0), (3,1).
  • ms_sweep.analyse_slots: unwritten_headers 1, missing_vertex_only 1, missing_primitive_only 1. The explicit zeros are accepted, and the geometry counts come only from the complete slot (3 vertices, 1 primitive).
  • Image: the complete triangle covers 496 pixels. The two incomplete slots cover 0, so the fallback VS clips them.
  • Control with 5f6bb485's VS: the vertex-only and primitive-only slots each draw their triangle (496 and 528 pixels).
  • Control with 5f6bb485's runner (buffer zeroed, no sentinels): the headers read back (0,0), (3,0), (0,1). Nothing is flagged, and the primitive-only slot is drawn and counted as geometry.

Not run: real translated mesh shaders (no game files), the whole ms_sweep.py run/compare flow on a GPU.

AI-assisted (Claude Code).

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested ce561c1 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass, with 2 timeouts to look at

  • tools/ms_sweep.py sample, translate, run --mode native, run --mode compute, compare, on a 178-shader sample from a local game copy (variant z).
  • Result: 176 agree on geometry (7 of them have NaN or Inf positions on both sides), 2 timeouts (1 on both paths, 1 on the native path only). 0 unwritten headers, 0 "missing header writes" (both count words are seeded with 0xFFFFFFFF, so the new class would show), 0 over-max, 0 bad indices. Fallback emitted 1466 vertices, 1466 primitives; 408 vertices had a bad position.
  • No device loss in either run; both runs exited 0.
  • Not done: a run against the pre-PR tools as a negative control; the other variants; other GPUs.

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.

5 participants