shader: static Wave32 LDS hazard analysis for branched/disjoint compute (vitutu1#12 handover) #50

Open
github-bot wants to merge 2 commits from github-bot/gh-50 into beta AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-25 21:26 UTC · original
Vladimir-Human:shader/wave32-lds-disjoint → beta · +3441 −110 · 4 files · 2 commits · open

Summary

AI-assisted handover of upstream vitutu1/victory-perf work (specifically original PR #12, since that repository is now unavailable) onto PastiiJay/klbf-lab beta, with additional adversarial soundness hardening.

Instead of blindly falling back to emulated 64-lane subgroup execution (wave64) whenever LDS (ds_*) operations appear under conditional branches or per-lane offsets, this PR adds static Wave32 LDS alias/hazard proof analysis (crates/victory-shader/src/emit/lds.rs) so proven-safe compute shaders run natively in Wave32 on NVIDIA and other 32-wide GPUs.

Key Details & Soundness Hardening

  • Refinement A (Disjoint constant byte ranges): Proves cross-lane accesses on a shared group-uniform base use disjoint byte ranges within non-wrapping MAX_OFFSET = 1 MiB 32-bit bounds (including <4-byte unaligned vs >=4-byte dword overlap guards, zero RMWs, acyclic !all regions, symmetric RAW/WAR/WAW).
  • Refinement B (Injective per-lane private slots): Proves lane-private slots remain injective across all active workgroup dimensions and paired v_mbcnt console_lane for group <= 64, alignment, sub-array splitting, non-wrapping group footprints, cross-cluster disjointness, and returning atomics / cyclic !all.
  • Adversarial hardening added before handover:
    • Primary 1-dword dst verification in eval_inst, uniform_result_tz, and is_group_uniform_val (rejects VOP3B v.carry / Reg::Scc confusion).
    • Tightened SGPR input uniformity (c < cs.user_sgprs() + Input::GroupId, refusing scratch_wave_offset and uninitialized SGPRs).
    • Refuses execution refinement if any !all region contains s_barrier.
    • Refuses non-inline SOP special constants (c != 253) and Operand::Attr as group-uniform.

Verification (0948a4fd5)

  • cargo clippy -p victory-shader --all-targets -- -D warnings: exit 0, 0 warnings.
  • VICTORY_REQUIRE_HW_GPU=1 cargo test -p victory-shader --lib lds -- --nocapture: 19 passed; 0 failed (all 13 emit::lds::tests::*, lds_shared_returning_atomic_stays_wave64, and 3 hardware D3D12 Wave32 execution tests ran with no skip).
  • cargo test -p victory-shader --all-targets: 241 passed; 0 failed; 3 ignored.

Co-Authored-By: AI Assistant

**@⁠Vladimir-Human** on GitHub · 2026-11-25 21:26 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50) `Vladimir-Human:shader/wave32-lds-disjoint` → `beta` · +3441 −110 · 4 files · 2 commits · open ## Summary AI-assisted handover of upstream `vitutu1/victory-perf` work (specifically original PR #12, since that repository is now unavailable) onto `PastiiJay/klbf-lab` `beta`, with additional adversarial soundness hardening. Instead of blindly falling back to emulated 64-lane subgroup execution (`wave64`) whenever LDS (`ds_*`) operations appear under conditional branches or per-lane offsets, this PR adds static Wave32 LDS alias/hazard proof analysis (`crates/victory-shader/src/emit/lds.rs`) so proven-safe compute shaders run natively in Wave32 on NVIDIA and other 32-wide GPUs. ### Key Details & Soundness Hardening - **Refinement A (Disjoint constant byte ranges)**: Proves cross-lane accesses on a shared group-uniform base use disjoint byte ranges within non-wrapping `MAX_OFFSET = 1 MiB` 32-bit bounds (including `<4`-byte unaligned vs `>=4`-byte dword overlap guards, zero RMWs, acyclic `!all` regions, symmetric RAW/WAR/WAW). - **Refinement B (Injective per-lane private slots)**: Proves lane-private slots remain injective across all active workgroup dimensions and paired `v_mbcnt` `console_lane` for `group <= 64`, alignment, sub-array splitting, non-wrapping group footprints, cross-cluster disjointness, and returning atomics / cyclic `!all`. - **Adversarial hardening added before handover**: - Primary 1-dword `dst` verification in `eval_inst`, `uniform_result_tz`, and `is_group_uniform_val` (rejects VOP3B `v.carry` / `Reg::Scc` confusion). - Tightened SGPR input uniformity (`c < cs.user_sgprs()` + `Input::GroupId`, refusing `scratch_wave_offset` and uninitialized SGPRs). - Refuses execution refinement if any `!all` region contains `s_barrier`. - Refuses non-inline SOP special constants (`c != 253`) and `Operand::Attr` as group-uniform. ### Verification (`0948a4fd5`) - `cargo clippy -p victory-shader --all-targets -- -D warnings`: exit 0, 0 warnings. - `VICTORY_REQUIRE_HW_GPU=1 cargo test -p victory-shader --lib lds -- --nocapture`: **19 passed; 0 failed** (all 13 `emit::lds::tests::*`, `lds_shared_returning_atomic_stays_wave64`, and 3 hardware D3D12 Wave32 execution tests ran with no skip). - `cargo test -p victory-shader --all-targets`: **241 passed; 0 failed; 3 ignored**. Co-Authored-By: AI Assistant
Replace the coarse read-plus-write refusal in divergent `!all` regions with
static LDS alias and hazard analysis (`emit/lds.rs`) when lowering Wave64
compute shaders to 32-lane host waves:
- Refinement A (disjoint byte ranges on a shared group-uniform base,
  non-wrapping bounds, zero RMW self-overlap, zero RAW/WAR/WAW overlap,
  acyclic `!all` regions only).
- Refinement B (lane-private per-thread slots injective across active group
  dimensions with alignment and cross-cluster footprint disjointness,
  supporting returning atomics and cyclic `!all` regions).
- Conservative refusal for unknown DS ops, `s_barrier` inside `!all`
  regions, non-uniform scalar CFG/SOP/SMEM sources (including non-inline
  SOP special constants, `scratch_wave_offset`/uninitialized SGPRs, and
  multi-write VALU carry-out outputs), shift/wrap overflow, half-only
  `v_mbcnt`, and shared WAW cycles.
- Add unit soundness coverage in `emit/lds.rs` and hardware D3D12 Wave32
  execution tests in `emit/wave64_tests.rs`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:53:36 +00:00
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 21:28 UTC · original

Thanks a lot @⁠Vladimir-Human, and thank you for bringing the original vitutu1/victory-perf #12 work over, with credit, now that its repository is gone. What we keep: instead of falling back to emulated 64-lane execution whenever LDS accesses sit under branches or per-lane offsets, the shader translator now proves which compute shaders are safe to run natively in Wave32, and refuses the cases it can't prove (barriers in divergent regions, returning atomics, unproven uniform inputs). The 19 LDS tests, including 3 on real D3D12 hardware, and the full victory-shader suite pass on your side.

This is a large change (+3,056 lines) to how compute shaders are translated, so it will get a run of its own on the RX 9070 XT: same save, same run, fps and picture against our reference build, since a wrong proof would show up as image errors rather than a crash. Results will be posted here. The NVIDIA testers from #30 would be the best people to measure the Wave32 gain itself, if any of them has time.

**@⁠PastiiJay** on GitHub · 2026-11-25 21:28 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7175122468) Thanks a lot @⁠Vladimir-Human, and thank you for bringing the original vitutu1/victory-perf #12 work over, with credit, now that its repository is gone. What we keep: instead of falling back to emulated 64-lane execution whenever LDS accesses sit under branches or per-lane offsets, the shader translator now proves which compute shaders are safe to run natively in Wave32, and refuses the cases it can't prove (barriers in divergent regions, returning atomics, unproven uniform inputs). The 19 LDS tests, including 3 on real D3D12 hardware, and the full `victory-shader` suite pass on your side. This is a large change (+3,056 lines) to how compute shaders are translated, so it will get a run of its own on the RX 9070 XT: same save, same run, fps **and** picture against our reference build, since a wrong proof would show up as image errors rather than a crash. Results will be posted here. The NVIDIA testers from #30 would be the best people to measure the Wave32 gain itself, if any of them has time.
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-25 21:33 UTC · original

