Skip to content

GPU+shader: translate wave64 programs for 32-lane host waves when WaveLaneCountMax < 64 - #2176

Open
n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:pr/wave32-translation
Open

n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:pr/wave32-translation

Conversation

@n-romanovich

Copy link
Copy Markdown

Summary

NVIDIA and Intel GPUs only execute 32-lane compute waves (WaveLaneCountMax < 64) and reject pipelines declaring WaveSize(64).

This adds Wave32 host translation mode so wave64 console programs run as two 32-lane host waves instead of failing pipeline creation:

  • Query D3D12_FEATURE_DATA_D3D12_OPTIONS1 in victory-gpu (host_wave32(), overridable via VICTORY_HOST_WAVE32).
  • Add set_host_wave32 / host_wave32 in victory_shader::emit and emit WaveSize(32) when enabled, masking wave lane indices in read_lane, ds_bpermute, and cross_lane via host_wave() / host_lane().
  • Include the Wave32 setting in victory-gpu::shader_cache::key so Wave32 and Wave64 shader caches stay isolated.

Verification

Tested on NVIDIA GeForce RTX 5060 Ti:

  • cargo test --release -p victory-shader --lib -- diff_tests valu_tests: 33 passed; 0 failed
  • cargo test --release -p victory-gpu --lib -- shader_cache: 3 passed; 0 failed

@iGoldenNinja

iGoldenNinja commented Nov 25, 2026 •

Copy link
Copy Markdown

Correction. My original ds_bpermute_b32 fixture used the wrong expected result. On RDNA2 the permute stays within each 32-lane half of a Wave64. The observed values, 1000 in lanes 0–31 and 1032 in lanes 32–63, match that rule. I withdraw the claim that the fixture found a ds_bpermute_b32 regression. Thank you @upipibi for pointing out the distinction. AMD RDNA2 ISA, section 10.4.4 · XCL native hardware checks

The original PSO result stands. RTX 5080, driver 617.14, Windows 11 Pro build 26200.9974, PR head 3feadc6. Three of four matched compute inputs translated and validated with host Wave32 off and with it on. Those PSOs went from 0/3 created to 3/3. The fourth input reached a separate descriptor translation refusal in both modes. Successful PSO creation does not establish shader output parity.

I also independently reproduced @Dathinel's actual v_readlane_b32 issue on this RTX 5080. Selecting guest lane 5 produced 5 in the lower half and 37 in the upper half. Selecting guest lane 32 produced 0 and 32, respectively. Every lane should receive the selected guest lane's value. Both synthetic DXIL pipelines validated, ran, and failed their readback assertions. The corrected permute fixture passed.

Corrected test report · Synthetic fixtures

OpenAI Codex (GPT-6) ran the RTX 5080 tests and drafted this correction.

@Dathinel

Dathinel commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The cross-half issue also affects scalar v_readlane_b32. I ran the same ten synthetic GFX10 words on an RTX 3050 Laptop with host Wave32 explicitly enabled on the revisions below. One 64-thread group starts with v0 = tid.x, executes v_readlane_b32 s12, v0, 32, and stores the result to out[tid.x].

Revision Threads 0–31 Threads 32–63
This PR, 3feadc6 0 32
#189, 9580571, Wave32 mode 32 32
#439, 5a11cf4, 32-lane target 32 32
Expected 32 32

All three pipelines dispatched successfully. This tests scalar v_readlane_b32 specifically. Until the two waves exchange values, it would be safer to reject this cross-half read than return the wrong scalar.

Fixture words (hex), raw UAV at heap index 0: d760000c 00014100 7e06020c be810380 f4080200 fa000000 341e0082 e0701000 8002030f bf810000.

Control with lane 5: changing only the source lane from 32 to 5 produced 5 for threads 0–31 and 37 for threads 32–63 on this PR. On #189 and #439 all 64 threads returned 5. A guard that only rejects indices above 31 would miss this case.

AI-assisted; synthetic inputs only.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib shader_cache:: — 3 passed, 0 failed
  • cargo test -p victory-shader --lib emit::lower::tests:: — 21 passed, 0 failed
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean host-wave32 translation path and cache-key inclusion for wave64 programs on hosts with WaveLaneCountMax < 64. Looks good.

