Shaders: wave64 compute programs run in 32-lane halves on hosts of 32-lane waves #2633

Open
github-bot wants to merge 15 commits from github-bot/gh-2633 into main AGit
Owner

@⁠chippy01 on GitHub · 2026-11-25 17:15 UTC · original
chippy01:shaders/wave64-in-32-lane-halves → main · +6024 −1382 · 26 files · 15 commits · open

The problem

A console wave64 compute program that needs the console's lanes (cross-lane reads, masks read as numbers, LDS one wave shares) declares WaveSize(64). NVIDIA and Intel run waves of at most 32 lanes (WaveLaneCountMax 32) and refuse it. On an RTX 3070 Ti the debug layer says:

Shader wants wave lane count of 64 but maximum wave lane count for device is 32 (id 622)

and the pipeline is refused with E_INVALIDARG. A Series S run to the loading screen refused 100 compute pipelines; 95 of them were for this reason.

The change

On such a host, a wave64 program that needs the console's lanes is translated for waves of 32 ("halves", emit::lower::halves, set by emit::Options::host_wave32). The thread relabelling gives each host wave a 32-aligned run of thread ids, so host wave 2w + h holds lanes 32h..32h + 31 of console wave w. What each cross-lane operation needs, and where the halves can meet, is in docs/wave64-on-32-lane-hosts.md.

Level 1, exact within a half (the first commits): DPP rows, ds_swizzle, and ds_bpermute_b32, which the console's wave64 permutes within each half on its own (RDNA2 ISA; measured on RDNA2 in #573). A lane's bit of a mask held as a number, v_writelane_b32, v_mbcnt and the row a DPP row mask names take the console lane. A first-lane read of a value proven the same in every lane of the console wave (halves::lane_uniform) is the host's. A group of 32 threads or fewer is one host wave, which holds its whole console wave.

Level 2, the halves trade where every thread meets (Lower::trade): each half writes its words to group-shared slots, a group barrier, each half reads both, a second barrier. Only at blocks every thread of the group reaches the same number of times (no lane-dependent branch has them in its region; in groups of several console waves, no branch at all), since a barrier one half skips hangs NVIDIA.

  • v_readlane_b32: the half holding the lane gives it.
  • v_readfirstlane_b32: each half's first lane in EXEC and whether it has one; the low half's if any.
  • Lane masks read as data: each half's ballot is one dword of the console's mask.
  • Whole-wave reductions and prefix sums: each half's part, combined low half first.
  • LDS of a group of one console wave (33-64 threads, which the console compiler leaves without barriers): group barriers put the two host waves in the console's order, before an access that may meet an earlier one and around regions only some lanes run.