The Windows SDK DXIL validator accepted all three new Wave32 fixtures at 0948a4f, both on this PR alone and after merging the shader optimizer from #41 (ba88ab0). The 16 other tests selected by lds passed in both builds. On Linux, the shader library suite passed 189 tests, with two ignored. Windows validation log for both revisions

One limit for anyone reproducing this in hosted Windows CI: the runner’s WARP adapter reported a maximum wave width of 4. D3D12 rejected all three 32-lane pipelines at creation, before any dispatch. The log distinguishes that from a rejected DXIL blob. The three execution results in the PR description are the author’s physical-GPU results.

**@⁠HandshakeHackin** on GitHub · 2026-11-25 21:33 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7175235006) The Windows SDK DXIL validator accepted all three new Wave32 fixtures at `0948a4f`, both on this PR alone and after merging the shader optimizer from #41 (`ba88ab0`). The 16 other tests selected by `lds` passed in both builds. On Linux, the shader library suite passed 189 tests, with two ignored. [Windows validation log for both revisions](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45704936757/job/139524389316) One limit for anyone reproducing this in hosted Windows CI: the runner’s WARP adapter reported a maximum wave width of **4**. D3D12 rejected all three 32-lane pipelines at creation, before any dispatch. The log distinguishes that from a rejected DXIL blob. The three execution results in the PR description are the author’s physical-GPU results.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 21:34 UTC · original

