Skip to content

Shaders: emulate Wave64 compute shaders on Wave32 and narrower hosts - #189

Open
alfycs wants to merge 19 commits into
Marvisak:mainfrom
alfycs:feat/wave64-compute-emulation
Open

alfycs wants to merge 19 commits into
Marvisak:mainfrom
alfycs:feat/wave64-compute-emulation

Conversation

@alfycs

@alfycs alfycs commented Nov 24, 2026 •

Copy link
Copy Markdown

Problem

Wave64 compute shaders that rely on lane layout (console_lanes or single-wave LDS) currently emit WaveSize(64) (PSV0 min/max = 64). On 32-lane GPUs (NVIDIA/Intel) and narrower hosts such as WARP (WaveLaneCountMin = 4), D3D12 rejects these PSOs in CreateComputePipelineState with E_INVALIDARG (0x80070057).

Related to #71, #85, #97, #3.

Summary of Changes

  • Translation modes (victory-shader::emit):
    • Added Wave64Mode (Native, Wave32, Emulate), TranslateOptions, translate_with, and emit_with. Default translate/emit keep Wave64Mode::Native.
    • Added Host::supports_wave32 and Host::recommended_wave64_mode in emit::host, and checked DXGI_ADAPTER_FLAG_SOFTWARE in Host::new(true) for WARP environments.
  • Constant-lane SGPR spill resolution (victory-shader::resource):
    • Extracted index_values and added spilled_sgprs so constant-lane v_readlane_b32 reads from v_writelane_b32 (including spills to lanes >= 32 in <= 32-thread groups) resolve directly to their scalar values or constants.
  • Wave64 lowering (victory-shader::emit::lower):
    • Wave64Mode::Wave32:
      • <= 32 threads: runs inside one native 32-lane wave with zero scratch LDS or cross-half barriers, resolving SGPR spills, zeroing the high ballot dword, and supporting <= 32-thread LDS accesses directly.
      • > 32 threads: emits WaveSize(32) when wave emulation is needed and maps each virtual 64-lane wave onto two aligned 32-lane host waves ((waveReadLaneFirst(flattenedThreadIdInGroup) & !31) + waveGetLaneIndex()). ds_swizzle_b32, DPP (with out-of-range lane indices clamped via inside and row_mask indexed by 64-lane console_lane), v_mbcnt_*, v_writelane_b32, and lane_bit execute without cross-half barriers; 64-lane ballots, Shape::Active/Shape::Prefix, uniform-block non-uniform v_readfirstlane_b32 (with empty-EXEC fallback to lane 0), and unresolved v_readlane_b32 exchange through disjoint scratch LDS slots (handling partial virtual waves and enforcing the 32 KiB / 8192-dword TGSM limit).
    • Wave64Mode::Emulate:
      • Emits wave_size = None without setting flags::WAVE_OPS, using flattenedThreadIdInGroup + TGSM + barrier(1 | 8) for ballots (atomicOr), tree reductions (Shape::Active), Hillis-Steele scans (Shape::Prefix), v_readlane_b32, v_readfirstlane_b32 (atomicMin, with lane 0 fallback when empty), ds_swizzle_b32, and DPP.
    • Deadlock / divergence & LDS fence safety:
      • Post-dominator (compute_postdoms) + group-uniformity analysis (compute_uniformity, preserving val_uniform across unguarded v_mov_b32) ensures barriers are never emitted inside divergent control flow or inside begin_guarded blocks; unsafe divergent cross-half operations fail cleanly with ShaderError::Unsupported.
      • Cross-block ballots are pre-emitted in defining uniform blocks (preemit_masks), and per-instruction ballots/guards are materialized before operand evaluation (materialize_masks).
      • For 32 < threads <= 64 (Wave32) or 1 < threads <= 64 (Emulate) accessing LDS (has_lds_mem), plan_lds_fences inserts group-uniform barrier(1 | 8) checkpoints at uniform joins/exits (lds_fences.enter / lds_fences.leave), permits multiple divergent pure LDS reads, and refuses unfenceable divergent LDS write/read or write/write conflicts cleanly (LDS accesses without a uniform LDS fence in split wave64).
  • Host integration & cache (victory-gpu, apps/victory):
    • victory-gpu::Host queries D3D12 wave capabilities on open (recommended_wave64_mode) and updates shader_cache: native 64-lane hosts use Wave64Mode::Native, while < 64-lane hosts (including 32-lane NVIDIA/Intel GPUs and WARP) default to Wave64Mode::Emulate (which still leaves non-lane-dependent shaders native without scratch LDS, while avoiding Wave32 divergent/cross-half miscompilations). VICTORY_WAVE64_EMULATE=auto|wave32|1|0 remains available as an override (with the mode byte included in cache keys).
    • victory translate --pipelines passes the host's recommended Wave64Mode via emit_with.
  • Tests (crates/victory-shader/src/emit/wave64_tests.rs):
    • Added synthetic RDNA2 translation, validator, and live D3D12/WARP GPU readback tests (running under Wave32 and Emulate, plus host capability and Native PSO rejection checks).

