Skip to content

rdna2spirv: --mesh-serial-waves, an emulated mesh program's waves one after the other (SHADER-W64-MESH-SERIAL-WAVES) - #2435

Open
quartz-heron-58 wants to merge 6 commits into
ProjectLeonida:mainfrom
quartz-heron-58:mesh-serial-waves
Open

quartz-heron-58 wants to merge 6 commits into
ProjectLeonida:mainfrom
quartz-heron-58:mesh-serial-waves

Conversation

@quartz-heron-58

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: SHADER-W64-MESH-SERIAL-WAVES (#1608 (comment))

What and why

Under --wave64-emulate a mesh program of 128 threads is two waves of 64 lanes run side by side, and the planner gives it mini-schedulers: each exchange between lanes becomes rounds over the whole workgroup. On an RTX 4080 that form measured 11 to 15 times the GPU time of the same programs' native form, and mesh draws were about 60 % of a frame in the 3D world (measurements in #1608).

--mesh-serial-waves (off by default, no environment variable) changes the shape for a mesh program that

  • has more than 64 threads, a multiple of 64,
  • has no ds_ instruction, no store and no atomic instruction,
  • is not translated with --mesh-compute.

Such a program declares LocalSize 64 and runs its body once per wave: pass w sees local_index = real index + 64*w, every initialised function variable is stored again at the start of a pass, and the values the epilogue needs are copied to a per-pass twin at the end of the pass. The epilogue keeps one barrier, one count and one OpSetMeshOutputsEXT, then writes each pass's vertices and primitives. Each pass is a single wave, so the planner gives it the existing inline_all plan. Nothing in the planner changes.

A program outside those conditions, and every program when the switch is off, is translated as before. The index records mesh_serial_waves (the number of passes); local_size stays the program's own.

New fixture ms_w64x_wave_votes: the two waves take different branches and vote differently (ballot count 8 in wave 0, 3 plus v_readfirstlane in wave 1), and the triangle's vertices come from threads 0, 1 and 64, so a pass that saw the wrong wave's lanes or the wrong index draws something else.

Tested

All on Windows 11, RTX 4080, NVIDIA 621.24, branch on main d1dff79.

  • scripts/run_gpu_tests.py: the 7 mesh fixtures pass in the side-by-side form and with LEONIDA_MESH_SERIAL_WAVES=1 (which adds the switch).
  • pytest tests/test_mesh_serial_waves.py: 19 passed. pytest tests/test_translate.py: 722 passed.
  • Semantic suite: 500 files, 6,374 tests, 0 failed.
  • pytest tests with tests/test_run_game_wine.py (imports fcntl, not on Windows) and tests/test_run_semantic_tests.py (its tests send an interrupt that ends the whole run here) left out: 10,069 passed, 288 skipped, 7 failed. The 7 are in test_bink_names, test_opus_tags, test_world_names (unreadable-directory cases), test_translate_pipeline_compute (Windows job limits) and test_run_wine_tests (two --jobs cases). Run alone on main d1dff79 on this machine the same 7 fail; on this branch 5 of them failed and the two --jobs cases passed in that rerun.
  • With the switch off, 45 mesh and vertex programs translated by this branch are byte-identical to main's output.
  • One run of the game's 3D world with the mesh programs translated with the switch: 700 s, no device loss; mesh draws averaged 0.074 ms against 1.04 ms before, and the world ran at 0.77 frames/s against 0.45. Compute is now the larger part of the frame.
  • Independent check by @ecox982745 on an RTX 4090 (reported in Coordinating who works on what (continued from #14) #1608): 32 draws, 16 paired readbacks byte-identical between the two forms, validation clean.

Not checked: whether the in-game picture is correct (frames on this machine alternate with white-outs in both forms); AMD, Intel, llvmpipe; a second game run; a negative control that shows the new fixture failing on a deliberately wrong translation; thread counts that are not a multiple of 64 (they keep the old form). Thanks to @HasiKe and @tiguan26 for offering runs on their setups.

GPUs tested: NVIDIA RTX 4080, driver 621.24, Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code

quartz-heron-58 and others added 3 commits November 27, 2026 10:58
… other in 64 invocations (work in progress)

Under --wave64-emulate a mesh program of more than 64 threads (a multiple
of 64, no LDS instruction, not --mesh-compute) declares 64 invocations and
runs one pass per wave: the invocation's index is the built-in plus 64 x
pass, every initialised Function variable is set again per pass, the
exports of a pass are copied to per-pass twins, and the epilogue sets the
counts once and writes each pass's outputs. Each pass is one wave, so the
plan is the single-wave one and the exchange buffer is one wave's.

Off by default; with the flag off the output is unchanged. Work in
progress for SHADER-W64-MESH-SERIAL-WAVES: no test or docs row yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ory writes in a serial program (work in progress)

ms_w64x_wave_votes: two waves take different branches, each with its own
ballot count (and a v_readfirstlane in the second), and the triangle's
vertices come from threads 0 and 1 of the first wave and thread 64 of the
second, so ms_tri's picture needs both waves to have run their own branch
with their own votes. It passes in the side-by-side form and with
--mesh-serial-waves on an RTX 4080 (NVIDIA 621.24).

A program with a store or an atomic to memory keeps the side-by-side
form, as one with LDS does: its waves could pass each other something.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tests/test_mesh_serial_waves.py: the module shape of a program that
qualifies (64 invocations, the pass loop, the index from the built-in,
the exchange's own place, per-pass copies of the exports, one
OpSetMeshOutputsEXT), that every initialised Function variable is set
again per pass, and that ms_wave_info_s3 (LDS), a 32-thread program,
native wave64 and --mesh-compute are unchanged by the flag.

LEONIDA_MESH_SERIAL_WAVES=1 is read by scripts/run_gpu_tests.py, like the
other translation switches, and no longer by rdna2spirv.py itself.
docs/design.md and docs/testing.md say what the flag does and how it is
tested; conftest gives ms_w64x_wave_votes its 128-vertex PSV0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Added coverage, not mine: @tiguan26 ran this branch (fbceecf) on llvmpipe under Wine (Mesa, 8-wide subgroups, emulated path) and reports the 7 mesh GPU fixtures pass with LEONIDA_MESH_SERIAL_WAVES=0 and with =1, with ms_w64x_wave_votes.spv at LocalSize 128 without the switch and 64 with it: #1608 (comment). So llvmpipe moves out of the "not checked" list above; AMD and Intel hardware and in-game picture correctness stay in it. Thank you.

@ecox982745

ecox982745 commented Nov 27, 2026 •

Copy link
Copy Markdown

I tested the negative control requested in the PR description at fbceecf042 on a Windows 11 RTX 4090 (NVIDIA 616.64). The stock ms_w64x_wave_votes fixture passed the runner's check_grad at all 4,096 pixels with both LocalSize 64 and LocalSize 128. Two deliberate translation errors made that same checker fail in both forms.

I kept the fixture unchanged and varied only the addition that combines the two 32-bit population counts for each s_bcnt1_i32_b64 s10, s[6:7] in its emitted SPIR-V.

Sum used Wave 0 gets (expects 8) Wave 1 gets (expects 3) First pixel's blue (expects 0.5)
low + high 8 3 0.5
low only 4 3 0.001953125
low + low 8 6 0.498046875

Each error picked out a different wave. I checked the full image independently: for normalized pixel-center height y, blue was exactly y/4 when only wave 0 was wrong and 0.5 - y/4 when only wave 1 was wrong. Red, green, alpha, and coverage matched at every pixel. All six modules passed Vulkan 1.2 SPIR-V validation, and all six draws ran with Khronos validation without errors. This check measured image correctness only.

Taken early exit on cd25a5c95. The new unit test checks the emitted control flow with a branch on wave 7, which a two-wave workgroup never takes. I ran a synthetic draw that takes the early s_endpgm on wave 0 or wave 1, selected at draw time via mesh s24 (push dword 16). Both waves first emit the triangle geometry. The selected wave exports blue 0 and ends; the surviving wave exports its checked ballot value, blue 0.5. Selector 7 is the control. The same shader binary handled all three selectors in each mode.

All six 64×64 RTX 4090 draws matched their expected RGBA at every pixel. Ending wave 0 yielded blue y/4, ending wave 1 yielded 0.5 - y/4, and selector 7 yielded constant 0.5 (y is the normalized pixel-center height). The side-by-side and serial outputs were byte-identical in each pair. Both SPIR-V modules validated and the draws reported no Vulkan validation errors. This checks that ending the first wave still lets the later wave export its vertices' color.

Partial final wave on cd25a5c95. I checked the thread-count case listed in the PR description on the same RTX 4090. Using synthetic PSV0 workgroups of 65, 96 and 127 threads, enabling the serial flag produced byte-identical SPIR-V and equal shader metadata in each case. The modules kept their declared workgroup sizes. A 128-thread control switched from 128 invocations to 64 and recorded two serial waves.

In each fixture, threads 0 and 1 exported two triangle vertices. The last thread in the workgroup exported the third vertex with blue 0.5. This made the pixel result depend on the last active lane of the final wave. Across all eight 64×64 draws, every pixel matched the expected RGBA (x, y, y/4, 1) for normalized pixel centers. Both flag settings returned identical images for each size. All eight modules passed Vulkan 1.2 SPIR-V validation and the draws reported no Khronos validation errors.

@tiguan26 tiguan26 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.

Approving. Checked on fbceecf, which fast-forwards onto main (d1dff79).

Translator suite: same as main (only the known test_fspx_dot4_op_sel_disasm and test_int32_to_f64 failures). tests/test_mesh_serial_waves.py plus tests/test_translate.py: 740 passed, the one failure is main's ps_sdwa_f16_const.asm. GPU fixtures on llvmpipe under Wine with LEONIDA_W64_EMULATE=1: all 7 ms_ fixtures pass with and without LEONIDA_MESH_SERIAL_WAVES=1, and the switch really changes the module (LocalSize 128 vs 64).

Read the diff. Things I checked rather than took on trust: %ms_counts is a Workgroup variable, so the allocation count survives the per-pass re-initialisation even when only wave 0 sends GS_ALLOC_REQ (your fixture covers that case); %done and the other initialised Function variables are stored again at the top of each pass; the exchange's %x_buf index comes from the real index. I also tried a variant of ms_w64x_wave_votes with an s_endpgm reachable mid-program (a branch on wave id 7, so never taken): it still qualifies, passes spirv-val, and main keeps one OpReturn after the pass loop and the output writes, so an early-ending wave cannot skip later passes. If you want, that variant would make a cheap extra case in the unit tests, but it is not a blocker.

One small note, not a blocker: the qualifying check matches store and atomic as substrings of the opcode, which is conservative (it also catches s_store/s_buffer_store), so it errs on the side of keeping the side-by-side form. Fine as it is.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Thank you both.

@ecox982745: that is the negative control I listed as missing, so it comes off the "not checked" list: with the fixture unchanged, a wrong count in either wave fails the runner's check in both forms, and each error shows in a different wave.

@tiguan26: agreed on both notes. The substring match on store and atomic is meant to be conservative; a program it catches only keeps the side-by-side form. The mid-program s_endpgm variant is a good extra case and I will add it to tests/test_mesh_serial_waves.py in a follow-up commit on this branch.

Still not checked: AMD and Intel hardware, and whether the in-game picture is correct.

A variant of ms_w64x_wave_votes with an s_endpgm behind a branch in the middle of the program:
the module still qualifies, validates, and main keeps one return, after the loop over the passes
and the output writes. Suggested in review by tiguan26.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Second game run with the mesh programs in the serial form (same RTX 4080, NVIDIA 621.24, Windows 11; the unit case suggested above is pushed as cd25a5c, 20 passed): the 3D world ran to the run's time cap without a device loss or a fault. The GPU profile agrees with the first run: 32,768 profiled mesh draws at 0.074 ms each, and 0.75 frames/s on average between 330 s and 480 s (0.45 before, side by side). In the profiled windows compute is now most of the GPU time (about 31 s of 48 s, against 2.4 s for mesh draws).

One thing I have not explained: frames stopped being presented at about 726 s while submissions went on at the same rate until the cap; that is when the run's scripted pad presses end, and I have not checked whether the two are related or whether it also happens side by side. Picture correctness is still not checked.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

CI note: linux-gpu-tools failed in its Build step, before any test ran, on runtime/test/vk_null_descriptor_test.cpp:97 (LEONIDA_TEST_NULL_DESCRIPTORS_SPV not declared). runtime/CMakeLists.txt only defines that macro when it finds glslangValidator, and line 97 uses it outside the test's #ifndef guard. This pull request does not touch either file (it changes tools/rdna2spirv.py, scripts/run_gpu_tests.py, tests, docs and one .asm fixture), and the same lines are in main d1dff79. #2055 is the open pull request for that build failure. The other checks are still queued; change-scope and no-game-data passed.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

CI on cd25a5c has finished. Passed: translator-tests, semantic-tests, stdlib-tests-linux, viewer-tests, change-scope, no-game-data. Not passed, with what each log shows:

None of these is in a file this pull request changes, and the pull request has no runtime (C++) change. I have not checked whether each of them also fails on main's own latest run, so I am only saying what the logs show, not that main is red. If a maintainer wants the branch re-run after those are fixed, an empty merge of main will do it.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Added coverage, not mine: @HasiKe ran this branch (cd25a5c) on an RTX 2070 SUPER (NVIDIA 616.56, Windows 11), the card on which the world lost the device at mesh draws: #1608 (comment). Their report: the whole main corpus (26,503 programs) translates with --wave64-emulate --mesh-serial-waves and passes spirv-val; the four mesh programs that were at their loss sites declare LocalSize 64 with no OpSwitch; in 3 boots no mesh draw is at a loss site (before: 6 of 9 boots lost the device at such a draw). Those 3 boots were not clean for other reasons (one early int3, one boot that stopped presenting, one loss at a compute dispatch), and they say three compile-heavy boots do not settle whether those are new. So this is evidence about the mesh draws only.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Open problem, please do not merge yet. @HasiKe's second series on the RTX 2070 SUPER (NVIDIA 616.56) with this branch: #1608 (comment). Across their six boots with the serial form: no mesh draw at a loss site and one device loss, but three stalls in which GPU work never completes and the device is not reset (at 209 s, 407 s and 419 s), plus one CPU fault at 90 s. Their stock shader set had no failure before the world in 11 boots on that card. Whatever the cause, 3 stalls in 6 against 0 in 11 is a signal against this change on that card, and it outweighs my four clean runs on the RTX 4080.

What I have checked so far is only by reading the emitted module of ms_w64x_wave_votes: every pass starts by zeroing the exchange's mask slots and ends that with a workgroup barrier, the round counter is one of the function variables stored again at the top of a pass, and all 64 invocations run every pass, so I do not see how a barrier could be reached a different number of times by the invocations of one pass. Reading is not proof, and no fixture here has a loop whose trip count differs between the passes. I will add one (two waves, voted loops of different lengths, a barrier in the loop) and report whether it terminates and matches in both forms. Until the stalls are explained this should stay unmerged.

…nt length

ms_w64x_wave_loops: each wave loops while a wave-wide count is not 0, 5 iterations in wave 0 and 9 in
wave 1, so under --wave64-emulate the waves reach different numbers of workgroup barriers. Written after
stalls were reported with the serial form on an RTX 2070 SUPER (issue 1608). On an RTX 4080 (NVIDIA
621.24) it draws 4096/4096 pixels exact side by side and in series; that does not explain the stalls.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

The loop fixture is pushed as dbdef2e: ms_w64x_wave_loops. Each wave loops while a wave-wide count (s_bcnt1 of a 64-lane compare) is not 0; wave 0 leaves after 5 iterations and wave 1 after 9, and a wave only gets its blue channel if its sum over the iterations is right (160 and 288). Under emulation every count is an exchange with a workgroup barrier inside the loop, so side by side the two waves reach different numbers of barriers.

On the RTX 4080 (NVIDIA 621.24, Windows 11) it terminates and draws 4096/4096 pixels exact in both forms; the other seven mesh fixtures still pass in both forms (8/8 and 8/8). tests/test_translate.py with tests/test_mesh_serial_waves.py: 766 passed.

This does not explain the stalls @HasiKe reported on the RTX 2070 SUPER, and it does not clear the change: it only shows that this shape (loops of different length per pass, barriers in the loop) is not by itself the fault on this card and driver. Not checked: the same fixture on their card and driver (616.56), which is the test that would count; and whether their stalls have the GPU busy or idle. The "do not merge yet" above stands.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

For the record beside the open problem above, a third card, not mine: @MoonEyes on an RTX 4060 8 GB (NVIDIA 610.88, Windows 11, GPU timeout at the Windows default of 2 s): #1608 (comment). Before: 9 of 13 runs lost the device, 7 of those with one mesh draw started and not finished. With the mesh programs retranslated from this branch (cd25a5c; 9,235 of 9,282 change form, spirv-val clean on 301 sampled): one run, reached its 910 s limit with no device loss and no driver fault line. They list as not checked: picture correctness, a second run (queued), a raised timeout.

So the cards stand like this, serial form: RTX 4080 four runs of 630 to 872 s without loss or stall; RTX 4060 one run without loss; RTX 2070 SUPER six boots with no mesh draw at a loss site but three stalls. The stalls are unexplained and the "do not merge yet" stands.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Update on the open problem (the stalls on the RTX 2070 SUPER). Two measurements since my "do not merge yet":

  • @HasiKe's latency series with this branch on that card (Coordinating who works on what (continued from #14) #1608 (comment)): in the stalled boot the direct queue had work 6.7 % of the time while batches waited on the CPU for a fence value. So the stall is a CPU-side wait with the GPU mostly idle, not a mesh workgroup that never finishes. Their device loss in that series had a compute dispatch as its last checkpoint, with one submission over 5 s. Over their nine boots with the serial form: no mesh draw at a loss site, 2 device losses, 4 stalls, 2 early exceptions, 1 clean full run.
  • On the RTX 4080 with main d1dff79 (Coordinating who works on what (continued from #14) #1608 (comment)): the same stall lines, with the direct queue 0.4 % and 8.1 % busy, with the serial form and with the stock side-by-side form alike.

What this settles: the hypothesis that the serial form hangs a workgroup is not supported; the stalls are not GPU work. What it does not settle: on HasiKe's card the stock set had no failure before the world in 11 boots on e5a7c8942, and the serial form had stalls in 4 of 9, so the serial form may still make that CPU-side wait more likely there, for instance by changing timing. They report one pre-world loss in three stock boots on a newer main and plan to bisect the wait on stock shaders.

So I withdraw "do not merge yet" as a statement that this change is known to be wrong, and leave the above as the known risk for whoever reviews it. The switch is off by default either way.

@zmasi

zmasi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

On fixed-wave64 gfx906 (RADV 26.0.8) at dbdef2efd, I could verify the compute exclusion, not native serial mesh execution. This device has no VK_EXT_mesh_shader; the native harness exits 77 before pipeline creation.

For both hand-written fixtures, ms_w64x_wave_votes and ms_w64x_wave_loops, the emulated serial mesh module validated with LocalSize 64, versus 128 without serial. With --mesh-compute, toggling the serial flag produced byte-identical compute modules and companion vertex modules. On this adapter, both fixtures matched the expected values at all 4,096 pixels in each compute configuration, including native wave64 without emulation. Making only one wave's expected result wrong made the pixel check fail for either wave.

This confirms the non-mesh path is unchanged; it does not test serial-path performance, hangs, or the outstanding merge concern.

AI-assisted.

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Correction to the evidence listed above: the RTX 4060 entry does not hold. @MoonEyes has corrected their report (#1608 (comment)): in the run I cited as "reached its 910 s limit with no device loss", the game stopped presenting before the foliage mesh pipeline was built, so that pipeline was never drawn while frames were shown; four more runs with the same shaders stopped presenting at 299 to 380 s. Their runs without this change stop presenting at the same point and then lose the device. Their reading: the common event is the game ceasing to present on that 8 GB card, possibly from memory; whether this change removes the long mesh draws there is still open.

So the cards now stand: RTX 4080, measured mesh draw time 1.04 ms to 0.074 ms and five runs without loss; RTX 2070 SUPER, no mesh draw at a loss site in nine boots, with the other failures described above; RTX 4090, synthetic fixtures only; RTX 4060, no evidence either way. Please disregard my earlier line that counted the RTX 4060 as a clean run.

@GrahamboJangles

Copy link
Copy Markdown

Reviewed the translation work at dbdef2e (pure Python on Windows, no llvm-mc/spirv-as on PATH, so the repo's own new tests skip locally; CI already shows them green).

Verified locally:

  • The two fixtures' arithmetic, by simulating the asm's loop in Python. ms_w64x_wave_loops: wave 0 counts 64,48,32,16,0 (5 iterations, sum 160), wave 1 counts 64..8 (9 iterations, 288) — exactly the two s_cselect'd s14 constants the program compares its sum against. ms_w64x_wave_votes: wave 0 ballot 8, wave 1 ballot 3 plus v_readfirstlane 0. m0 = 0x1041 = 1 primitive / 65 vertices, and the export guard (v0 < 2 via 2 > v0, OR v0 == 64) covers threads 0, 1 and 64 as the header comment claims.
  • The qualification predicate in _translate: "store" in op catches every global write the translator implements, image writes included — its only image-write mnemonic is image_store (emits OpImageWrite); atomics and ds_ are covered by the other two terms. No mnemonic escapes the check.
  • %local_index scoping: only (hdr, dec, gvars) are renamed to %real_local_index, so every other load of %local_index (the mesh prologue's %lidx, Gen.local_index()) is inside %main and reads the per-pass Function variable, which ms_serial_passes stores at the loop head before those loads run. v5 = wbase + lidx and the wave id lidx >> 6 then see pass w's lanes, 64w..64w+63.
  • One thing the re-init pass deliberately leaves alone: gen.eager_vars and gen.x_spills declare Function variables with no initialiser, so they are not set again per pass — a value written in pass 0 can still be there when pass 1 reads it. That only matters for a read-before-write, which is already undefined in the side-by-side form, so it cannot diverge for any defined program; noting it because it is the one state serialisation shares between waves.
  • ms_serial_epilogue renames every id the write block defines per pass (exports to their __w twins, %mli to %mli_w{w}), keeps ids defined earlier intact; ids reserved up front (g.cu(k), g.cu(64*k)) keep the loop's constants from colliding with insert_late_constants.

Nothing here speaks to the open problem above — the RTX 2070 SUPER stalls are a runtime-side investigation still in flight, and my findings say nothing about it.

docs/design.md: keep the new row and take main's text of the row below it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

Merged main (3d6050b) into the branch as ad1789d to clear a conflict in docs/design.md (one table row beside ours; I kept our row and took main's text of the other). Locally after the merge: tests/test_translate.py with tests/test_mesh_serial_waves.py 768 passed, and the 8 mesh GPU fixtures pass side by side and in series on the RTX 4080.

CI on ad1789d: translator-tests, semantic-tests, viewer-tests, change-scope, no-game-data passed; stdlib-tests-linux still running. Not passed, the same places as on cd25a5c: linux-gpu-tools (build, vk_null_descriptor_test.cpp:97), windows (vk_xdxr_postbuild_readback), macos-python (test_calibrated_texture_extra.py, one test), check (cancelled at 15 minutes), and macos (ps_ssharp, plus now cs_imgatomic_ext, a compute fixture that came in with main). None is in a file this pull request changes.

@OreoFR

OreoFR commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

In-game A/B on an 8 GB laptop (profile M) for this PR. Both arms use the same executable, recipe, caches and input script; only the mesh programs differ, retranslated with this PR's --mesh-serial-waves (head ad1789d) in arm B. A second agent on the same machine recomputed the numbers from the raw logs. AI-assisted (Claude Code, Claude Opus 5.5).

RUN regA | 2026-11-27 | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        main ec91d695c | shaders: main translation + #2447 (one-lane) pack
MACHINE:     RTX 4070 Laptop 8 GB, laptop (profile M) | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      documented + DEVIATIONS: ASYNC_PIPELINES=1 ASYNC_MIN_BYTES=1048576 VALUE_WAIT_TIMEOUT_MS=30000 MAP_READBACK=1 DEVICE_TYPE=6 PIPELINE_PREWARM_ORDER=1 ARENA_MB=4095 DEVICE_FAULT=1 | precompile: partial journal
OS/DRIVER:   TdrDelay 60
TARGET:      gpu-stall lines (direct queue ticket not done after >= 4 s) | PREDICTED: fewer with the PR
MEASURED:    10 gpu-stall lines (longest 16.3 s), 2 device-stall | world between 223 and 229 s | 8,990 submissions
END:         time limit | 0 device lost, 0 exceptions
CACHES:      warm | RUN 1 of 1
INSTRUMENTS: device fault checkpoints, thread stacks at 230/280/330/380 s
VERDICT:     baseline

RUN mswA | same, shaders: same pack with all mesh programs retranslated by this PR (--mesh-serial-waves)
MEASURED:    0 gpu-stall lines, 0 device-stall | world between 313 and 326 s | 11,248 submissions
END:         time limit | 0 device lost, 0 exceptions; the extra STALL_CHECKPOINTS=1 instrument was on in this arm only
CACHES:      warm except the retranslated mesh programs (first use, cold): likely why the world comes later
VERDICT:     prediction held: the 4-16 s direct-queue submissions on this machine came from the emulated mesh draws

Not fixed by this PR, in either arm: the display drops to ~0.2 frames/s right after world entry. Without the PR the GPU sits at 100 % during that stop; with it, the long submissions are gone and the stop stays, so the stop has another cause. Another 8 GB machine (RTX 4060, 610.88) with this PR sees the same stop with an idle GPU. n=1 per arm.

@HasiKe

HasiKe commented Nov 27, 2026

Copy link
Copy Markdown

RTX 2070 SUPER (8 GB), NVIDIA 616.56, TdrDelay 30 s, n=3 each, same exe, Enter at 55 s: stock shaders ran 1 of 3 to the 600 s limit; this PR's retranslation 0 of 3. One lost the device at ~540 s, two stopped presenting at ~290/320 s. The stop looks like the 8 GB one on the 4060/4070 Laptop (CPU submit cost, GPU mostly idle), not something this PR causes or fixes. Details and memory numbers: #1608 (comment). AI-assisted (Claude Code, Claude Opus 5.5).

@OreoFR

OreoFR commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Addendum to the RUN above (7223228320), for the merge test: this PR's own tests at the current head ad1789d pass locally on Windows 11 (python -m pytest tests/test_mesh_serial_waves.py with the pins of tests/requirements.txt: 23/23). The game A/B above used the mesh pack retranslated with ad1789d, the current head. AI-assisted (Claude Code, Claude Opus 5.5).

@tiguan26 tiguan26 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.

Approving again at the current head, ad1789d, merged onto current main (43a9d56) with no conflicts. Thanks for adding the early-ending wave test.

tests/test_mesh_serial_waves.py: 23 passed, including cd25a5c95's wave that ends early. GPU fixtures on llvmpipe under Wine (8-wide subgroups, so the emulated path) with LEONIDA_W64_EMULATE=1: all 8 ms_ fixtures pass side by side, and with LEONIDA_MESH_SERIAL_WAVES=1 the three ms_w64x_ ones (ballot, the new wave_loops, wave_votes) pass at 4096/4096 exact. The new loops fixture is a good addition: two waves running loops of different length is the case where a mistake in the per-pass re-initialisation would show.

I'm only approving the code and the tests here. The merge decision belongs with the open question about the RTX 2070 SUPER stalls you listed.

@qhukz13

qhukz13 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Code read of ad1789d7e (no llvm-mc / SPIR-V tools on this machine, so the new tests skip here; CI and the RTX 4080 runs above cover them). I checked the two places where running the waves one after the other could lose state between passes:

  • The counts. s_sendmsg MSG_GS_ALLOC_REQ stores into %ms_counts, a Workgroup variable (tools/rdna2spirv.py:7953). ms_serial_passes re-initializes only Function variables that have an initializer, so a program where only wave 0 sends the request keeps pass 0's counts through pass 1, and the epilogue's single OpSetMeshOutputsEXT reads them.
  • The exports. Every Function variable the epilogue writes from is named %ms_*: %ms_pos, %ms_param{n}, %ms_clip, %ms_cull_dist, %ms_prim, %ms_has_vtx and %ms_has_prim. Each one gets a per-pass twin, and the %ms_out_* targets are Output variables that are not copied. No export can skip the twins.

One scope note, not a finding: the switch is off with --mesh-compute, which is the path for every GPU without VK_EXT_mesh_shader (Pascal, and the other cards that need wave64 emulation the most). I'd like to extend it to --mesh-compute in a follow-up built on this PR, unless you plan to.

AI-assisted (Claude Code).

@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

@qhukz13 thanks for the read; both points match how I understand the pass loop. On --mesh-compute: I do not plan to do it, so the follow-up is yours. One thing that may help: I only ever ran the switch on a card with VK_EXT_mesh_shader, so nothing here says how the serial form behaves through the compute path; it would need its own fixture run. 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.

8 participants