Level 3, inside a branch only some lanes take (the per-lane form turns the console's wave-wide tests, s_cbranch_execz and s_cbranch_vccz on a ballot, into such branches):

  • One half alone (emit::lower::confine): where a block's entry condition shows that only one half's lanes can run it (tid < 16 in an LDS tree step), that half's host wave runs it alone, in the console's order, and nothing crosses.
  • Wave-wide (emit::lower::wide): otherwise, a branch where every thread meets runs its region wave-wide: every thread runs every block of it, each block acting only in its own lanes (guards take the block's lanes in, join phis pick per lane by the edge it came by), so the halves trade and order LDS there. Only a region with no loop, one way out, no end and no scalar side effect qualifies, and only where an attempt was refused for want of a meeting: programs that need none are lowered exactly as before.

Still refused, each with a reason naming the host: a region holding a loop whose exit is lane-dependent (nearly all that remains), groups of several rows a host may tile (rows 32+ threads wide or not a power of two; measured here and in #2126), 16-bit whole-wave sums.

victory-gpu asks the device once (D3D12_OPTIONS1) and translates for it. The shader cache keys on it, so entries made for 64-lane hosts are never read on a 32-lane one, or the other way round. victory translate --wave32 translates for such a host offline; with --pipelines it follows the GPU that makes them.

New code lives in emit/lower/halves.rs, confine.rs and wide.rs, with a few named hooks in lower.rs; lower.rs's unit tests move to lower/tests.rs (as #233 does), so lower.rs is 472,697 bytes, under the policy's 512 KiB cap.

Evidence

victory translate --list --wave32 --validate over shaders.rpf, the executable, XboxBvhBuilder.dll and amd_fidelityfx_upscaler_xbox.dll; compute programs emitted (of 2,763), commit by commit, none lost on the way:

Commit Compute emitted
halves, Level 1 (86a16dc) 2,369
groups of 32 threads or fewer 2,375
lane reads traded 2,421
one-wave LDS put in order 2,443
first lanes, masks, reductions traded 2,463
regions one half runs alone 2,485
wave-wide regions 2,542
  • Every program gained validates but 2, which fail the validator's "incompatible with the shader stage" check as 735 compute programs did before this PR.
  • With --pipelines on the RTX 3070 Ti (driver 621.24): 2,542 of 2,542 compute pipelines made, none refused by the driver; vertex/pixel 14,258 and mesh 8,765 (25,565 in all).
  • Gained by Levels 2-3 include CS_ApplyTemporalAA, the mip generators, the tiled shadow passes and shadow denoisers, the depth pyramids, the BVH builder's passes, the particle emitters and spawners, the tile classifiers, the LDS tree reductions (heap defrag, water culling, lightning) and the allocation-request passes.
  • Still refused in halves: 93 one-wave LDS regions, 59 masks, 19 first lanes, 16 reductions (nearly all in a region holding a loop with a lane-dependent exit), 6 tiled group shapes, 2 16-bit sums.

Earlier, at the first commits, on the RTX 3070 Ti (driver 32.0.16.2124): main refused 405 compute pipelines (the driver), this PR none; in the title (Series S mode, to the loading screen) no pipeline refused (main: 100).

Tests

emit::halves_tests runs hand-encoded programs on every hardware adapter, in halves everywhere and as one wave64 where the adapter has 64-lane waves, against the console's results: an RTX 3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2, halves and wave64), 0 lanes differ.

  • Level 1: DPP, swizzles, permutes, v_mbcnt, v_writelane, constant masks, DPP row masks, first lanes kept, every thread's id in 4x4x4 to 64x1x4 groups (and tiled shapes refused).
  • Level 2: lane reads, first lanes (also under a narrowed EXEC), masks, sums and prefix sums in groups of 48, 64, 96 and 128; one-wave LDS across the halves, across a branch, and after a spin that only barriers keep in order (64 of 64 lanes wrong without them, on both GPUs).
  • Level 3: LDS tree steps in either half alone; branches of both halves run wave-wide with first lanes, masks, lane reads (including a lane outside the branch, which keeps its old value as on the console) and one-wave LDS written and read or written twice; each trade costs two barriers, a one-half region none.
  • Refusals name their reasons; a kept refused value refuses the write instead of storing 0; the hand-encoded words are checked against the disassembler.

emit::halves_random_tests generates random wave64 programs (cross-lane steps at the top level and in branches one inside another, LDS, scalar branches) and runs each in halves on both GPUs and as one wave64 on the Radeon, lane by lane: 3,000 seeds, 2,998 compared, 0 differ (2 seeds crash the Radeon driver's compiler making the one-wave64 reference and are skipped). It found the kept-value bug, fixed in its own commit.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: clean. cargo xtask policy: ok. cargo test -p victory-shader --lib -- --test-threads=1: 319 passed, 3 failed, the same 3 as on main on this NVIDIA machine (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware); memory_tests::heap_direct_texture_reads_mark_their_heap_index crashes the test process on main here too and is skipped.

This overlaps #189, #192, #233/#320/#439, #1890, #2176, #2214, #2711 and #2925 (wave64 on 32-lane hosts) and #578 (refusing them). It differs in that cross-half reads are refused or traded at the site that makes them, with a reason (programs whose crossing value is unused still translate), the halves meet only where every thread provably does (wave-wide only where needed, instead of the console flow everywhere), and every form is checked against the console's own wave64 on an RDNA2 adapter in the same test. The cache-key idea is #2176's (n-romanovich). It does not change ds_bpermute_b32 for 64-lane hosts, which is #573's.

Credits

  • The approach of running console wave64 programs as two 32-lane host waves, with the thread relabelling into halves, follows DexNom's fork (DexNom/Victory, 5f4c3df, set_host_max_wave), which credits the victory-world-runtime line (ZSlayerHQ and contributors). Here it is written anew on main as a translation option.
  • Keying the shader cache on the host's wave width: #2176 (n-romanovich).
  • ds_bpermute_b32 within halves: #573 (banbanzhige) and the RDNA2 measurements in its thread.
  • Which values are the same in every lane of the console wave (halves::lane_uniform), and the first-lane bug report: justrealyme (chippy01/VIctory#1), ported from fxceless/victory-fork (#497 there).
  • The tests move out of lower.rs as in r4tedx's #233.

AI-assisted (Co-authored by Claude Opus 5.5) and measured on my own machine.

**@⁠chippy01** on GitHub · 2026-11-25 17:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633) `chippy01:shaders/wave64-in-32-lane-halves` → `main` · +6024 −1382 · 26 files · 15 commits · open ## The problem A console wave64 compute program that needs the console's lanes (cross-lane reads, masks read as numbers, LDS one wave shares) declares `WaveSize(64)`. NVIDIA and Intel run waves of at most 32 lanes (`WaveLaneCountMax` 32) and refuse it. On an RTX 3070 Ti the debug layer says: > Shader wants wave lane count of 64 but maximum wave lane count for device is 32 (id 622) and the pipeline is refused with `E_INVALIDARG`. A Series S run to the loading screen refused 100 compute pipelines; 95 of them were for this reason. ## The change On such a host, a wave64 program that needs the console's lanes is translated for waves of 32 ("halves", `emit::lower::halves`, set by `emit::Options::host_wave32`). The thread relabelling gives each host wave a 32-aligned run of thread ids, so host wave `2w + h` holds lanes `32h..32h + 31` of console wave `w`. What each cross-lane operation needs, and where the halves can meet, is in `docs/wave64-on-32-lane-hosts.md`. **Level 1, exact within a half** (the first commits): DPP rows, `ds_swizzle`, and `ds_bpermute_b32`, which the console's wave64 permutes within each half on its own (RDNA2 ISA; measured on RDNA2 in #573). A lane's bit of a mask held as a number, `v_writelane_b32`, `v_mbcnt` and the row a DPP row mask names take the **console** lane. A first-lane read of a value proven the same in every lane of the console wave (`halves::lane_uniform`) is the host's. A group of 32 threads or fewer is one host wave, which holds its whole console wave. **Level 2, the halves trade where every thread meets** (`Lower::trade`): each half writes its words to group-shared slots, a group barrier, each half reads both, a second barrier. Only at blocks every thread of the group reaches the same number of times (no lane-dependent branch has them in its region; in groups of several console waves, no branch at all), since a barrier one half skips hangs NVIDIA. - `v_readlane_b32`: the half holding the lane gives it. - `v_readfirstlane_b32`: each half's first lane in EXEC and whether it has one; the low half's if any. - Lane masks read as data: each half's ballot is one dword of the console's mask. - Whole-wave reductions and prefix sums: each half's part, combined low half first. - LDS of a group of one console wave (33-64 threads, which the console compiler leaves without barriers): group barriers put the two host waves in the console's order, before an access that may meet an earlier one and around regions only some lanes run. **Level 3, inside a branch only some lanes take** (the per-lane form turns the console's wave-wide tests, `s_cbranch_execz` and `s_cbranch_vccz` on a ballot, into such branches): - **One half alone** (`emit::lower::confine`): where a block's entry condition shows that only one half's lanes can run it (`tid < 16` in an LDS tree step), that half's host wave runs it alone, in the console's order, and nothing crosses. - **Wave-wide** (`emit::lower::wide`): otherwise, a branch where every thread meets runs its region wave-wide: every thread runs every block of it, each block acting only in its own lanes (guards take the block's lanes in, join phis pick per lane by the edge it came by), so the halves trade and order LDS there. Only a region with no loop, one way out, no end and no scalar side effect qualifies, and only where an attempt was refused for want of a meeting: programs that need none are lowered exactly as before. **Still refused**, each with a reason naming the host: a region holding a loop whose exit is lane-dependent (nearly all that remains), groups of several rows a host may tile (rows 32+ threads wide or not a power of two; measured here and in #2126), 16-bit whole-wave sums. `victory-gpu` asks the device once (`D3D12_OPTIONS1`) and translates for it. **The shader cache keys on it**, so entries made for 64-lane hosts are never read on a 32-lane one, or the other way round. `victory translate --wave32` translates for such a host offline; with `--pipelines` it follows the GPU that makes them. New code lives in `emit/lower/halves.rs`, `confine.rs` and `wide.rs`, with a few named hooks in `lower.rs`; `lower.rs`'s unit tests move to `lower/tests.rs` (as #233 does), so `lower.rs` is 472,697 bytes, under the policy's 512 KiB cap. ## Evidence `victory translate --list --wave32 --validate` over `shaders.rpf`, the executable, `XboxBvhBuilder.dll` and `amd_fidelityfx_upscaler_xbox.dll`; compute programs emitted (of 2,763), commit by commit, none lost on the way: | Commit | Compute emitted | |---|---| | halves, Level 1 (`86a16dc`) | 2,369 | | groups of 32 threads or fewer | 2,375 | | lane reads traded | 2,421 | | one-wave LDS put in order | 2,443 | | first lanes, masks, reductions traded | 2,463 | | regions one half runs alone | 2,485 | | wave-wide regions | **2,542** | - Every program gained validates but 2, which fail the validator's "incompatible with the shader stage" check as 735 compute programs did before this PR. - With `--pipelines` on the RTX 3070 Ti (driver 621.24): **2,542 of 2,542 compute pipelines made**, none refused by the driver; vertex/pixel 14,258 and mesh 8,765 (25,565 in all). - Gained by Levels 2-3 include CS_ApplyTemporalAA, the mip generators, the tiled shadow passes and shadow denoisers, the depth pyramids, the BVH builder's passes, the particle emitters and spawners, the tile classifiers, the LDS tree reductions (heap defrag, water culling, lightning) and the allocation-request passes. - Still refused in halves: 93 one-wave LDS regions, 59 masks, 19 first lanes, 16 reductions (nearly all in a region holding a loop with a lane-dependent exit), 6 tiled group shapes, 2 16-bit sums. Earlier, at the first commits, on the RTX 3070 Ti (driver 32.0.16.2124): main refused 405 compute pipelines (the driver), this PR none; in the title (Series S mode, to the loading screen) no pipeline refused (main: 100). ## Tests `emit::halves_tests` runs hand-encoded programs on **every hardware adapter**, in halves everywhere and as one wave64 where the adapter has 64-lane waves, against the console's results: an RTX 3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2, halves and wave64), 0 lanes differ. - Level 1: DPP, swizzles, permutes, `v_mbcnt`, `v_writelane`, constant masks, DPP row masks, first lanes kept, every thread's id in 4x4x4 to 64x1x4 groups (and tiled shapes refused). - Level 2: lane reads, first lanes (also under a narrowed EXEC), masks, sums and prefix sums in groups of 48, 64, 96 and 128; one-wave LDS across the halves, across a branch, and after a spin that only barriers keep in order (64 of 64 lanes wrong without them, on both GPUs). - Level 3: LDS tree steps in either half alone; branches of both halves run wave-wide with first lanes, masks, lane reads (including a lane outside the branch, which keeps its old value as on the console) and one-wave LDS written and read or written twice; each trade costs two barriers, a one-half region none. - Refusals name their reasons; a kept refused value refuses the write instead of storing 0; the hand-encoded words are checked against the disassembler. `emit::halves_random_tests` generates random wave64 programs (cross-lane steps at the top level and in branches one inside another, LDS, scalar branches) and runs each in halves on both GPUs and as one wave64 on the Radeon, lane by lane: 3,000 seeds, 2,998 compared, 0 differ (2 seeds crash the Radeon driver's compiler making the one-wave64 reference and are skipped). It found the kept-value bug, fixed in its own commit. Checks: `cargo clippy --workspace --all-targets --locked -- -D warnings` and the same with `--all-features`: clean. `cargo xtask policy`: ok. `cargo test -p victory-shader --lib -- --test-threads=1`: 319 passed, 3 failed, the **same 3** as on `main` on this NVIDIA machine (`stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`); `memory_tests::heap_direct_texture_reads_mark_their_heap_index` crashes the test process on `main` here too and is skipped. ## Related pull requests This overlaps #189, #192, #233/#320/#439, #1890, #2176, #2214, #2711 and #2925 (wave64 on 32-lane hosts) and #578 (refusing them). It differs in that cross-half reads are refused or traded at the site that makes them, with a reason (programs whose crossing value is unused still translate), the halves meet only where every thread provably does (wave-wide only where needed, instead of the console flow everywhere), and every form is checked against the console's own wave64 on an RDNA2 adapter in the same test. The cache-key idea is #2176's (n-romanovich). It does not change `ds_bpermute_b32` for 64-lane hosts, which is #573's. ## Credits - The approach of running console wave64 programs as two 32-lane host waves, with the thread relabelling into halves, follows DexNom's fork ([DexNom/Victory](https://github.com/DexNom/Victory), `5f4c3df`, `set_host_max_wave`), which credits the victory-world-runtime line (ZSlayerHQ and contributors). Here it is written anew on main as a translation option. - Keying the shader cache on the host's wave width: #2176 (n-romanovich). - `ds_bpermute_b32` within halves: #573 (banbanzhige) and the RDNA2 measurements in its thread. - Which values are the same in every lane of the console wave (`halves::lane_uniform`), and the first-lane bug report: justrealyme (chippy01/VIctory#1), ported from fxceless/victory-fork (#497 there). - The tests move out of `lower.rs` as in r4tedx's #233. AI-assisted (Co-authored by Claude Opus 5.5) and measured on my own machine.
What was wrong: a console wave64 compute program that needs the
console's lanes (cross-lane reads, masks as numbers, LDS one wave shares)
declares WaveSize(64). NVIDIA and Intel run waves of 32 lanes at most
(WaveLaneCountMax 32) and refuse it: on an RTX 3070 Ti (driver
32.0.16.2124) the debug layer gives "Shader wants wave lane count of 64
but maximum wave lane count for device is 32" (id 622), and every such
pipeline is refused with E_INVALIDARG. A Series S run to the loading
screen refused 100 compute pipelines, 95 of them for this.

What changed: on such a host, a wave64 program that needs the console's
lanes is translated for waves of 32 (`emit::Options::host_wave32`;
`emit::lower::halves`). The thread relabelling gives each host wave a
32-aligned run of thread ids, so host wave 2w + h is console wave w's
lanes 32h..32h + 31. What a lane reads within its half is exact: DPP
rows, ds_swizzle, and ds_bpermute_b32, which the console's wave64
permutes within each half on its own (RDNA2 ISA; measured in #573). A
lane's bit of a mask held as a number, v_writelane_b32 and v_mbcnt take
the console lane. Reads across the halves have no host form and are
refused where they are lowered, with a reason that names the host:
ballots (masks read as data), v_readlane_b32 of a lane that may be in the
other half, whole-wave reductions and prefix sums; one a program never
uses costs nothing (the lowering's retry with the value missing). A group
of 33 to 64 threads with LDS, which the console compiler orders without
barriers as one wave, is refused too. v_readfirstlane_b32 reads the host
wave's first lane, as it already does in every program without console
lanes (marked as that shortcut).

victory-gpu asks the device once (OPTIONS1) and translates for it; the
shader cache keys on it, so entries made for 64-lane hosts are not read.
`victory translate --wave32` translates for such a host offline; with
--pipelines it follows the GPU that makes them.

Approach after DexNom's fork (DexNom/Victory 5f4c3df: the host's wave
width and the relabelling into halves) and #2176 (n-romanovich: the
setting in the cache key); here the setting is a translation option, and
cross-half reads are refused at the sites that make them instead of by
instruction name, which keeps programs whose crossing value is unused.

Evidence, `translate --list --pipelines` over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL, RTX 3070 Ti:

| | main 67e8ae1 | this |
|---|---|---|
| compute programs emitted | 2,733 | 2,372 |
| compute pipelines made | 2,328 | 2,372 |
| refused by the driver | 405 | 0 |

No program that made a pipeline on main fails to now (25,347 pipelines,
all kept). In the title (Series S mode, diagnostics build, to the
loading screen, 2.5 min): no pipeline refused, against 100 on main; the
113 programs that do not translate say why (51 LDS, the rest mostly
ballots). The 44 new ones include the depth pyramids (occlusion),
the sky and atmosphere gathers (scattering_transmittance_system),
shader binning and the mipmap generators. The 361 still refused now say
why: 192 LDS in a one-wave group, 107 ballots, 48 lane reads across
halves, 20 reductions (those need an exchange between the two host waves,
a change of its own).

Tests (halves_tests): one wave64 program (DPP, ds_swizzle, ds_bpermute,
v_mbcnt, v_writelane to lane 40, a constant mask's high dword) runs on
every hardware adapter, in halves and, where the adapter has 64-lane
waves, as one wave64: all 64 lanes give the console's results on the RTX
3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2: halves
and wave64). The refusals and the LDS rule each have an offline test;
the hand-encoded words are checked against the disassembler.

Found on the way, not changed here: a wave64 mask built by two
s_mov_b32 (low and high dword written apart) reads its low dword for all
64 lanes (`Lower::pair_high` looks for the high dword in the instruction
that wrote the low one); the same with and without this change, on AMD's
own wave64 too.

Co-Authored-By: Claude Opus 5.5
What was wrong: two results in halves were wrong in the upper host wave
(console lanes 32-63). Measured before this change on an RTX 3070 Ti
(driver 32.0.16.2124) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2),
32 of 64 lanes wrong on both, while the Radeon's own wave64 form gave the
console's results:

- v_readfirstlane_b32 read the host wave's first lane, which in the upper
  half is console lane 32 or later: a first-lane read of the thread id gave
  32 in lanes 32-63, the console 0 (reported on #2633 by justrealyme).
- A DPP row mask was applied by the host lane's row, 0 or 1: with
  row_mask:0xc, lanes 32-63 (the console's rows 2 and 3) kept their old
  value instead of taking the DPP result.

What changed:

- A first-lane read in halves is kept for a value proven the same in every
  lane of the console wave (halves::lane_uniform: values made from scalars,
  constants and such values, under conditions that are themselves alike;
  LDS reads, and buffer loads through a scalar descriptor, at alike
  addresses; the thread id shifted past the console wave) and in groups of
  32 threads or fewer, which one host wave holds whole. Any other is
  refused with its reason; one nothing uses costs nothing. The analysis is
  justrealyme's (chippy01/VIctory#1), ported from fxceless/victory-fork
  (#497 there). Added here: buffer loads (a typed buffer's element the
  compiler loads with a vector load, then reads the first lane of), the
  dwords a waterfall loop reads (each lane's own, so not alike), and the
  small-group exception.
- DPP row masks take the row from the console lane.
- The GPU tests share one dispatch helper.

Evidence, translate --list --wave32 over shaders.rpf, the executable,
XboxBvhBuilder.dll and the FidelityFX DLL: compute programs emitted
2,372 -> 2,369. The 3 no longer emitted read the first lane of a value the
analysis cannot show is alike (scattering_transmittance_system's cloud
multiple-scattering cache: a value joined from a branch on a per-lane
compare; two ptx_prerender light-atlas programs: a select on a mask made
from EXEC, in a loop), so in halves they could compute per-half values. 14
programs refused before give this reason first now; no other outcome
changes. The analysis as chippy01/VIctory#1 has it refuses 12: the
small-group exception keeps 5 of them, buffer loads 4. No program of the title uses a DPP row mask
other than 0xF in halves, so that fix changes none of its translations.

Tests (emit::halves_tests):

- dpp_row_masks_name_the_console_rows_on_every_gpu (new): row_mask:0xc;
  0 of 64 lanes differ on both GPUs (32 before).
- first_lanes_kept_in_halves_match_the_console_on_every_gpu (new): the
  thread id's first lane in a group of 32 and l >> 6 in a group of 128;
  0 lanes differ on both GPUs.
- reads_across_32_lane_halves_are_refused_with_their_reason: the thread
  id's first lane is refused in a group of 64 and kept in a group of 32;
  an unused one costs nothing; a buffer dword loaded at an offset alike in
  every lane is kept, at the thread id's offset refused.
- the_test_programs_are_what_their_comments_say: every hand-encoded
  program checked against the disassembler.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 273 passed, 3 failed, the same 3
as on main on this NVIDIA machine (two stride_tests,
gathers_at_a_level_match_the_hardware);
heap_direct_texture_reads_mark_their_heap_index skipped as before. lower.rs
is 495,122 bytes.

Co-Authored-By: justrealyme <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts resolved:

- emit/lower.rs: ds_bpermute_b32 takes main's lowering (#573: within
  the reader's own 32-lane half, the half's base from the host lane),
  which in halves is the host wave itself, so halves::permute_lanes,
  which did that for halves alone, is gone. Lowered keeps both sides'
  test fields (wave_size, and main's uses_lane_index and
  has_half_wave_mask).
- emit/host.rs: main's Host::new (one shared WARP device, the warp
  field). Host::each_hardware and create_device share one SM 6.6 check,
  the sm66 function.
- apps/victory/src/main.rs: --wave32 beside main's non-zero --jobs.
- README.md: main's "GPU: world" row, this branch's "Shaders" row.

For main's new code: host_wave32: false in four new tests' lower::Parts
and in one emit::Options; victory-gpu takes its shader host by
Host::from_device, as main now has it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was wrong: the thread relabelling gives a thread the flat id of its
host wave's first lane, rounded down to 32, plus its host lane. That is
a bijection only while every host wave holds a 32-aligned run of flat
ids. Hosts fill the waves of a group of several rows with tiles when its
rows are 32 threads wide or more. A wave then holds a 16 x 2 tile, two
waves round down to the same base, and two threads share every id while
half the ids go unused. Measured in halves with a program that stores 1
at its own id, on an RTX 3070 Ti (driver 32.0.16.2124) and the Radeon
iGPU of a Ryzen 9 7900X (RDNA2):

- 32x2, 32x8, 64x4, 32x32 and 32x2x2 groups store half their ids, on
  both;
- 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4 and
  one-row groups store all of them.

#2126 (0xkn0wh3r3) measured the same tiling on an RTX 5070 Ti, and for
rows 24, 12 and 10 threads wide too, for main's 32-lane programs.

What changed: halves refuse a group of several rows whose rows are 32
threads wide or more or not a power of two wide, with its reason
(`halves::halves_tiles`). halves.rs and halves_tests.rs are
rustfmt-clean.

Evidence: translate --list --wave32 over shaders.rpf, the executable,
XboxBvhBuilder.dll and the FidelityFX DLL, on main 842b0cb merged: no
emitted program changes (2,369); with --pipelines on the RTX 3070 Ti,
2,369 compute pipelines are made, none refused by the driver. The
title's programs in halves that translate are in groups of 8x8, 8x4, 4x4
or one row. Its programs in groups of 32x2, 32x32 or 6x6 were refused
already; 2 of them (GpuParticleEmit's water emitters) now give this
reason first, the rest the one-wave LDS reason. The exchanges planned
next would otherwise have run them wrongly.

Tests (emit::halves_tests):

- groups_a_host_wave_may_tile_are_refused_in_halves: 32x2, 64x4, 32x2x2
  and 6x6 are refused; 8x8, 16x2, 4x4x4 and 64x1 translate.
- every_thread_keeps_its_own_id_in_halves_on_every_gpu: 8x8, 16x2, 4x4x4
  and 64x1 store every id on both GPUs, in halves and (on the Radeon) as
  one wave64.

Found on the way, not changed here: under main's rounding to 64, the
Radeon's own wave64 stores 128 of a 64x4 group's 256 ids (32-wide groups
are laid out in rows there). #2126's per-wave tickets cover that too;
once it lands, halves can take their ids from it and drop this refusal.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 307 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:48 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-11-25 17:17 UTC · original · edited 2026-11-25 17:31 UTC

Ran the new halves tests at a7e78c1 (clean PR head on main 13f91ca):

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXIL validator from the Windows SDK default path (this filter does not print its version), debug build

Results

  • cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture: 5 passed, 0 failed, 0 ignored, 273 filtered out (exit 0)
  • wave64_programs_in_halves_match_the_console_on_every_gpu printed: NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console, and NVIDIA GeForce RTX 5070 Ti (wave64): no pipeline for 64-lane waves; skipped, twice (both adapters in the host list).

What this adds
The author's hardware evidence in the thread is an Ampere RTX 3070 Ti plus an RDNA2 iGPU. This adds a Blackwell wave32 part: the GPU parity test ran here and all 64 lanes matched the console's result in the halves form, while the 64-lane form was refused by the adapter as expected. The other four halves tests also pass.

Not tested
The whole victory-shader library (the description lists three pre-existing failures on NVIDIA), victory-gpu, the retail shader-pack census, a title run, the console compiler, release profile, Intel GPUs and native-wave64 hardware.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

Update (25/11, after the head moved to 25db879): relative to the head I tested (a7e78c1), the new commit only changes README.md; no shader code changed. Re-ran the same command at 25db879:

cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture
5 passed; 0 failed; 0 ignored; 273 filtered out      (exit 0)

Same GPU output: NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console, and the 64-lane form skipped because this adapter has no 64-lane waves.

**@⁠Aniseto** on GitHub · 2026-11-25 17:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7169285954) · edited 2026-11-25 17:31 UTC Ran the new halves tests at `a7e78c1` (clean PR head on `main` `13f91ca`): **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124 - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXIL validator from the Windows SDK default path (this filter does not print its version), debug build **Results** - `cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture`: 5 passed, 0 failed, 0 ignored, 273 filtered out (exit 0) - `wave64_programs_in_halves_match_the_console_on_every_gpu` printed: `NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console`, and `NVIDIA GeForce RTX 5070 Ti (wave64): no pipeline for 64-lane waves; skipped`, twice (both adapters in the host list). **What this adds** The author's hardware evidence in the thread is an Ampere RTX 3070 Ti plus an RDNA2 iGPU. This adds a Blackwell wave32 part: the GPU parity test ran here and all 64 lanes matched the console's result in the halves form, while the 64-lane form was refused by the adapter as expected. The other four halves tests also pass. **Not tested** The whole `victory-shader` library (the description lists three pre-existing failures on NVIDIA), `victory-gpu`, the retail shader-pack census, a title run, the console compiler, release profile, Intel GPUs and native-wave64 hardware. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. Update (25/11, after the head moved to `25db879`): relative to the head I tested (`a7e78c1`), the new commit only changes README.md; no shader code changed. Re-ran the same command at `25db879`: ``` cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture 5 passed; 0 failed; 0 ignored; 273 filtered out (exit 0) ``` Same GPU output: `NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console`, and the 64-lane form skipped because this adapter has no 64-lane waves.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:49 UTC · original

Heads-up: the README hunk contains a committed merge conflict — <<<<<<< HEAD / ======= / >>>>>>> a7e78c1 markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers.

The actual change — --wave32 translate flag conflicting with --cache, wave64 split halves on 32-lane hosts — looks right otherwise; CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7170056983) Heads-up: the README hunk contains a committed merge conflict — `<<<<<<< HEAD` / `=======` / `>>>>>>> a7e78c1` markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers. The actual change — `--wave32` translate flag conflicting with `--cache`, wave64 split halves on 32-lane hosts — looks right otherwise; CI green.
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 17:56 UTC · original

Heads-up: the README hunk contains a committed merge conflict — <<<<<<< HEAD / ======= / >>>>>>> a7e78c1 markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers.

The actual change — --wave32 translate flag conflicting with --cache, wave64 split halves on 32-lane hosts — looks right otherwise; CI green.

My bad, I just fixed it

**@⁠chippy01** on GitHub · 2026-11-25 17:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7170206837) > Heads-up: the README hunk contains a committed merge conflict — `<<<<<<< HEAD` / `=======` / `>>>>>>> a7e78c1` markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers. > > The actual change — `--wave32` translate flag conflicting with `--cache`, wave64 split halves on 32-lane hosts — looks right otherwise; CI green. My bad, I just fixed it
Author
Owner

@⁠sergiocr06 on GitHub · 2026-11-25 18:01 UTC · original

Ran the halves tests on a machine that has both kinds of host, a 32-lane NVIDIA dGPU and an RDNA3 iGPU with native wave64, so wave64_programs_in_halves_match_the_console_on_every_gpu checks all three paths on one box. PR head 25db879 on main 13f91ca.

System: RTX 5060 Laptop GPU 8 GB (Blackwell, driver 610.47) + Radeon 780M (RDNA3 iGPU, driver 32.0.31018.1), Ryzen 7 260, 32 GB, Windows 11 build 26300, Rust 1.98.1, debug build, validator from Windows SDK 10.0.26100.

NVIDIA GeForce RTX 5060 Laptop GPU (halves): 0 lanes of 64 differ from the console
NVIDIA GeForce RTX 5060 Laptop GPU (wave64): no pipeline for 64-lane waves; skipped
AMD Radeon 780M Graphics (halves): 0 lanes of 64 differ from the console
AMD Radeon 780M Graphics (wave64): 0 lanes of 64 differ from the console

Full victory-shader --lib:

main 13f91ca this PR
RTX 5060 (--skip heap_direct_texture_reads_mark_their_heap_index, #2571) 266 passed, 3 failed 271 passed, same 3 failed
Radeon 780M 270 passed, 0 failed 275 passed, 0 failed

The 3 are the known NVIDIA failures (#1835): stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware. No regression on either GPU.

Note for hybrid-laptop testers: Host::new in the test host takes the first adapter with dedicated memory. On this laptop that is the 780M (it reports a 417 MB carve-out), so a plain cargo test runs the single-adapter hardware tests on the iGPU, not the NVIDIA card. I forced the dGPU with a per-exe GPU preference (HKCU\Software\Microsoft\DirectX\UserGpuPreferences, GpuPreference=2;) and confirmed with nvidia-smi that the test process was on it.

AI-assisted (Claude Code); the runs were done on my machine.

**@⁠sergiocr06** on GitHub · 2026-11-25 18:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7170338846) Ran the halves tests on a machine that has both kinds of host, a 32-lane NVIDIA dGPU and an RDNA3 iGPU with native wave64, so `wave64_programs_in_halves_match_the_console_on_every_gpu` checks all three paths on one box. PR head `25db879` on `main` `13f91ca`. **System:** RTX 5060 Laptop GPU 8 GB (Blackwell, driver 610.47) + Radeon 780M (RDNA3 iGPU, driver 32.0.31018.1), Ryzen 7 260, 32 GB, Windows 11 build 26300, Rust 1.98.1, debug build, validator from Windows SDK 10.0.26100. ``` NVIDIA GeForce RTX 5060 Laptop GPU (halves): 0 lanes of 64 differ from the console NVIDIA GeForce RTX 5060 Laptop GPU (wave64): no pipeline for 64-lane waves; skipped AMD Radeon 780M Graphics (halves): 0 lanes of 64 differ from the console AMD Radeon 780M Graphics (wave64): 0 lanes of 64 differ from the console ``` Full `victory-shader --lib`: | | main `13f91ca` | this PR | |---|---|---| | RTX 5060 (`--skip heap_direct_texture_reads_mark_their_heap_index`, #2571) | 266 passed, 3 failed | 271 passed, same 3 failed | | Radeon 780M | 270 passed, 0 failed | 275 passed, 0 failed | The 3 are the known NVIDIA failures (#1835): `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`. No regression on either GPU. **Note for hybrid-laptop testers:** `Host::new` in the test host takes the first adapter with dedicated memory. On this laptop that is the 780M (it reports a 417 MB carve-out), so a plain `cargo test` runs the single-adapter hardware tests on the iGPU, not the NVIDIA card. I forced the dGPU with a per-exe GPU preference (`HKCU\Software\Microsoft\DirectX\UserGpuPreferences`, `GpuPreference=2;`) and confirmed with `nvidia-smi` that the test process was on it. AI-assisted (Claude Code); the runs were done on my machine.
Author
Owner

@⁠justrealyme on GitHub · 2026-11-25 18:09 UTC · original

Tested this on an RTX 5070 Ti (driver 621.40, Windows 11). The halves tests pass here too. I found one wrong result, though: v_readfirstlane_b32 in halves reads the host wave's first lane, which is console lane 32 for the upper half. Dispatched in halves (with v_mbcnt so the program has console lanes), v_readfirstlane_b32 s12, v0 gives 32 in all 32 upper lanes; the console gives 0.

Fix with tests: chippy01/VIctory#1 (onto this branch, rebased on 360f8aa). It keeps the first-lane read only for values proven alike across the console wave, ported from the analysis in fxceless/victory-fork, and refuses the rest with a reason. Offline over the title, 12 of 2,372 compute programs drop out with that reason; nothing else changes. On the GPU, alike values give 0 of 128 lanes wrong on the 5070 Ti and the Intel iGPU.

AI-assisted (Claude Code); no game data.

**@⁠justrealyme** on GitHub · 2026-11-25 18:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7170523156) Tested this on an RTX 5070 Ti (driver 621.40, Windows 11). The halves tests pass here too. I found one wrong result, though: `v_readfirstlane_b32` in halves reads the **host** wave's first lane, which is console lane 32 for the upper half. Dispatched in halves (with `v_mbcnt` so the program has console lanes), `v_readfirstlane_b32 s12, v0` gives 32 in all 32 upper lanes; the console gives 0. Fix with tests: chippy01/VIctory#1 (onto this branch, rebased on `360f8aa`). It keeps the first-lane read only for values proven alike across the console wave, ported from the analysis in fxceless/victory-fork, and refuses the rest with a reason. Offline over the title, 12 of 2,372 compute programs drop out with that reason; nothing else changes. On the GPU, alike values give 0 of 128 lanes wrong on the 5070 Ti and the Intel iGPU. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 18:17 UTC · original

On a machine that also has a 16-lane Intel iGPU (UHD 8086:a78b, WaveLaneCount 16..16), wave64_programs_in_halves_match_the_console_on_every_gpu fails with Intel(R) UHD Graphics (halves): no pipeline, because each_hardware() lists the iGPU and that driver refuses WaveSize(32) too. On that device the PR also keeps WaveSize(64), which is refused. On the RTX 4060 the halves form is exact (0 of 64 lanes differ). Details and table: #2220

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

**@⁠KainanP** on GitHub · 2026-11-25 18:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7170696403) On a machine that also has a 16-lane Intel iGPU (UHD `8086:a78b`, `WaveLaneCount` 16..16), `wave64_programs_in_halves_match_the_console_on_every_gpu` fails with `Intel(R) UHD Graphics (halves): no pipeline`, because `each_hardware()` lists the iGPU and that driver refuses `WaveSize(32)` too. On that device the PR also keeps `WaveSize(64)`, which is refused. On the RTX 4060 the halves form is exact (0 of 64 lanes differ). Details and table: https://git.gtahub.st/github/Marvisak--VIctory/issues/2220 _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 18:37 UTC · original · edited 2026-11-25 18:59 UTC

If this PR gets merged, I'll follow up by working on a way to implement Selective Cross-Wave Communication or, alternatively, a Hybrid Wave64 (32 physical + 32 virtual lanes) approach. The goal would be to allow the compiler to correctly execute instructions that require communication between lanes 0–31 and lanes 32–63.
In my opinion, addressing the underlying problem at its root is a better approach than introducing workarounds to bypass its limitations.
If this PR doesn't get merged, I'll still try to pursue at least one of these approaches, applying it to whichever alternative PR gets merged.
If anyone has any ideas or suggestions, I'll be glad to listen.

**@⁠chippy01** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7171167126) · edited 2026-11-25 18:59 UTC If this PR gets merged, I'll follow up by working on a way to implement Selective Cross-Wave Communication or, alternatively, a Hybrid Wave64 (32 physical + 32 virtual lanes) approach. The goal would be to allow the compiler to correctly execute instructions that require communication between lanes 0–31 and lanes 32–63. In my opinion, addressing the underlying problem at its root is a better approach than introducing workarounds to bypass its limitations. If this PR doesn't get merged, I'll still try to pursue at least one of these approaches, applying it to whichever alternative PR gets merged. If anyone has any ideas or suggestions, I'll be glad to listen.
Author
Owner

@⁠Mericas77 on GitHub · 2026-11-25 18:51 UTC · original

Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head 360f8aa against main 13f91ca. That's an Ada card, a generation after the 3070 Ti in the description.

  • halves_tests (--test-threads=1): 5/5 pass. wave64_programs_in_halves_match_the_console_on_every_gpu prints (halves): 0 lanes of 64 differ from the console and (wave64): no pipeline for 64-lane waves; skipped, which is the expected result on a 32-lane host.
  • victory-shader --lib (with --skip heap_direct_texture_reads_mark_their_heap_index, #2571): 271 passed / 3 failed. That's main's 266 plus the 5 new tests, and the same 3 known NVIDIA failures (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware).
  • victory-gpu: 193 passed / 2 failed, the same as main (the two 1,000,000-view heap-cap tests).

No regression on Ada. No game data; the title was not run.

AI-assisted.

**@⁠Mericas77** on GitHub · 2026-11-25 18:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7171508517) Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head `360f8aa` against `main` `13f91ca`. That's an Ada card, a generation after the 3070 Ti in the description. - `halves_tests` (`--test-threads=1`): **5/5 pass**. `wave64_programs_in_halves_match_the_console_on_every_gpu` prints `(halves): 0 lanes of 64 differ from the console` and `(wave64): no pipeline for 64-lane waves; skipped`, which is the expected result on a 32-lane host. - `victory-shader --lib` (with `--skip heap_direct_texture_reads_mark_their_heap_index`, #2571): 271 passed / 3 failed. That's `main`'s 266 plus the 5 new tests, and the same 3 known NVIDIA failures (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`). - `victory-gpu`: 193 passed / 2 failed, the same as `main` (the two 1,000,000-view heap-cap tests). No regression on Ada. No game data; the title was not run. AI-assisted.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 20:15 UTC · original

Independent run on another machine: Ryzen 9 9950X3D with an RTX 4090 (driver 32.0.16.2140) and the CPU's Radeon iGPU (RDNA2, driver 32.0.21045.29003), Windows 11 26H2.

victory translate --list --pipelines over the same four inputs as in the description, main 13f91ca against this PR 360f8aa, pipelines made on the RTX 4090:

main this PR
compute programs emitted 2,733 2,372
compute pipelines made 2,328 2,372
refused by the driver 405 0
vertex/pixel, mesh pipelines 14,254 / 8,765 14,254 / 8,765

Every pipeline made on main (25,347) is made here too, and 44 are new. The programs this PR refuses give their reason: 192 LDS in a one-wave group, 107 ballots, 48 lane reads across halves, 20 reductions.

halves_tests with --nocapture, which lists both adapters:

NVIDIA GeForce RTX 4090 (halves): 0 lanes of 64 differ from the console
NVIDIA GeForce RTX 4090 (wave64): no pipeline for 64-lane waves; skipped
AMD Radeon(TM) Graphics (halves): 0 lanes of 64 differ from the console
AMD Radeon(TM) Graphics (wave64): 0 lanes of 64 differ from the console

cargo test --release -p victory-shader --lib -- --test-threads=1, skipping memory_tests::heap_direct_texture_reads_mark_their_heap_index as in the description: main 266 passed and 3 failed, this PR 271 passed and the same 3 failed (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware).

**@⁠TaynanGT** on GitHub · 2026-11-25 20:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7173396819) Independent run on another machine: Ryzen 9 9950X3D with an RTX 4090 (driver 32.0.16.2140) and the CPU's Radeon iGPU (RDNA2, driver 32.0.21045.29003), Windows 11 26H2. `victory translate --list --pipelines` over the same four inputs as in the description, `main` 13f91ca against this PR 360f8aa, pipelines made on the RTX 4090: | | `main` | this PR | |---|---:|---:| | compute programs emitted | 2,733 | 2,372 | | compute pipelines made | 2,328 | **2,372** | | refused by the driver | 405 | **0** | | vertex/pixel, mesh pipelines | 14,254 / 8,765 | 14,254 / 8,765 | Every pipeline made on `main` (25,347) is made here too, and 44 are new. The programs this PR refuses give their reason: 192 LDS in a one-wave group, 107 ballots, 48 lane reads across halves, 20 reductions. `halves_tests` with `--nocapture`, which lists both adapters: ``` NVIDIA GeForce RTX 4090 (halves): 0 lanes of 64 differ from the console NVIDIA GeForce RTX 4090 (wave64): no pipeline for 64-lane waves; skipped AMD Radeon(TM) Graphics (halves): 0 lanes of 64 differ from the console AMD Radeon(TM) Graphics (wave64): 0 lanes of 64 differ from the console ``` `cargo test --release -p victory-shader --lib -- --test-threads=1`, skipping `memory_tests::heap_direct_texture_reads_mark_their_heap_index` as in the description: `main` 266 passed and 3 failed, this PR 271 passed and the same 3 failed (`stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`).
Author
Owner

