Shaders: take the wave-wide form as a last resort on 32-lane hosts #1176

Open
github-bot wants to merge 1 commit from github-bot/gh-1176 into main AGit
Owner

@⁠notquiteog on GitHub · 2026-11-25 22:48 UTC · original
notquiteog:fx-wave-wide-last-resort → main · +23 −0 · 1 files · 1 commits · open

What

On a host with 32-lane waves (NVIDIA), a console wave64 compute program that no existing form takes off 64-lane waves keeps WaveSize(64). The host refuses its pipeline and every dispatch of it is dropped.

This tries the exact wave-wide form (widen) as a last resort for those programs only, after every other form has failed. One file, 23 lines, in crates/victory-shader/src/emit/mod.rs. The same change is open against DexNom's tree as DexNom/VIctory#40.

Why it should be safe where the form is off today

The wave-wide form is off unless VICTORY_WAVE_WIDE=1 because it lost a card on ptfx_CS_lightAtlas_Sprite and _Trail. Those two have another working form, so they return before the new code is reached. The new attempt only runs where the alternative is the pass not running at all.

  • VICTORY_WAVE_WIDE=0: such programs stay refused, as before.
  • VICTORY_WAVE_WIDE=1: unchanged.
  • Unset: the new last-resort attempt.

Tested

RTX 5060 Ti 16 GB (wave lanes min 32, max 32), i5-13600K, Windows 11, on 9c184b3 plus this commit, with VICTORY_HOST_MAX_WAVE=32 victory translate --list --validate --pipelines:

Program Before After With VICTORY_WAVE_WIDE=0
sr_tracing:CS_Tiling_Generate_Opaque 2cc4c197ee29e291 pipeline refused validated, pipeline created refused
GpuParticleUpdate:CS_Visibility 369cbe906ea72764 pipeline refused validated, pipeline created refused

In game, on a DexNom-based branch that also carries your commits up to ca8829f: several sessions of 7 to 40 minutes in the story world with this on, no device loss.

A tester on the DexNom pull request reports, on an RTX 4080 over the whole shaders.rpf: compute programs requiring WaveSize(64) 29 → 7, 22 more pipelines created, every other program's DXIL byte-identical, and 10 minutes in game without a loss. Those are their measurements, not mine. They also report one device loss they could not explain with --rt and the structure builder running.

Not tested, and what it does not fix

  • I have not isolated what the recovered passes change in the picture.
  • The unit tests were not run on this tree.
  • Programs whose thread group is several console waves are not helped by this change alone, because widen refuses them; #1124 is the pull request that extends widen to those, and the two stack.

🤖 Generated with Claude Code

