Shaders: lower Wave32 compute branches that reuse lane masks as scalar data #2091

Open
github-bot wants to merge 8 commits from github-bot/gh-2091 into main AGit
Owner

@⁠rezioliver-collab on GitHub · 2026-11-25 04:37 UTC · original
talleyrand222:fix/wave32-compute-scalar-control → main · +1416 −303 · 11 files · 8 commits · open

Why these 40 shaders

We started with 40 RDNA 2 Wave32 compute shaders. On main, every one stopped with a register joining a lane mask and data, read as data. At a branch or loop join, the guest could use the same scalar register as a 32-bit number and as a mask with one bit per lane. The goal was to emit DXIL for every shader in that fixed set while preserving the word that all lanes read after reconvergence. This PR emits all 40.

What changed and why

The compiler keeps the complete scalar word at joins it can lower directly. For the remaining supported compute groups made up of complete Wave32 waves, it follows native scalar branches with an explicit 32-bit EXEC. If the wave reaches a scalar write with EXEC == 0, that write still takes effect. Vector writes respect the enabled lanes. A later scalar read sees the last write reached by the wave. These rules follow AMD's wavefront execution model, §3.3 on EXEC, §4.1 on program control and the S_AND_SAVEEXEC_B32 definition in §12.3. AMD RDNA 2 ISA reference

Some of these programs also read resource descriptor word zero as a number. For a buffer view, that word is the low 32 bits of its guest byte address, including the first-element offset. An image stores its base in 256-byte units, so word zero contains guest address bits 39–8. The host supplies this value when the shader reads the descriptor numerically. AMD RDNA 2 ISA, §8.1.8 table 37 and §8.2.6 table 45

Translation and validation

All four configurations use main at 940d32f, the same archive and the Windows x64 SDK validator (dxil.dll 1.8.2502.11). The last two columns cover all 25,889 matched entries.

Build Target 40 emitted Target 40 SDK accepted Archive emitted Archive SDK accepted
Main 0 0 25,591 23,918
This PR 40 16 25,633 23,936
Main + Halfect’s #1065 0 0 25,591 24,653
This PR + #1065, tested locally 40 40 25,633 24,695

This PR gains 42 emissions (the target 40 plus two more programs) and 18 SDK passes over main, with zero losses in either set. The remaining 24 shaders in the target group use compute derivatives and pass with the validator 1.8 metadata supplied by Halfect’s separate #1065. That accounts for the 42 additional SDK passes when Wave32 is applied on top of #1065. The metadata commit has been removed from this branch. YaBulochka independently measured the standalone gain of 18 on AMD/Linux at 93685fe, before the descriptor layout revision. Independent archive run

Compatibility with #2048

The host and compiler use two dwords (8 bytes) per slot in the t1 view-address table. A buffer keeps its original low/high address pair. For a view that supplies only native word zero, the first dword holds that word and bit 16 in the second identifies the entry. A buffer-pointer read of such a slot yields zero. Clearing the slot publishes two zeros.

Both PRs edit descriptor/host.rs. The linked merge of this head and #2048 (dfb8093) publishes staged descriptors and their two address words together and initializes the table from already-published slots. An RTX 5080 readback checked the value before and after flushing an image replacement and a clear. It also checked that an older queued update could not overwrite a newer direct write at the next flush. All five staging regressions from #2048 passed. Tested merge and conflict resolution

Seven hand-written Wave32 fixtures passed SDK validation and produced the expected four dwords for all 704 threads on the RTX 5080. The archive measurements cover offline translation and SDK acceptance. The GPU execution results cover the synthetic fixtures. Both workspace Clippy configurations and the upstream CI job passed. GitHub CI

Full local Windows test suite

Six tests failed in the full local run. Five also failed in the unmodified-main suite. The sixth, a_page_list_filled_after_its_request_starts, failed intermittently on unmodified main and passed three isolated reruns of the PR test binary.

AI-assisted with OpenAI Codex.