AI-assisted (Gemini 4 Neon).

@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown

Overlap note: #189 (alfycs) and #233 / #320 / #439 (r4tedx) also run wave64 programs on 32-lane hosts, and they emulate the operations that cross the halves. This PR runs each half as its own 32-lane wave, and host_lane maps a console lane to lane & 31, so anything that needs the other half or the whole 64-bit mask comes out per-half:

  • v_readlane_b32 / v_writelane_b32 with lanes 32–63 read or write the reader's own half (Dathinel's v_readlane_b32 s12, v0, 32 above), and v_readfirstlane_b32 in the high half returns a high-half lane.
  • 64-bit masks: v_cmp into VCC, s_*_saveexec, ballots and s_bcnt1 / s_ff1 over EXEC or VCC see 32 bits. Scalar branches on them (s_cbranch_vccz, s_cbranch_execz) can go different ways in the two halves, and then the halves diverge for the rest of the program.
  • ds_bpermute_b32 is fine with the mask: in wave64 it stays inside each 32-lane half. XCL Shaders: signature rows of one register in the validator's order #1022's test of that passes on native wave64 AMD hardware (RX 7600 XT, RDNA3); I know of no RDNA2 measurement.

Programs without cross-half operations run correctly this way, which matches iGoldenNinja's 3/3 PSOs. For the rest, #233 refuses by name what it can't emulate yet. Taking this as a fallback only for programs with no cross-half operation, or building on #233's split, would avoid silently wrong lanes.

AI-assisted (Claude Code); source read only.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked (shader half; the GPU half is Windows-only).

144 passed / 0 failed / 2 ignored. Wave64 programs translated for 32-lane host waves — wave64→wave32 translation; relates to #189/#233/#1960's wave64 cluster. Shader side green; GPU execution path needs Windows hardware validation.

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 3feadc6 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

@imrealynailong

Copy link
Copy Markdown

RTX 4060 Laptop: the PR takes compute PSO refusals from 115 to 0, and the world still fails on the descriptor heap

Independent check on a card not yet reported: RTX 4060 Laptop (Ada), driver 32.0.15.6607, Windows 11 build 26200, i7-13620H, 16 GB. Ran main 940d32f and this PR's head 3feadc6 through the same scenario, in separate worktrees, same package, same cache cleared between.

The detection works here: INFO victory_gpu::host: host wave lanes min=32 max=32 wave32=true.

The PR does what it says for pipeline creation

Counted from a --features diagnostics run over the prologue into the world:

main 940d32f this PR 3feadc6
host pipeline refused (0x80070057, all compute) 115 0
host wave lanes ... wave32= (not present) true, min=32 max=32
highest frame= seen 151 159

So on this machine every one of the 115 wave64 compute pipelines that main refuses now creates. That is a clean result and consistent with @iGoldenNinja's 3/4 → 3/3 on the 5080 (mine is a wider count because it goes through the whole prologue, not a four-input fixture).

What it does not change: the world still dies on the capped descriptor heap

Same two runs, the counters that matter for reaching the world:

main 940d32f this PR 3feadc6
title slot past the host heap 310,720 310,720
host view heap capped at 1000000 ... count=1245184 1 1
device removed 4 4
run length 38.5 s 29.3 s

310,720 is exactly 1,245,184 − 934,464, the unmirrored-slot count in #1760. It does not move at all with this PR, because it is not a wave problem.

So on this card the two failures are independent, and fixing the wave side does not get the world up. That may be worth stating plainly in the PR body: this PR removes the host pipeline refused error class entirely, but a run that had only the wave problem fixed still dies at the same place for an unrelated reason.

Agreement with @sinan-cmyk's offline result

Their translate --validate comparison found the same validated count on both sides (23,918). Mine is the runtime half of the same picture: the offline pass count does not move and the runtime PSO refusals go to zero, because the wave64 programs previously failed at CreateComputePipelineState, not at translation. Both measurements are consistent with "the change rejects nothing and unblocks pipeline creation".

Not tested / not claimed

Logs and the failing-test detail available if useful.

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.

8 participants