**@⁠notquiteog** on GitHub · 2026-11-25 22:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176) `notquiteog:fx-wave-wide-last-resort` → `main` · +23 −0 · 1 files · 1 commits · open ## What On a host with 32-lane waves (NVIDIA), a console wave64 compute program that no existing form takes off 64-lane waves keeps `WaveSize(64)`. The host refuses its pipeline and every dispatch of it is dropped. This tries the exact wave-wide form (`widen`) as a last resort for those programs only, after every other form has failed. One file, 23 lines, in `crates/victory-shader/src/emit/mod.rs`. The same change is open against DexNom's tree as DexNom/VIctory#40. ## Why it should be safe where the form is off today The wave-wide form is off unless `VICTORY_WAVE_WIDE=1` because it lost a card on `ptfx_CS_lightAtlas_Sprite` and `_Trail`. Those two have another working form, so they return before the new code is reached. The new attempt only runs where the alternative is the pass not running at all. - `VICTORY_WAVE_WIDE=0`: such programs stay refused, as before. - `VICTORY_WAVE_WIDE=1`: unchanged. - Unset: the new last-resort attempt. ## Tested RTX 5060 Ti 16 GB (wave lanes min 32, max 32), i5-13600K, Windows 11, on `9c184b3` plus this commit, with `VICTORY_HOST_MAX_WAVE=32 victory translate --list --validate --pipelines`: | Program | Before | After | With `VICTORY_WAVE_WIDE=0` | |---|---|---|---| | `sr_tracing:CS_Tiling_Generate_Opaque` `2cc4c197ee29e291` | pipeline refused | validated, pipeline created | refused | | `GpuParticleUpdate:CS_Visibility` `369cbe906ea72764` | pipeline refused | validated, pipeline created | refused | In game, on a DexNom-based branch that also carries your commits up to `ca8829f`: several sessions of 7 to 40 minutes in the story world with this on, no device loss. A tester on the DexNom pull request reports, on an RTX 4080 over the whole `shaders.rpf`: compute programs requiring `WaveSize(64)` 29 → 7, 22 more pipelines created, every other program's DXIL byte-identical, and 10 minutes in game without a loss. Those are their measurements, not mine. They also report one device loss they could not explain with `--rt` and the structure builder running. ## Not tested, and what it does not fix - I have not isolated what the recovered passes change in the picture. - The unit tests were not run on this tree. - Programs whose thread group is several console waves are not helped by this change alone, because `widen` refuses them; #1124 is the pull request that extends `widen` to those, and the two stack. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A console wave64 compute program that no other form takes off 64-lane waves
keeps WaveSize(64), so a host whose waves are 32 lanes (NVIDIA) refuses its
pipeline and every dispatch of it is dropped.

The wave-wide form (`widen`) is exact, but it is off unless
VICTORY_WAVE_WIDE=1, because it lost a card on two particle programs. Those
programs have another form and return before this point.

It is now also tried last of all, after every other form has left the program
on 64-lane waves, where the only other outcome is the pass not running.
VICTORY_WAVE_WIDE=0 leaves such programs refused, as before; =1 is unchanged.

On an RTX 5060 Ti (32-lane waves) this makes host pipelines for
sr_tracing:CS_Tiling_Generate_Opaque (2cc4c197ee29e291) and
GpuParticleUpdate:CS_Visibility (369cbe906ea72764); both pass the DXIL
validator. Programs whose thread group is several console waves are not
helped: `widen` refuses those.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:56 +00:00
Author
Owner

@⁠HLVM04 on GitHub · 2026-11-25 22:56 UTC · original

On "what the recovered passes change in the picture", one data point from an RTX 5070 Ti (32-lane waves, driver 616.64). It comes from a similar last-resort wide form, not this PR's code.

  • Fork 9376fd6, Series X profile: when only the otherwise-refused programs took a wave-wide form, 4 of the 7 refused pipelines were built. It cost frame rate and did not visibly reduce artifacts. One machine, few runs, picture judged by eye.
  • The two in your table (2cc4c197ee29e291, 369cbe906ea72764) are also built on the same card by #799's loose-LDS fallback, which builds 5 of the 7 (Series S, 9376fd6 + #798/#783/#799). There's more detail in my comment on #1141, which has the same idea: #1141
**@⁠HLVM04** on GitHub · 2026-11-25 22:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176#issuecomment-7176960423) On "what the recovered passes change in the picture", one data point from an RTX 5070 Ti (32-lane waves, driver 616.64). It comes from a similar last-resort wide form, not this PR's code. - Fork `9376fd6`, Series X profile: when only the otherwise-refused programs took a wave-wide form, 4 of the 7 refused pipelines were built. It cost frame rate and did not visibly reduce artifacts. One machine, few runs, picture judged by eye. - The two in your table (`2cc4c197ee29e291`, `369cbe906ea72764`) are also built on the same card by #799's loose-LDS fallback, which builds 5 of the 7 (Series S, `9376fd6` + #798/#783/#799). There's more detail in my comment on #1141, which has the same idea: https://git.gtahub.st/github/fxceless--victory-fork/pulls/1141
Author
Owner

@⁠ishan-2025 on GitHub · 2026-11-26 00:42 UTC · original

