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

Merged
atk3001 merged 1 commit from upstream-pr/1866 into main 2026-11-29 08:16:52 +00:00
atk3001 commented 2026-11-29 01:07:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by atk3001 on 2026-11-29T01:07:02Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5546294727 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1866). Originally posted by [atk3001](https://github.com/atk3001) on 2026-11-29T01:07:02Z. --- 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)
Sign in to join this conversation.
No reviewers
No labels
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.

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