Thanks @⁠HandshakeHackin, that's a very useful split. What we keep: the DXIL validator accepts all three new Wave32 fixtures, both on this PR alone and combined with the #41 shader optimizer, and the other LDS tests pass in both; on hosted CI, WARP only offers a wave width of 4, so the 32-lane pipelines can't be created there at all, and the execution results rest on real GPUs.

That makes our RX 9070 XT run the first independent execution check on hardware. We'll post it here, picture and fps.

**@⁠PastiiJay** on GitHub · 2026-11-25 21:34 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7175252898) Thanks @⁠HandshakeHackin, that's a very useful split. What we keep: the DXIL validator accepts all three new Wave32 fixtures, both on this PR alone and combined with the #41 shader optimizer, and the other LDS tests pass in both; on hosted CI, WARP only offers a wave width of 4, so the 32-lane pipelines can't be created there at all, and the execution results rest on real GPUs. That makes our RX 9070 XT run the first independent execution check on hardware. We'll post it here, picture and fps.
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-26 07:11 UTC · original

Tested this PR on an RTX 4080 16 GB / Windows 10 in GTA 6 (--console series-s, 10-minute runs, integrated alongside VICTORY_LDS_FLAGS / lds_flag_region inside lds::meetings):

Results

  • Unit tests: 21/21 lds + wave64_tests pass cleanly.
  • Real GTA 6 shader refusal regression on NVIDIA (6 → 10 refused compute pipelines, 0x80070057):
    • Baseline (lds_meetings + VICTORY_LDS_FLAGS, 6 refused):
      2da4beb386509b77, 369cbe906ea72764, 02384a60fda6f2d0, 6b82bc7d22016cb5, 5dc3b25986622949, 6f225b641c5b0708
    • With #50 (10 refused — same 6 PLUS 4 newly refused):
      • 89d08e561897d4e5 (one of the character skinning passes noted in card_steps.rs!)
      • 55679a0547649d0b (another skinning pass noted in card_steps.rs!)
      • 1f1fbd86759b3da2
      • caf96a3229145fa6

Root Cause

In lds.rs (else if writes[r] && !has_rmw[r]), the stricter has_provable_shared_waw / region_has_cycle write-only check refuses write-only branched LDS regions that upstream lds_meetings previously allowed in Wave32 (upstream explicitly carried shortcut: two writes in one region are taken not to hit the same dword from both halves). On Wave32 GPUs (NVIDIA), refusing those 4 shaders sends them back to WaveSize(64), causing CreateComputePipelineState to fail with E_INVALIDARG and dropping their dispatches completely (including two skinning shaders).

Keeping lds::meetings's exact read+write proofs (Refinement A/B) while relaxing write-only non-RMW regions (or gating the stricter write-only refusal behind a switch on 32-lane hosts) would avoid regressing those 4 GTA 6 compute passes on NVIDIA.