An in-game A/B on current main, on a 32-lane 8 GB card: the pipelines are made and nothing is lost, but the frame gets slower and the card goes over its budget here.

Machine: RTX 3070 Ti Laptop GPU 8 GB (7,249 MB budget, host wave lanes min=32 max=32), NVIDIA 621.40, i9-12900H, 32 GB RAM, Windows 11 26200.

Tree: dc4c0fc, and dc4c0fc + this PR's diff (applies cleanly). Diagnostics builds, Series X, shader cache warmed again for the PR's tree with VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=999999. New game by scripted Enter presses into the prologue, 400 s per run, "world" is everything after 250 s. VICTORY_WAVE_WIDE unset. Switches in both: LEVELS_ON_DEMAND=1 ASYNC_SUBMIT=1 QUEUE2=1 INDIRECT_WINDOW=1 TEXTURE_NO_WAIT=1 MERGE_GAP=64 MERGE_RUNS=4096 STAGING_POOL=0 COPY_PLAIN=1 JOIN_PARTS=1 BACK_OWN_VIEW=1 INDIRECT_GATHER=1 CARD_REHASH_RUNS=1.

dc4c0fc + this PR
Warm-up: do not translate 254 252
Compute pipelines refused in the run 7 3
Median frame in the world 149 ms (6.7 fps) 177 ms (5.6 fps)
Card memory in use at the end 6,924 of 7,249 MB 7,420 of 7,249 MB
Submit thread waiting for the card, usual frame 13.1 ms 62.9 ms
"all other lists" on the card's clock 80.3 ms 92.5 ms
Device loss, ERROR lines, driver-watch events none none

Refused before: 02384a60fda6f2d0 2cc4c197ee29e291 2da4beb386509b77 369cbe906ea72764 5dc3b25986622949 6b82bc7d22016cb5 6f225b641c5b0708.
Still refused with the PR: 02384a60fda6f2d0 2da4beb386509b77 6b82bc7d22016cb5. So four are made here, the two in your table and 5dc3b25986622949, 6f225b641c5b0708.

How far to trust the frame time: one run each. The scripted run gets further in the same 400 s when it is faster, so the two windows are not the same shots (4,496 against 6,117 draws a frame in the last line). The direction agrees with HLVM04's note above (pipelines built, frame rate down), and the card's memory crossing its budget is a second, separate cost on 8 GB. I did not compare pictures, so I can't say what the four passes add.

One thing in the diff: the new block builds the deep form with ir::without_skips(p, true) without asking VICTORY_WAVE_DEEP_SKIPS, so with VICTORY_WAVE_DEEP_SKIPS=0 the last resort still widens from the form that switch turns off above. Reusing the deep already computed in the loop (or the same deep_on test) would keep the switch's meaning.

Given the cost on this card, an opt-out that is easy to find (it is VICTORY_WAVE_WIDE=0 today) or a memory-budget condition may be worth having before this is the default on 8 GB.

Runs on my machine with my own copy; no game data attached. AI-assisted (Claude Code).

