shader: a wave64 mesh program's first-lane read is its console wave's (#517) #522

Manually merged
github merged 1 commit from github-bot/gh-518 into main 2026-11-28 00:23:21 +00:00 AGit
Owner

@⁠alexballvideos-netizen on GitHub · 2026-11-27 23:47 UTC · original
alexballvideos-netizen:mesh-wide-firstlane → main · +141 −1 · 4 files · 1 commits · merged 2026-11-28 00:22 UTC

Refs #521, #258

The G-buffer mesh programs are wave64 groups whose threads are console lanes, so each 32-lane host wave is half a console wave. Their v_readfirstlane_b32 lowered to waveReadLaneFirst, so lanes 32 to 63 read lane 32's value instead of lane 0's and built their vertices and primitives from the wrong meshlet. That's the fans and sheets in the G-buffer.

What this changes

  • mesh_first_lane (halves.rs): each host wave finds its own first active lane (host_ballot + FirstbitLo + waveReadLaneAt). Its lane 0 stores the value and its lane 1 whether any lane was on, in group-shared memory. After a group barrier, every thread takes the lower half's value if it had a lane on, else the upper half's. This is the same exchange #302 proposes for compute.
  • Where: wave64 mesh programs only, in blocks every thread runs once (once_blocks), so both halves always reach the barriers. Elsewhere the read stays per host wave, as before.
  • Cost: two group barriers per read, and 4 bytes of group-shared memory per thread.

Checks

  • New test export_tests::a_wave64_mesh_programs_first_lane_read_is_its_console_waves: it fails without the fix and passes with it. All victory-shader tests pass (403 + 5).
  • Clippy (x86_64-pc-windows-gnullvm, -D warnings) and cargo xtask policy pass.
  • Corpus sweep against main (21,579 shaders): no shader is newly refused or newly translated. The output of 6,959 vertex (mesh) programs changes, which is expected since they're the ones with the instruction.
  • In game (M3 Max 36 GB, Series X, applied on preview b3c1a1b0, VICTORY_GUESS_GRAPHICS=1 VICTORY_DEPTH_TWINS=0): G-buffer dumps every 20 s from 140 to 290 s show clean characters, cars and buildings, where every earlier run had fans. There were no GPU timeouts, and the run ended at the same image+0x55e56f8 exception as the baselines.

docs/native-host.md has a new section on this.

**@⁠alexballvideos-netizen** on GitHub · 2026-11-27 23:47 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518) `alexballvideos-netizen:mesh-wide-firstlane` → `main` · +141 −1 · 4 files · 1 commits · merged 2026-11-28 00:22 UTC Refs #521, #258 The G-buffer mesh programs are wave64 groups whose threads are console lanes, so each 32-lane host wave is half a console wave. Their `v_readfirstlane_b32` lowered to `waveReadLaneFirst`, so lanes 32 to 63 read lane 32's value instead of lane 0's and built their vertices and primitives from the wrong meshlet. That's the fans and sheets in the G-buffer. ### What this changes - **`mesh_first_lane` (`halves.rs`):** each host wave finds its own first active lane (`host_ballot` + `FirstbitLo` + `waveReadLaneAt`). Its lane 0 stores the value and its lane 1 whether any lane was on, in group-shared memory. After a group barrier, every thread takes the lower half's value if it had a lane on, else the upper half's. This is the same exchange #302 proposes for compute. - **Where:** wave64 mesh programs only, in blocks every thread runs once (`once_blocks`), so both halves always reach the barriers. Elsewhere the read stays per host wave, as before. - **Cost:** two group barriers per read, and 4 bytes of group-shared memory per thread. ### Checks - New test `export_tests::a_wave64_mesh_programs_first_lane_read_is_its_console_waves`: it fails without the fix and passes with it. All `victory-shader` tests pass (403 + 5). - Clippy (`x86_64-pc-windows-gnullvm`, `-D warnings`) and `cargo xtask policy` pass. - Corpus sweep against `main` (21,579 shaders): no shader is newly refused or newly translated. The output of 6,959 vertex (mesh) programs changes, which is expected since they're the ones with the instruction. - In game (M3 Max 36 GB, Series X, applied on preview `b3c1a1b0`, `VICTORY_GUESS_GRAPHICS=1 VICTORY_DEPTH_TWINS=0`): G-buffer dumps every 20 s from 140 to 290 s show clean characters, cars and buildings, where every earlier run had fans. There were no GPU timeouts, and the run ended at the same `image+0x55e56f8` exception as the baselines. `docs/native-host.md` has a new section on this.
The G-buffer mesh programs are wave64 groups whose threads are console
lanes, so each 32-lane host wave is half a console wave. Their
v_readfirstlane_b32 lowered to waveReadLaneFirst, so lanes 32-63 read
lane 32's value instead of lane 0's, and built vertices and primitives
from the wrong meshlet: the fans and sheets in the G-buffer.