**@⁠Proudnoob4** on GitHub · 2026-11-26 07:11 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7185191820) Tested this PR on an **RTX 4080 16 GB / Windows 10** in GTA 6 (`--console series-s`, 10-minute runs, integrated alongside `VICTORY_LDS_FLAGS` / `lds_flag_region` inside `lds::meetings`): ### Results - **Unit tests:** 21/21 `lds` + `wave64_tests` pass cleanly. - **Real GTA 6 shader refusal regression on NVIDIA (`6 → 10` refused compute pipelines, `0x80070057`):** - **Baseline (`lds_meetings` + `VICTORY_LDS_FLAGS`, 6 refused):** `2da4beb386509b77`, `369cbe906ea72764`, `02384a60fda6f2d0`, `6b82bc7d22016cb5`, `5dc3b25986622949`, `6f225b641c5b0708` - **With `#50` (10 refused — same 6 PLUS 4 newly refused):** - `89d08e561897d4e5` *(one of the character skinning passes noted in `card_steps.rs`!)* - `55679a0547649d0b` *(another skinning pass noted in `card_steps.rs`!)* - `1f1fbd86759b3da2` - `caf96a3229145fa6` ### Root Cause In `lds.rs` (`else if writes[r] && !has_rmw[r]`), the stricter `has_provable_shared_waw` / `region_has_cycle` write-only check refuses write-only branched LDS regions that upstream `lds_meetings` previously allowed in Wave32 (upstream explicitly carried `shortcut: two writes in one region are taken not to hit the same dword from both halves`). On Wave32 GPUs (NVIDIA), refusing those 4 shaders sends them back to `WaveSize(64)`, causing `CreateComputePipelineState` to fail with `E_INVALIDARG` and dropping their dispatches completely (including two skinning shaders). Keeping `lds::meetings`'s exact read+write proofs (`Refinement A/B`) while relaxing write-only non-RMW regions (or gating the stricter write-only refusal behind a switch on 32-lane hosts) would avoid regressing those 4 GTA 6 compute passes on NVIDIA.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 07:14 UTC · original

Good catch, that is a real regression on 32-lane cards: 4 more compute pipelines refused (including two skinning passes) because the stricter write-only check sends them back to wave 64. Noted for this PR together with your suggested fix (keep the read+write proofs, relax or gate the write-only refusal on 32-lane hosts).

**@⁠PastiiJay** on GitHub · 2026-11-26 07:14 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7185239927) Good catch, that is a real regression on 32-lane cards: 4 more compute pipelines refused (including two skinning passes) because the stricter write-only check sends them back to wave 64. Noted for this PR together with your suggested fix (keep the read+write proofs, relax or gate the write-only refusal on 32-lane hosts).
Author
Owner

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

Follow-up from testing the fix live on RTX 4080 16 GB (Windows 10, Series S) — important detail before you patch this PR:

Relaxing only the else if writes[r] && !has_rmw[r] branch was not enough: all 4 of those shaders (89d08e561897d4e5, 55679a0547649d0b, 1f1fbd86759b3da2, caf96a3229145fa6) were still refused (0x80070057) in our Pass 8/9 10-minute runs.

Root cause

In lds.rs:

  • record_kind() sets both reads[r] = true and writes[r] = true (plus has_rmw[r] = true) for Kind::Rmw (LDS atomics).
  • Upstream lds_meetings only set reads[r] = true on name.starts_with("ds_read") — any non-ds_read LDS instruction (including atomics) only set writes[r] = true.
  • Because those 4 shaders have LDS atomics with no ds_read* in the !all region, reads[r] && writes[r] became true and skipped the write-only branch entirely.

Verified fix

Track has_plain_read: Vec<bool> (set only when kind == Kind::Read), and when opt-in VICTORY_LDS_WRITE_ONLY_OK=1 is active on 32-lane hosts, accept reads[r] && writes[r] when !has_plain_read[r] (and keep the relaxed write-only branch):

  • Unit tests (default / env unset): all 21/21 emit::lds::tests still pass unchanged (including atomics_are_rmw_and_require_lane_privacy).
  • Live RTX 4080 verification (Pass 10, currently running): all 4 shaders translated and bound cleanly as Wave32 host pipelines:
    • 89d08e561897d4e5 — passed
    • 55679a0547649d0b — passed
    • 1f1fbd86759b3da2 — passed
    • caf96a3229145fa6 — passed