**@⁠ishan-2025** on GitHub · 2026-11-26 00:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176#issuecomment-7179039751) An in-game A/B on current main, on a 32-lane 8 GB card: the pipelines are made and nothing is lost, but the frame gets slower and the card goes over its budget here. **Machine:** RTX 3070 Ti Laptop GPU 8 GB (7,249 MB budget, `host wave lanes min=32 max=32`), NVIDIA 621.40, i9-12900H, 32 GB RAM, Windows 11 26200. **Tree:** `dc4c0fc`, and `dc4c0fc` + this PR's diff (applies cleanly). Diagnostics builds, Series X, shader cache warmed again for the PR's tree with `VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=999999`. New game by scripted Enter presses into the prologue, 400 s per run, "world" is everything after 250 s. `VICTORY_WAVE_WIDE` unset. Switches in both: `LEVELS_ON_DEMAND=1 ASYNC_SUBMIT=1 QUEUE2=1 INDIRECT_WINDOW=1 TEXTURE_NO_WAIT=1 MERGE_GAP=64 MERGE_RUNS=4096 STAGING_POOL=0 COPY_PLAIN=1 JOIN_PARTS=1 BACK_OWN_VIEW=1 INDIRECT_GATHER=1 CARD_REHASH_RUNS=1`. | | `dc4c0fc` | + this PR | |---|---|---| | Warm-up: do not translate | 254 | 252 | | Compute pipelines refused in the run | 7 | 3 | | Median frame in the world | 149 ms (6.7 fps) | 177 ms (5.6 fps) | | Card memory in use at the end | 6,924 of 7,249 MB | 7,420 of 7,249 MB | | Submit thread waiting for the card, usual frame | 13.1 ms | 62.9 ms | | "all other lists" on the card's clock | 80.3 ms | 92.5 ms | | Device loss, `ERROR` lines, driver-watch events | none | none | **Refused before:** `02384a60fda6f2d0 2cc4c197ee29e291 2da4beb386509b77 369cbe906ea72764 5dc3b25986622949 6b82bc7d22016cb5 6f225b641c5b0708`. **Still refused with the PR:** `02384a60fda6f2d0 2da4beb386509b77 6b82bc7d22016cb5`. So four are made here, the two in your table and `5dc3b25986622949`, `6f225b641c5b0708`. **How far to trust the frame time:** one run each. The scripted run gets further in the same 400 s when it is faster, so the two windows are not the same shots (4,496 against 6,117 draws a frame in the last line). The direction agrees with HLVM04's note above (pipelines built, frame rate down), and the card's memory crossing its budget is a second, separate cost on 8 GB. I did not compare pictures, so I can't say what the four passes add. **One thing in the diff:** the new block builds the `deep` form with `ir::without_skips(p, true)` without asking `VICTORY_WAVE_DEEP_SKIPS`, so with `VICTORY_WAVE_DEEP_SKIPS=0` the last resort still widens from the form that switch turns off above. Reusing the `deep` already computed in the loop (or the same `deep_on` test) would keep the switch's meaning. Given the cost on this card, an opt-out that is easy to find (it is `VICTORY_WAVE_WIDE=0` today) or a memory-budget condition may be worth having before this is the default on 8 GB. Runs on my machine with my own copy; no game data attached. AI-assisted (Claude Code).
Author
Owner

@⁠ishan-2025 on GitHub · 2026-11-26 00:57 UTC · original

Correction to my comment above: please disregard its frame-time rows.

I repeated the unmodified dc4c0fc baseline at the end of the session, same settings, and it measured 206 ms median (4.9 fps) where the first baseline, 40 minutes earlier, measured 149 ms. The laptop got slower over the session (title-memory copy rate in the log fell from about 2.3 to 1.6 GB/s on the same build; I assume heat, not established). The PR's run sat between the two baselines in time, so its 177 ms says nothing either way about the cost of this change. Card memory also moved between the two baselines (6,924 and 7,094 MB), so the 7,420 MB with the PR is a smaller margin than I made it look.

What still stands from that run, because it does not depend on timing:

  • compute pipelines refused: 7 on dc4c0fc (both baseline runs), 3 with this PR; the four now made are 2cc4c197ee29e291, 369cbe906ea72764, 5dc3b25986622949, 6f225b641c5b0708;
  • no device loss, no ERROR line and no driver-watch event in 400 s;
  • the note about VICTORY_WAVE_DEEP_SKIPS=0 and the last-resort block.

I withdraw the suggestion about a memory condition; it rested on the timing. A proper A/B needs interleaved runs, which I have not done.

AI-assisted (Claude Code).