Trade-offs & Known Limitations

  • Translator refusal count delta vs Wave64Mode::Native: Because Native emits WaveSize(64) DXIL that passes translation even when a Wave32 host rejects it in CreateComputePipelineState (E_INVALIDARG), enabling Wave32/Emulate replaces unsafe split-wave barriers/hazards with explicit ShaderError::Unsupported refusals. On the 26,084-program corpus tested by @bittertea0323, host CreateComputePipelineState compute rejections dropped from 97 to 0, while offline translation reported +26 refusals (14× "LDS accesses without a uniform LDS fence in split wave64" and 12× "a cross-lane wave operation in divergent control flow"). Translator refusal totals before and after this PR are therefore not directly comparable without accounting for PSO rejections.
  • v_readfirstlane_b32 in divergent control flow (Wave32): Because separate 32-lane hardware warps cannot enter a group barrier inside divergent control flow without risking a GPU deadlock, emulated_readfirstlane in Wave32 returns each half's own first active lane when divergent (Emulate refuses). This is exact when the value is uniform across active lanes or in half-local waterfall iteration, but if both halves are active in divergent control flow with differing first active lane values, the upper half (32..63) observes its own first active lane rather than the lower half's (0..31) as on Wave64.

Verification

On Windows (feat/wave64-compute-emulation @ 54b333f):

  • cargo xtask policy: 155 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings -A deprecated: 0 errors, 0 warnings
  • cargo test -p victory-shader --locked -- wave64 --test-threads=1: 26 passed, 0 failed (including live GPU execution tests)
  • cargo test -p victory-gpu --locked -- --test-threads=1: 50 passed, 0 failed, 1 ignored
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- wave64 --test-threads=1: 26 passed, 0 failed

@ifBars

ifBars commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested d0fd9bf on Windows 10, RTX 3060 Ti, driver 610.88, with Agility SDK 620 exports added to the probe executable for this OS. I used four locally held compute shaders from first-story loading, including three large-group programs previously rejected by CreateComputePipelineState. On the build with #54 only the small-group program created a pipeline.

With this change, three of the four passed the Windows SDK DXIL validator and created native D3D12 compute pipelines. Two previously refused large-group shaders now work at pipeline creation. The remaining program (02384a60fda6f2d0) returned the translator diagnostic v_readfirstlane in divergent control flow at 0x1d0. This probe measured pipeline creation only.

@AKA0GHOST

Copy link
Copy Markdown

Tested on an RTX 5070 (Blackwell, 12 GB, driver 621.14, 32-lane waves only), Windows 11, diag build of d0fd9bf (main d2a4bae + this PR), own 1.0.2.1 copy.

Synthetic tests: all 14 wave64_tests pass on the hardware. I also added two lane-order probes: one console wave in 64×1×1, 8×8×1 and 4×4×4 groups, and four console waves in 256×1×1, 16×16×1 and 8×8×4 groups. The ballot count across halves and v_readlane of lane 50 come out right in both Wave32 and Emulate modes. So the (waveReadLaneFirst(flat) & !31) + lane mapping holds on Blackwell, 3-D groups included.

World run (VICTORY_D3D12_DRED=1), compared with an earlier run of main + #20 + #55 (a slightly older main, plus a local render-target view guard):

before this PR
compute pipelines refused (E_INVALIDARG) 88 0
compute shaders that do not translate 121 239
ended DEVICE_HUNG, frame 2967, 7.2 s submission DEVICE_HUNG, frame 2846, 7.7 s submission

Matching by hash: of the 88 refused before, 35 now build and 53 no longer translate. 107 shaders that translated and built before now fail with v_readfirstlane in divergent control flow (about 50) or a cross-lane wave operation in divergent control flow (about 38). That makes more dropped dispatches than before.