**@⁠rezioliver-collab** on GitHub · 2026-11-25 04:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091) `talleyrand222:fix/wave32-compute-scalar-control` → `main` · +1416 −303 · 11 files · 8 commits · open ## Why these 40 shaders We started with 40 RDNA 2 Wave32 compute shaders. On `main`, every one stopped with `a register joining a lane mask and data, read as data`. At a branch or loop join, the guest could use the same scalar register as a 32-bit number and as a mask with one bit per lane. The goal was to emit DXIL for every shader in that fixed set while preserving the word that all lanes read after reconvergence. **This PR emits all 40.** ## What changed and why The compiler keeps the complete scalar word at joins it can lower directly. For the remaining supported compute groups made up of complete Wave32 waves, it follows native scalar branches with an explicit 32-bit `EXEC`. If the wave reaches a scalar write with `EXEC == 0`, that write still takes effect. Vector writes respect the enabled lanes. A later scalar read sees the last write reached by the wave. These rules follow AMD's wavefront execution model, §3.3 on `EXEC`, §4.1 on program control and the `S_AND_SAVEEXEC_B32` definition in §12.3. [AMD RDNA 2 ISA reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) Some of these programs also read resource descriptor word zero as a number. For a buffer view, that word is the low 32 bits of its guest byte address, including the first-element offset. An image stores its base in 256-byte units, so word zero contains guest address bits 39–8. The host supplies this value when the shader reads the descriptor numerically. [AMD RDNA 2 ISA, §8.1.8 table 37 and §8.2.6 table 45](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) ## Translation and validation All four configurations use `main` at `940d32f`, the same archive and the Windows x64 SDK validator (`dxil.dll` 1.8.2502.11). The last two columns cover all 25,889 matched entries. | Build | Target 40 emitted | Target 40 SDK accepted | Archive emitted | Archive SDK accepted | | --- | ---: | ---: | ---: | ---: | | Main | 0 | 0 | 25,591 | 23,918 | | **This PR** | **40** | **16** | **25,633** | **23,936** | | Main + Halfect’s #1065 | 0 | 0 | 25,591 | 24,653 | | This PR + #1065, tested locally | 40 | 40 | 25,633 | 24,695 | This PR gains **42 emissions** (the target 40 plus two more programs) and **18 SDK passes** over main, with zero losses in either set. The remaining 24 shaders in the target group use compute derivatives and pass with the validator 1.8 metadata supplied by Halfect’s separate #1065. That accounts for the **42 additional SDK passes** when Wave32 is applied on top of #1065. The metadata commit has been removed from this branch. YaBulochka independently measured the standalone gain of 18 on AMD/Linux at `93685fe`, before the descriptor layout revision. [Independent archive run](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2091) ## Compatibility with #2048 The host and compiler use **two dwords (8 bytes) per slot** in the `t1` view-address table. A buffer keeps its original low/high address pair. For a view that supplies only native word zero, the first dword holds that word and bit 16 in the second identifies the entry. A buffer-pointer read of such a slot yields zero. Clearing the slot publishes two zeros. Both PRs edit `descriptor/host.rs`. The linked merge of this head and #2048 (`dfb8093`) publishes staged descriptors and their two address words together and initializes the table from already-published slots. An RTX 5080 readback checked the value before and after flushing an image replacement and a clear. It also checked that an older queued update could not overwrite a newer direct write at the next flush. All five staging regressions from #2048 passed. [Tested merge and conflict resolution](https://github.com/talleyrand222/VIctory/commit/fa89bb652278b700f190335523d759f9476e7ea6) Seven hand-written Wave32 fixtures passed SDK validation and produced the expected four dwords for all 704 threads on the RTX 5080. The archive measurements cover offline translation and SDK acceptance. The GPU execution results cover the synthetic fixtures. Both workspace Clippy configurations and the upstream CI job passed. [GitHub CI](https://github.com/Marvisak/VIctory/actions/runs/45622836365) <details> <summary>Full local Windows test suite</summary> Six tests failed in the full local run. Five also failed in the unmodified-main suite. The sixth, `a_page_list_filled_after_its_request_starts`, failed intermittently on unmodified main and passed three isolated reruns of the PR test binary. </details> AI-assisted with OpenAI Codex.
Resolve the descriptor and shader conflicts against the four-dword view-address table. Preserve the original Wave32 history and publish the tree tested on macOS arm64.
Keep dynamic 16-byte descriptor records and native EXEC source selection for Wave32 DPP. Preserve the Wave64 and partial-group test coverage, and split DPP lowering to stay within the repository file-size limit.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:34 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:44 UTC · original

Triage verdict — Review the Wave32 work independently of #1065 (00f14fa)

Evidence

  • @⁠rezioliver-collab’s Wave32 work ends at 93685fe. The final commit has identical added and removed lines to @⁠Halfect’s open #1065 across both changed files. The derivative metadata is already available as a separately reviewable change. Stack commits · #1065 patch
  • The Wave32 work expands each address side-table entry from two words to three. #2048 stages updates using two-word address records. If both proceed, allocation, staged publication, and shader reads need to move to the three-word layout together, including clearing the added word when a slot is reused. Address layout · #2048 staged record

