Shader: preserve scalar loop exits in native wave32 compute #647

Open
github-bot wants to merge 1 commit from github-bot/gh-647 into a-publier AGit
Owner

@⁠ANDREANIADS on GitHub · 2026-11-27 16:23 UTC · original
ANDREANIADS:fix-native-wave32-scalar-loops → a-publier · +407 −1 · 4 files · 1 commits · draft

Related to #352; complements the split-wave64 work in #366.

Native wave32 compute currently lets lanes leave a divergent loop before its scalar result has reached the final wave-wide value. On an RTX 3070 the synthetic 64-thread probe returned 1..64 instead of 32 for the first wave and 64 for the second.

This routes a conservative subset of native wave32 loops through the existing structured wide emitter: 1D compute, no LDS, spills or waterfalls, properly nested EXEC backedges, and scalar results used after the latch. Unsupported control flow, mask-as-data and cross-lane operations are rejected by the detector. The emitted wave width stays 32 even when the host allows 64. Translator cache version increases from 2 to 3.

Validation on Windows / NVIDIA RTX 3070 / driver 621.40 / Rust 1.98.1:

  • Original production code reproduced the incorrect GPU output.
  • Five targeted tests passed: original scalar probe, nested loops, scalar/vector output at 32/64/80/128 threads, vector-only control, and wave-width pinning. Seven GPU dispatches ran with matching output and DXIL validation.
  • A sixth test adds negative detector coverage for barriers, readfirstlane and forward SCC branches.
  • git diff --check passes.
  • Full shader library tests, Clippy and asset-policy checks were started, but the remote computer connection stopped returning results. Their completion is NOT yet confirmed; this PR remains a draft pending that validation.

Credit: the conservative loop detector is adapted from fladit123's #366; the synthetic scalar-loop fixture builds on adrianmjim's 471e11b. This does not claim to fix all of #352. No gameplay or performance claims.

AI-assisted with Codex.

**@⁠ANDREANIADS** on GitHub · 2026-11-27 16:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/647) `ANDREANIADS:fix-native-wave32-scalar-loops` → `a-publier` · +407 −1 · 4 files · 1 commits · draft Related to #352; complements the split-wave64 work in #366. Native wave32 compute currently lets lanes leave a divergent loop before its scalar result has reached the final wave-wide value. On an RTX 3070 the synthetic 64-thread probe returned 1..64 instead of 32 for the first wave and 64 for the second. This routes a conservative subset of native wave32 loops through the existing structured wide emitter: 1D compute, no LDS, spills or waterfalls, properly nested EXEC backedges, and scalar results used after the latch. Unsupported control flow, mask-as-data and cross-lane operations are rejected by the detector. The emitted wave width stays 32 even when the host allows 64. Translator cache version increases from 2 to 3. Validation on Windows / NVIDIA RTX 3070 / driver 621.40 / Rust 1.98.1: - Original production code reproduced the incorrect GPU output. - Five targeted tests passed: original scalar probe, nested loops, scalar/vector output at 32/64/80/128 threads, vector-only control, and wave-width pinning. Seven GPU dispatches ran with matching output and DXIL validation. - A sixth test adds negative detector coverage for barriers, readfirstlane and forward SCC branches. - git diff --check passes. - Full shader library tests, Clippy and asset-policy checks were started, but the remote computer connection stopped returning results. Their completion is NOT yet confirmed; this PR remains a draft pending that validation. Credit: the conservative loop detector is adapted from fladit123's #366; the synthetic scalar-loop fixture builds on adrianmjim's 471e11b. This does not claim to fix all of #352. No gameplay or performance claims. AI-assisted with Codex.
Adapt the conservative scalar-loop detector from fladit123 PR #366 and extend the synthetic loop fixture attributed to adrianmjim (471e11b). Add native wave32 coverage and bump translator cache version.

AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:24:54 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/647/head:github-bot/gh-647'
git switch 'github-bot/gh-647'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-647'
git switch 'github-bot/gh-647'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-647'
git switch 'github-bot/gh-647'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-647'
git switch 'a-publier'
git merge --squash 'github-bot/gh-647'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-647'
git switch 'a-publier'
git merge 'github-bot/gh-647'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.