Skip to content

shader: fence single-wave LDS at uniform joins and reject unsafe divergent accesses - #1

Closed
erickbobd wants to merge 2 commits into
alfycs:feat/wave64-compute-emulationfrom
erickbobd:codex/vi-wave64-lds-fencing
Closed

erickbobd wants to merge 2 commits into
alfycs:feat/wave64-compute-emulationfrom
erickbobd:codex/vi-wave64-lds-fencing

Conversation

@erickbobd

Copy link
Copy Markdown

Split wave64 programs on Marvisak#189 can read LDS before the other host half has finished its write. On the exact PR head, the delayed/divergent writer fixtures return stale values on an RTX 5070 Ti and WARP.

This is a one-commit follow-up to Marvisak#189 at d0fd9bf. It adds group synchronization at proven uniform joins and exits for single-console-wave groups. Divergent regions with multiple LDS accesses and no safe checkpoint are refused conservatively, including sibling arms and early-return cases. The permanent tests also protect the already-correct same-block EXEC-guarded case.

Credit: follows marquezinii's synthetic report. Related approaches on different stacks: Marvisak#192 and Marvisak#439.

Validation on Windows 11 25H2 26200.9974, RTX 5070 Ti / NVIDIA 617.14, Rust 1.98.1, SDK 10.0.26100.0 DXIL validator; 20 readbacks per fixture/mode:

Adapter and mode Wrong on parent Wrong with fix
RTX 5070 Ti, Wave32 40/80 0/80
RTX 5070 Ti, Emulate 40/80 0/80
WARP, 4..4 lanes, Emulate 8/80 0/80
  • 7 permanent LDS tests and 46 other CPU tests passed.
  • 16 synthetic DXIL modules validated; the separated-write cases gain the missing synchronization.
  • All-target clippy with -D warnings, changed-file rustfmt, asset policy and diff checks passed.

Scope: single-wave synthetic coverage. Multi-wave groups, gameplay and performance are unverified. The refusal is deliberately conservative and can reject otherwise independent accesses. No game files, generated game shaders, captures or raw title logs are included.

AI-assisted (Codex).

alfycs and others added 2 commits November 24, 2026 02:15
Add Wave64Mode (Native, Wave32, Emulate) and TranslateOptions so Wave64 compute shaders lower and run on 32-lane GPUs (NVIDIA/Intel) and narrower hosts such as WARP instead of failing CreateComputePipelineState with E_INVALIDARG on WaveSize(64).

- Add Wave64Mode, TranslateOptions, translate_with, and emit_with while keeping translate/emit defaulting to Wave64Mode::Native.
- Resolve constant-lane SGPR spills across v_writelane_b32/v_readlane_b32 via resource::spilled_sgprs.
- Implement virtual 64-lane mapping for Wave32 (two aligned 32-lane waves) and portable LDS emulation without WAVE_OPS for narrower hosts, with post-dominator uniformity checks to reject cross-half barriers in divergent control flow rather than hanging.
- Auto-detect host wave capabilities in victory-gpu::Host (with VICTORY_WAVE64_EMULATE override and mode byte in shader_cache keys) and in victory translate --pipelines.
- Add synthetic RDNA2 compute tests (PSO validation + execution on hardware GPU and WARP).
Follow the synthetic LDS ordering case reported by marquezinii on Marvisak#189. Fence at proven uniform joins and exits, and reject unfenceable divergent accesses. Keep the native path and multi-console-wave lowering unchanged.
@alfycs
alfycs force-pushed the feat/wave64-compute-emulation branch from d0fd9bf to b472733 Compare November 24, 2026 13:20
alfycs added a commit that referenced this pull request Nov 24, 2026
…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>
@alfycs

alfycs commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Integrated cleanly (with Co-authored-by: erickbobd) into rebased feat/wave64-compute-emulation at b472733 on origin/main (ffe310e), with the 4-argument resource::track update. Thanks for the fix and tests, @erickbobd!

@alfycs alfycs closed this Nov 24, 2026
enbo1223 pushed a commit to enbo1223/VIctory that referenced this pull request Nov 24, 2026
…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 alfycs#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>
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
alfycs pushed a commit that referenced this pull request Nov 25, 2026
Exercise the descriptor cursor regression on the actual heap capacity
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
alfycs added a commit that referenced this pull request Nov 25, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants