Shaders: mesh groups in whole console waves, mesh loop limits through the loop's exit, 16-bit writes over registers the host lacks #1866

Manually merged
github merged 1 commit from github-bot/gh-1866 into main 2026-11-29 08:20:48 +00:00 AGit
Owner

@⁠atk3001 on GitHub · 2026-11-29 01:07 UTC · original
atk3001:pr/mesh-waves-and-half-writes → main · +237 −22 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC

Found with the shader oracle in diff_tests.rs. Each case is compiled with the GDK's Scarlett compiler (VICTORY_CONSOLE_DXC, the pixsc\dxc.exe of a GDK install) and translated. It is then drawn next to the PC compiler's build of the same HLSL, on the card and on WARP. Three findings in one PR, because the oracle tests all of them.

What

  • Mesh groups run in whole console waves (lower.rs, mod.rs mesh_stride).
    • A wave64 mesh program turns all 64 lanes on (s_mov_b64 exec, -1). Newer compilers then give lanes 32-63 of a 32-thread group vertices and primitives to export.
    • The host group had the HLSL count (ms.threads), so those lanes never ran, and their vertices and triangles were missing.
    • The group is now rounded up to the console wave (64 or 32), and mesh_stride uses the same count.
  • Mesh loop limits leave through the loop's exit (lower.rs: find_exit_caps, exit_caps, limit_test).
    • A latch that jumps back without a condition (LaneExit::Jump) was capped as CondBr(count < limit, header, abort), and the abort block ends in ret.
    • In a mesh program that ret broke the group's LDS round trip and its triangles on NVIDIA, even though it was never taken. Seen on an RTX 5080 with the 2026-11 driver; WARP drew the same shader correctly.
    • Shown by experiment: with the limit folded away the case matches; one ret block shared by all loops still fails; an opaque limit constant still fails.
    • For mesh programs, the limit now joins the condition of a branch out of the loop. That branch dominates every such latch and isn't wave-wide, so every iteration passes it. This mirrors how a conditional back edge already folds the limit into its exit.
    • The latch becomes a plain br. Loops without such an exit keep the abort block. Other stages are unchanged.
    • count_iteration is split into count_on (the increment and its phi entry) and loop_cap (the per-stage limit), with no change in behaviour.
  • 16-bit writes keep zeros of a register the host has no value for (lower.rs: kept_half).
    • The 2026 Scarlett compiler writes a vertex program's f16 results with v_fma_mixlo_f16 into v2, which holds the primitive id on entry. A host vertex shader has no primitive id.
    • mixlo keeps the register's other half, so the whole program was refused: Unsupported { what: "the primitive id" }.
    • The program then masks that half off (v_and_b32 …, 0xffff), so zeros stand in now.
    • This applies only to the kept half of v_fma_mixlo/mixhi_f16 and of the 16-bit loads that write one half. A real read of the primitive id is still refused.

Tests

  • diff_tests.rs (test code only):
    • Fixes so the oracle runs on main:
      • A HostWave guard follows the device's wave size.
      • The translated compute run gets raw views and the PC run structured ones (make_views).
    • New WARP-only case "terminates on unknown counts". A mesh loop about 30 million iterations long, with a Jump latch, stops at the limit. Before the change its translation had 2 rets, after it 1.
  • Oracle with the GDK 2026.10 Scarlett compiler. Every case matches on the RTX 5080 and on WARP:
    • compute 21/21
    • pixel 13/13 (before: "16-bit varyings and front face" was refused)
    • mesh 5/5 (before: "grid through shared memory" differed on NVIDIA only, worst relative difference 1.0)
  • victory-shader on main f9dfb76 with this patch: 387 passed, 0 failed. The diff tests on WARP: 4 passed.
  • Clippy: only the existing manual checked division at lower.rs spare / per. rustfmt flags none of the changed lines.

Limits

  • The NVIDIA cause is shown by experiment, not by a driver reference. Loops whose exit doesn't dominate every latch still use the ret abort.
  • The mesh limit is checked one step earlier than before: at the exit, before the rest of the last iteration's body runs. It still stops after 256 iterations.
  • Changes the translator, so caches are translated again.
  • The oracle needs a GDK install (VICTORY_CONSOLE_DXC) and skips itself without one; no GDK files are in the repository.

🤖 Generated with Claude Code

**@⁠atk3001** on GitHub · 2026-11-29 01:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1866) `atk3001:pr/mesh-waves-and-half-writes` → `main` · +237 −22 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC Found with the shader oracle in `diff_tests.rs`. Each case is compiled with the GDK's Scarlett compiler (`VICTORY_CONSOLE_DXC`, the `pixsc\dxc.exe` of a GDK install) and translated. It is then drawn next to the PC compiler's build of the same HLSL, on the card and on WARP. Three findings in one PR, because the oracle tests all of them. ## What - **Mesh groups run in whole console waves** (`lower.rs`, `mod.rs` `mesh_stride`). - A wave64 mesh program turns all 64 lanes on (`s_mov_b64 exec, -1`). Newer compilers then give lanes 32-63 of a 32-thread group vertices and primitives to export. - The host group had the HLSL count (`ms.threads`), so those lanes never ran, and their vertices and triangles were missing. - The group is now rounded up to the console wave (64 or 32), and `mesh_stride` uses the same count. - **Mesh loop limits leave through the loop's exit** (`lower.rs`: `find_exit_caps`, `exit_caps`, `limit_test`). - A latch that jumps back without a condition (`LaneExit::Jump`) was capped as `CondBr(count < limit, header, abort)`, and the abort block ends in `ret`. - In a mesh program that `ret` broke the group's LDS round trip and its triangles on NVIDIA, even though it was never taken. Seen on an RTX 5080 with the 2026-11 driver; WARP drew the same shader correctly. - Shown by experiment: with the limit folded away the case matches; one `ret` block shared by all loops still fails; an opaque limit constant still fails. - For mesh programs, the limit now joins the condition of a branch out of the loop. That branch dominates every such latch and isn't wave-wide, so every iteration passes it. This mirrors how a conditional back edge already folds the limit into its exit. - The latch becomes a plain `br`. Loops without such an exit keep the abort block. Other stages are unchanged. - `count_iteration` is split into `count_on` (the increment and its phi entry) and `loop_cap` (the per-stage limit), with no change in behaviour. - **16-bit writes keep zeros of a register the host has no value for** (`lower.rs`: `kept_half`). - The 2026 Scarlett compiler writes a vertex program's f16 results with `v_fma_mixlo_f16` into v2, which holds the primitive id on entry. A host vertex shader has no primitive id. - `mixlo` keeps the register's other half, so the whole program was refused: `Unsupported { what: "the primitive id" }`. - The program then masks that half off (`v_and_b32 …, 0xffff`), so zeros stand in now. - This applies only to the kept half of `v_fma_mixlo/mixhi_f16` and of the 16-bit loads that write one half. A real read of the primitive id is still refused. ## Tests - `diff_tests.rs` (test code only): - Fixes so the oracle runs on main: - A `HostWave` guard follows the device's wave size. - The translated compute run gets raw views and the PC run structured ones (`make_views`). - New WARP-only case "terminates on unknown counts". A mesh loop about 30 million iterations long, with a Jump latch, stops at the limit. Before the change its translation had 2 `ret`s, after it 1. - Oracle with the GDK 2026.10 Scarlett compiler. Every case matches on the RTX 5080 and on WARP: - compute 21/21 - pixel 13/13 (before: "16-bit varyings and front face" was refused) - mesh 5/5 (before: "grid through shared memory" differed on NVIDIA only, worst relative difference 1.0) - `victory-shader` on main f9dfb76 with this patch: 387 passed, 0 failed. The diff tests on WARP: 4 passed. - Clippy: only the existing manual checked division at `lower.rs` `spare / per`. rustfmt flags none of the changed lines. ## Limits - The NVIDIA cause is shown by experiment, not by a driver reference. Loops whose exit doesn't dominate every latch still use the `ret` abort. - The mesh limit is checked one step earlier than before: at the exit, before the rest of the last iteration's body runs. It still stops after 256 iterations. - Changes the translator, so caches are translated again. - The oracle needs a GDK install (`VICTORY_CONSOLE_DXC`) and skips itself without one; no GDK files are in the repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Found with the shader oracle (diff_tests, GDK Scarlett compiler):

- A wave64 mesh program sets all 64 lanes on and newer compilers give
  lanes 32-63 of a 32-thread group vertices and primitives to export;
  the host group now has whole console waves (and mesh_stride with it).
- A mesh loop whose latch jumps back unconditionally stopped at the
  limit through a `ret`; even untaken, it lost the group's LDS round
  trip and triangles on NVIDIA. The limit now joins a branch out of
  the loop that dominates every such latch.
- The 2026 compiler writes f16 results with v_fma_mixlo_f16 into a
  vertex program's v2 (the primitive id, which a host vertex shader
  lacks) and masks the kept half off; that half is now zeros.

The oracle runs on main again (HostWave guard, raw and structured
views per side) and gains a WARP-only runaway mesh loop case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 01:07:50 +00:00
github manually merged commit 89406b2985 into main 2026-11-29 08:20:48 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1866
No description provided.