Shaders: refuse side effects in whole-wave sections #2872

Open
yumaste wants to merge 4 commits from upstream-pr/2874 into main
yumaste commented 2026-11-25 22:54:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-25T22:54:25Z.


Summary

The whole-wave simulator reconstructs values that leave a section. Before this change, the shader translator could accept a section containing an effect such as an s_barrier or a buffer store and emit the same DXIL as if that instruction were absent.

Use the regular lowering path's side-effect classification for instructions inside the section and reject an effect with its byte offset. This includes buffer and global loads that write to LDS. Also reject structured pixel discards inside the section, since the normal discard emission would be skipped there.

#2886 preserves rounding-mode writes in whole-wave sections. A trial merge with #2771 and #2886 onto main passed. Their decoder and rounding-mode fixes both remain in the merged tree.

Validation

  • A synthetic compute regression covers both s_barrier and buffer_store_dword. Before the fix, putting either instruction inside the section produced byte-identical DXIL to omitting it. With the fix, both are rejected at the expected offset. Both still translate outside the section.
  • Follow-up at 6b906eb: regressions cover buffer/global loads into LDS and a structured discard annotation supplied directly to lowering. With #2771 and #2886 merged locally, all 37 lowering tests and the FP16 rounding regression passed under WARP. Clippy with all targets and features passed. Moving the whole-wave regressions to their own module brought the merged emit/lower.rs to 522,717 bytes, below the 524,288-byte asset-policy limit.
  • The original full victory-shader library suite with VICTORY_WARP=1 reported 299 passed, 4 failed, and 3 ignored. The same four tests failed with the same diagnostics on base commit 842b0cb: three wave32 pipeline failures and one texture gather mismatch.
  • Clippy for victory-shader with all targets and features and -D warnings passed. The staged asset policy check passed.

AI-assisted (Codex). Only synthetic fixtures were used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6615417377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-25T22:54:25Z. --- ## Summary The whole-wave simulator reconstructs values that leave a section. Before this change, the shader translator could accept a section containing an effect such as an `s_barrier` or a buffer store and emit the same DXIL as if that instruction were absent. Use the regular lowering path's side-effect classification for instructions inside the section and reject an effect with its byte offset. This includes buffer and global loads that write to LDS. Also reject structured pixel discards inside the section, since the normal discard emission would be skipped there. #2886 preserves rounding-mode writes in whole-wave sections. A trial merge with #2771 and #2886 onto `main` passed. Their decoder and rounding-mode fixes both remain in the merged tree. ## Validation - A synthetic compute regression covers both `s_barrier` and `buffer_store_dword`. Before the fix, putting either instruction inside the section produced byte-identical DXIL to omitting it. With the fix, both are rejected at the expected offset. Both still translate outside the section. - Follow-up at `6b906eb`: regressions cover buffer/global loads into LDS and a structured discard annotation supplied directly to lowering. With #2771 and #2886 merged locally, all 37 lowering tests and the FP16 rounding regression passed under WARP. Clippy with all targets and features passed. Moving the whole-wave regressions to their own module brought the merged `emit/lower.rs` to 522,717 bytes, below the 524,288-byte asset-policy limit. - The original full `victory-shader` library suite with `VICTORY_WARP=1` reported 299 passed, 4 failed, and 3 ignored. The same four tests failed with the same diagnostics on base commit `842b0cb`: three wave32 pipeline failures and one texture gather mismatch. - Clippy for `victory-shader` with all targets and features and `-D warnings` passed. The staged asset policy check passed. AI-assisted (Codex). Only synthetic fixtures were used.
cloph-dsp commented 2026-11-25 23:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T23:04:54Z.


Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.

  • cargo test --locked -p victory-shader emit::lower::tests::whole_wave_sections_reject_side_effects --quiet -> 1 passed, 305 filtered out.
  • cargo test --locked -p victory-shader emit::lower::tests --quiet -> 34 passed, 0 failed.
  • git diff --check against merge-base 842b0cb clean; the PR changes 1 file, +51/-12 (crates/victory-shader/src/emit/lower.rs).
  • Negative control: the new test name is absent from the merge-base, so the coverage is new here.
  • Only synthetic instruction fixtures were used.