Checks and limits

  • Compared the commit patches and the two side-table layouts. The hardware/WARP and descriptor checks in the existing review are the execution evidence for this head. I did not run the combined branches.

Next step

  • Preserve the Wave32 commits and credit, and land or rebase the derivative commit only once. When reconciling #2048, add a slot-reuse test that observes the new descriptor base word through the staged publication path.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7153117303) **Triage verdict — Review the Wave32 work independently of #1065** (`00f14fa`) **Evidence** - @⁠rezioliver-collab’s Wave32 work ends at `93685fe`. The final commit has identical added and removed lines to @⁠Halfect’s open #1065 across both changed files. The derivative metadata is already available as a separately reviewable change. [Stack commits](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2091/commits) · [#1065 patch](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1065/files) - The Wave32 work expands each address side-table entry from two words to three. #2048 stages updates using two-word address records. If both proceed, allocation, staged publication, and shader reads need to move to the three-word layout together, including clearing the added word when a slot is reused. [Address layout](https://github.com/Marvisak/VIctory/blob/00f14fab140bced44933cf7b18b64e6ab7093908/crates/victory-gpu/src/descriptor/host.rs#L538-L565) · [#2048 staged record](https://github.com/Marvisak/VIctory/blob/da8574ba542debc39f456a19fce3f5626cdef593/crates/victory-gpu/src/descriptor/host.rs#L68-L80) **Checks and limits** - Compared the commit patches and the two side-table layouts. The hardware/WARP and descriptor checks in the existing review are the execution evidence for this head. I did not run the combined branches. **Next step** - Preserve the Wave32 commits and credit, and land or rebase the derivative commit only once. When reconciling #2048, add a slot-reuse test that observes the new descriptor base word through the staged publication path. This verification was AI-assisted.
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-25 06:42 UTC · original

AMD/Linux validation run of this stack, on the full retail dump. It is not a small win: +777 programs validate, and almost all of it comes from the last commit, not the scalar-mask ones.

Method: victory translate shaders.rpf --validate --list, retail 1.0.2.1, x86_64-pc-windows-gnu release under Wine, dxil.dll 1.9.2609.5. Same dump for every build.

Build validated vs 940d32f
940d32f (main) 23,918 -
93685fe (this stack without the last commit) 23,936 +18
pr2091 (all five commits) 24,695 +777

So of the +777, +759 is the "validator 1.8 for compute derivatives" commit alone, and the four scalar-mask/Wave32 commits give +18. Nothing is lost in either step (validated sets grow, no program disappears from the list).

What the 777 are: the whole RaytracingResolve family - standard 388, ped 114, prop 50, normal 32, rtdirectionalshadows 28, trees 26, weapon 22, trunk 12, indirect 11, sr 10 and the rest. On main they fail with

validator: Function: main: error: Entry function performs some operation that is
incompatible with the shader stage or other entry properties. See other errors for details.

which is the gradient-in-compute rejection the last commit describes; the validator gives no further detail in this path.

Two process notes, since the title only mentions scalar masks:

  • the behavioural weight of the PR is in its last commit; a reviewer skimming the title will not expect +759 validated programs, and it would be worth a line in the description (or splitting the validator bump out, if that is easier to review);
  • it needs dxil.dll 1.8+ at run time. With 1.9 here it is fine; on a host that ships 1.6/1.7 the derivative modules would be emitted and then rejected, so the version requirement is worth stating explicitly.

I did not check whether these 777 also compile in DXC or run; this is the DXIL validator count only.

**@⁠YaBulochka** on GitHub · 2026-11-25 06:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7155076603) AMD/Linux validation run of this stack, on the full retail dump. It is not a small win: +777 programs validate, and almost all of it comes from the last commit, not the scalar-mask ones. Method: `victory translate shaders.rpf --validate --list`, retail 1.0.2.1, `x86_64-pc-windows-gnu` release under Wine, dxil.dll **1.9.2609.5**. Same dump for every build. | Build | validated | vs `940d32f` | |---|---:|---:| | `940d32f` (main) | 23,918 | - | | `93685fe` (this stack without the last commit) | 23,936 | +18 | | `pr2091` (all five commits) | **24,695** | **+777** | So of the +777, **+759 is the "validator 1.8 for compute derivatives" commit alone**, and the four scalar-mask/Wave32 commits give +18. Nothing is lost in either step (validated sets grow, no program disappears from the list). What the 777 are: the whole `RaytracingResolve` family - `standard` 388, `ped` 114, `prop` 50, `normal` 32, `rtdirectionalshadows` 28, `trees` 26, `weapon` 22, `trunk` 12, `indirect` 11, `sr` 10 and the rest. On main they fail with ``` validator: Function: main: error: Entry function performs some operation that is incompatible with the shader stage or other entry properties. See other errors for details. ``` which is the gradient-in-compute rejection the last commit describes; the validator gives no further detail in this path. Two process notes, since the title only mentions scalar masks: - the behavioural weight of the PR is in its last commit; a reviewer skimming the title will not expect +759 validated programs, and it would be worth a line in the description (or splitting the validator bump out, if that is easier to review); - it needs dxil.dll 1.8+ at run time. With 1.9 here it is fine; on a host that ships 1.6/1.7 the derivative modules would be emitted and then rejected, so the version requirement is worth stating explicitly. I did not check whether these 777 also compile in DXC or run; this is the DXIL validator count only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:18 UTC · original · edited 2026-11-26 01:20 UTC