**@⁠Proudnoob4** on GitHub · 2026-11-26 08:08 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7186234129) Follow-up from testing the fix live on **RTX 4080 16 GB (Windows 10, Series S)** — important detail before you patch this PR: Relaxing **only** the `else if writes[r] && !has_rmw[r]` branch was **not** enough: all 4 of those shaders (`89d08e561897d4e5`, `55679a0547649d0b`, `1f1fbd86759b3da2`, `caf96a3229145fa6`) were **still** refused (`0x80070057`) in our Pass 8/9 10-minute runs. ### Root cause In `lds.rs`: - `record_kind()` sets **both** `reads[r] = true` **and** `writes[r] = true` (plus `has_rmw[r] = true`) for `Kind::Rmw` (LDS atomics). - Upstream `lds_meetings` only set `reads[r] = true` on `name.starts_with("ds_read")` — any non-`ds_read` LDS instruction (including atomics) only set `writes[r] = true`. - Because those 4 shaders have LDS atomics with **no** `ds_read*` in the `!all` region, `reads[r] && writes[r]` became `true` and skipped the write-only branch entirely. ### Verified fix Track `has_plain_read: Vec<bool>` (set **only** when `kind == Kind::Read`), and when opt-in `VICTORY_LDS_WRITE_ONLY_OK=1` is active on 32-lane hosts, accept `reads[r] && writes[r]` when `!has_plain_read[r]` (and keep the relaxed write-only branch): - **Unit tests (default / env unset):** all `21/21` `emit::lds::tests` still pass unchanged (including `atomics_are_rmw_and_require_lane_privacy`). - **Live RTX 4080 verification (Pass 10, currently running):** **all 4** shaders translated and bound cleanly as Wave32 host pipelines: - `89d08e561897d4e5` — passed - `55679a0547649d0b` — passed - `1f1fbd86759b3da2` — passed - `caf96a3229145fa6` — passed
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-26 08:16 UTC · original

On 0948a4f, VICTORY_WAVE_WHY=1 prints “an LDS read and write in one lane-branch region” even for two plain writes to the same dword, with no read in the shader.

I put a diagnostic patch on top of this PR. It reports which check kept Wave64 and distinguishes a write/write overlap, an atomic with no plain LDS read, and a mixed region with an explicit read. A shared-address atomic with and without an explicit read still chose Wave64 in both tests. The lane-private atomic still chose Wave32. The before/after log checks and the full shader library suite passed. Diagnostic patch · CI and emitted messages

In a separate four-kernel check, relaxing only the write/write guard changed just the same-dword write-only case (64 → 32). Separate writes stayed at 32, overlapping reads/writes stayed at 64, and a read disjoint from both writes stayed at 32. This was synthetic shader lowering. @⁠Proudnoob4’s Pass 10 above is the hardware evidence for the four game shaders. Four-kernel comparison