**@⁠ishan-2025** on GitHub · 2026-11-26 00:57 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176#issuecomment-7179286186) **Correction to my comment above: please disregard its frame-time rows.** I repeated the unmodified `dc4c0fc` baseline at the end of the session, same settings, and it measured **206 ms** median (4.9 fps) where the first baseline, 40 minutes earlier, measured 149 ms. The laptop got slower over the session (title-memory copy rate in the log fell from about 2.3 to 1.6 GB/s on the same build; I assume heat, not established). The PR's run sat between the two baselines in time, so its 177 ms says nothing either way about the cost of this change. Card memory also moved between the two baselines (6,924 and 7,094 MB), so the 7,420 MB with the PR is a smaller margin than I made it look. What still stands from that run, because it does not depend on timing: - compute pipelines refused: 7 on `dc4c0fc` (both baseline runs), 3 with this PR; the four now made are `2cc4c197ee29e291`, `369cbe906ea72764`, `5dc3b25986622949`, `6f225b641c5b0708`; - no device loss, no `ERROR` line and no driver-watch event in 400 s; - the note about `VICTORY_WAVE_DEEP_SKIPS=0` and the last-resort block. I withdraw the suggestion about a memory condition; it rested on the timing. A proper A/B needs interleaved runs, which I have not done. AI-assisted (Claude Code).
Author
Owner

@⁠slauko on GitHub · 2026-11-26 09:05 UTC · original