Likely cause: in Wave32 mode, need_emu = console_lanes || !sections.is_empty() || has_non_uniform_firstlane. On main, wave64 programs whose only lane use is a whole-wave section or a v_readfirstlane of a non-uniform value get no WaveSize and run on host waves. A waterfall loop's readfirstlane is likely still correct per 32-lane wave. This PR pulls those programs into the split form, and where the ops sit in divergent flow the check refuses the whole shader. Suggestion: refuse in divergent flow only when console_lanes is set. For programs split only because of sections or a non-uniform firstlane, fall back to the host-wave lowering (or retry without the split) instead of failing.

The world hang itself is unchanged with or without this PR.

AI-assisted (Claude Code); no game files attached.

@DaviTostes

Copy link
Copy Markdown

Tested d0fd9bf on Arch Linux x86_64, rustc 1.98.1: pass.

No game data used.

@dpalacios69

Copy link
Copy Markdown
Contributor

Validated PR #189 (d0fd9bf, clean mergeable against main d2a4bae) on a 32-lane NVIDIA Turing GPU under Linux + Wine + vkd3d-proton (AI-assisted).

Environment

  • GPU / Driver: NVIDIA GeForce GTX 1660 SUPER (Turing, 32-lane waves) / NVIDIA 620.70.06
  • Runtime: wine-11.21 (Staging) + vkd3d-proton 3.1.0 (4522cc1a8b1347f) + DXVK DXGI 2.7.1
  • Target: x86_64-pc-windows-msvc (--release)

Results

  • cargo test --release -p victory-shader --target x86_64-pc-windows-msvc: 82 passed, 2 failed, 0 ignored
    • All 14/14 emit::wave64_tests::* tests PASS on real 32-lane hardware, including all 9 emit::wave64_tests::gpu::* GPU execution tests (gpu_128_threads_cross_block_ballot_and_constant_mask, gpu_128_threads_ds_swizzle_and_dpp_row_mask, gpu_128_threads_readlane_writelane_spills_and_firstlane, gpu_64_threads_lockstep_lds_without_s_barrier, gpu_32_threads_wave32_fast_path_with_high_lane_spills, gpu_96_threads_partial_virtual_wave, gpu_128_threads_whole_wave_active_and_prefix, gpu_128_threads_uniform_loop_cross_half_ballot, gpu_64_threads_mbcnt_ballot_and_high_ff1).
    • Failures (2):
      1. emit::tests::stub_pipeline_is_created — baseline vkd3d-proton behavior (zero digest accepted).
      2. emit::host::tests::recommended_wave64_mode_matches_device_capabilities — panicked at crates/victory-shader/src/emit/host.rs:1465 (left: Wave32, right: Emulate). Under Wine + DXVK, EnumWarpAdapter is not supported and falls back to returning the first hardware adapter (DxgiFactory::EnumWarpAdapter: WARP not supported, returning first hardware adapter), so Host::new(true) opens the hardware GTX 1660 SUPER (Wave32) instead of a software WARP adapter. Checking DXGI_ADAPTER_FLAG_SOFTWARE in Host::new(true) (as victory-gpu/src/host.rs does) would avoid this false failure on Wine/DXVK.
  • cargo test --release -p victory-gpu --target x86_64-pc-windows-msvc: 40 passed, 3 failed, 1 ignored (matches main d2a4bae baseline: indirect::tests::argument_clamp_builds, pipeline::library::tests::a_rejected_blob_gives_an_empty_library, resource::tests::buffer_data_reaches_the_host_texture)
  • cargo xtask policy: PASS (asset policy: 152 files ok)

Summary

All 14 Wave64 translation and GPU execution tests pass on NVIDIA GTX 1660 SUPER (Wave32) under Wine 11.21 + vkd3d-proton 3.1.0. One minor test-harness issue: recommended_wave64_mode_matches_device_capabilities assumes EnumWarpAdapter only returns a software adapter, which fails under Wine/DXVK's hardware fallback.

No game data used.

@Vyral1978

Copy link
Copy Markdown

Tested d0fd9bf on Ampere, in the title up to the world. Pipeline refusals go away; the world hang stays, as in #71.

Setup: RTX 3070 8 GB (Ampere, 32-lane waves only), driver 610.88, i7-12700, 32 GB, Windows 11 26300. Release build of main d2a4bae + this PR, plus #40, #55, #74 and a local render-target-view guard (the one described in #71). #54 is not included: it conflicts with this PR in lower.rs and mod.rs, and this PR covers the same small-group case. Own 1.0.2.1 copy, two runs (cold, then warm shader cache).