**@⁠HandshakeHackin** on GitHub · 2026-11-26 08:16 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7186399134) On `0948a4f`, `VICTORY_WAVE_WHY=1` prints “an LDS read and write in one lane-branch region” even for two plain writes to the same dword, with no read in the shader. I put a diagnostic patch on top of this PR. It reports which check kept Wave64 and distinguishes a write/write overlap, an atomic with no plain LDS read, and a mixed region with an explicit read. A shared-address atomic with and without an explicit read still chose Wave64 in both tests. The lane-private atomic still chose Wave32. The before/after log checks and the full shader library suite passed. [Diagnostic patch](https://github.com/HandshakeHackin/klbf-lab/compare/0948a4fd56d97548e0b746ae3c9b4bcbb881032e...455f4b1eccf2d58f9ad7787919858872f4c04193) · [CI and emitted messages](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45781436302/job/139777597682) In a separate four-kernel check, relaxing only the write/write guard changed just the same-dword write-only case (64 → 32). Separate writes stayed at 32, overlapping reads/writes stayed at 64, and a read disjoint from both writes stayed at 32. This was synthetic shader lowering. @⁠Proudnoob4’s Pass 10 above is the hardware evidence for the four game shaders. [Four-kernel comparison](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45780138547/job/139773324258)
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 09:46 UTC · original

Thank you @⁠Proudnoob4, @⁠HandshakeHackin, and @⁠PastiiJay for the live hardware testing, root-cause isolation, and diagnostic checks! Pushed follow-up commit 4fa24ff addressing both findings:

  1. 32-lane opt-in VICTORY_LDS_WRITE_ONLY_OK=1 + has_plain_read (emit/lds.rs):

    • record_kind() now tracks has_plain_read strictly on Kind::Read (ds_read*), separate from Kind::Rmw (LDS atomics).
    • Added lds_write_only_ok(), gated strictly on host_max_wave() == 32 and VICTORY_LDS_WRITE_ONLY_OK=1 (always off by default and always disabled on 64-lane hosts).
    • When active on 32-lane hosts, !all regions with no plain ds_read* (write-only non-RMW regions and shared/unproven LDS atomics without a plain LDS read, matching the 4 newly refused compute shaders @Proudnoob4 verified on RTX 4080) are accepted for Wave32. Divergent s_barrier, unhandled DS ops (ds_nop, GDS, etc.), and mixed regions with an explicit plain ds_read* (has_plain_read == true) remain refused. Default behavior when unset is unchanged.
  2. Specific VICTORY_WAVE_WHY=1 refusal diagnostics (emit/lds.rs, emit/lower.rs):

    • Replaced the single generic "an LDS read and write in one lane-branch region" message with typed lds::Refusal variants returned by lds::analyze(...) and reused directly by log_wave64_why (no redundant analysis pass):
      • Write/write overlap: "overlapping LDS writes in one lane-branch region"
      • Atomic with no plain LDS read: "an LDS atomic with no plain LDS read in one lane-branch region"
      • Mixed region with explicit plain ds_read*: "an LDS read and write in one lane-branch region"
      • Divergent barrier / unhandled DS op / cyclic shared write each report their own specific reason.
  3. Verification:

    • Added unit tests covering shared atomics with/without plain ds_read* (default vs VICTORY_LDS_WRITE_ONLY_OK=1 on 32-lane and 64-lane hosts), all four synthetic lowering kernels (same-dword write-only 64 -> 32 under flag, separate writes 32, overlapping read+write 64, read disjoint from both writes 32), negative s_barrier/ds_nop checks under the flag, and exact VICTORY_WAVE_WHY reason strings.
    • cargo test -p victory-shader -- --test-threads=4: 243 passed; 0 failed; 3 ignored (including the 3 hardware D3D12 Wave32 LDS execution tests).
    • cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.
**@⁠Vladimir-Human** on GitHub · 2026-11-26 09:46 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7188462221) Thank you @⁠Proudnoob4, @⁠HandshakeHackin, and @⁠PastiiJay for the live hardware testing, root-cause isolation, and diagnostic checks! Pushed follow-up commit `4fa24ff` addressing both findings: 1. **32-lane opt-in `VICTORY_LDS_WRITE_ONLY_OK=1` + `has_plain_read` (`emit/lds.rs`):** - `record_kind()` now tracks `has_plain_read` strictly on `Kind::Read` (`ds_read*`), separate from `Kind::Rmw` (LDS atomics). - Added `lds_write_only_ok()`, gated strictly on `host_max_wave() == 32` **and** `VICTORY_LDS_WRITE_ONLY_OK=1` (always off by default and always disabled on 64-lane hosts). - When active on 32-lane hosts, `!all` regions with no plain `ds_read*` (write-only non-RMW regions and shared/unproven LDS atomics without a plain LDS read, matching the 4 newly refused compute shaders `@Proudnoob4` verified on RTX 4080) are accepted for Wave32. Divergent `s_barrier`, unhandled DS ops (`ds_nop`, GDS, etc.), and mixed regions with an explicit plain `ds_read*` (`has_plain_read == true`) remain refused. Default behavior when unset is unchanged. 2. **Specific `VICTORY_WAVE_WHY=1` refusal diagnostics (`emit/lds.rs`, `emit/lower.rs`):** - Replaced the single generic `"an LDS read and write in one lane-branch region"` message with typed `lds::Refusal` variants returned by `lds::analyze(...)` and reused directly by `log_wave64_why` (no redundant analysis pass): - Write/write overlap: `"overlapping LDS writes in one lane-branch region"` - Atomic with no plain LDS read: `"an LDS atomic with no plain LDS read in one lane-branch region"` - Mixed region with explicit plain `ds_read*`: `"an LDS read and write in one lane-branch region"` - Divergent barrier / unhandled DS op / cyclic shared write each report their own specific reason. 3. **Verification:** - Added unit tests covering shared atomics with/without plain `ds_read*` (default vs `VICTORY_LDS_WRITE_ONLY_OK=1` on 32-lane and 64-lane hosts), all four synthetic lowering kernels (same-dword write-only 64 -> 32 under flag, separate writes 32, overlapping read+write 64, read disjoint from both writes 32), negative `s_barrier`/`ds_nop` checks under the flag, and exact `VICTORY_WAVE_WHY` reason strings. - `cargo test -p victory-shader -- --test-threads=4`: **243 passed; 0 failed; 3 ignored** (including the 3 hardware D3D12 Wave32 LDS execution tests). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: **0 warnings**.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 10:41 UTC · original