@⁠qtLkz on GitHub · 2026-11-25 20:53 UTC · original

Tested on NVIDIA Ada, a 32-lane-only host: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged onto main 13f91ca (clean merge).

cargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index
(The skipped test crashes the NVIDIA driver on main, #2571. The fix is in #2596 / #2587.)

All 5 new tests pass:

  • halves_tests::wave64_programs_in_halves_match_the_console_on_every_gpu ... ok
  • halves_tests::a_wave64_program_reading_lanes_declares_32_lane_waves_in_halves ... ok
  • halves_tests::reads_across_32_lane_halves_are_refused_with_their_reason ... ok
  • halves_tests::lds_of_a_one_wave64_group_is_refused_in_halves ... ok
  • halves_tests::the_test_program_is_what_its_comments_say ... ok

Whole lib: 271 passed, 3 failed, 3 ignored. The 3 failures (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on plain main on this card (#2317). Nothing new from this PR.

So in addition to the RTX 3070 Ti (Ampere) in the description, the halves path checks out on Ada.

AI-assisted (Claude).

**@⁠qtLkz** on GitHub · 2026-11-25 20:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7174337746) Tested on NVIDIA Ada, a 32-lane-only host: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged onto main `13f91ca` (clean merge). `cargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index` (The skipped test crashes the NVIDIA driver on main, #2571. The fix is in #2596 / #2587.) All 5 new tests pass: - `halves_tests::wave64_programs_in_halves_match_the_console_on_every_gpu ... ok` - `halves_tests::a_wave64_program_reading_lanes_declares_32_lane_waves_in_halves ... ok` - `halves_tests::reads_across_32_lane_halves_are_refused_with_their_reason ... ok` - `halves_tests::lds_of_a_one_wave64_group_is_refused_in_halves ... ok` - `halves_tests::the_test_program_is_what_its_comments_say ... ok` Whole lib: 271 passed, 3 failed, 3 ignored. The 3 failures (`stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`) fail the same way on plain main on this card (#2317). Nothing new from this PR. So in addition to the RTX 3070 Ti (Ampere) in the description, the halves path checks out on Ada. AI-assisted (Claude).
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 20:59 UTC · original

Pushed a second commit with two fixes. Both were wrong results in the upper host wave (console lanes 32-63), and both now have tests:

  1. First-lane reads. Thanks @⁠justrealyme for the report and the fix in chippy01/VIctory#1; it's folded into this commit with you as co-author. v_readfirstlane_b32 read the host wave's first lane, which for the upper half is console lane 32. Reproduced here on the RTX 3070 Ti and the Radeon iGPU: the first lane of the thread id gave 32 in lanes 32-63, where the console gives 0. The Radeon's own wave64 form gave 0. A first-lane read is now kept only for values proven the same in every lane of the console wave. The analysis gains two cases:

    • buffer loads at alike addresses through a scalar descriptor (how the compiler reads one element of a typed buffer)
    • groups of 32 threads or fewer, where one host wave holds the whole console wave

    Every other first-lane read is refused with its reason. Offline over the title, compute programs emitted go from 2,372 to 2,369. The 3 dropped read values that can really differ between halves: the cloud multiple-scattering cache, for example, reads a value joined from a branch on a per-lane compare.

  2. DPP row masks. The row came from the host lane (0-1), so the upper half applied row_mask bits 0-1 to console rows 2-3. With row_mask:0xc, lanes 32-63 kept their old value on both GPUs (32 of 64 lanes wrong); now 0 are. No program in this title uses such a mask in halves, so none of its translations change.

New GPU tests: dpp_row_masks_name_the_console_rows_on_every_gpu and first_lanes_kept_in_halves_match_the_console_on_every_gpu. The refusal cases are in reads_across_32_lane_halves_are_refused_with_their_reason. victory-shader --lib: 273 passed, with the same 3 NVIDIA failures as main. Clippy (both runs) and cargo xtask policy are clean.

The refused first-lane reads come back exactly once the two host waves can exchange values, which is the follow-up mentioned above.

**@⁠chippy01** on GitHub · 2026-11-25 20:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7174465246) Pushed a second commit with two fixes. Both were wrong results in the upper host wave (console lanes 32-63), and both now have tests: 1. **First-lane reads.** Thanks @⁠justrealyme for the report and the fix in chippy01/VIctory#1; it's folded into this commit with you as co-author. `v_readfirstlane_b32` read the host wave's first lane, which for the upper half is console lane 32. Reproduced here on the RTX 3070 Ti and the Radeon iGPU: the first lane of the thread id gave 32 in lanes 32-63, where the console gives 0. The Radeon's own wave64 form gave 0. A first-lane read is now kept only for values proven the same in every lane of the console wave. The analysis gains two cases: - buffer loads at alike addresses through a scalar descriptor (how the compiler reads one element of a typed buffer) - groups of 32 threads or fewer, where one host wave holds the whole console wave Every other first-lane read is refused with its reason. Offline over the title, compute programs emitted go from 2,372 to 2,369. The 3 dropped read values that can really differ between halves: the cloud multiple-scattering cache, for example, reads a value joined from a branch on a per-lane compare. 2. **DPP row masks.** The row came from the host lane (0-1), so the upper half applied `row_mask` bits 0-1 to console rows 2-3. With `row_mask:0xc`, lanes 32-63 kept their old value on both GPUs (32 of 64 lanes wrong); now 0 are. No program in this title uses such a mask in halves, so none of its translations change. New GPU tests: `dpp_row_masks_name_the_console_rows_on_every_gpu` and `first_lanes_kept_in_halves_match_the_console_on_every_gpu`. The refusal cases are in `reads_across_32_lane_halves_are_refused_with_their_reason`. `victory-shader --lib`: 273 passed, with the same 3 NVIDIA failures as `main`. Clippy (both runs) and `cargo xtask policy` are clean. The refused first-lane reads come back exactly once the two host waves can exchange values, which is the follow-up mentioned above.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 21:16 UTC · original

Thanks, @⁠qtLkz, for running the five tests on the RTX 4070 Ti, and @⁠chippy01 for the first-lane and DPP row-mask fixes. My RTX 4090 results above are from 360f8aa, before the follow-up. The 2,372 compute programs in that table are from that earlier revision.

**@⁠TaynanGT** on GitHub · 2026-11-25 21:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7174864136) Thanks, @⁠qtLkz, for running the five tests on the RTX 4070 Ti, and @⁠chippy01 for the first-lane and DPP row-mask fixes. My RTX 4090 results above are from `360f8aa`, before the follow-up. The 2,372 compute programs in that table are from that earlier revision.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:16 UTC · original · edited 2026-11-26 00:24 UTC

Automated triage for the maintainers.

Needs the maintainer's decision, plus one small fix. The rebase merges cleanly and CI check is passing. The approach is gated by emit::Options::host_wave32, which is set from Host::wave32 (D3D12_OPTIONS1, at most 32 lanes with 32 among them). It runs console wave64 compute programs as two 32-lane host waves. Reads across halves, LDS in one-wave groups, unproven first-lane reads, and tile-prone group shapes are refused with reasons in emit/lower/halves.rs. The shader cache key in crates/victory-gpu/src/shader_cache.rs now includes the wave width. Several testers report the halves tests exact on NVIDIA Ampere/Ada/Blackwell and on RDNA2/RDNA3 (where they also match the native wave64 form).

  • Fix: wave64_programs_in_halves_match_the_console_on_every_gpu (and every_thread_keeps_its_own_id_in_halves_on_every_gpu) in emit/halves_tests.rs iterate Host::each_hardware(), which also lists 16-lane-only adapters. There both forms are refused and the assert!(*form == "wave64" && wave32, ...) fires, as reported in the thread on an Intel UHD iGPU. Please skip adapters where the halves form cannot be made, the same way the 64-lane form is skipped.
  • Maintainer: this is one of several open approaches to wave64 on 32-lane hosts (#189, #192, #233, #1960, #2176; #578 refuses them instead). Choosing between them is the maintainer's call.

On your reply: the third commit's refusal of group shapes a host wave may tile, and the merge of main (using #573's ds_bpermute_b32 within halves), read correctly.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7176150922) · edited 2026-11-26 00:24 UTC <!-- victory-triage v1 head=86a16dcefb757c7b97d6afd6c1e76ed9fb80cd19 verdict=needs-work at=2026-11-26T00:24:40Z --> Automated triage for the maintainers. Needs the maintainer's decision, plus one small fix. The rebase merges cleanly and CI `check` is passing. The approach is gated by `emit::Options::host_wave32`, which is set from `Host::wave32` (`D3D12_OPTIONS1`, at most 32 lanes with 32 among them). It runs console wave64 compute programs as two 32-lane host waves. Reads across halves, LDS in one-wave groups, unproven first-lane reads, and tile-prone group shapes are refused with reasons in `emit/lower/halves.rs`. The shader cache key in `crates/victory-gpu/src/shader_cache.rs` now includes the wave width. Several testers report the halves tests exact on NVIDIA Ampere/Ada/Blackwell and on RDNA2/RDNA3 (where they also match the native wave64 form). - **Fix:** `wave64_programs_in_halves_match_the_console_on_every_gpu` (and `every_thread_keeps_its_own_id_in_halves_on_every_gpu`) in `emit/halves_tests.rs` iterate `Host::each_hardware()`, which also lists 16-lane-only adapters. There both forms are refused and the `assert!(*form == "wave64" && wave32, ...)` fires, as reported in the thread on an Intel UHD iGPU. Please skip adapters where the halves form cannot be made, the same way the 64-lane form is skipped. - **Maintainer:** this is one of several open approaches to wave64 on 32-lane hosts (#189, #192, #233, #1960, #2176; #578 refuses them instead). Choosing between them is the maintainer's call. On your reply: the third commit's refusal of group shapes a host wave may tile, and the merge of `main` (using #573's `ds_bpermute_b32` within halves), read correctly. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠davesousa on GitHub · 2026-11-25 23:22 UTC · original