Automated triage for the maintainers.

Needs work. Merging main fixed the conflicts; it merges cleanly and CI passes (check). The two earlier asks are still open:

  • Split the descriptor change. This PR still carries the view-address change: descriptor/host.rs::address_words/view_addresses publish a native base word with VIEW_NO_BUFFER_POINTER for non-buffer views, and resource.rs changes too. It is a separate change to runtime state and needs its own PR and evidence, e.g. the RDNA2 ISA descriptor layout for word 0 and a readback like the one you ran with #2048.
  • Evidence for the Wave32 lowering. The seven synthetic fixtures check that the RTX 5080 output matches what the fixtures expect, and Capi360's run shows the programs translate. Neither compares the whole-wave lowering in emit/lower/wave32.rs (explicit EXEC, scalar writes taking effect with EXEC == 0) with the console. A reference would do: an RDNA2 ISA citation for scalar writes under EXEC == 0, or expected values derived from that behaviour rather than from this lowering.

The translation numbers (40 targets emitted, 16 validated, all 40 with #1065) are useful context. They show the modules are accepted, not that they are right.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7159526986) · edited 2026-11-26 01:20 UTC <!-- victory-triage v1 head=7a110d93c3613e4a916507315cb47b806321f89a verdict=needs-work at=2026-11-26T01:20:58Z --> Automated triage for the maintainers. **Needs work.** Merging `main` fixed the conflicts; it merges cleanly and CI passes (`check`). The two earlier asks are still open: - **Split the descriptor change.** This PR still carries the view-address change: `descriptor/host.rs::address_words`/`view_addresses` publish a native base word with `VIEW_NO_BUFFER_POINTER` for non-buffer views, and `resource.rs` changes too. It is a separate change to runtime state and needs its own PR and evidence, e.g. the RDNA2 ISA descriptor layout for word 0 and a readback like the one you ran with #2048. - **Evidence for the Wave32 lowering.** The seven synthetic fixtures check that the RTX 5080 output matches what the fixtures expect, and Capi360's run shows the programs translate. Neither compares the whole-wave lowering in `emit/lower/wave32.rs` (explicit `EXEC`, scalar writes taking effect with `EXEC == 0`) with the console. A reference would do: an RDNA2 ISA citation for scalar writes under `EXEC == 0`, or expected values derived from that behaviour rather than from this lowering. The translation numbers (40 targets emitted, 16 validated, all 40 with #1065) are useful context. They show the modules are accepted, not that they are right. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-25 13:42 UTC · original

Thanks for the review, @⁠Marvisak. We removed Halfect’s validator commit so it can land through #1065. The updated PR explains why reusing a lane mask as scalar data blocked 40 Wave32 compute shaders. This branch now emits DXIL for all 40. The SDK validator accepts 16 on this branch and all 40 with #1065 applied.

We also tested this branch together with #2048. On an RTX 5080, we verified descriptor slot reuse and clearing with the two-dword layout. Tested merge with #2048

Ready for another review.

**@⁠rezioliver-collab** on GitHub · 2026-11-25 13:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7164183150) Thanks for the review, @⁠Marvisak. We removed Halfect’s validator commit so it can land through #1065. The updated PR explains why reusing a lane mask as scalar data blocked 40 Wave32 compute shaders. This branch now emits DXIL for all 40. The SDK validator accepts 16 on this branch and all 40 with #1065 applied. We also tested this branch together with #2048. On an RTX 5080, we verified descriptor slot reuse and clearing with the two-dword layout. [Tested merge with #2048](https://github.com/talleyrand222/VIctory/commit/fa89bb652278b700f190335523d759f9476e7ea6) Ready for another review.
Author
Owner

@⁠Capi360 on GitHub · 2026-11-25 15:02 UTC · original