Thanks @⁠Vladimir-Human, keeping the new behaviour opt-in on 32-lane cards is the right call. We'll try VICTORY_LDS_WRITE_ONLY_OK=1 in game on our Radeon as well.

**@⁠PastiiJay** on GitHub · 2026-11-26 10:41 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7189714494) Thanks @⁠Vladimir-Human, keeping the new behaviour opt-in on 32-lane cards is the right call. We'll try `VICTORY_LDS_WRITE_ONLY_OK=1` in game on our Radeon as well.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 12:50 UTC · original

@⁠Vladimir-Human, data from @⁠seth1295 on an RTX 2080, head of this PR with VICTORY_WAVE_WHY=1 but without the opt-in (logs in #65, shader hashes redacted): 11 compute pipelines refused with 0x80070057, against 7 on current beta. The most frequent WAVE64-WHY reasons are 64-thread groups with "an LDS read and write in one lane-branch region" or "an LDS atomic with no plain LDS read in one lane-branch region", often with mask as data, v_mbcnt or v_readlane. He will rerun with VICTORY_LDS_WRITE_ONLY_OK=1 and unredacted hashes after the weekend.

**@⁠PastiiJay** on GitHub · 2026-11-26 12:50 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7192539839) @⁠Vladimir-Human, data from @⁠seth1295 on an RTX 2080, head of this PR with `VICTORY_WAVE_WHY=1` but without the opt-in (logs in #65, shader hashes redacted): 11 compute pipelines refused with `0x80070057`, against 7 on current beta. The most frequent WAVE64-WHY reasons are 64-thread groups with "an LDS read and write in one lane-branch region" or "an LDS atomic with no plain LDS read in one lane-branch region", often with `mask as data`, `v_mbcnt` or `v_readlane`. He will rerun with `VICTORY_LDS_WRITE_ONLY_OK=1` and unredacted hashes after the weekend.
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 19:19 UTC · original

Thanks @⁠PastiiJay and @⁠seth1295 — that 11 vs 7 delta without VICTORY_LDS_WRITE_ONLY_OK=1 matches the stricter default in 4fa24ff: beta only refused regions with both a plain ds_read* and a write, whereas AtomicWithoutPlainRead now conservatively catches unguarded LDS atomics with no plain ds_read* until proven lane-private or opted in.
Rerunning with VICTORY_LDS_WRITE_ONLY_OK=1 and unredacted hashes after the weekend will cleanly isolate those cases from genuine ReadWriteOverlap hazards.

**@⁠Vladimir-Human** on GitHub · 2026-11-26 19:19 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7201450499) Thanks @⁠PastiiJay and @⁠seth1295 — that 11 vs 7 delta without `VICTORY_LDS_WRITE_ONLY_OK=1` matches the stricter default in `4fa24ff`: `beta` only refused regions with both a plain `ds_read*` and a write, whereas `AtomicWithoutPlainRead` now conservatively catches unguarded LDS atomics with no plain `ds_read*` until proven lane-private or opted in. Rerunning with `VICTORY_LDS_WRITE_ONLY_OK=1` and unredacted hashes after the weekend will cleanly isolate those cases from genuine `ReadWriteOverlap` hazards.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 19:26 UTC · original

Thanks @⁠Vladimir-Human, that explains the 11 vs 7 gap neatly. We'll leave the default as it is for now and post seth1295's opt-in rerun here as soon as it lands, so the AtomicWithoutPlainRead cases can be sorted one by one.

**@⁠PastiiJay** on GitHub · 2026-11-26 19:26 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/50#issuecomment-7201594011) Thanks @⁠Vladimir-Human, that explains the 11 vs 7 gap neatly. We'll leave the default as it is for now and post seth1295's opt-in rerun here as soon as it lands, so the `AtomicWithoutPlainRead` cases can be sorted one by one.
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/50/head:github-bot/gh-50'
git switch 'github-bot/gh-50'

Merge

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