First run in the world with this PR, on the same Ampere card as the description: RTX 3070 Ti 8 GB, driver 621.40, Windows 11 26200, 32 GB RAM. diag build, VICTORY_D3D12_DRED=1. The base is 13f91ca + #2319 + #1906 + #2178 (without those, this card does not get through the world on NVIDIA; #1906 is in main now). This PR at b15a57b; the only conflict there was shader_cache.rs against #2178 (each adds a key parameter; I kept both). Cache and pipelines rebuilt for each build. These runs are of your two commits before your merge of main (f60027f); the conflict resolution in that merge is not covered here.

Offline (translate --cache --pipelines, same four inputs), on the base and then with this PR:

base + this PR
pipelines refused by the host 397 1
containers refused by the translator 233 597
pipelines made or already in the library 26,736 26,777

In the title, two 15-minute runs from the start screen through the world and the intro cutscene, one per build. The script stopped both; neither had a device removal:

base + this PR
compute programs refused by the host (unique) 170 0
programs dropped in total (host or translator, unique) 178 170
dropped on the base, running here 9
running on the base, dropped here 0 (one program refused here was not requested in the base run)
host submissions in the slow log / longest 92 / 0.68 s 13 / 0.99 s
world frame time, median of 10-s samples 0.84 s 0.83 s

The 170 dropped here all give a reason. The ones I could classify: 76 for LDS one console wave64 shares without barriers, 18 for lane masks or lane reads across halves, 11 for reductions over both halves, 7 for first-lane reads of values that may differ between the halves. emit::halves_tests passes 7/7 here: (halves) 0 lanes of 64 differ from the console, and the wave64 form is skipped as expected. victory-shader --lib and victory-gpu --lib show no new failures against the base.

I did not compare images, so this says nothing yet about whether the 9 programs that run now draw correctly.

AI-assisted (Claude Code); the runs are on my machine.

**@⁠davesousa** on GitHub · 2026-11-25 23:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7177463486) First run in the world with this PR, on the same Ampere card as the description: RTX 3070 Ti 8 GB, driver 621.40, Windows 11 26200, 32 GB RAM. `diag` build, `VICTORY_D3D12_DRED=1`. The base is `13f91ca` + #2319 + #1906 + #2178 (without those, this card does not get through the world on NVIDIA; #1906 is in `main` now). This PR at `b15a57b`; the only conflict there was `shader_cache.rs` against #2178 (each adds a key parameter; I kept both). Cache and pipelines rebuilt for each build. These runs are of your two commits before your merge of `main` (`f60027f`); the conflict resolution in that merge is not covered here. Offline (`translate --cache --pipelines`, same four inputs), on the base and then with this PR: | | base | + this PR | |---|---|---| | pipelines refused by the host | 397 | 1 | | containers refused by the translator | 233 | 597 | | pipelines made or already in the library | 26,736 | 26,777 | In the title, two 15-minute runs from the start screen through the world and the intro cutscene, one per build. The script stopped both; neither had a device removal: | | base | + this PR | |---|---|---| | compute programs refused by the host (unique) | 170 | 0 | | programs dropped in total (host or translator, unique) | 178 | 170 | | dropped on the base, running here | | 9 | | running on the base, dropped here | | 0 (one program refused here was not requested in the base run) | | host submissions in the slow log / longest | 92 / 0.68 s | 13 / 0.99 s | | world frame time, median of 10-s samples | 0.84 s | 0.83 s | The 170 dropped here all give a reason. The ones I could classify: 76 for LDS one console wave64 shares without barriers, 18 for lane masks or lane reads across halves, 11 for reductions over both halves, 7 for first-lane reads of values that may differ between the halves. `emit::halves_tests` passes 7/7 here: (halves) 0 lanes of 64 differ from the console, and the wave64 form is skipped as expected. `victory-shader --lib` and `victory-gpu --lib` show no new failures against the base. I did not compare images, so this says nothing yet about whether the 9 programs that run now draw correctly. AI-assisted (Claude Code); the runs are on my machine.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 23:23 UTC · original

Thanks for running this in-game, @⁠davesousa. The drop from 170 host refusals to zero on the 3070 Ti lines up with what I saw offline on the 4090. The median world frame time barely moved, even with fewer slow submissions.

Your numbers give us a baseline for b15a57b on the stack you listed. A matched run on f60027f with screenshots would show whether those results held after the merge and what the nine newly running programs actually draw.

**@⁠TaynanGT** on GitHub · 2026-11-25 23:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7177498239) Thanks for running this in-game, @⁠davesousa. The drop from 170 host refusals to zero on the 3070 Ti lines up with what I saw offline on the 4090. The median world frame time barely moved, even with fewer slow submissions. Your numbers give us a baseline for `b15a57b` on the stack you listed. A matched run on `f60027f` with screenshots would show whether those results held after the merge and what the nine newly running programs actually draw.
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 23:45 UTC · original

Merged main (842b0cb) in f60027f. main's own ds_bpermute_b32 lowering from #573 already reads within the reader's half, so it replaces the halves-only permute_lanes. The Host test helpers now sit on main's shared WARP device. Nothing measured changes.

Then pushed a third commit: halves now refuse group shapes that a 32-lane host wave may tile.