Tests: cargo test --release -p victory-gpu -p victory-shader passes on this card, including all GPU wave64_tests (64, 96 and 128 threads, cross-half ballots, readlane/writelane, DPP row masks, the 32-thread fast path).

In the title:

d2a4bae + #40/#54/#55/#74 + this PR (no #54)
mode logged n/a wave64_mode=Wave32
compute pipelines refused (unique) 111 (0x80070057) 1 (0x8007000E, out of memory)
compute programs that do not translate (unique) 297 404
menus 30 fps 30 fps
world ~1 fps, ~64 s, then 0x887A0006 0.4–2.6 fps, ~40 s and ~44 s, then 0x887A0006
last slow host submission 5332 ms / 19 lists 5330 ms / 32 lists, 4938 ms / 31 lists

World time varies between 40 s and 2 min 20 s from run to run on this machine without any change, so I read the difference in world time as noise.

Where the refusals went: of the 111 programs refused on d2a4bae, 69 are now rejected at translation instead and about 41 build. The new translation failures (unique programs) are mostly this PR's own guards:

  • v_readfirstlane in divergent control flow is not supported: 77 (0 before)
  • a cross-lane wave operation in divergent control flow is not supported: 51 (0 before)
  • a lane mask holding lanes elsewhere read as data is not supported: +37

So on this title a large share of the wave64 compute programs still does not run on a 32-lane host, now as dropped dispatches instead of refused pipelines. That matches what others reported in #71: refusals are not what hangs the world.

No game files, captures or logs attached. AI-assisted (Claude Code).

@ifBars

ifBars commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I ran the 128-thread gpu_128_threads_ds_swizzle_and_dpp_row_mask test from this branch on Windows 10 using Agility SDK 620 and app-local Microsoft WARP 1.0.22. In the Wave32 path, WARP removed its software device. The test passes with a small change in DPP row shifts.

For the first lane of a row, row_shr:1 subtracts one before the inside predicate gets applied. The lowerer still issues the lane read for that edge. Selecting the lane's own index when inside is false before the shuffle avoids passing an out-of-range source and preserves the existing bound_ctrl and write-mask behavior. All 128 outputs matched the synthetic reference afterward. WARP also reports support for native Wave64 on this version, so the test expectation that every software adapter selects Emulate needs to follow the advertised capabilities.

Causeway change. This was software-only. Gameplay and hardware-driver effects remain unmeasured. AI-assisted testing.

@Kam471

Kam471 commented Nov 24, 2026

Copy link
Copy Markdown

Data point from an RTX 5070 Ti (D3D12 wave range 32..32), diag build, retail title:

  • With Shaders: emulate Wave64 compute shaders on Wave32 and narrower hosts #189 applied, compute pipeline refusals go from ~111 to 0; 425 compute programs translate and the title gets past the intro.
  • The remaining device removal is not compute. Every DRED stop is a mesh dispatch. The console mesh programs have FSSM flags 0x110000 (bit 5 clear = wave64); their ISA derives lane numbers with v_mbcnt_lo/hi and 64-bit EXEC. On a 32-lane host wave, lanes 32..63 get the wrong numbers, mesh output is corrupted and the device eventually hangs.
  • Mesh PSOs cannot declare WaveSize(64), so today those pipelines are refused instead of run. That avoids the hang but drops the terrain/mesh geometry.

So #189 fixes the compute half of the wave64 problem; mesh needs the same two-halves-per-console-wave emulation through groupshared memory. No game data attached, only the header flag, instruction names and counts.

@tanishq-dubey

Copy link
Copy Markdown

Independent synthetic test of head d0fd9bf4b9a2b63d303e692c82c9fc8669642cc2 on Linux x86_64 with an RTX 5090 (NVIDIA 620.70.06), Wine 11.22, vkd3d-proton 3.2.0 and DXVK 3.1.1. Cross-built the Windows victory-shader test binary and ran wave64_tests --nocapture --test-threads=1: 14 passed, 0 failed. The native-wave64 rejection messages on the 32-wide adapter were expected by the tests.

Wine/DXVK reported that EnumWarpAdapter returned a hardware adapter, so this is not an independent WARP result. DXIL validator use was not separately confirmed. No game files used in these tests. AI-assisted.

@miniongk

Copy link
Copy Markdown