A case this does not reach, from Wine + RTX 3080 Ti (vkd3d-proton ec20719, uiliannn's line, VICTORY_WAVE_WIDE=1 set for the whole run):

info:  first bind ... stage="compute" size=3104 hash=02384a60fda6f2d0
info:  shader translated stage="compute" hash=02384a60fda6f2d0 user_data=1 samplers=0
err:   vkd3d-proton:d3d12_device_validate_shader_meta: Required WaveSize range [64, 64], but supported range is [32, 32].
warn:  vkd3d-proton:d3d12_pipeline_state_init_compute: Failed to create Vulkan compute pipeline, hr 0x80070057.
warn:  victory_gpu::pipeline::host: host pipeline refused ... shaders=[compute 02384a60fda6f2d0]
warn:  victory_gpu::draw: a dispatch without a host pipeline dropped pipeline=0x70d06160

The second one is 2da4beb386509b77 (user_data=2, samplers=2), the same three lines. VICTORY_WAVE_WIDE=1 changes neither: the retry block never prints a WAVE64-RETRY line even with VICTORY_WAVE_WHY=1, and no WAVE64-WHY either — so the two programs come out of the first lowering with WaveSize(64) and stuck is false for them.

My reading of the code: lower skips the 32-lane decision when the lowering is partial (if !partial && wave == 64 && host_max_wave() == 32 && ...), and these two are partially lowered (an instruction the emitter cannot express). That skip is right for a complete program and wrong for the host: the shader is emitted with WaveSize(64) regardless, and a 32-lane host refuses it, so the pass does not run at all.

What I would expect a fix to do: a partially lowered program that still declares WaveSize(64) on a 32-lane host either takes the wave-wide form (a partial lowering is approximate already) or is emitted without WaveSize at all. The two hashes above are a repro; they are the only two refusals in the run, and they are refused identically with and without the switch.

**@⁠slauko** on GitHub · 2026-11-26 09:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176#issuecomment-7187400113) A case this does not reach, from Wine + RTX 3080 Ti (vkd3d-proton `ec20719`, uiliannn's line, `VICTORY_WAVE_WIDE=1` set for the whole run): ``` info: first bind ... stage="compute" size=3104 hash=02384a60fda6f2d0 info: shader translated stage="compute" hash=02384a60fda6f2d0 user_data=1 samplers=0 err: vkd3d-proton:d3d12_device_validate_shader_meta: Required WaveSize range [64, 64], but supported range is [32, 32]. warn: vkd3d-proton:d3d12_pipeline_state_init_compute: Failed to create Vulkan compute pipeline, hr 0x80070057. warn: victory_gpu::pipeline::host: host pipeline refused ... shaders=[compute 02384a60fda6f2d0] warn: victory_gpu::draw: a dispatch without a host pipeline dropped pipeline=0x70d06160 ``` The second one is `2da4beb386509b77` (user_data=2, samplers=2), the same three lines. `VICTORY_WAVE_WIDE=1` changes neither: the retry block never prints a `WAVE64-RETRY` line even with `VICTORY_WAVE_WHY=1`, and no `WAVE64-WHY` either — so the two programs come out of the first lowering with `WaveSize(64)` and `stuck` is false for them. My reading of the code: `lower` skips the 32-lane decision when the lowering is `partial` (`if !partial && wave == 64 && host_max_wave() == 32 && ...`), and these two are partially lowered (an instruction the emitter cannot express). That skip is right for a complete program and wrong for the host: the shader is emitted with `WaveSize(64)` regardless, and a 32-lane host refuses it, so the pass does not run at all. What I would expect a fix to do: a partially lowered program that still declares `WaveSize(64)` on a 32-lane host either takes the wave-wide form (a partial lowering is approximate already) or is emitted without `WaveSize` at all. The two hashes above are a repro; they are the only two refusals in the run, and they are refused identically with and without the switch.
Author
Owner

@⁠slauko on GitHub · 2026-11-26 10:08 UTC · original

A follow-up with the exact reason, from the same stack (VICTORY_WAVE_WHY=1 on a fresh translation — the shader cache otherwise serves the old DXIL and nothing prints):

WAVE64-WHY group=128 lds=true [LDS in a group over 32, an LDS read and write in one lane-branch region, mask as data, v_mbcnt, v_readlane]
WAVE64-KEPT group=128 lds=true console_lanes=true one_wave=false partial=false host_wave=32
WAVE-SIZE wave=Some(64)
WAVE64-RETRY wave-wide branches (last resort): GFX10 code at 0x0: wave-wide branches in a thread group of several console waves is not supported

So the last-resort form is reached (my earlier comment guessed the retry chain did not run — it does, as soon as stuck is Ok((_, Some(64)))), and widen refuses it for a reason of its own: the program's group is 128 threads, i.e. two console waves, and the wave-wide branches support one. VICTORY_WAVE_WIDE=1 makes no difference (same two refusals).

That is the shape I would ask for: a group of N console waves, each console wave split into two host waves, the per-lane branches taken wave-wide per console wave — the same construct, once per 64 threads, with the group barriers already there. Until then this pass does not run at all on a 32-lane host, which is worse than an approximate one.

**@⁠slauko** on GitHub · 2026-11-26 10:08 UTC · [original](https://github.com/fxceless/victory-fork/pull/1176#issuecomment-7188969312) A follow-up with the exact reason, from the same stack (`VICTORY_WAVE_WHY=1` on a fresh translation — the shader cache otherwise serves the old DXIL and nothing prints): ``` WAVE64-WHY group=128 lds=true [LDS in a group over 32, an LDS read and write in one lane-branch region, mask as data, v_mbcnt, v_readlane] WAVE64-KEPT group=128 lds=true console_lanes=true one_wave=false partial=false host_wave=32 WAVE-SIZE wave=Some(64) WAVE64-RETRY wave-wide branches (last resort): GFX10 code at 0x0: wave-wide branches in a thread group of several console waves is not supported ``` So the last-resort form **is** reached (my earlier comment guessed the retry chain did not run — it does, as soon as `stuck` is `Ok((_, Some(64)))`), and `widen` refuses it for a reason of its own: the program's group is 128 threads, i.e. two console waves, and the wave-wide branches support one. `VICTORY_WAVE_WIDE=1` makes no difference (same two refusals). That is the shape I would ask for: a group of N console waves, each console wave split into two host waves, the per-lane branches taken wave-wide per console wave — the same construct, once per 64 threads, with the group barriers already there. Until then this pass does not run at all on a 32-lane host, which is worse than an approximate one.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/mod.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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