The relabelling gives a thread the first flat id of its host wave, rounded down to 32, plus its host lane. That is right only while every host wave holds a run of consecutive ids. I ran a program in halves that stores 1 at its own id, on the RTX 3070 Ti and the Radeon iGPU. 32x2, 32x8, 64x4, 32x32 and 32x2x2 groups store half their ids on both GPUs, because the host gives a wave a 16x2 tile of the group. 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4 and one-row groups store all of them. #2126 found the same tiling on an RTX 5070 Ti for main's 32-lane programs.

No program the title translates in halves uses such a group; they are 8x8, 8x4, 4x4 or one row, so 2,369 are still emitted. Its 32x2, 32x32 and 6x6 programs were refused already, and they would have run wrongly once the exchanges arrive. When #2126's per-wave tickets land, halves can take its ids from them and drop this refusal.

New tests: groups_a_host_wave_may_tile_are_refused_in_halves and every_thread_keeps_its_own_id_in_halves_on_every_gpu. victory-shader --lib: 307 passed on the merged head, with the same 3 NVIDIA failures as main.

**@⁠chippy01** on GitHub · 2026-11-25 23:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7178007936) Merged `main` (`842b0cb`) in `f60027f`. `main`'s own `ds_bpermute_b32` lowering from #573 already reads within the reader's half, so it replaces the halves-only `permute_lanes`. The `Host` test helpers now sit on `main`'s shared WARP device. Nothing measured changes. Then pushed a third commit: halves now refuse group shapes that a 32-lane host wave may tile. The relabelling gives a thread the first flat id of its host wave, rounded down to 32, plus its host lane. That is right only while every host wave holds a run of consecutive ids. I ran a program in halves that stores 1 at its own id, on the RTX 3070 Ti and the Radeon iGPU. 32x2, 32x8, 64x4, 32x32 and 32x2x2 groups store **half** their ids on both GPUs, because the host gives a wave a 16x2 tile of the group. 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4 and one-row groups store all of them. #2126 found the same tiling on an RTX 5070 Ti for `main`'s 32-lane programs. No program the title translates in halves uses such a group; they are 8x8, 8x4, 4x4 or one row, so 2,369 are still emitted. Its 32x2, 32x32 and 6x6 programs were refused already, and they would have run wrongly once the exchanges arrive. When #2126's per-wave tickets land, halves can take its ids from them and drop this refusal. New tests: `groups_a_host_wave_may_tile_are_refused_in_halves` and `every_thread_keeps_its_own_id_in_halves_on_every_gpu`. `victory-shader --lib`: 307 passed on the merged head, with the same 3 NVIDIA failures as `main`.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 23:53 UTC · original

Thanks for testing those group shapes on both adapters, @⁠chippy01. The store-at-own-ID test shows where the flat-ID assumption breaks: a 16×2 tile crosses rows, and the wider groups lose half their writes.

The unchanged count of 2,369 gives us a reference for 86a16dc. A matched run of that head and b15a57b can check whether the picture and frame times still agree after the merge and the new guard.

**@⁠TaynanGT** on GitHub · 2026-11-25 23:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7178172216) Thanks for testing those group shapes on both adapters, @⁠chippy01. The store-at-own-ID test shows where the flat-ID assumption breaks: a 16×2 tile crosses rows, and the wider groups lose half their writes. The unchanged count of 2,369 gives us a reference for `86a16dc`. A matched run of that head and `b15a57b` can check whether the picture and frame times still agree after the merge and the new guard.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:20 UTC · original

I tested the single-half case on 86a16dc. A 32-thread group fits entirely inside one Wave32. The guest compares the thread ID, saves and narrows EXEC, runs v_readfirstlane_b32 s12, v0, restores EXEC, and writes the scalar from all 32 threads. There is no branch or second half. The four masks select lane 0, lane 7, lane 31, or no lanes (the lane-zero fallback).

Wrong output dwords out of 128 This PR This PR merged locally with #2830 (36eb5f6)
RTX 5080, Wave32 64 0
WARP 1.0.22, Wave32 64 0
WARP 1.0.22, Wave64 64 64

Both Wave32 runs returned zero for the lane-7 and lane-31 masks before #2830. The two PR heads merge cleanly. Windows' built-in WARP advertises Wave4 only here and skipped both requested widths.

I also compiled a standalone HLSL shader with DXC to check the remaining WARP result. With [WaveSize(64)], 32 threads per group, and tid = SV_GroupIndex, thread 7 reported an all-zero WaveActiveBallot(tid >= 7). A direct WaveReadLaneAt(100 + tid, 7) in the same shader returned 107. Changing only the group size to 64 produced ballot words ffffff80 ffffffff and elected lane 7. A native Wave64 Radeon readback on the 32-thread fixture would help distinguish the WARP result.

Test-only commit a5a1999. To run from the head of this PR:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-masked-first-lane
git cherry-pick a5a1999
cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture
**@⁠steven-seagull27** on GitHub · 2026-11-26 02:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7180718024) I tested the single-half case on `86a16dc`. A 32-thread group fits entirely inside one Wave32. The guest compares the thread ID, saves and narrows EXEC, runs `v_readfirstlane_b32 s12, v0`, restores EXEC, and writes the scalar from all 32 threads. There is no branch or second half. The four masks select lane 0, lane 7, lane 31, or no lanes (the lane-zero fallback). | Wrong output dwords out of 128 | This PR | This PR merged locally with #2830 (`36eb5f6`) | |---|---:|---:| | RTX 5080, Wave32 | 64 | 0 | | WARP 1.0.22, Wave32 | 64 | 0 | | WARP 1.0.22, Wave64 | 64 | 64 | Both Wave32 runs returned zero for the lane-7 and lane-31 masks before #2830. The two PR heads merge cleanly. Windows' built-in WARP advertises Wave4 only here and skipped both requested widths. I also compiled a standalone HLSL shader with DXC to check the remaining WARP result. With `[WaveSize(64)]`, 32 threads per group, and `tid = SV_GroupIndex`, thread 7 reported an all-zero `WaveActiveBallot(tid >= 7)`. A direct `WaveReadLaneAt(100 + tid, 7)` in the same shader returned 107. Changing only the group size to 64 produced ballot words `ffffff80 ffffffff` and elected lane 7. A native Wave64 Radeon readback on the 32-thread fixture would help distinguish the WARP result. [Test-only commit a5a1999](https://github.com/steven-seagull27/VIctory/commit/a5a19991047a54263aa11aa9c1e27eb8dc5aa604). To run from the head of this PR: ```sh git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-masked-first-lane git cherry-pick a5a1999 cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture ```
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 02:24 UTC · original

Thanks for the minimal repro, @⁠steven-seagull27. The 32-thread fixture reproduces the lane 7 and 31 failures within a single half, and both Wave32 runs go from 64 wrong dwords to zero with #2830. I can use a5a1999 for the same comparison on my 4090.

I'd still like to see a native Wave64 Radeon run of the 32-thread fixture, especially whether the ballot is zero when the direct lane read returns 107.

**@⁠TaynanGT** on GitHub · 2026-11-26 02:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7180777634) Thanks for the minimal repro, @⁠steven-seagull27. The 32-thread fixture reproduces the lane 7 and 31 failures within a single half, and both Wave32 runs go from 64 wrong dwords to zero with #2830. I can use `a5a1999` for the same comparison on my 4090. I'd still like to see a native Wave64 Radeon run of the 32-thread fixture, especially whether the ballot is zero when the direct lane read returns 107.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:35 UTC · original

@⁠TaynanGT I put both comparisons on one branch at 34c8e1c. It contains this PR, #2830 and the guest fixture, plus a separate HLSL shader compiled by the Windows SDK's PC DXC. It prints the actual adapter, selected wave width, ballot words, elected read, and direct read from lane 7.

@⁠zed6000 Thanks for the native Wave64 result on #1737. If your 7900 XTX is available for this one, could you post the Radeon lines for the 32-thread group and the 64-thread control? From an existing clone, the following creates a separate worktree:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-radeon-comparison
git worktree add --detach ../victory-2633-radeon FETCH_HEAD
cd ../victory-2633-radeon
cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture
cargo test -p victory-shader --lib native_ballot_in_a_partial_wave -- --ignored --nocapture

In the standalone test on WARP 1.0.22, 25 of the 32 threads had their own predicate missing from the Wave64 ballot. Thread 7 read 100 through the elected lane and 107 directly from lane 7. Increasing only the group size to 64 gave 107 both ways and 0/64 wrong. On the RTX 5080, Wave32 had zero wrong for both group sizes. The standalone test prints all adapter/width results before reporting any mismatches.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7180946016) @⁠TaynanGT I put both comparisons on [one branch at 34c8e1c](https://github.com/steven-seagull27/VIctory/commit/34c8e1cc84348df602fb9ef0899574849de8fcb6). It contains this PR, #2830 and the guest fixture, plus a separate HLSL shader compiled by the Windows SDK's PC DXC. It prints the actual adapter, selected wave width, ballot words, elected read, and direct read from lane 7. @⁠zed6000 Thanks for the native Wave64 result on #1737. If your 7900 XTX is available for this one, could you post the Radeon lines for the 32-thread group and the 64-thread control? From an existing clone, the following creates a separate worktree: ```sh git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-radeon-comparison git worktree add --detach ../victory-2633-radeon FETCH_HEAD cd ../victory-2633-radeon cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture cargo test -p victory-shader --lib native_ballot_in_a_partial_wave -- --ignored --nocapture ``` In the standalone test on WARP 1.0.22, 25 of the 32 threads had their own predicate missing from the Wave64 ballot. Thread 7 read `100` through the elected lane and `107` directly from lane 7. Increasing only the group size to 64 gave `107` both ways and 0/64 wrong. On the RTX 5080, Wave32 had zero wrong for both group sizes. The standalone test prints all adapter/width results before reporting any mismatches.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 02:38 UTC · original

Thanks for putting both fixtures on 34c8e1c, @⁠steven-seagull27. I can use that head for the 4090 check and report the actual wave width with the ballot and both reads.

I'd look for whether Radeon also gets 100 from the elected lane and 107 from lane 7 with 32 threads, then 107 both ways with 64. That would show whether the WARP result also reproduces on native Wave64 hardware.

**@⁠TaynanGT** on GitHub · 2026-11-26 02:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7180986259) Thanks for putting both fixtures on `34c8e1c`, @⁠steven-seagull27. I can use that head for the 4090 check and report the actual wave width with the ballot and both reads. I'd look for whether Radeon also gets `100` from the elected lane and `107` from lane 7 with 32 threads, then `107` both ways with 64. That would show whether the WARP result also reproduces on native Wave64 hardware.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 02:46 UTC · original

@⁠steven-seagull27 I ran both tests on 34c8e1c. The guest first-lane test matched all four masks on the RTX 4090 in Wave32 and on the Ryzen 9 9950X3D's integrated Radeon in Wave32 and native Wave64.

Standalone DXC run 32 threads 64 threads
RTX 4090 (621.40), Wave32 0/32 wrong 0/64 wrong
Radeon iGPU (32.0.21045.29003), Wave32 0/32 wrong 0/64 wrong
Radeon iGPU, native Wave64 0/32 wrong 0/64 wrong

For thread 7, the 4090's Wave32 ballot was ffffff80 00000000 with either group size. On the Radeon in Wave64, it was ffffff80 00000000 with 32 threads and ffffff80 ffffffff with 64. In all of those runs, lane 7 was elected and both reads returned 107.

The built-in WARP adapter reported Wave4 and skipped Wave32 and Wave64.

**@⁠TaynanGT** on GitHub · 2026-11-26 02:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7181113589) @⁠steven-seagull27 I ran both tests on `34c8e1c`. The guest first-lane test matched all four masks on the RTX 4090 in Wave32 and on the Ryzen 9 9950X3D's integrated Radeon in Wave32 and native Wave64. | Standalone DXC run | 32 threads | 64 threads | | --- | ---: | ---: | | RTX 4090 (621.40), Wave32 | 0/32 wrong | 0/64 wrong | | Radeon iGPU (32.0.21045.29003), Wave32 | 0/32 wrong | 0/64 wrong | | Radeon iGPU, native Wave64 | 0/32 wrong | 0/64 wrong | For thread 7, the 4090's Wave32 ballot was `ffffff80 00000000` with either group size. On the Radeon in Wave64, it was `ffffff80 00000000` with 32 threads and `ffffff80 ffffffff` with 64. In all of those runs, lane 7 was elected and both reads returned `107`. The built-in WARP adapter reported Wave4 and skipped Wave32 and Wave64.
Author
Owner

@⁠chippy01 on GitHub · 2026-11-26 09:14 UTC · original