This is independent local verification, not a formal approval.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177124435 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7177124435). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T23:04:54Z. --- Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup. - `cargo test --locked -p victory-shader emit::lower::tests::whole_wave_sections_reject_side_effects --quiet` -> 1 passed, 305 filtered out. - `cargo test --locked -p victory-shader emit::lower::tests --quiet` -> 34 passed, 0 failed. - `git diff --check` against merge-base `842b0cb` clean; the PR changes 1 file, +51/-12 (`crates/victory-shader/src/emit/lower.rs`). - Negative control: the new test name is absent from the merge-base, so the coverage is new here. - Only synthetic instruction fixtures were used. This is independent local verification, not a formal approval. AI-assisted (Hy4 flash).
fuzeofficlal commented 2026-11-25 23:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:04:57Z.


Reviewed and verified 854cc9e4 on Windows 11 (RTX 5090 + WARP + dxil.dll) against main (842b0cb):

  • Extracting has_side_effect(inst) and checking has_side_effect(inst) || self.x.st.discards.contains_key(&(b, i)) in section_inst cleanly rejects exports, non-global_load_* flat/global/scratch ops, store/atomic ops, s_barrier, non-read/swizzle/permute DS ops, and structured pixel discards with the exact instruction byte offset.
  • Local checks: emit::lower::tests 34/34 passed (including whole_wave_sections_reject_side_effects), section tests 5/5 passed on RTX 5090 + WARP, cargo clippy --locked -p victory-shader --all-targets -- -D warnings 0 warnings, cargo xtask policy (191 files ok).
  • Two minor notes:
    1. crates/victory-shader/src/emit/lower.rs is at 521,946 bytes (2,342 bytes below the 512 KiB xtask policy limit).
    2. Future-proofing edge cases (unlikely to enter sections today): Fields::Buffer { lds: true, .. } (buffer_load_* lds) and s_sendmsg*/s_setreg_* aren't matched by has_side_effect.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7177125232 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7177125232). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:04:57Z. --- Reviewed and verified `854cc9e4` on Windows 11 (RTX 5090 + WARP + `dxil.dll`) against `main` (`842b0cb`): - Extracting `has_side_effect(inst)` and checking `has_side_effect(inst) || self.x.st.discards.contains_key(&(b, i))` in `section_inst` cleanly rejects exports, non-`global_load_*` flat/global/scratch ops, store/atomic ops, `s_barrier`, non-read/swizzle/permute DS ops, and structured pixel discards with the exact instruction byte offset. - Local checks: `emit::lower::tests` 34/34 passed (including `whole_wave_sections_reject_side_effects`), `section` tests 5/5 passed on RTX 5090 + WARP, `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` 0 warnings, `cargo xtask policy` (`191 files ok`). - Two minor notes: 1. `crates/victory-shader/src/emit/lower.rs` is at `521,946` bytes (`2,342` bytes below the 512 KiB `xtask policy` limit). 2. Future-proofing edge cases (unlikely to enter sections today): `Fields::Buffer { lds: true, .. }` (`buffer_load_* lds`) and `s_sendmsg*`/`s_setreg_*` aren't matched by `has_side_effect`.
AwsAli05 commented 2026-11-26 00:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:06:51Z.

Review: COMMENTED


The focused whole-wave test passed on Windows at 854cc9e. I checked that barriers and stores are still accepted outside a simulated section, while both return the explicit byte-offset refusal inside it.

st.discards is a separate condition from has_side_effect. A structured pixel discard case would cover that branch, since removing it would leave the current barrier and store test green.

