Shaders: lower Wave32 compute branches that reuse lane masks as scalar data #2089
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2091"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-25T04:37:19Z.
Review order: #3468 supplies the numeric descriptor word used by this lowering. Merge it first. Review the seven Wave32-only files here. GitHub’s Files changed tab compares against upstream
mainand includes both parts until the prerequisite lands.The shader test commit is
8bc4ccb4c9e9b3b356f3cd82c4a37cf0855923af. The PR heada2fe470chas the same tree and retains the earlier review history.What the shader change fixes
A scalar register can hold a 32-bit number on one edge and a lane mask on another. A later scalar read needs the full word. The compiler handles the joins it already supports on the normal path. When a supported mask/data case needs whole-wave control, the fallback follows the guest’s scalar branches for compute groups made up of complete Wave32 waves. Numeric descriptor reads in that path use #3468’s existing-width, 16-byte record.
Saved EXEC and a scalar write under empty EXEC
The expected values come from the guest instructions.
S_AND_SAVEEXEC_B32saves the old EXEC and intersects EXEC with its operand. Each enabled lane corresponds to one set bit. In the nested fixture only lane 2 survives in the first wave (mask0x00000004), and no lanes survive in the second (mask0x00000000). EXEC gates vector writes. A scalar move reached by the wave still changes the shared scalar from 11 to 37 in the second wave. After EXEC is restored, lanes can observe that 37. Predicating the scalar move on a nonempty EXEC would leave 11. AMD RDNA 2 ISA, §§3.3, 4.1 and the definition of S_AND_SAVEEXEC_B32The fixture then computes
saved_outer & ~inner_selection. With lane L numbered 0–31 in each wave, these are the four expected output dwords per lane.0x800000050x800000010x00000004[0xaaaaaaaa, 4, u32(L == 2), 37]0x0001000a0x0001000a0x00000000[0xaaaaaaaa, 0, 0, 37]On Apple M1, all eight synthetic fixtures emitted parseable DXIL. We replayed the scalar-write-order fixture (128 threads) and the new nested saved-EXEC fixture (64 threads) on the CPU. All 768 output dwords matched expectations derived independently of the lowering. The old combined head rejected the new fixture at offset
0x88. On each split head the shader suite reported 175 passed and 3 ignored. The targeted Clippy checks and repository policy passed. The workspace formatting check also fails on the upstream base.Windows hardware verification: upipibi tested
8bc4ccb4, whose files match PR heada2fe470c, on an RTX 3070 (driver 616.56) using the x64 Windows SDK validator. All eight Wave32 fixtures validated and matched actual GPU readback across 768 threads, including the new nested saved-EXEC case. The compare and saved-EXEC controls matched on hardware, and the DPP regression passed. WARP skipped only the saved-EXEC half of the compare control because Wave32 was unavailable. These are synthetic regression results. Independent Windows log.Earlier hardware and translation results
On the earlier combined head
7a110d9, @upipibi reported 10/10 targeted tests on an RTX 3070: seven SDK-validated Wave32 fixtures with readback across 704 threads, plus two adjacent 16-byte D3D12 slots checked after image writes, clearing and buffer reuse. The older RTX 5080 integration with closed #2048 tested an 8-byte staging layout. The current descriptor PR uses four dwords per slot. RTX 3070 log · Historical RTX 5080 integrationOriginal translation and validation results on the
940d32fbaseAll four configurations used
mainat940d32f, the same archive and the Windows x64 SDK validator (dxil.dll1.8.2502.11). The last two columns cover all 25,889 matched entries.The original Wave32 build gained 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 runEarlier 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.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:37Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib wave32— passed on RTX 5090 hardware + WARPcargo test -p victory-shader --lib emit::memory_tests::— 3 passed, 0 failedcargo test -p victory-gpu --lib descriptor_base_word_tracks_the_guest_view_address— passedcargo clippy -p victory-shader -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (184 files ok)Clean Wave32 compute branch scalar mask preservation and guest view base word tracking across
victory-shaderandvictory-gpu. Looks great.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:44:14Z.
Triage verdict — Review the Wave32 work independently of #1065 (
00f14fa)Evidence
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 patchChecks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:09:22Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Scalar mask words preserved across Wave32 compute branches — mask-word liveness fix; mixed gpu+shader, gpu half Windows-only.
Imported from Marvisak/VIctory. Originally posted by YaBulochka on 2026-11-25T06:42:38Z.
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-gnurelease under Wine, dxil.dll 1.9.2609.5. Same dump for every build.940d32f940d32f(main)93685fe(this stack without the last commit)pr2091(all five commits)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
RaytracingResolvefamily -standard388,ped114,prop50,normal32,rtdirectionalshadows28,trees26,weapon22,trunk12,indirect11,sr10 and the rest. On main they fail withwhich 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:
I did not check whether these 777 also compile in DXC or run; this is the DXIL validator count only.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:18:57Z.
Automated triage for the maintainers.
Needs work. Merging
mainfixed the conflicts; it merges cleanly and CI passes (check). The two earlier asks are still open:descriptor/host.rs::address_words/view_addressespublish a native base word withVIEW_NO_BUFFER_POINTERfor non-buffer views, andresource.rschanges 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.emit/lower/wave32.rs(explicitEXEC, scalar writes taking effect withEXEC == 0) with the console. A reference would do: an RDNA2 ISA citation for scalar writes underEXEC == 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
[PR #2091] Shaders: preserve scalar mask words across Wave32 compute branchesto [PR #2091] Shaders: lower Wave32 compute branches that reuse lane masks as scalar dataImported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-25T13:42:57Z.
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.
Imported from Marvisak/VIctory. Originally posted by Capi360 on 2026-11-25T15:02:09Z.
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
940d32fwith 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 syntheticemit::semantics_tests::wave32tests 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
Imported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-25T18:47:39Z.
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
mainat13f91caand 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.dllavailable for SDK validation.Please reply with your NVIDIA driver version, the seven
DXIL validatedandreadback matchedresults (704 threads total), and theD3D12 readback matched both 16-byte slotsline. 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!Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T21:00:12Z.
Not the RTX 5080 you asked for, but the same Wave32 and D3D12 checks on an RTX 3070, on the current head.
RTX 3070 8 GB (Ampere, wave32), driver 616.56, Windows 11, rustc 1.98.1. PR head
7a110d9vs main63bcca4, separate trees,--locked,--test-threads=1.wave32_(shader), 3 runstitle_memory_is_read_and_written_at_computed_addresses, 3 runsa_reused_title_slot_publishes_the_native_base_word(gpu)*Skipping
heap_direct_texture_reads_mark_their_heap_index, which kills the process on main and PR (#2571). Same failures on both:dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views(#3178); the twoa_heap_buffer_read_*stride tests (#1835);gathers_at_a_level_match_the_hardware(#2323). No nvlddmkm resets.AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-26T21:41:05Z.
Thanks, @upipibi, for running the checks on
7a110d9and comparingagainst
63bcca4. The RTX 3070 is fine for this Wave32 check; no needto find a 5080.
Could you paste the relevant lines from one
--nocapturerun on thePR head? I’m looking for the seven new Wave32 fixtures’
readback matchedlines (especially the saved-EXEC case), anyDXIL validatedlines, and
D3D12 readback matched both 16-byte slotsfrom thedescriptor test. Could you also confirm the D3D12 adapter was the RTX
3070 rather than WARP? The fixtures can report
okafter an earlyreturn if the required device or Wave32 support isn’t available, so
those lines help distinguish an actual GPU readback from a skip. No
need to rerun the full suites. Thanks!
On Thu, 26 Nov 2026 13:00:35 -0800, upipibi @.***> wrote:
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T02:03:43Z.
@rezioliver-collab will do. I didn't keep the
--nocaptureoutput from that run, so I'll do one--nocapturerun on7a110d9and paste the seven Wave32 fixtures'readback matchedlines (saved-EXEC case included), anyDXIL validatedlines, the descriptor test'sD3D12 readback matched both 16-byte slots, and the adapter line, so you can see it was the RTX 3070 and not WARP. The card is busy for a while; I'll post them as soon as it's free.Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T02:59:30Z.
@rezioliver-collab here is one
--nocapturerun on7a110d9: RTX 3070, driver 616.56, Windows 11, rustc 1.98.1. I ran your three commands as written (--locked --nocapture --test-threads=1), all 10 tests passed, and these are their output lines:That is 704 threads over the seven fixtures, with no
no SM 6.6 deviceorWave32 unavailablelines (semantics_tests.rs:424,:428). The saved-EXEC case (EXEC = saved & ~selected,semantics_tests.rs:589) is inwave32_scalar_write_order_across_exec_branches, 128 threads.Adapter: neither test prints one, so I checked which adapter each would take:
Host::new(false), which takes the first adapter that is not flagged software and has dedicated memory (emit/host.rs:137-146).diagnosticsit callsD3D12CreateDevice(None, ...)(victory-gpu/src/host.rs:193).DXGI's
EnumAdapters1on this machine lists adapters 0 and 1 as the NVIDIA GeForce RTX 3070 (8017 MiB dedicated, not software) and adapter 2 as Microsoft Basic Render Driver (software, 0 MiB). So both tests ran on the RTX 3070, not WARP. No driver resets.AI-assisted (Claude Code, Claude Opus 5.5 ran the tests and checked the lines).
Imported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-27T04:05:51Z.
@upipibi, thanks for the RTX 3070 log on
7a110d9. That covered all seven earlier fixtures. Could you run these six targeted commands on the two split commits when the card is free? The new eighth fixture checks the nested saved-EXEC case.From an existing VIctory clone in Windows x64 Developer PowerShell, create two worktrees so each result has an unambiguous SHA.
1. Descriptor / #3468 —
3c979791. The first test checks the guest address fields. The second reads back two adjacent 16-byte D3D12 records through image, clear and buffer writes. The third reads numeric words and pointers from a shader.Please include
D3D12 readback matched both 16-byte slots after image, clear and buffer writesandhardware: view-address numeric words and pointer reads matched.2. Wave32 / #2091 —
8bc4ccb4. This is the shader commit on top of #3468. Its tree is identical to PR heada2fe470c. Please use the x64 Windows SDKdxil.dll(VICTORY_DXILcan point to it).For the eight fixtures, please paste each
DXIL validatedandreadback matched on <N> threadsline (768 threads total). The new pair should readWave32 nested saved EXEC DXIL validatedandWave32 nested saved EXEC readback matched on 64 threads. For the compare control, please includehardware: compare readback matched on 32 lanesandhardware: saved EXEC readback matched on 32 lanes. The DPP test has an ordinary pass/fail result.Please include the NVIDIA driver and the DXGI adapter selected by each path, as in your previous report. The shader harness picks the first hardware adapter with dedicated memory. The GPU test uses the default D3D12 device. If a fixture prints
no SM 6.6 deviceorWave32 unavailable, please paste that line even if Cargo reportsok. These targeted runs are all we need. Thanks!Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T04:23:06Z.
@rezioliver-collab here are your six commands on the two split commits. Each commit had its own worktree, on the RTX 3070 with driver 616.56, Windows 11,
cargo +1.98.1,--locked,VICTORY_DXIL= the x64 Windows SDKdxil.dll(10.0.26100.0). All passed, with no driver resets.3c97979112cb81a3cf624e0231ad79212ea7813a(#3468; its heade9f2a68only adds an empty CI-retry commit, same tree)8bc4ccb4c9e9b3b356f3cd82c4a37cf0855923af(same tree as #2091 heada2fe470)The eight fixtures add up to 768 threads. No fixture printed
no SM 6.6 deviceorWave32 unavailable. The only skip line is the WARP half of the compare control (saved EXEC requires Wave32), which you'd expect on WARP.Adapters are the same as in my last report. The shader harness takes the first non-software adapter with dedicated memory. The victory-gpu test uses the default D3D12 device. On this machine, DXGI lists adapters 0 and 1 as the RTX 3070 and adapter 2 as Microsoft Basic Render Driver, so both paths ran on the 3070.
AI-assisted (Claude Code, Claude Opus 5.5 ran the tests and checked the lines).
Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-27T17:25:31Z.
I checked two affected programs offline on an RX 9070 XT with RADV. Current main refused translation for both (0/2 pipelines); this PR head (
a2fe470cb) translated and validated both and created both pipelines (2/2). Applying the stack to current main conflicted, so the PR-head comparison includes base differences and does not isolate this change. Not tested on NVIDIA hardware.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.