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

Merged
alexballvideos-netizen merged 1 commit from upstream-pr/518 into main 2026-11-28 00:22:59 +00:00
alexballvideos-netizen commented 2026-11-27 23:47:33 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-27T23:47:33Z.


Refs #517, #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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5534594382 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518). Originally posted by [alexballvideos-netizen](https://github.com/alexballvideos-netizen) on 2026-11-27T23:47:33Z. --- Refs #517, #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 commented 2026-11-28 00:39:18 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-28T00:39:18Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231087368 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231087368). Originally posted by [alexballvideos-netizen](https://github.com/alexballvideos-netizen) on 2026-11-28T00:39:18Z. --- 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.
Olima34 commented 2026-11-28 01:05:13 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T01:05:13Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231410354 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231410354). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:05:13Z. --- 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 commented 2026-11-28 01:28:06 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T01:28:06Z.


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 (#526) and some small rectangles of a regular dot pattern in the lit scene, not investigated yet.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231686301 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/518#issuecomment-7231686301). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:28:06Z. --- 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 (#526) and some small rectangles of a regular dot pattern in the lit scene, not investigated yet.
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
LakshanSivakumar/Native-Victory-macOS!518
No description provided.