AI-assisted review and test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066206922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6066206922). Originally posted by [AwsAli05](https://github.com/AwsAli05) on 2026-11-25T23:06:51Z. **Review:** COMMENTED --- The focused whole-wave test passed on Windows at `854cc9e`. I checked that barriers and stores are still accepted outside a simulated section, while both return the explicit byte-offset refusal inside it. `st.discards` is a separate condition from `has_side_effect`. A structured pixel discard case would cover that branch, since removing it would leave the current barrier and store test green. AI-assisted review and test.
kotekompotek commented 2026-11-26 00:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:36:05Z.

Review: COMMENTED


Correct conservative boundary: whole-wave simulation can only reconstruct side-effect-free sections — a store/atomic/barrier would execute once in simulation instead of per real lane, and a discard changes which lanes the wave ops reason about. Refusing via the unsupported path is the right failure mode. The has_side_effect table looks right (exp, flat non-global-load, ds non-read/swizzle/permute). LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066488338 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6066488338). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:36:05Z. **Review:** COMMENTED --- Correct conservative boundary: whole-wave simulation can only reconstruct side-effect-free sections — a store/atomic/barrier would execute once in simulation instead of per real lane, and a discard changes which lanes the wave ops reason about. Refusing via the unsupported path is the right failure mode. The has_side_effect table looks right (exp, flat non-global-load, ds non-read/swizzle/permute). LGTM.
Marvisak commented 2026-11-26 05:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:25:51Z.


Automated triage for the maintainers.