Tested head d0fd9bf on Windows 11 26300, RTX 5080 (32-lane), driver 621.24, with a local 1.0.2.1 copy.

  • cargo test --workspace: 279 passed, 0 failed, 4 ignored.
  • The title selected wave64_mode=Wave32.
  • It reached the world with no host-pipeline refusal in the run, versus refusals on current main.
  • The host device was still removed with DXGI_ERROR_DEVICE_HUNG after a compute submission; 450 shader translation attempts remained unsupported, many reported as cross-lane wave operations in divergent control flow.

So this improves the Wave64 path here but does not by itself close #97. Menus and first-boot rendering remained stable. Only counts and error classes are shared. AI-assisted (Kimi Code).

@Raxstreams

Copy link
Copy Markdown

Tested the PR head at d0fd9bf with 96 distinct compute shaders whose DXIL validated but whose D3D12 compute pipelines were refused on an RTX 3080 Ti. On this PR alone, 33/96 passed both validation and pipeline creation, including all three depth-pyramid shaders. Five more created a pipeline but failed DXIL validation. Of the 58 that did not emit, 30 reported a cross-lane operation in divergent control flow, 26 reported read-first-lane in divergent control flow, and two reported byte/half LDS writes. This was an offline test of pipeline creation.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report on a machine with a 32-lane and a 64-lane adapter.