@⁠TaynanGT here is the matched comparison. Same card as davesousa's, an RTX 3070 Ti 8 GB, but on driver 621.24 (theirs was 621.40). Ryzen 9 7900X, 32 GB RAM, Windows 11 26200, TDR delay at the default 2 s. diag builds, VICTORY_D3D12_DRED=1, --console series-x. b15a57b is on davesousa's stack (+ #2319 + #1906 + #2178). 86a16dc has #2319 + #2178; #1906 comes with the merge. shader_cache.rs keeps both key parameters, as davesousa did. Cache and pipelines were rebuilt for each build.

Offline, translate --cache --pipelines on the same four inputs:

b15a57b 86a16dc
containers refused by the translator 597 593
pipelines refused by the host 1 1
pipelines made or already in the library 26,777 26,779

b15a57b reproduces davesousa's column exactly.

translate --list --wave32 on the same inputs, program by program:

b15a57b 86a16dc
compute programs emitted (in halves) 2,369 of 2,763 2,369 of 2,763
vertex and pixel programs emitted 14,254 of 14,259 14,258 of 14,259
mesh programs emitted 8,765 of 8,765 8,765 of 8,765

No compute program changes outcome. The guard refuses two programs, both of which b15a57b already refused for a lane mask read as data. The guard now stops them before that check. The other halves reasons have the same counts on both builds: 192 LDS, 48 lane reads across halves, 20 reductions, 17 first-lane reads. Four pixel programs change outcome: b15a57b refused them for a lane mask read as data, and they translate after the merge.

In the title I couldn't get the 15-minute runs. Both builds stopped in the world, the same way:

b15a57b 86a16dc
world's first frame 2.4 min 3.7 min
run ended 8.5 min 5.2 min
compute programs refused by the host 0 0

Once the world loaded, the emulator's working set reached 20-22 GB, VRAM sat at 7.0-7.2 of 8 GB, and about 1 GB of RAM was left. Frames took seconds each (up to 15 s). Then no frame came for about a minute, and the title's own crash handler ended it ("Game Running" in its report). Both builds did this, even with most apps closed, so I read it as a limit of this machine rather than of either commit. The page file and the game data are both on a nearly full QLC SSD. davesousa's runs got through 15 minutes with the same card and RAM. Frame times from these runs aren't meaningful.

In the part both runs covered, no program ran on one build and was dropped on the other. The 43 programs 86a16dc refused in its run all give halves reasons; none of them is the new tile-prone-group refusal.

The captures can't answer the picture question on NVIDIA yet. In both builds the world frames show only the cutscene's subtitles and letterboxing over a flat background. Both runs log the same host refusal of a 2560x1440 texture (#797), which looks like the scene target.

One more thing about b15a57b's stack. Its first boot on a fresh library hung for 28 s shortly after a library save, and the title crashed itself in "Game Init". b15a57b doesn't have #2179, so a pipeline load waits while a save serialises the whole ~1 GB library. 86a16dc gets #2179 with the merge. The hang didn't happen on every first boot. To keep the two builds alike, each got one throwaway boot on its fresh library before its run.

**@⁠chippy01** on GitHub · 2026-11-26 09:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7187653617) @⁠TaynanGT here is the matched comparison. Same card as davesousa's, an RTX 3070 Ti 8 GB, but on driver 621.24 (theirs was 621.40). Ryzen 9 7900X, 32 GB RAM, Windows 11 26200, TDR delay at the default 2 s. `diag` builds, `VICTORY_D3D12_DRED=1`, `--console series-x`. `b15a57b` is on davesousa's stack (+ #2319 + #1906 + #2178). `86a16dc` has #2319 + #2178; #1906 comes with the merge. `shader_cache.rs` keeps both key parameters, as davesousa did. Cache and pipelines were rebuilt for each build. **Offline**, `translate --cache --pipelines` on the same four inputs: | | `b15a57b` | `86a16dc` | |---|---:|---:| | containers refused by the translator | 597 | 593 | | pipelines refused by the host | 1 | 1 | | pipelines made or already in the library | 26,777 | 26,779 | `b15a57b` reproduces davesousa's column exactly. `translate --list --wave32` on the same inputs, program by program: | | `b15a57b` | `86a16dc` | |---|---:|---:| | compute programs emitted (in halves) | 2,369 of 2,763 | 2,369 of 2,763 | | vertex and pixel programs emitted | 14,254 of 14,259 | 14,258 of 14,259 | | mesh programs emitted | 8,765 of 8,765 | 8,765 of 8,765 | No compute program changes outcome. The guard refuses two programs, both of which `b15a57b` already refused for a lane mask read as data. The guard now stops them before that check. The other halves reasons have the same counts on both builds: 192 LDS, 48 lane reads across halves, 20 reductions, 17 first-lane reads. Four pixel programs change outcome: `b15a57b` refused them for a lane mask read as data, and they translate after the merge. **In the title** I couldn't get the 15-minute runs. Both builds stopped in the world, the same way: | | `b15a57b` | `86a16dc` | |---|---:|---:| | world's first frame | 2.4 min | 3.7 min | | run ended | 8.5 min | 5.2 min | | compute programs refused by the host | 0 | 0 | Once the world loaded, the emulator's working set reached 20-22 GB, VRAM sat at 7.0-7.2 of 8 GB, and about 1 GB of RAM was left. Frames took seconds each (up to 15 s). Then no frame came for about a minute, and the title's own crash handler ended it ("Game Running" in its report). Both builds did this, even with most apps closed, so I read it as a limit of this machine rather than of either commit. The page file and the game data are both on a nearly full QLC SSD. davesousa's runs got through 15 minutes with the same card and RAM. Frame times from these runs aren't meaningful. In the part both runs covered, no program ran on one build and was dropped on the other. The 43 programs `86a16dc` refused in its run all give halves reasons; none of them is the new tile-prone-group refusal. The captures can't answer the picture question on NVIDIA yet. In both builds the world frames show only the cutscene's subtitles and letterboxing over a flat background. Both runs log the same host refusal of a 2560x1440 texture (#797), which looks like the scene target. One more thing about `b15a57b`'s stack. Its first boot on a fresh library hung for 28 s shortly after a library save, and the title crashed itself in "Game Init". `b15a57b` doesn't have #2179, so a pipeline load waits while a save serialises the whole ~1 GB library. `86a16dc` gets #2179 with the merge. The hang didn't happen on every first boot. To keep the two builds alike, each got one throwaway boot on its fresh library before its run.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 09:21 UTC · original

Thanks for running both builds, @⁠chippy01. The 2,369 compute programs on each build answer my question about the guard. It rejects the same two programs earlier, and the merge gets four more pixel programs through translation.

The picture and frame-time comparison is still open. Both runs hit the same 2560×1440 texture refusal and ended before 15 minutes. Could you share the HRESULT and the format and flags for texture #797 if they're in the log? The 28-second fresh-library stall also fits the save/load contention that #2179 addresses.

**@⁠TaynanGT** on GitHub · 2026-11-26 09:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7187833144) Thanks for running both builds, @⁠chippy01. The 2,369 compute programs on each build answer my question about the guard. It rejects the same two programs earlier, and the merge gets four more pixel programs through translation. The picture and frame-time comparison is still open. Both runs hit the same 2560×1440 texture refusal and ended before 15 minutes. Could you share the HRESULT and the format and flags for texture `#797` if they're in the log? The 28-second fresh-library stall also fits the save/load contention that #2179 addresses.
Author
Owner

@⁠chippy01 on GitHub · 2026-11-26 09:48 UTC · original

@⁠TaynanGT it's in the logs. Both builds write the same pair of lines once per run, at the cutscene (b15a57b at 08:40:10, 86a16dc at 08:52:16):

WARN victory_gpu::resource: the host refuses castable formats: textures of one memory in other formats get their own host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }
WARN victory_gpu::resource: no host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }
  • HRESULT 0x80070057 (E_INVALIDARG; "Parametro non corretto" is the Italian system text). It comes back on both tries: first with castable formats, then as a plain texture.
  • TEXTURE2D, 2560x1440, 1 mip, 1 slice, 1 sample. format: 115 is DXGI_FORMAT_B4G4R4A4_UNORM and flags: 1 is D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET.
  • The D3D12 debug layer was off for these runs, so there's no message saying which part it objects to. I can rerun with VICTORY_D3D12_DEBUG=1 if you want the debug layer's own reason.

That's one of the two textures in #797. The other one (format: 86, B5G5R5A1_UNORM, flags: 5) is created in both runs now. main makes it without unordered access; the log line just before the refusal is no unordered access for this format: textures are made without it, their unordered views are refused format=86. So on this card only the 115 texture is still refused.

On the 28 s stall: agreed, that's the save/load contention #2179 removes. It's why each build got one throwaway boot before its measured run.

@⁠steven-seagull27 thanks for the masked first-lane fixture. The wrong lanes come from main's lowering, not from the halves. An instruction with a scalar destination drops its EXEC guard, so under a narrowed EXEC v_readfirstlane_b32 reads the host wave's lane 0 on any host. #2830 fixes that on main, and with it the halves path matches (TaynanGT's run on the 4090 and the Radeon iGPU at 34c8e1c). I'll leave that fix to #2830 rather than duplicate it here.

**@⁠chippy01** on GitHub · 2026-11-26 09:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7188500068) @⁠TaynanGT it's in the logs. Both builds write the same pair of lines once per run, at the cutscene (`b15a57b` at 08:40:10, `86a16dc` at 08:52:16): ``` WARN victory_gpu::resource: the host refuses castable formats: textures of one memory in other formats get their own host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 } WARN victory_gpu::resource: no host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 } ``` - HRESULT `0x80070057` (`E_INVALIDARG`; "Parametro non corretto" is the Italian system text). It comes back on both tries: first with castable formats, then as a plain texture. - `TEXTURE2D`, 2560x1440, 1 mip, 1 slice, 1 sample. `format: 115` is `DXGI_FORMAT_B4G4R4A4_UNORM` and `flags: 1` is `D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET`. - The D3D12 debug layer was off for these runs, so there's no message saying which part it objects to. I can rerun with `VICTORY_D3D12_DEBUG=1` if you want the debug layer's own reason. That's one of the two textures in #797. The other one (`format: 86`, `B5G5R5A1_UNORM`, `flags: 5`) is created in both runs now. `main` makes it without unordered access; the log line just before the refusal is `no unordered access for this format: textures are made without it, their unordered views are refused format=86`. So on this card only the 115 texture is still refused. On the 28 s stall: agreed, that's the save/load contention #2179 removes. It's why each build got one throwaway boot before its measured run. @⁠steven-seagull27 thanks for the masked first-lane fixture. The wrong lanes come from `main`'s lowering, not from the halves. An instruction with a scalar destination drops its EXEC guard, so under a narrowed EXEC `v_readfirstlane_b32` reads the host wave's lane 0 on any host. #2830 fixes that on `main`, and with it the halves path matches (TaynanGT's run on the 4090 and the Radeon iGPU at `34c8e1c`). I'll leave that fix to #2830 rather than duplicate it here.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 09:50 UTC · original

Yes, please try VICTORY_D3D12_DEBUG=1 on 86a16dc, @⁠chippy01. A run to the cutscene is enough. Could you paste the debug-layer message ID and text for the plain creation of the B4G4R4A4_UNORM render target?

Thanks for checking both formats. Format 86 now creates without the UAV flag, and 115 still returns E_INVALIDARG on the plain path. If you already have a format-support dump, could you include the D3D12_FORMAT_SUPPORT1_RENDER_TARGET bit for 115?

**@⁠TaynanGT** on GitHub · 2026-11-26 09:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7188545972) Yes, please try `VICTORY_D3D12_DEBUG=1` on `86a16dc`, @⁠chippy01. A run to the cutscene is enough. Could you paste the debug-layer message ID and text for the plain creation of the `B4G4R4A4_UNORM` render target? Thanks for checking both formats. Format 86 now creates without the UAV flag, and 115 still returns `E_INVALIDARG` on the plain path. If you already have a format-support dump, could you include the `D3D12_FORMAT_SUPPORT1_RENDER_TARGET` bit for 115?
Author
Owner

@⁠chippy01 on GitHub · 2026-11-26 12:56 UTC · original

@⁠TaynanGT the debug layer can't get this title to the cutscene on this PC. With VICTORY_D3D12_DEBUG=1, 86a16dc (the same diag build and stack as the matched run) stopped in Game Init. The boot's descriptor work went several times slower than without the debug layer: a few thousand title-slot warnings per 10 s instead of 40,000-85,000. The title's own watchdog ended the run at 79 s. Its deliberate write at +0x2215c35 left a crash report that says Game State: Game Init, Frame: 0. Without the debug layer the emulator gets to that texture at 81 s.

So I repeated the two calls make_texture makes for that texture outside the emulator, with the debug layer on. The arguments are the same: 2560x1440, 1 mip, B4G4R4A4_UNORM, ALLOW_RENDER_TARGET, default heap. The castable list is what castable(115) gives (formats 49-52, 54, 56-59, 68, 69, 85, 86).

call RTX 3070 Ti Radeon iGPU (Ryzen 9 7900X)
CreateCommittedResource3 with those castable formats and a clear value in format 115 E_INVALIDARG, ID 817 made
CreateCommittedResource3 with the same castable formats, no clear value made made
CreateCommittedResource (plain), with or without that clear value E_INVALIDARG, ID 599 made

ID 599 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS (severity ERROR, category STATE_CREATION):

ID3D12Device::CreateCommittedResource: A texture that has D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET set in D3D12_RESOURCE_DESC::Flags must be created with a format that either can be used as a render target, or cast to a format that could be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM.

ID 817 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT:

ID3D12Device::CreateCommittedResource3: When D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET is set in D3D12_RESOURCE_DESC::Flags, D3D12_CLEAR_VALUE::Format must be valid to be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_CLEAR_VALUE::Format is B4G4R4A4_UNORM.

In the runs the castable try failed as well. Outside the emulator it only fails with a clear value in format 115, so the title most likely passes one. The emulator then falls back to the plain creation, which fails with 599.

Format support (CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)):

RTX 3070 Ti, driver 621.24 Radeon iGPU
115 B4G4R4A4_UNORM, Support1 0x008413f0, RENDER_TARGET clear 0x02e4d3f0, RENDER_TARGET set
86 B5G5R5A1_UNORM, Support1 0x00e4d3f0, RENDER_TARGET set 0x02e4d3f0, RENDER_TARGET set

Both adapters report RelaxedFormatCastingSupported. So on this card 115 can never be a render target format, but the castable texture is accepted once the clear value in 115 is left out. I haven't tested whether its render target views work in one of the castable formats.

**@⁠chippy01** on GitHub · 2026-11-26 12:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7192658146) @⁠TaynanGT the debug layer can't get this title to the cutscene on this PC. With `VICTORY_D3D12_DEBUG=1`, `86a16dc` (the same diag build and stack as the matched run) stopped in Game Init. The boot's descriptor work went several times slower than without the debug layer: a few thousand title-slot warnings per 10 s instead of 40,000-85,000. The title's own watchdog ended the run at 79 s. Its deliberate write at `+0x2215c35` left a crash report that says `Game State: Game Init`, `Frame: 0`. Without the debug layer the emulator gets to that texture at 81 s. So I repeated the two calls `make_texture` makes for that texture outside the emulator, with the debug layer on. The arguments are the same: 2560x1440, 1 mip, `B4G4R4A4_UNORM`, `ALLOW_RENDER_TARGET`, default heap. The castable list is what `castable(115)` gives (formats 49-52, 54, 56-59, 68, 69, 85, 86). | call | RTX 3070 Ti | Radeon iGPU (Ryzen 9 7900X) | |---|---|---| | `CreateCommittedResource3` with those castable formats and a clear value in format 115 | `E_INVALIDARG`, ID 817 | made | | `CreateCommittedResource3` with the same castable formats, no clear value | made | made | | `CreateCommittedResource` (plain), with or without that clear value | `E_INVALIDARG`, ID 599 | made | ID 599 is `D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS` (severity `ERROR`, category `STATE_CREATION`): ``` ID3D12Device::CreateCommittedResource: A texture that has D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET set in D3D12_RESOURCE_DESC::Flags must be created with a format that either can be used as a render target, or cast to a format that could be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM. ``` ID 817 is `D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT`: ``` ID3D12Device::CreateCommittedResource3: When D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET is set in D3D12_RESOURCE_DESC::Flags, D3D12_CLEAR_VALUE::Format must be valid to be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_CLEAR_VALUE::Format is B4G4R4A4_UNORM. ``` In the runs the castable try failed as well. Outside the emulator it only fails with a clear value in format 115, so the title most likely passes one. The emulator then falls back to the plain creation, which fails with 599. Format support (`CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)`): | | RTX 3070 Ti, driver 621.24 | Radeon iGPU | |---|---|---| | 115 `B4G4R4A4_UNORM`, `Support1` | `0x008413f0`, `RENDER_TARGET` clear | `0x02e4d3f0`, `RENDER_TARGET` set | | 86 `B5G5R5A1_UNORM`, `Support1` | `0x00e4d3f0`, `RENDER_TARGET` set | `0x02e4d3f0`, `RENDER_TARGET` set | Both adapters report `RelaxedFormatCastingSupported`. So on this card 115 can never be a render target format, but the castable texture is accepted once the clear value in 115 is left out. I haven't tested whether its render target views work in one of the castable formats.
What was wrong: in halves (#2633), a wave64 program's masks read as
data, whole-wave reductions and prefix sums, and lane reads are refused
in every group, as reads across the two host waves. A group of 32
threads or fewer has no upper half: its console wave has no lane 32-63,
and one host wave holds every lane it has. Such programs were refused
for nothing: 6 in the title, among them avgLuminanceCompute (exposure)
and deferred_lighting.

What changed: in halves, when the group fits one host wave:

- masks read as data take the host wave's ballot, whose high dword is 0,
  as the console's is;
- whole-wave reductions and prefix sums run over the host wave, which
  holds every lane the console takes them over (its lanes 32-63 hold the
  identity there); a 16-bit section's lane `hi` past 32 gives the
  identity, as the lowering already does for lanes the host lacks;
- a lane read of a constant lane below 32 is the host's (halves::lane_read,
  out of lower.rs). Any other lane read stays refused: a lane past the group holds whatever its registers
  did on the console.