Merge candidate. Side-effect classification in emit/lower.rs moves into has_side_effect, and section_inst uses it to refuse an effect or structured discard inside a whole-wave section. Before, stores, LDS writes, exports or s_barrier inside such a span were silently dropped, so failing the shader is the correct outcome. The test checks that s_barrier and buffer_store_dword translate outside a section and are refused inside one.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182588473 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7182588473). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:25:51Z. --- <!-- victory-triage v1 head=854cc9e415146205ec66008d80ddbcd94c8ed496 verdict=merge-candidate at=2026-11-26T04:25:45Z --> Automated triage for the maintainers. **Merge candidate.** Side-effect classification in `emit/lower.rs` moves into `has_side_effect`, and `section_inst` uses it to refuse an effect or structured discard inside a whole-wave section. Before, stores, LDS writes, exports or `s_barrier` inside such a span were silently dropped, so failing the shader is the correct outcome. The test checks that `s_barrier` and `buffer_store_dword` translate outside a section and are refused inside one. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 11:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T10:09:11Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1: 34/34 passed (including whole_wave_sections_reject_side_effects).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly refuses side-effecting instructions inside whole-wave sections.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6072133442 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6072133442). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T10:09:11Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1`: 34/34 passed (including `whole_wave_sections_reject_side_effects`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly refuses side-effecting instructions inside whole-wave sections. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 11:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:46:18Z.

Review: CHANGES_REQUESTED


Refusing s_barrier, buffer_store_dword, and structured st.discards inside whole-wave sections closes a real silent-omission bug, and git merge-tree against 63bcca43 is clean (emit/lower.rs = 521,946 bytes).

Two gaps remain in has_side_effect / section handling (emit/lower.rs:480-491, 1388-1396):

  1. LDS-writing loads (Fields::Buffer { lds: true, .. }, gfx10/fields.rs:343): buffer_load_* with lds set writes to LDS without matching "store" or "atomic", so it is still silently skipped inside a section.
  2. Rounding-mode updates (s_round_mode / s_setreg* to HW_REG_MODE): section_inst neither refuses them nor calls round16_after, so a same-block conversion after EXEC is restored uses the stale rounding mode (tracked separately in #2886 if preserved rather than refused).

Please cover the lds flag (and either reject or preserve rounding-mode updates), and add regression coverage for lds-load and st.discards.

Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, 854cc9e4):

  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • emit::lower::tests: 34 passed, 0 failed
  • section -- --test-threads=1 (RTX 5090 and VICTORY_WARP=1): 5 passed, 0 failed on both
<!-- greyfinch-sync:Marvisak/VIctory:review:6072736630 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6072736630). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:46:18Z. **Review:** CHANGES_REQUESTED --- Refusing `s_barrier`, `buffer_store_dword`, and structured `st.discards` inside whole-wave sections closes a real silent-omission bug, and `git merge-tree` against `63bcca43` is clean (`emit/lower.rs` = `521,946` bytes). Two gaps remain in `has_side_effect` / section handling (`emit/lower.rs:480-491, 1388-1396`): 1. **LDS-writing loads (`Fields::Buffer { lds: true, .. }`, `gfx10/fields.rs:343`)**: `buffer_load_*` with `lds` set writes to LDS without matching `"store"` or `"atomic"`, so it is still silently skipped inside a section. 2. **Rounding-mode updates (`s_round_mode` / `s_setreg*` to `HW_REG_MODE`)**: `section_inst` neither refuses them nor calls `round16_after`, so a same-block conversion after `EXEC` is restored uses the stale rounding mode (tracked separately in #2886 if preserved rather than refused). Please cover the `lds` flag (and either reject or preserve rounding-mode updates), and add regression coverage for `lds`-load and `st.discards`. Verified locally on Windows 11 x64 (RTX 5090 + WARP + `dxil.dll`, `854cc9e4`): - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `emit::lower::tests`: 34 passed, 0 failed - `section -- --test-threads=1` (RTX 5090 and `VICTORY_WARP=1`): 5 passed, 0 failed on both
fuzeofficlal commented 2026-11-26 13:03:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:58:12Z.

Review: CHANGES_REQUESTED


The updated tests close both gaps from the earlier review: an LDS-writing buffer load (Fields::Buffer { lds: true, .. }) and a structured-program discard inside a whole-wave section, with the check now running before every simulated instruction in lower_block (crates/victory-shader/src/emit/lower.rs:1384-1392).

Two items still need attention before landing alongside sibling fixes:

  1. has_side_effect at crates/victory-shader/src/emit/lower.rs:483 still excludes all global_load_* instructions without checking Fields::Flat { lds: true, .. }, so a global_load_* ... lds inside a whole-wave section can still be skipped and directly conflicts with #2771.
  2. In-memory integration onto origin/main (63bcca43) keeping the shared predicate and both regressions produces a 524,348-byte emit/lower.rs (#2874 + #2771, 60 bytes over xtask's 524,288-byte limit), or 524,437 bytes (+149 bytes over) when also retaining #2886's per-instruction mode16 rounding-mode update (emit/lower.rs:1382-1395). Please carry Fields::Flat { lds: true, .. } into has_side_effect (and keep #2886's rounding-mode update when integrating) while moving tests out of lower.rs or trimming enough bytes to stay under the 512 KiB cap.

Local verification on c9d1fcfb22e6: xtask policy (191 files ok; lower.rs standalone = 523,549 bytes), cargo clippy -p victory-shader --all-targets / --all-features, emit::lower::tests (35 passed), and section tests (6 passed on both RTX 5090 and VICTORY_WARP=1).

<!-- greyfinch-sync:Marvisak/VIctory:review:6074518329 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6074518329). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T12:58:12Z. **Review:** CHANGES_REQUESTED --- The updated tests close both gaps from the earlier review: an LDS-writing buffer load (`Fields::Buffer { lds: true, .. }`) and a structured-program discard inside a whole-wave section, with the check now running before every simulated instruction in `lower_block` (`crates/victory-shader/src/emit/lower.rs:1384-1392`). Two items still need attention before landing alongside sibling fixes: 1. `has_side_effect` at `crates/victory-shader/src/emit/lower.rs:483` still excludes all `global_load_*` instructions without checking `Fields::Flat { lds: true, .. }`, so a `global_load_* ... lds` inside a whole-wave section can still be skipped and directly conflicts with `#2771`. 2. In-memory integration onto `origin/main` (`63bcca43`) keeping the shared predicate and both regressions produces a `524,348`-byte `emit/lower.rs` (`#2874 + #2771`, 60 bytes over `xtask`'s `524,288`-byte limit), or `524,437` bytes (+149 bytes over) when also retaining `#2886`'s per-instruction `mode16` rounding-mode update (`emit/lower.rs:1382-1395`). Please carry `Fields::Flat { lds: true, .. }` into `has_side_effect` (and keep `#2886`'s rounding-mode update when integrating) while moving tests out of `lower.rs` or trimming enough bytes to stay under the 512 KiB cap. Local verification on `c9d1fcfb22e6`: `xtask policy` (`191 files ok`; `lower.rs` standalone = `523,549` bytes), `cargo clippy -p victory-shader --all-targets` / `--all-features`, `emit::lower::tests` (`35 passed`), and `section` tests (`6 passed` on both RTX 5090 and `VICTORY_WARP=1`).
yumaste commented 2026-11-26 13:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T12:33:11Z.