Tested

  • NVIDIA RTX 5070 (D3D12 wave range 32..32) and an AMD Radeon iGPU (RDNA2, 32..64); Windows 11; Rust 1.98.1; debug.
  • This PR at d0fd9bf, translating with TranslateOptions { wave64: host.recommended_wave64_mode() }: Wave32 on the RTX 5070, Native on the Radeon.
  • Hand-assembled wave64 GFX10 compute programs (the ones in Shaders: wave64 compute on 32-lane hosts, in halves and in the console flow #233's split_tests.rs plus two more), each lane's output checked against the console's result, five runs each with identical results:
Program (64 threads unless noted) RTX 5070 (Wave32) Radeon (Native)
ds_swizzle xor 16 + DPP row_mirror, 64 and 128 threads exact exact
s_bcnt1 of lanes below 40, 64, 48 and 32 threads exact exact
v_readlane 40 exact exact
DPP row_mask:0x3 exact exact
DPP + v_readfirstlane (all lanes active) exact exact
LDS without s_barrier: every lane writes dword t, lanes below 20 then read dword t + 40 exact exact
v_readlane 10 inside a branch only lanes below 20 take refused exact
a loop lane t runs t times with v_readlane 40 in each iteration refused wrong, as on main (#225)

The two refusals are a cross-lane read in divergent control flow, as the description says. On main the RTX 5070 creates no pipeline for any of these programs, so every exact cell in its column is new. Forcing Wave32 and Emulate on the Radeon gives the RTX 5070 column there too.

  • cargo test -p victory-shader: 84 passed, 0 failed. One caveat: the first of 15 runs of the suite hung (the wave64_tests::gpu and valu_tests GPU tests still running after 10 minutes) and was killed. Other GPU tests were running on the same machine at the time, it did not happen again in 14 further runs, and I have no cause, so treat it as an observation, not a finding.

The two refused programs are the kind #233 / #320 run in their console flow (both halves take every branch together, so an exchange inside a divergent branch or loop is reached by both). The approaches fit together: this PR's exchanges for what the whole group reaches, including groups of several console waves, LDS and reductions, which #233 does not do; the console flow for exchanges in divergent code.

Not tested: the LDS case is exact in five runs with two groups, which does not rule out a race; release build; the title (no game files used).

AI-assisted.

@noxite-four-life

Copy link
Copy Markdown

Tested on a real RTX 5070 Laptop GPU (32-lane) with a GTA VI dump. With this PR applied (on main + #205 + #334), the host logs Wave64 compute lowering mode selected wave64_mode=Wave32 and the CreateComputeShader: wave lane count of 64 … maximum … is 32 rejections drop from 112 to 0 — every previously-refused compute PSO now creates (the "compute pipelines refused" from #71). The title progresses further into the world.

The world still doesn't render yet, but for a different reason now: ~395 compute shaders still fail translation on divergent lane ops (v_readfirstlane / cross-lane wave op / select on an untracked mask in divergent control flow — looks like #320's territory), plus some vertex/pixel/mesh gaps. The Wave64 size rejection this PR fixes is fully resolved on real NVIDIA hardware. Thanks!

edsuuu pushed a commit to edsuuu/VI-BR-PORT that referenced this pull request Nov 24, 2026
A wave64 program split over two 32-lane waves took the DPP row index
from the host lane, so the upper half (console rows 2 and 3) read
row_mask bits 0 and 1. The row now comes from the console lane there.
New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only,
exact on an RTX 5070 (split) and a Radeon iGPU (native).

Found in review against #189 and #192, which both get this right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alfycs and others added 18 commits November 26, 2026 00:33
…PP, host)

Incorporate verified follow-up fixes from PR Marvisak#189 reviewers and contributors:

- Fence single-console-wave LDS accesses at group-uniform joins/exits and reject unfenceable divergent regions (fixes marquezinii's split-block stale LDS readback; from #1 by @erickbobd).
- Allow Wave32 divergent v_readfirstlane per half without LDS barriers (fixes waterfall loops / common divergent refusals reported by @AKA0GHOST and @NuraadGit), preserve ValUniform propagation across unguarded v_mov_b32 copies for uniform v_readfirstlane in divergent branches (@marquezinii), and return lane 0 when EXEC == 0 in emulated_readfirstlane.
- Clamp DPP row_shr/row_shl lane indices using inside before read_lane/exchange_64 to avoid out-of-range waveReadLaneAt on WARP 1.0.22 (@ifBars).
- Verify DXGI_ADAPTER_FLAG_SOFTWARE in shader::emit::host::Host::new(true) for Wine/DXVK (@dpalacios69, @tanishq-dubey), base recommended_wave64_mode_matches_device_capabilities on queried capabilities (@ifBars), and serialize wave64 GPU tests under valu_tests::ONE_AT_A_TIME (@r4tedx).

Co-authored-by: erickbobd <188809599+erickbobd@users.noreply.github.com>
Avoid false positives in plan_lds_fences on Wave32:

- Skip need_lds_barriers in Wave32 when total_threads <= 32 (single native host wave).
- Track reads vs writes/atomics separately in plan_lds_fences so multiple pure ds_read* instructions inside a divergent region or loop are allowed while RAW/WAW/WAR hazards remain rejected.
Log every rejected adapter and WARP in Host::all_adapters(), and print SKIPPED <test>: no SM 6.6 adapter instead of panicking on an empty host list. This makes Turing/SM 6.5 machines diagnosable instead of producing identical failures.
…on, then native

The two 64-lane emulations refuse different programs: Wave32 those with a
cross-lane operation in divergent control flow, Emulate those with a
non-uniform v_readfirstlane there. A program the asked-for lowering refuses
now tries the other one, then the native lowering; the refusal reported is
the asked-for one's. On an RTX 4050 Laptop (32 lanes) this takes the shader
pack's pipelines the host refuses from 395 (native) to 257, with the same
307 container refusals as native.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@steven-seagull27

Copy link
Copy Markdown

@alfycs @KainanP I tested the new divergent v_readfirstlane_b32 path at 3e39e34 with 40 executing lanes per virtual Wave64. The existing v0 < 32 test does not distinguish an election in the first physical Wave32 from an election across both halves on a Wave32 adapter. Test-only commit.

The 128-thread workgroup contains two guest waves. Active lanes should read group-thread ID 0 in the first guest wave and 64 in the second. Inactive lanes should retain 42. These are wrong output dwords out of 128 read back:

Adapter Emulate Explicit Wave32 Native Wave64
RTX 5080 (32..32) 16 16 Unsupported
Windows built-in WARP (4..4) 72 Unsupported Unsupported
Microsoft.Warp 1.0.22 (4..128) 48 16 0

RTX lanes 32–39 read 32 instead of 0, and lanes 96–103 read 96 instead of 64. Built-in WARP first diverged at lane 4 and app-local WARP in Emulate first diverged at lane 16. The repeated host-local election is observable in the new Emulate path even when capability filtering has chosen a supported shader. The empty-EXEC and 128-thread swizzle/DPP controls still matched on the supported modes.

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr189-divergent-readfirstlane-readback
git cherry-pick fa11afdc74a8ef7f3096a0c9f200dfc8bafb7165
cargo test -p victory-shader --lib gpu_divergent_readfirstlane_spans_host_waves -- --nocapture

The test deliberately asserts the guest result. The table comes from running each supported adapter/mode independently through the same fixture and oracle so a first failure cannot hide later cases. I'm checking whether we can elect across the guest wave before the divergent branch for this case.

@steven-seagull27

Copy link
Copy Markdown

@alfycs I opened the source fix against your current branch. Stacked PR with the readback and implementation.

Across six 128-thread dispatches, Emulate went from 48/768 wrong to zero on RTX 5080, 312/768 to zero on built-in WARP, and 208/768 to zero on Microsoft.Warp 1.0.22. Explicit Wave32 went from 48/768 to zero on both supported adapters. The suite includes both EXEC branch directions, a high-half winner and an entirely inactive guest wave. All 35 stock Wave64 tests passed.

The fix elects before the branch when the read starts the active edge and the VGPR is already available in its uniform predecessor. The separate Native Wave64 high-half control still varied on portable WARP before and after the patch. @KainanP, your Intel Wave16 result on this branch would check the one hardware width I couldn't run here.

To pick up both commits on feat/wave64-compute-emulation:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr189-firstlane-before-exec-split
git cherry-pick fa11afdc74a8ef7f3096a0c9f200dfc8bafb7165 e3b6fdbbd66e81510c777f52c05fe4a324ee9729

@postblink

Copy link
Copy Markdown

An in-game data point on Linux and NVIDIA: with this PR (3e39e34) the wave64 refusals are gone.

Setup: CachyOS (Linux 7.3.6), RTX 5080 (driver 620.73.04, 32-lane waves). GE-Proton11-14's wine run directly, with vkd3d-proton master 71cae091 in the prefix. main 63bcca4 with #2723 and #2969, then this PR, diag build, retail 1.0.2.1. No VICTORY_WAVE64_EMULATE set; the log shows Wave64 compute lowering mode selected wave64_mode=Emulate.

without #189 (main + #2723) with #189 (+ #2969)
host pipeline refused … (0x80070057) in a 30-minute run 169 0
device loss, Xid or crash none none, in a 19-minute and a 30-minute run

The runs reach the first playable section, and camera input moves the view. I can't tell you which effects looked wrong before, since the scene's lighting changed between the two runs. But the refusals that #1107 and #2725 describe on Windows NVIDIA hosts are all gone here too.

The only conflict carrying this onto main with #2723 was two #[cfg(test)] fields in Lowered (annotations from #2723, lds_dwords from here). Keeping both builds. I haven't run the shader tests on that combination.

AI-assisted (Claude), runs and numbers from my own hardware.

@gmankab

gmankab commented Nov 26, 2026 •

Copy link
Copy Markdown

I tested the original Wave64 patch on the Wine-free Linux runtime with native VKD3D-Proton. Auto-selection chose software emulation on an eight-lane Lavapipe device.

During Series S loading, fixed Wave64 pipeline rejections went from 128 to zero. The 96 fixed Wave32 rejections remained. The local native test build passed 14 cases, including nine compute readback fixtures. These results cover the original patch adapted to the native runtime.

Follow-up with Wave32. I generalized the original port to keep a separate ballot and scratch region for each 32-lane wave. The fallback applies to compute shaders that already needed a fixed wave size. Matching shader identities across two Series S loading runs, two of the original 96 host-refused Wave32 shaders built a host pipeline. Eight still required Wave32 and 86 stopped during translation because their collectives were in control flow where a group barrier could not be proven safe. The previous working compute shaders in the comparison kept translating. The native shader library suite passed 94 tests, including a two-wave readback with a partial second wave and lane-select wrapping. Native test commit

I also verified the empty-EXEC lane-zero rule and a branch controlled by an emulated first-lane read on a single virtual wave. The native shader suite passed 96 tests, and the Series S loading comparison had the same translated and rejected shader sets. The remaining divergent collectives still need a different control-flow lowering, as in #233. Native first-lane commit

Tested-on: Fedora Linux 45, Intel Xeon E5-2670 v3, Mesa Lavapipe 26.2.7, native VKD3D-Proton
Assisted-by: gpt-6.2 sol xhigh

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
@pickles976

pickles976 commented Nov 26, 2026 •

Copy link
Copy Markdown

Focused Linux/NVIDIA verification of production head 3e39e34037915da6d0f10b58b2872799bd9f3ca8: 34 passed, 0 failed, 0 ignored, 5.88s; fresh victory-shader compilation from the selected checkout took6.85s.

Environment: Linux6.17, Wine11.0, RTX4060 Laptop8GiB / NVIDIA590.48.1, DXVK3.1.1, Rust1.98.1 MSVC target. Diagnostic-relaxed vkd3d-proton3.2.0 2576c0b4adfae4a+: assertions disabled, allocator/list vtable-identity checks removed with null checks retained. This is not stock-runtime certification.

Only local source change: replace the with_hosts empty-adapter skip with an assertion, so lack of GPU execution cannot pass this verification. No production changes. DXVK_CONFIG='dxgi.hideNvidiaGpu = False', NVIDIA ICD, native d3d12/dxgi DLL overrides; selected test command:

cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-shader --lib wave64_tests -- --nocapture --test-threads=1

Shared-target worktree switch was forced fresh by touching crates/victory-shader/src/lib.rs; the compile line names VIctory-pr189. Test/build scope: MemoryMax9GiB, MemorySwapMax512MiB, 180s timeout. Preflight: availableRAM12031.3MiB, GPU233MiB, available disk19.673GiB.

The named NVIDIA adapter reports wave=(true, 32..=32) and runs [Emulate, Wave32]. Native-Wave64 negative controls produce the expected [64,64] versus [32,32] rejection; emulated dispatch readback assertions pass, including partial virtual waves, cross-block ballots, LDS ordering and masked-lane cases. The helper also labels an adapter WARP; DXGI/Wine can alias that to hardware, so I am not claiming independent software-WARP coverage.

Evidence: .compat-runtime/logs/verify-pr189-wave64.log. This is the focused fixture result, not yet a title-run/FPS or full-corpus claim. The local title previously refused the same three IDs listed in #2725 (13dfdd3b1136e407, b68f0931f1f47e61, 88994c3496045f51); guarded title verification is the next gate, leaving automatic Emulate selection intact rather than forcing the documented divergent-first-lane Wave32 compromise.

Integrated title follow-through

Ported the exact owner change onto the existing local #2945 head 3ed7d725f6895fe1a235eb6fa8ff2485261ca151 stack, retaining its verified heap-retention fix, the GPU-write notification portion of #2112, 1080p support and read-only memory counters. Mixed integration, not a pristine #189 title run; the standalone #189 checkout lacks this lab's mode/in-place support.

Before launch: combined Wave64 module34/34 (4.96s), shader-cache tests5/5 (0.03s), in-place selection8/8 (0.75s, including the three prior fail-closed pin/heap/selected-host alias gates), GPU-write alias notification1/1 (0.00s). WARP labels remain non-certifying here.

Fresh diagnostics release build41.80s. Actual100s guarded run with VICTORY_IN_PLACE=1, VICTORY_LAB_MEMORY=1, VICTORY_WAVE64_EMULATE=auto, scheduled20s confirm. Log confirms1920x1080 title size,1280x720 window fitting, and preferred mode Emulate.

All three previously refused compute IDs now translate and successfully create host pipelines:

  • b68f0931f1f47e61: host pipeline at07:33:01.214122Z
  • 13dfdd3b1136e407: host pipeline at07:33:01.226423Z
  • 88994c3496045f51: host pipeline at07:33:13.152490Z

No host pipeline refused line in this run. Ended on100s wall guard/137, not a resource stop: GPU peak3233MiB, minimum availableRAM2452.6MiB, peak scope8273.7MiB, minimum available disk19.570GiB. Last sample99.44s: scope8187.0, anon3044.3, file5088.3 including shmem4159.7MiB.

Evidence prefix .compat-runtime/logs/20261126T073143Z; build wrapper log verify-pr2945-wave64-title.log. No visual/gameplay/FPS claim: my separately scheduled capture started too late and found no client after the guarded stop. The automatic mode can also fall back to Wave32; this does not remove the documented divergent-first-lane correctness caveat. Resource ceilings and diagnostic-relaxed-vkd3d caveat are unchanged.

AI use: omp, harness model openai-codex/gpt-6-astra, ran these checks and drafted this report. No upstream code changes.

Visual follow-through

Reused that same verified binary/source, unchanged settings and100s guard, with screenshot timers anchored inside the launcher. Run 20261126T073953Z: actual45/85/95s client captures all show loading artwork, not gameplay. All three compute host pipelines again created; zero host-pipeline refusals. Wall stop100s/137, GPUpeak3233MiB, minimum availableRAM2492.6MiB, peak scope8665.0MiB, minimum available disk19.488GiB. No stock-vkd3d, world-entry or FPS certification.

The existing descriptor-cap issue remains:310720 title slot past the host heap warnings. This run establishes the real-title pipeline improvement without claiming it solves loading completion. No title content attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.