First-lane reads already kept the host wave's first lane there.

Evidence, translate --list --wave32 over shaders.rpf, the executable,
XboxBvhBuilder.dll and the FidelityFX DLL: compute programs emitted
2,369 -> 2,375; with --pipelines on the RTX 3070 Ti, 2,375 compute
pipelines made, none refused by the driver; no other outcome changes.
The 6: avgLuminanceCompute's luminance from HDR, deferred_lighting's
infinite-range intensity, ShallowWaterSim's disturbance pairs,
subsurfacescatter's tile classification, water_shading's foam decal test
and weatherParticle's decal arguments.

Tests (emit::halves_tests):

- a_group_one_host_wave_holds_reads_nothing_across_halves (offline): a
  program counting a compare's lanes (s_bcnt1_i32_b64), reading the
  mask's high dword, lane 5 and the exclusive prefix sum the console
  compiler expands translates in groups of 32 and 16 and is refused in a
  group of 64; a read of lane 40 is refused in a group of 32.
- a_group_one_host_wave_holds_matches_the_console_on_every_gpu: that
  program in a group of 32 gives the console's results in every lane on
  an RTX 3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (halves
  and wave64).

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 309 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was wrong: in halves, v_readlane_b32 is refused, since its result is
the wave's and the lane read is in one half only. Programs that need
nothing else across the halves were refused for it: 46 in the title,
among them the 20 depth pyramids and five of the BVH builder's passes.

What changed: the halves trade the value (Lower::across, in
emit/lower/halves.rs).

- The first lane of each host wave stores its lane (L mod 32)'s value in
  its half's slot of group-shared memory, a dword per half of each
  console wave, beside the program's own LDS. A group barrier follows;
  every lane loads the slot of the half that holds lane L, and a second
  barrier keeps the next trade from overwriting the slot first.
- A barrier needs every thread of the group, the same number of times:
  one half skipping it hangs the GPU (D3D12 leaves it undefined, NVIDIA
  waits for every thread). The trade is made only in blocks outside
  every region of a branch on a lane-dependent condition, and in groups
  of several console waves, which may take a uniform branch each its
  own way, outside every branch (Exchange, from the branch
  regions the first-lane analysis already finds). Elsewhere the read is
  refused with its reason.
- A lane read of a value the same in every lane of the console wave
  (halves::lane_uniform) is the lane's own: nothing is traded.
- The slots and the program's LDS stay within 32 KiB, or the read is
  refused.