Follow-up to the requested changes in c9d1fcf. Loads with the LDS flag now count as side effects, and focused regression coverage exercises both the LDS-writing load and the structured discard path. Both tests fail when their corresponding guard is removed.

#2886 preserves rounding-mode writes. The two branches now merge together cleanly, so #2886 can land first and #2874 picks up the round-mode behavior on main.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192150013 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7192150013). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T12:33:11Z. --- Follow-up to the requested changes in `c9d1fcf`. Loads with the LDS flag now count as side effects, and focused regression coverage exercises both the LDS-writing load and the structured discard path. Both tests fail when their corresponding guard is removed. #2886 preserves rounding-mode writes. The two branches now merge together cleanly, so #2886 can land first and #2874 picks up the round-mode behavior on `main`.
yumaste commented 2026-11-26 14:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T13:44:04Z.


Addressed in 6b906eb. Whole-wave lowering now rejects global_load_dword ... lds at its instruction byte offset, with a synthetic regression. The whole-wave effect tests now live in lower/whole_wave_effect_tests.rs.

I merged this branch, #2771 and #2886 onto main (63bcca4) locally without conflict. The combined lower.rs is 522,717 bytes. Under WARP the 37 lowering tests and the rounding-mode regression passed, along with all-targets/all-features Clippy and asset policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193761231 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7193761231). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T13:44:04Z. --- Addressed in `6b906eb`. Whole-wave lowering now rejects `global_load_dword ... lds` at its instruction byte offset, with a synthetic regression. The whole-wave effect tests now live in `lower/whole_wave_effect_tests.rs`. I merged this branch, #2771 and #2886 onto `main` (`63bcca4`) locally without conflict. The combined `lower.rs` is 522,717 bytes. Under WARP the 37 lowering tests and the rounding-mode regression passed, along with all-targets/all-features Clippy and asset policy.
AurumCarlos commented 2026-11-26 15:01:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T14:08:01Z.

Review: COMMENTED


On 6b906eb: refusing global_load_* … lds in whole-wave sections makes sense (it writes LDS once per simulated wave instead of per lane, like the buffer form), and moving the tests into lower/whole_wave_effect_tests.rs keeps lower.rs down.

One maintainability point. The new effect in the instruction lowering is has_side_effect minus the Flat { lds: true } arm, written out a second time:

let effect = matches!(inst.fields, Fields::Exp { .. })
    || matches!(inst.fields, Fields::Flat { .. }) && !name.starts_with("global_load_")
    || name.contains("store")
    || has_atomic_barrier_or_lds_effect(inst);

I assume the difference is on purpose: outside a section, a global LDS load that fails to lower should still mark its results missing instead of refusing the program, as on main. But nothing says so, and the next arm someone adds to has_side_effect will silently not reach this copy. Writing it as has_side_effect(inst) && !matches!(inst.fields, Fields::Flat { lds: true, .. }), with a one-line comment on why the LDS form is excluded here, would keep the two from drifting apart.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075518524 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6075518524). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-26T14:08:01Z. **Review:** COMMENTED --- On `6b906eb`: refusing `global_load_* … lds` in whole-wave sections makes sense (it writes LDS once per simulated wave instead of per lane, like the buffer form), and moving the tests into `lower/whole_wave_effect_tests.rs` keeps `lower.rs` down. One maintainability point. The new `effect` in the instruction lowering is `has_side_effect` minus the `Flat { lds: true }` arm, written out a second time: ```rust let effect = matches!(inst.fields, Fields::Exp { .. }) || matches!(inst.fields, Fields::Flat { .. }) && !name.starts_with("global_load_") || name.contains("store") || has_atomic_barrier_or_lds_effect(inst); ``` I assume the difference is on purpose: outside a section, a global LDS load that fails to lower should still mark its results missing instead of refusing the program, as on `main`. But nothing says so, and the next arm someone adds to `has_side_effect` will silently not reach this copy. Writing it as `has_side_effect(inst) && !matches!(inst.fields, Fields::Flat { lds: true, .. })`, with a one-line comment on why the LDS form is excluded here, would keep the two from drifting apart.
fuzeofficlal commented 2026-11-26 15:01:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T14:15:32Z.