Offline follow-up on RTX 3060 Ti (8 GiB, NVIDIA 616.56), Ryzen 7 5700X3D, 32 GiB RAM, Windows 11 Pro build 26200.

I tested this PR together with #1065 on a code-only integration of 940d32f with the NVIDIA graphics compatibility changes. All five compute shaders that had produced the mixed mask/data join refusal during the preceding Series X run translated successfully. The seven synthetic emit::semantics_tests::wave32 tests passed.

The run produced nine intervals above 200 draws/frame (0.77 FPS average). The captures still did not show a usable scene. Windows dropped below 2 GiB of available commit and the monitor stopped the run, so this does not establish that the later GPU reset is fixed.

AI-assisted testing. Integration branch: https://github.com/Capi360/VIctory/tree/codex/rtx-3060-ti-wave32-data

**@⁠Capi360** on GitHub · 2026-11-25 15:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7166200910) Offline follow-up on RTX 3060 Ti (8 GiB, NVIDIA 616.56), Ryzen 7 5700X3D, 32 GiB RAM, Windows 11 Pro build 26200. I tested this PR together with #1065 on a code-only integration of `940d32f` with the NVIDIA graphics compatibility changes. All five compute shaders that had produced the mixed mask/data join refusal during the preceding Series X run translated successfully. The seven synthetic `emit::semantics_tests::wave32` tests passed. The run produced nine intervals above 200 draws/frame (0.77 FPS average). The captures still did not show a usable scene. Windows dropped below 2 GiB of available commit and the monitor stopped the run, so this does not establish that the later GPU reset is fixed. AI-assisted testing. Integration branch: https://github.com/Capi360/VIctory/tree/codex/rtx-3060-ti-wave32-data
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-25 18:47 UTC · original

I’m on a Mac until Friday. Could someone with Windows and an RTX 5080 run the Wave32 and D3D12 checks on the updated PR head, 8bd4b17?

This head includes upstream main at 13f91ca and uses its 16-byte view-address records. On macOS arm64, 158 shader tests passed, two benchmarks were ignored, and the asset-policy check passed. All the fixtures below are synthetic.

Please run these with the RTX 5080 as the hardware adapter and a current x64 dxil.dll available for SDK validation.

cargo test -p victory-shader --lib --locked wave32_ -- --nocapture --test-threads=1
cargo test -p victory-shader --lib --locked title_memory_is_read_and_written_at_computed_addresses -- --nocapture --test-threads=1
cargo test -p victory-gpu --lib --locked a_reused_title_slot_publishes_the_native_base_word -- --nocapture --test-threads=1

Please reply with your NVIDIA driver version, the seven DXIL validated and readback matched results (704 threads total), and the D3D12 readback matched both 16-byte slots line. The last test reads two adjacent slots back from the GPU after an image write, a clear, and reuse as a buffer. If a test skips or fails, the skip message or first error would help too. Thanks!

**@⁠rezioliver-collab** on GitHub · 2026-11-25 18:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2091#issuecomment-7171408105) I’m on a Mac until Friday. Could someone with Windows and an **RTX 5080** run the Wave32 and D3D12 checks on the updated PR head, `8bd4b17`? This head includes upstream `main` at `13f91ca` and uses its 16-byte view-address records. On macOS arm64, 158 shader tests passed, two benchmarks were ignored, and the asset-policy check passed. All the fixtures below are synthetic. Please run these with the RTX 5080 as the hardware adapter and a current x64 `dxil.dll` available for SDK validation. ```powershell cargo test -p victory-shader --lib --locked wave32_ -- --nocapture --test-threads=1 cargo test -p victory-shader --lib --locked title_memory_is_read_and_written_at_computed_addresses -- --nocapture --test-threads=1 cargo test -p victory-gpu --lib --locked a_reused_title_slot_publishes_the_native_base_word -- --nocapture --test-threads=1 ``` Please reply with your NVIDIA driver version, the seven `DXIL validated` and `readback matched` results (704 threads total), and the `D3D12 readback matched both 16-byte slots` line. The last test reads two adjacent slots back from the GPU after an image write, a clear, and reuse as a buffer. If a test skips or fails, the skip message or first error would help too. Thanks!
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/2091/head:github-bot/gh-2091'
git switch 'github-bot/gh-2091'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2091'
git switch 'github-bot/gh-2091'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2091'
git switch 'github-bot/gh-2091'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2091'
git switch 'main'
git merge --squash 'github-bot/gh-2091'
git switch 'main'
git merge --ff-only 'github-bot/gh-2091'
git switch 'main'
git merge 'github-bot/gh-2091'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2091
No description provided.