lower.rs grows by 219 bytes (523,389, under the policy's 512 KiB); the
rest is in emit/lower/halves.rs, and Shader::shared makes the slots.

Evidence, translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL: compute programs
emitted 2,375 -> 2,421, every new one validated: depth_pyramid (20), im
(8), cascadeshadows_processing (5), MotionBlur (3), DepthOfField (2),
trailmapCompute (2), Autofocus (1) and five of XboxBvhBuilder.dll. Lane
reads still refused: 2, where not every thread meets.

Tests (emit::halves_tests):

- lane_reads_across_halves_match_the_console_on_every_gpu: lanes 40, 63
  (named by an SGPR) and 5 of the thread id, in groups of 64 and 128:
  every lane gets its console wave's values on an RTX 3070 Ti (halves)
  and the Radeon iGPU of a Ryzen 9 7900X (halves and wave64).
- reads_across_32_lane_halves_are_refused_with_their_reason: the read at
  the top level translates; inside a branch only threads below 20 take,
  it is refused; under a branch on a scalar compare it translates in a
  group of 64 and is refused in a group of 128.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 310 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.

Co-Authored-By: Claude Opus 5.5
What was wrong: a group of 33 to 64 threads is one console wave, and the
console compiler leaves out barriers between its lanes' LDS accesses,
since the wave runs one instruction at a time. In halves the two host
waves run out of step, so all such programs were refused: 192 in the
title.

What changed: group barriers put the two halves back in the console's
order (Lds, in emit/lower/halves.rs, on the blocks where every thread
meets that the lane-read trade already finds):

- where every thread meets, a barrier before an LDS access that may meet
  one since the last barrier (any access after a write, a write after a
  read); a read after reads needs none;
- around each region only some lanes run that accesses LDS, a barrier at
  the end of every meeting block that branches into it and at the start
  of every meeting block it comes back to;
- inside such a region nothing can be ordered (a barrier there would be
  one only some threads reach), so a region that both writes and reads,
  or writes in two instructions, or holds an atomic beside another
  access, is refused with its reason.

Evidence, translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL: compute programs
emitted 2,421 -> 2,443, every new one validated and none lost:
scattering_transmittance_system (3), tiled_lighting (3), RiverSimPacket
(3), alphaResolve (2), compute_graph_ops (2), WindNew (2),
deferred_mirror, deferred_studio_shot, GpuParticleUpdate,
height_buffer_offset, sr_tracing, TAA2 and TAA_Utilities. Of the 192
programs that shared one console wave's LDS, 142 now stop at a region
that both writes and reads it (or writes it twice), which needs every
lane to run every block; the rest stop at other reads across the halves.

Tests (emit::halves_tests):

- lds_of_a_one_wave64_group_is_ordered_in_halves (offline): a write and
  a read where every thread meets translate in groups of 64, 48, 32 and
  128; a region that writes and reads, and one that writes twice, are
  refused.
- one_wave_lds_crosses_the_halves_in_order_on_every_gpu: in a group of
  64, every lane reads the dword lane tid ^ 32 (in the other half) wrote,
  where every thread meets, after a region only lanes below 48 write in,
  and after lanes below 32 spin 20,000 times and every lane first
  poisons its partner's dword. 0 of 64 lanes differ from the console on
  an RTX 3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (halves
  and wave64). With the barriers left out, the last program gives 64 of
  64 lanes wrong in halves on both GPUs, three runs out of three, and 0
  on the Radeon's own wave64.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 311 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs grows by 66 bytes (523,455).

Co-Authored-By: Claude Opus 5.5
What was wrong: in halves, three reads into the other half were still
refused wherever they were made: `v_readfirstlane_b32` of a value that
may differ between the halves, lane masks read as data (`s_bcnt1`,
`v_mbcnt`, `vcc_hi` moved to a VGPR, scalar compares of masks), and the
whole-wave reductions and prefix sums the console compiler expands
(sections the wave simulation follows). The census on b15a57b counted
188, 164 and 96 refused programs needing them.

What changed (emit/lower/halves.rs):

- `Lower::trade`: the lane-read trade, generalized. Each half's words
  (each the same in every lane of its host wave) are stored by every
  lane, then a group barrier, then both halves' words are loaded, then a
  second barrier. A console wave whose high half has no threads (a group
  ending inside its low half) gives the word's identity there. The slots
  grow to two dwords per half. `v_readlane_b32` uses it too.
- `v_readfirstlane_b32`: each half reads its first lane in EXEC (the
  instruction's guard) and its ballot of EXEC. The console's first lane
  is the low half's where that has one, else the high half's, else lane 0
  (EXEC empty). Scalars, values the same in every lane of the console
  wave and groups of 32 threads or fewer keep the host wave's own read.
  `main` drops the guard of an instruction with a scalar result (#2830
  fixes that there), so the trade reads the guard itself.
- Lane masks read as data: each half's ballot is one dword of the
  console's mask, traded at the end of the block writing the mask.
- Whole-wave reductions combine the two halves' parts, low half first.
  A prefix sum in the high half adds the low half's total.
- Each stays refused, with its reason, where not every thread of the
  group meets: inside a branch only some lanes take, and, in a group of
  several console waves, inside any branch.

Relation to other PRs: #1890 (beamdotdev's) and #189 (alfycs's) trade
these reads through group-shared memory too. This builds on #2633's
trade and refuses where the halves cannot meet; #1890 lets each half
work over its own 32 lanes there.

Evidence, translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL: compute programs
emitted 2,443 -> 2,463, every new one validated and none lost:

- first lanes: CS_Slod_BatchCull and five of its variants,
  CS_HighDetailDeltas_ComputeDeltas;
- masks read as data: XboxBvhBuilder.dll (2), CS_DepthProcessing,
  CS_DepthProcessingHBO, CS_UpdateParticles,
  CS_UpdateSkinnedAttachMeshParticles, CS_CollisionWithWaterSim,
  CS_DownsampleAlphaShadowMap, CS_GenerateMaterialMasks;
- reductions: CS_RegenerateMinMaxDepth, CS_SortRayTiles,
  CS_GenerateNormalConesFirstPass, CS_FeedbackToParent4x4x4.

Still refused where not every thread of the group meets: 87 masks read
as data, 20 first-lane reads and 16 reductions. Those need the two halves
to follow the console's flow through the branch, the next step.

Tests (emit::halves_tests):

- collectives_are_traded_where_every_thread_meets (offline): masks, first
  lanes, a wave sum and small_group translate in groups of 48, 64, 96 and
  128; a first-lane read and a mask inside a lane branch are refused; a
  sum under a uniform branch translates in a group of 64 and is refused
  in one of 128.
- collectives_cross_the_halves_on_every_gpu: in groups of 48 (an upper
  half of 16 threads), 64, 96 (a second console wave with no upper half)
  and 128, the count and both dwords of a mask of lanes below 40, the
  first lane, a first lane in the upper half under a narrowed EXEC, the
  exclusive prefix sum and the total of the thread ids, and small_group's
  results. 0 lanes differ from the console on an RTX 3070 Ti (halves) and
  the Radeon iGPU of a Ryzen 9 7900X (halves and wave64). The first lane
  under a narrowed EXEC runs in halves only: the wave64 form gives lane
  0's thread id on `main` (#2830).
- reads_across_32_lane_halves_are_refused_with_their_reason and
  a_group_one_host_wave_holds_reads_nothing_across_halves: updated, the
  buffer-load first lane rule now checked inside a branch.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 313 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs shrinks by 259 bytes (523,196).

Co-Authored-By: Claude Opus 5.5
What was wrong: the tile guard (86a16dc) refused a group in halves when it
had more than one row or more than one layer (y * z above 1) and rows 32
threads wide or more, or not a power of two wide. Only rows are tiled:
a group of one row keeps every host wave's run of flat ids in any depth,
so such groups were refused for nothing.

What changed: `Lower::halves_tiles` (emit/lower/halves.rs) refuses groups
of several rows only (y above 1), and its comment lists the shapes
measured.

Evidence, measured in halves on an RTX 3070 Ti and the Radeon iGPU of a
Ryzen 9 7900X, with the same counts on both (each thread stores 1 at its
flat id, so ids two threads share leave others unstored):

- one row, any depth: 32 x 1 x 2, 32 x 1 x 4, 32 x 1 x 32, 64 x 1 x 2,
  64 x 1 x 4, 128 x 1 x 2, 256 x 1 x 4, 40 x 1 x 2, 48 x 1 x 2,
  96 x 1 x 2, 24 x 1 x 4, 12 x 1 x 3 and 6 x 1 x 6 store every id;
- several rows 32 wide or more, or not a power of two wide, store only
  some: 32 x 2 (32 of 64), 32 x 2 x 2 (64 of 128), 64 x 2 (64 of 128),
  48 x 2 (64 of 96), 24 x 2 (32 of 48), 12 x 4 (32 of 48), 6 x 6 (32 of
  36);
- several rows of a power of two below 32 store every id: 16 x 2, 8 x 8,
  16 x 4 x 2, 8 x 4 x 4.

Nothing in the title changes: translate --list --wave32 --validate still
emits 2,463 compute programs, and the six it refuses for tiles all have
several rows (CS_AmbientMapSky32, CS_AmbientMapSkyLocal32 and
CS_AmbientMapSkyClassified32 are 32 x 2, CS_ComputeTerrainVisibility is
6 x 6, and two are groups of several console waves). The guard now refuses
only what tiles.

Tests (emit::halves_tests):

- groups_a_host_wave_may_tile_are_refused_in_halves: 32 x 2, 64 x 4,
  32 x 2 x 2, 6 x 6 and 24 x 2 are refused; 8 x 8, 16 x 2, 4 x 4 x 4,
  64 x 1, 32 x 1 x 2, 48 x 1 x 2 and 6 x 1 x 6 translate.
- every_thread_keeps_its_own_id_in_halves_on_every_gpu: adds 32 x 1 x 2,
  48 x 1 x 2, 6 x 1 x 6 and 256 x 1 x 4. Every id is stored on both GPUs,
  in halves and, on the Radeon, as one wave64. Its program now multiplies
  (`v_mul_u32_u24`), so widths need not be powers of two.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 313 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was wrong: a write under a lane guard (EXEC narrowed, or DPP lanes
without a source lane) keeps the old value in the lanes the guard leaves
out. Where that old value was refused, the lowering keeps zero there
instead, and a phi kept that way does not count as read. On main that is
deliberate: the first half of an interpolation and barycentrics read
directly are refused values only the instruction that overwrites them
reads. In halves it turns a refusal into a wrong result. A mask read as
data, a first-lane read or a lane read refused where the halves cannot
meet, then kept by a later write, stores zero where the console stores
the value.

The random programs of the next commit found it: of 3,000, seeds 119,
2276 and 2877 read a mask's dword under a branch on a scalar compare in a
group of several console waves, and a DPP shift kept it in the lanes
without a source; seed 565 kept a lane read the same way. Each stored 0
in those lanes on the RTX 3070 Ti and the Radeon iGPU in halves, where
one wave64 stores the mask or the lane's value.

What changed (Lower::write_placed, emit/lower.rs): in halves, a guarded
write whose kept value was refused is refused with the same reason, as
lazily as every refusal (only if the written value is read), and a phi it
keeps counts as read. Elsewhere nothing changes.

Evidence: translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL gives the same
counts as before on every stage (2,463 compute, 14,258 vertex and pixel,
8,765 mesh programs emitted): no program is lost. The same rule outside
halves would lose 291 pixel programs (the interpolation cases above) and
23 mesh programs, so it stays in halves. The four seeds are now refused
with their reasons.

Tests (emit::halves_tests):

- a_kept_refused_value_refuses_the_write_in_halves: a mask read as data
  under a branch on a scalar compare, kept by a DPP shift after the join,
  is refused in a group of two console waves (the halves cannot meet
  there) and translates in a group of one. Without this change it
  translates in both.
- The module's program helpers are pub(super), for the random programs
  of the next commit.

Checks, with the next commit: cargo clippy --workspace --all-targets
--locked -- -D warnings, and with --all-features: clean. cargo xtask
policy: ok. cargo test -p victory-shader --lib -- --test-threads=1: 315
passed, 3 failed, the same 3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs grows by 395 bytes (523,591).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was missing: the halves tests are hand-written programs, one form of
each read at a time. Nothing checked the reads together, after branches
only some lanes take, in groups of several console waves, against a
reference that does not come from the same expectations.

What changed: emit::halves_random_tests generates random wave64 compute
programs (xorshift64*, from a seed) and runs each in halves on every
hardware adapter, and as one wave64 on an adapter that runs 64-lane waves
(AMD), which is the reference. Every program translated in halves must
store, lane by lane, what one wave64 stores. A refusal is fine, since it
comes with its reason; the test reports them by reason.

- The programs read across lanes at the top level: DPP16 (quad
  permutations, row shifts and rotations, mirrors, row share and xor),
  ds_swizzle_b32 in both modes, ds_bpermute_b32, v_readlane_b32 (a
  constant or an SGPR lane), v_writelane_b32, v_readfirstlane_b32, lane
  masks read as data (s_bcnt1, s_ff1, either dword, v_mbcnt over them),
  v_cndmask_b32, the console compiler's whole-wave prefix sum, and LDS
  (with the console's barriers in groups of several waves).
- They compute lane by lane in branches only some lanes take, where they
  may also write LDS, and take branches on a scalar compare.
- They are integer only, set every register before reading it, read only
  LDS that was written, and run in 1-D groups of 64, 128 or 256 threads,
  so both forms store one result each.
- VICTORY_HALVES_PROGRAMS (default 64, about 8 s) and VICTORY_HALVES_SEED
  (default 1) size a run; VICTORY_HALVES_TRACE=1 names each program and
  step as it starts. A difference names its seed and lists the program.

One driver crash shaped the generator: on the Radeon iGPU of a Ryzen 9
7900X (driver 32.0.21045.29003), a DPP read of a DPP read of a value the
same in every lane (from v_readlane_b32 or v_readfirstlane_b32) crashes
the driver's shader compiler, in the process, when it makes the one-wave64
form's pipeline. That held for every pair of quad_perm, row_shr,
row_mirror, row_share and row_xmask tried. The module validates, and the
halves form makes its pipeline and runs. So no DPP reads such a value
here.

Evidence: 6,000 programs (seeds 1-3,000 and 100,001-103,000) on an RTX
3070 Ti and that Radeon iGPU. 5,480 run in halves on both and store what
one wave64 stores, lane by lane. 520 are refused in halves: lane reads
(269) and masks read as data (211) where not every thread of the group
meets, and LDS a lane branch both writes and reads (40). Before the
previous commit, 4 of the first 3,000 stored 0 where one wave64 stores a
value: what that commit fixes.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 315 passed (the random test at
its default 64 programs among them), 3 failed, the same 3 as on main on
this NVIDIA machine; heap_direct_texture_reads_mark_their_heap_index
skipped as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lower.rs held its unit tests inline, 52 KB of the 512 KiB the asset
policy allows one file, and was 697 bytes short of that limit. They move
to emit/lower/tests.rs, beside bvh.rs and halves.rs, unchanged but for
one indent level (rustfmt), so the halves work has room for its hooks.
lower.rs goes from 523,591 to 471,189 bytes. Upstream PR #233
(r4tedx's) makes the same move for the same reason.

Checks: the 33 tests pass in their new place.

Co-Authored-By: Claude Opus 5.5
What was wrong: in halves, a lane mask read as data, a first-lane read,
a wave reduction or LDS both written and read inside a branch only some
lanes take was refused: the two host waves cannot meet there to trade or
to be put in order. Many such branches only ever take lanes of one half,
for example `if (tid < 16)` in an LDS tree reduction. There one host wave
runs alone, in the console's order, and nothing needs to cross.

What changed:

- emit/lower/confine.rs (new): per IR block not every thread meets at,
  the one half of each console wave whose lanes alone can run it. A
  block's entry condition (Structured::reach) is a decision diagram over
  atoms. Compares of a lane's position with constants are known in every
  lane: the console lane from v_mbcnt, the thread id of a group one row
  high, and simple arithmetic on them. The other atoms are left free. A
  half can run the block if some of its lanes meets the condition.
- emit/lower/halves.rs:
  - LDS that a region only one half runs both writes and reads is that
    half's own order; the barriers around the region stay.
  - A mask written there is that half's ballot, with the other half's
    dword 0.
  - A first-lane read there is that host wave's, unless a guard may leave
    EXEC empty.
  - A reduction there is that host wave's.
  - v_readlane stays refused inside branches: the lane it reads may not
    be running.
- The random programs also take branches of one half's lanes, with masks,
  first lanes and LDS reads inside.

Evidence, translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL: compute programs
emitted 2,463 -> 2,485, every new one validated and none lost. 20 are
LDS tree passes: CS_DefragHeap_Defrag, _PostDefrag and
_RelocateAllocations (2 each), CS_CullWaterPatches and
CS_CullWaterPatchesUsingCalmingInfo, CS_DenoiseShadowMaskLDS and its
packed form, CS_DotOperation, CS_BiasedDotOperation, CS_DrawBatch,
CS_Lightning_PointSelection, the CS_RelocateProjDecalTrail family (4) and
CS_RelocateVfxStartIndexLocation and its alternative. The others are
CS_GenerateShaderBinOffsets (a mask) and
CS_WaterTextureCodecGPU_DetermineMaxBucketIndex (a first lane).

Tests (emit::halves_tests):

- one_half_regions_translate_in_halves (offline): a first-lane read, a
  mask and a buffer-load first lane in a branch of the lanes below 20
  translate in groups of 64 and 128, and an LDS tree step in either half;
  the same branches below 40 (both halves) are refused.
- one_half_lds_regions_match_the_console_on_every_gpu: an LDS tree step
  in the low half (lanes below 16) and in the high half (lanes from 48),
  read across the halves after the join. 0 of 64 lanes differ from the
  console on an RTX 3070 Ti (halves) and the Radeon iGPU of a Ryzen 9
  7900X (halves and wave64).
- The branch programs of the refusal tests take a threshold; their
  refusals now use lanes below 40.
- random_wave64_programs_in_halves_match_one_wave64, 3,000 programs:
  2,772 run in halves on both GPUs and store what one wave64 stores, lane
  by lane.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 317 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs grows by 17 bytes (471,206).

Co-Authored-By: Claude Opus 5.5
What was wrong: in halves, a lane read, a first-lane read, a lane mask
read as data, a wave reduction, or LDS both written and read, inside a
branch that lanes of both halves take was refused. The halves trade at
group barriers, which every thread of the group must reach, and in the
per-lane form only the branch's lanes get there. The console's wave-wide
tests (`s_cbranch_execz`, `s_cbranch_vccz` on a ballot) become such
branches, so most of the remaining refusals were these.

What changed:

- emit/lower/wide.rs (new): wave-wide regions. A branch where every
  thread meets, whose region (the blocks before its join) has no loop, one
  way out, no end and no scalar code with effects beyond its values, can
  run wave-wide: every thread runs every block of it in reverse
  postorder. A block's lanes are those along its edges in; each vector
  instruction's guard takes them in, so a VGPR write keeps the old value
  elsewhere, memory is accessed by those lanes only, and ballots, first
  lanes and DPP source lanes see only them. The phis of the region and of
  its join pick, lane by lane, the value along the edge the lane came by.
  Every block of the region is one where every thread meets, so the halves
  trade and order LDS there as anywhere else.
- A region runs wave-wide only after an attempt at lowering was refused
  for want of a meeting at a block inside it (`wide::Plan`, in `lower`'s
  retry loop): a program that needs none is lowered as before, and one
  that does pays two group barriers per trade inside its regions and a
  select per write there. Phis a retry left missing for want of a meeting
  are tried again.
- emit/lower.rs: the hooks (guard, exit, block start, join phis, a mask's
  ballot) and a test-only count of group barriers.
- emit/lower/halves.rs: each refusal for want of a meeting names its
  block, and a refused one-wave LDS region its blocks; wave-wide blocks
  are meeting points. A first-lane read wave-wide always takes the traded
  path (lanes outside the block keep older values). A lane read of a value
  the same in every lane that holds it is the lane's own only where every
  lane holds it: inside a branch, a read of a lane outside it gave the
  branch's value where the console gives the lane's old one.

Evidence, translate --list --wave32 --validate over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL: compute programs
emitted 2,485 -> 2,542, none lost. Among them: CS_ApplyTemporalAA (2),
the mip generators (CS_Generate*Mips, 4), the tiled shadow passes
(CS_ShadowRenderTiled*, 7, CS_ShadowUnifiedClear*, 2), the shadow
denoisers (CS_DenoiseShadowMask and its packed form), the particle emitters
(CS_Emit_Static_*, 5), tile classifiers (CS_Tiling_Generate_*,
CS_MaterialTilesInitial, CS_HairTileClassify, CS_EntityFireClassify,
CS_ProjDecalClassify, CS_TileClassificationNeighborhood3x3), the trail-map
blurs (3) and the allocation-request passes (CS_*_RegisterAllocationRequests).
55 of the 57 validate; CS_DenoiseSpatial and CS_DensityShadowMapMips fail
the validator's "incompatible with the shader stage" check, as 735 compute
programs did before. With --pipelines on the RTX 3070 Ti (driver 621.24):
2,542 of 2,542 compute pipelines made, none refused. Still refused: 93 one-wave LDS regions, 59 masks, 19
first lanes and 16 reductions, nearly all in groups of one console wave,
in a region holding a loop whose exit is lane-dependent.

Tests (emit::halves_tests):

- wave_wide_regions_translate_in_halves (offline): first lanes, masks and
  lane reads in branches of both halves, a sum under a uniform branch in a
  group of two console waves, and one-wave LDS written and read or written
  twice in a branch translate; each trade costs two group barriers, and a
  region only one half runs none.
- wave_wide_regions_match_the_console_on_every_gpu: a branch of the
  console lanes from 8 or 20 that reads its first lane, a mask, lane 50 and
  a lane outside the branch (its old value), in groups of 64 and 128; a
  mask in a branch of the lanes below 40; a lane read in a branch of the
  lanes below 20; one-wave LDS written and read, or written twice, in a
  branch. 0 lanes differ from the console on an RTX 3070 Ti (halves) and
  the Radeon iGPU of a Ryzen 9 7900X (halves and wave64; reads of lanes
  outside the branch in halves only, as one wave64 reads them the way the
  host does, which D3D leaves undefined).
- The tests that showed these programs refused show them translated.
  a_kept_refused_value_refuses_the_write_in_halves keeps its refusal with
  a branch that may end the program (which cannot run wave-wide);
  lds_written_twice_in_a_branch reads its dword back and
  lds_written_and_read_in_a_branch zeroes LDS first.
- random_wave64_programs_in_halves_match_one_wave64: branches of both
  halves now hold first lanes, masks, lane reads (of lanes the branch
  takes), DPP, LDS reads and a branch inside; uniform values stay marked
  inside branches (the Radeon compiler crash), and a lane read by SGPR no
  longer overwrites the saved EXEC. 3,000 seeds: 2,998 compared, none
  refused, 0 lanes differ on either GPU; seeds 903 and 1376 crash the
  Radeon driver's shader compiler making their one-wave64 reference
  pipeline and were skipped. VICTORY_HALVES_TRACE=1 now lists each program
  as it starts.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 319 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.
lower.rs grows by 1,491 bytes (472,697).

Co-Authored-By: Claude Opus 5.5
What was missing: nothing says, operation by operation, which reads of a
console wave64 stay within a 32-lane half, which need the two host waves
to exchange values, where in a program such an exchange (a group barrier)
is legal, and what the halves do inside a branch only some lanes take.

What changed: docs/wave64-on-32-lane-hosts.md, linked from the Shaders
section of docs/architecture.md:

- the operations, with what the console does (RDNA2 ISA), what halves
  do, and the level each needs: exact within a half (DPP, ds_swizzle,
  ds_bpermute_b32 and ds_permute_b32, which wave64 permutes within each
  half, permlane16/x16, v_mbcnt, v_writelane), traded where every thread
  meets (v_readlane, v_readfirstlane of values that differ, lane masks
  read as data, whole-wave sections, LDS of a one-wave group), or inside
  a branch (one half alone, or the region run wave-wide);
- where a group barrier is legal in the per-lane form, and why waiting on
  a flag and count-paired barriers are left out;
- Level 3: regions only one half's lanes run, and wave-wide regions, with
  what makes a region eligible and what it costs;
- two console lanes per host lane, and why it is not used; why running
  the halves one after the other is not exact;
- compute programs emitted on the title at each step (2,369 with halves
  alone, 2,542 with Levels 2 and 3), what is still refused and why, and
  the census taken before Levels 2 and 3;
- the tests.

No code changes.

Co-Authored-By: Claude Opus 5.5
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 20:03 UTC · original

Thanks for isolating both calls, @⁠chippy01. I reproduced the format 115 result on an RTX 4090 (621.40) with a standalone D3D12 test using the same 2560×1440 texture, render-target flag and castable list. With GPU-based validation enabled, CreateCommittedResource3 returned E_INVALIDARG (817) with a B4G4R4A4_UNORM optimized clear and succeeded without it. The 4090 reported Support1=0x008413f0, with RENDER_TARGET clear.

I also created a B5G5R5A1_UNORM render-target view of the successful allocation and submitted a ClearRenderTargetView. The GPU completed it and the debug layer reported zero errors. The Ryzen 9 9950X3D’s Radeon iGPU (32.0.21045.29003) accepted both creation calls and the same view and clear.

That gives us a test for a separate texture fix. The title’s actual view format and the cutscene still need an in-game check.

**@⁠TaynanGT** on GitHub · 2026-11-26 20:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2633#issuecomment-7202253378) Thanks for isolating both calls, @⁠chippy01. I reproduced the format 115 result on an RTX 4090 (621.40) with a standalone D3D12 test using the same 2560×1440 texture, render-target flag and castable list. With GPU-based validation enabled, `CreateCommittedResource3` returned `E_INVALIDARG` (817) with a `B4G4R4A4_UNORM` optimized clear and succeeded without it. The 4090 reported `Support1=0x008413f0`, with `RENDER_TARGET` clear. I also created a `B5G5R5A1_UNORM` render-target view of the successful allocation and submitted a `ClearRenderTargetView`. The GPU completed it and the debug layer reported zero errors. The Ryzen 9 9950X3D’s Radeon iGPU (`32.0.21045.29003`) accepted both creation calls and the same view and clear. That gives us a test for a separate texture fix. The title’s actual view format and the cutscene still need an in-game check.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2633/head:github-bot/gh-2633'
git switch 'github-bot/gh-2633'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2633'
git switch 'github-bot/gh-2633'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2633'
git switch 'github-bot/gh-2633'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2633'
git switch 'main'
git merge --squash 'github-bot/gh-2633'
git switch 'main'
git merge --ff-only 'github-bot/gh-2633'
git switch 'main'
git merge 'github-bot/gh-2633'
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!2633
No description provided.