Review: APPROVED


Both items from the previous review are cleanly resolved:

  • has_side_effect (emit/lower.rs:480-498) now explicitly checks matches!(inst.fields, Fields::Flat { lds: true, .. }) so GLOBAL-to-LDS is rejected inside whole-wave sections at the exact instruction offset (16), covered by whole_wave_sections_reject_global_loads_into_lds.
  • Splitting the new tests into whole_wave_effect_tests.rs brings emit/lower.rs down to 521,821 B (2,467 B under the 512 KiB policy cap), and a clean 3-way merge with #2771 (26006ae4) produces 522,628 B (1,660 B under the cap, zero conflicts).

Note for maintainers: outside whole-wave sections, ordinary lowering of GLOBAL-to-LDS still depends on #2771 landing alongside this PR.

Local verification at 6b906eb9 (and merged onto origin/main 63bcca43 at 88e9b6a5): xtask policy passed (192 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features) passed with 0 warnings, emit::lower:: passed (36/36), and section tests passed on both RTX 5090 and VICTORY_WARP=1 (7/7). Approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075628557 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#pullrequestreview-6075628557). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T14:15:32Z. **Review:** APPROVED --- Both items from the previous review are cleanly resolved: - `has_side_effect` (`emit/lower.rs:480-498`) now explicitly checks `matches!(inst.fields, Fields::Flat { lds: true, .. })` so GLOBAL-to-LDS is rejected inside whole-wave sections at the exact instruction offset (`16`), covered by `whole_wave_sections_reject_global_loads_into_lds`. - Splitting the new tests into `whole_wave_effect_tests.rs` brings `emit/lower.rs` down to **`521,821 B`** (2,467 B under the 512 KiB policy cap), and a clean 3-way merge with #2771 (`26006ae4`) produces **`522,628 B`** (1,660 B under the cap, zero conflicts). Note for maintainers: outside whole-wave sections, ordinary lowering of GLOBAL-to-LDS still depends on #2771 landing alongside this PR. Local verification at `6b906eb9` (and merged onto `origin/main` `63bcca43` at `88e9b6a5`): `xtask policy` passed (`192 files ok`), `cargo clippy -p victory-shader --all-targets` (`default` and `--all-features`) passed with 0 warnings, `emit::lower::` passed (`36/36`), and `section` tests passed on both RTX 5090 and `VICTORY_WARP=1` (`7/7`). Approving.
yumaste commented 2026-11-26 15:02:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T14:22:38Z.


I documented why the whole-wave classifier has its own rule for global LDS loads and named it accordingly in ea146a8. I tried refactoring the ordinary error predicate to share more of the expression, but that changed the same hunk as #2771 and made the trial merge conflict. This head still merges cleanly with both #2771 and #2886. The shared helper still covers atomic, barrier and LDS-buffer effects. Under WARP, all 36 lowering tests passed, and all-target/all-feature Clippy passed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7194728965 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2874#issuecomment-7194728965). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T14:22:38Z. --- I documented why the whole-wave classifier has its own rule for global LDS loads and named it accordingly in `ea146a8`. I tried refactoring the ordinary error predicate to share more of the expression, but that changed the same hunk as #2771 and made the trial merge conflict. This head still merges cleanly with both #2771 and #2886. The shared helper still covers atomic, barrier and LDS-buffer effects. Under WARP, all 36 lowering tests passed, and all-target/all-feature Clippy passed.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2874:upstream-pr/2874'
git switch 'upstream-pr/2874'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2874'
git switch 'upstream-pr/2874'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2874'
git switch 'upstream-pr/2874'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2874'
git switch 'main'
git merge --squash 'upstream-pr/2874'
git switch 'main'
git merge --ff-only 'upstream-pr/2874'
git switch 'main'
git merge 'upstream-pr/2874'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2872
No description provided.