Where every thread runs the block once, the two halves now exchange
their first active lane through group-shared memory between two group
barriers (the exchange #302 proposes for compute). Elsewhere the read
stays per host wave.

Refs #517, #258
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:48:34 +00:00
github-bot force-pushed github-bot/gh-518 from 4e06f108a7 to b7dd2ee188 2026-11-27 23:54:57 +00:00 Compare
github manually merged commit 578134be0d into main 2026-11-28 00:23:21 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-28 00:22 UTC · original · approved these changes

**@⁠LakshanSivakumar** on GitHub · 2026-11-28 00:22 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#pullrequestreview-6094578412) · **approved these changes**
Author
Owner

@⁠alexballvideos-netizen on GitHub · 2026-11-28 00:39 UTC · original

Rechecked on main (86cefd22, which now has the preview's graphics fixes). M3 Max 36 GB, Series X, headless, VICTORY_DEPTH_TWINS=0, base-colour target dumped every 25 s from 140 s:

Base colour, 140–303 s
main Shards in all 7 dumps: dark sheets across the characters at 140 s, and nearly the whole frame is sheets from about 220 s
main + this PR (b7dd2ee1) Clean in all 7 dumps: characters, the car, trees and distant terrain

The run with the fix went the full 320 s with no GPU time-outs. The baseline's first attempt hit the usual image+0x55e56f8 exception at about 170 s, and its second attempt is the one in the table.

**@⁠alexballvideos-netizen** on GitHub · 2026-11-28 00:39 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231087368) Rechecked on `main` (`86cefd22`, which now has the preview's graphics fixes). M3 Max 36 GB, Series X, headless, `VICTORY_DEPTH_TWINS=0`, base-colour target dumped every 25 s from 140 s: | | Base colour, 140–303 s | |---|---| | `main` | Shards in all 7 dumps: dark sheets across the characters at 140 s, and nearly the whole frame is sheets from about 220 s | | `main` + this PR (`b7dd2ee1`) | Clean in all 7 dumps: characters, the car, trees and distant terrain | The run with the fix went the full 320 s with no GPU time-outs. The baseline's first attempt hit the usual `image+0x55e56f8` exception at about 170 s, and its second attempt is the one in the table.
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:05 UTC · original

Confirmed on another Mac: thanks @⁠alexballvideos-netizen, this fixes the shards.

M5 Pro 48 GB, Series S, windowed, 250 s a run, VICTORY_DEPTH_TWINS=0, G-buffer base colour (DXGI 29, 1280x720) dumped every 15 s from 150 s:

build broken frames GPU errors
main just before this PR (6c24066f) 6 of 6: sheets or fans across the picture, white holes in clothing 0
main at this PR's merge (578134be) 0 of 6: whole scenes (people, cars, yard, buildings, fence) 0

GPU memory drained to 0 GB after both runs. Left over after the fix: the sky is black in the G-buffer (expected there), and one head showed a blocky low-detail patch at one present. The two runs aren't at the same shots (the cutscene follows wall time), but every frame before is broken and every frame after is clean, so the result doesn't hang on alignment. A pair with depth twins on is running.

**@⁠Olima34** on GitHub · 2026-11-28 01:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231410354) Confirmed on another Mac: thanks @⁠alexballvideos-netizen, this fixes the shards. M5 Pro 48 GB, Series S, windowed, 250 s a run, `VICTORY_DEPTH_TWINS=0`, G-buffer base colour (DXGI 29, 1280x720) dumped every 15 s from 150 s: | build | broken frames | GPU errors | |---|---|---| | main just before this PR (`6c24066f`) | 6 of 6: sheets or fans across the picture, white holes in clothing | 0 | | main at this PR's merge (`578134be`) | 0 of 6: whole scenes (people, cars, yard, buildings, fence) | 0 | GPU memory drained to 0 GB after both runs. Left over after the fix: the sky is black in the G-buffer (expected there), and one head showed a blocky low-detail patch at one present. The two runs aren't at the same shots (the cutscene follows wall time), but every frame before is broken and every frame after is clean, so the result doesn't hang on alignment. A pair with depth twins on is running.
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:28 UTC · original

The same pair with depth twins on (the default), lit scene (DXGI 10, 1280x720), windowed, M5 Pro, Series S, 250 s:

build frames with sheets, black triangles or a ray fan GPU errors
main just before this PR (6c24066f), 6 dumps 4 of 6: large black triangles in 3, the yellow ray fan around the sun in 1, and 2 nearly black 0
main at its merge (578134be), 5 dumps 0 of 5: 4 coherent backlit scenes, 1 dark interior 0

So the "flying shards, fence panels and rays drawn into the lit scene" and the "triangles missing on characters and clothing" both came from the mesh programs' first-lane read, and this fixes them on our Mac too. What's left with twins on: dark interiors (#530) and some small rectangles of a regular dot pattern in the lit scene, not investigated yet.

**@⁠Olima34** on GitHub · 2026-11-28 01:28 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231686301) The same pair with depth twins **on** (the default), lit scene (DXGI 10, 1280x720), windowed, M5 Pro, Series S, 250 s: | build | frames with sheets, black triangles or a ray fan | GPU errors | |---|---|---| | main just before this PR (`6c24066f`), 6 dumps | 4 of 6: large black triangles in 3, the yellow ray fan around the sun in 1, and 2 nearly black | 0 | | main at its merge (`578134be`), 5 dumps | 0 of 5: 4 coherent backlit scenes, 1 dark interior | 0 | So the "flying shards, fence panels and rays drawn into the lit scene" and the "triangles missing on characters and clothing" both came from the mesh programs' first-lane read, and this fixes them on our Mac too. What's left with twins on: dark interiors (#530) and some small rectangles of a regular dot pattern in the lit scene, not investigated yet.
This discussion has been locked. Commenting is limited to contributors.
No description provided.