fix(shader): decode scalar NULL operand as Bool::FALSE in lane mask analysis #3369

Open
github-bot wants to merge 1 commit from github-bot/gh-3369 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-26 20:40 UTC · original
reeledMarek:fix/shader-structure-null-operand → main · +22 −1 · 1 files · 1 commits · open

Summary

  • Lanes::operand guarded scalar operands with if code != NULL, letting scalar NULL (code 125, which always reads as 0) fall through to _ => return None.
  • Scalar lane-mask instructions reading null (such as s_and_saveexec_b32 s0, null or s_mov_b32 exec_lo, null) therefore failed in Lanes::sop, turning EXEC and saved masks into Atom::Opaque instead of Bool::FALSE.
  • Decodes Operand::Scalar { code: NULL, .. } as (Bool::FALSE, false) in Lanes::operand, matching wave.rs and resource.rs.
  • Adds regression test null_scalar_operand_is_zero_mask.

Verification

  • Executed null_scalar_operand_is_zero_mask directly against victory-shader on Linux
  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
**@⁠reeledMarek** on GitHub · 2026-11-26 20:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3369) `reeledMarek:fix/shader-structure-null-operand` → `main` · +22 −1 · 1 files · 1 commits · open ### Summary - `Lanes::operand` guarded scalar operands with `if code != NULL`, letting scalar `NULL` (code 125, which always reads as 0) fall through to `_ => return None`. - Scalar lane-mask instructions reading `null` (such as `s_and_saveexec_b32 s0, null` or `s_mov_b32 exec_lo, null`) therefore failed in `Lanes::sop`, turning `EXEC` and saved masks into `Atom::Opaque` instead of `Bool::FALSE`. - Decodes `Operand::Scalar { code: NULL, .. }` as `(Bool::FALSE, false)` in `Lanes::operand`, matching `wave.rs` and `resource.rs`. - Adds regression test `null_scalar_operand_is_zero_mask`. ### Verification - Executed `null_scalar_operand_is_zero_mask` directly against `victory-shader` on Linux - `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:43:36 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:48 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Decoding Operand::Scalar { code: NULL, .. } as (Bool::FALSE, false) in Lanes::operand accurately reflects that NULL reads as 0 and keeps EXEC tracking precise instead of turning it opaque.
  • cargo test -p victory-shader --lib structure:: -- --test-threads=1: 14 passed, 0 failed (1 ignored; including null_scalar_operand_is_zero_mask).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 20:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3369#pullrequestreview-6080343191) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Decoding `Operand::Scalar { code: NULL, .. }` as `(Bool::FALSE, false)` in `Lanes::operand` accurately reflects that `NULL` reads as 0 and keeps `EXEC` tracking precise instead of turning it opaque. - `cargo test -p victory-shader --lib structure:: -- --test-threads=1`: 14 passed, 0 failed (1 ignored; including `null_scalar_operand_is_zero_mask`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:54 UTC · original · approved these changes

LGTM — decoding Operand::Scalar { code: NULL, .. } as (Bool::FALSE, false) in Lanes::operand matches RDNA2 (NULL always reads 0) across both wave32 and wave64, aligning structure.rs with wave.rs and resource.rs.

Verified

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --all-features): clean.
  • rustfmt --edition 2024: clean on all PR-touched hunks in crates/victory-shader/src/structure.rs.
  • cargo test --locked -p victory-shader --lib -- --test-threads=1 structure:: resource:: ir::: 58 passed, 0 failed, 1 ignored (including null_scalar_operand_is_zero_mask).

Non-blocking downstream notes

  • In structure.rs:1107-1114, "wqm" builds a | Atom::Quad(lo). With null now decoding to Bool::FALSE, s_wqm_b32 exec_lo, null produces Quad, which emit/lower.rs:2592 unconditionally lowers to true (same pre-existing behavior as inline 0; folding a == Bool::FALSE in "wqm" to (Bool::FALSE, Some(Bool::FALSE)) would avoid this).
  • s_cmp_eq/lg with null (structure.rs:1208) inherits the existing per-lane mask comparison behavior used for inline 0; float inline constants (240..=248) remain unresolved in Lanes::operand, and the new test covers wave32 only.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/3369#pullrequestreview-6080387263) · **approved these changes** LGTM — decoding `Operand::Scalar { code: NULL, .. }` as `(Bool::FALSE, false)` in `Lanes::operand` matches RDNA2 (`NULL` always reads 0) across both wave32 and wave64, aligning `structure.rs` with `wave.rs` and `resource.rs`. ### Verified - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--all-features`): clean. - `rustfmt --edition 2024`: clean on all PR-touched hunks in `crates/victory-shader/src/structure.rs`. - `cargo test --locked -p victory-shader --lib -- --test-threads=1 structure:: resource:: ir::`: **58 passed, 0 failed, 1 ignored** (including `null_scalar_operand_is_zero_mask`). ### Non-blocking downstream notes - In `structure.rs:1107-1114`, `"wqm"` builds `a | Atom::Quad(lo)`. With `null` now decoding to `Bool::FALSE`, `s_wqm_b32 exec_lo, null` produces `Quad`, which `emit/lower.rs:2592` unconditionally lowers to `true` (same pre-existing behavior as inline `0`; folding `a == Bool::FALSE` in `"wqm"` to `(Bool::FALSE, Some(Bool::FALSE))` would avoid this). - `s_cmp_eq/lg` with `null` (`structure.rs:1208`) inherits the existing per-lane mask comparison behavior used for inline `0`; float inline constants (`240..=248`) remain unresolved in `Lanes::operand`, and the new test covers wave32 only.
This pull request can be merged automatically.
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/3369/head:github-bot/gh-3369'
git switch 'github-bot/gh-3369'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3369'
git switch 'github-bot/gh-3369'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3369'
git switch 'github-bot/gh-3369'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3369'
git switch 'main'
git merge --squash 'github-bot/gh-3369'
git switch 'main'
git merge --ff-only 'github-bot/gh-3369'
git switch 'main'
git merge 'github-bot/gh-3369'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3369
No description provided.