Skip to content

Shaders: readfirstlane reads the first active lane with WaveReadLaneFirst - #21

Open
Sr-0w wants to merge 1 commit into
ThatRecompDev:mainfrom
Sr-0w:shaders/readfirstlane-amd
Open

Sr-0w wants to merge 1 commit into
ThatRecompDev:mainfrom
Sr-0w:shaders/readfirstlane-amd

Conversation

@Sr-0w

@Sr-0w Sr-0w commented Nov 25, 2026

Copy link
Copy Markdown

What changed

The prelude's readfirstlane (no wave emulation, no group wave) reads the first active lane with WaveReadLaneFirst instead of vw_read(x, firstbitlow(ballot)), i.e. WaveReadLaneAt with a lane computed from a ballot. With EXEC empty it still reads lane 0, as before. Emulated and group-wave programs keep the old path.

Why

On an RX 7800 XT (Adrenalin 32.0.32029.2010), the old pattern made the driver's shader compiler (amdxc64) crash in a story-load pixel program. I bisected the translated HLSL down to that one pattern:

  • without readfirstlane the program compiles and runs;
  • with only vw_any removed it still crashes;
  • the WaveReadLaneFirst form runs.

The result is the same: the first lane whose EXEC bit is set.

How I checked

  • dotnet test tests/FiveStar.Shaders.Tests: 320 passed, 12 skipped (the GPU cases cover v_readfirstlane_b32 with partial EXEC).
  • In game: the story load got past that program, where it had crashed in amdxc64 before.
  • docs/shader-translation.md notes the AMD form next to readfirstlane.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru

…irst

When the hardware wave holds no more than the program wave, readfirstlane now reads x under if (active) with WaveReadLaneFirst and spreads it with WaveActiveMax, instead of WaveReadLaneAt at the ballot's lowest bit. The old form crashed AMD's compiler (RX 7800 XT, driver 32.0.32029.2010) inside CreatePipelineState on the decoration-baking mesh pipeline's pixel program, which reads the first lane seven times in a loop; the crash took the process at the eighth present of the story load. The group forms and a wider hardware wave keep the ballot form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru
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.

1 participant