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.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 22:29 UTC · original

Windows 11, 63bcca4 + this PR:

  • structure::tests::null_scalar_operand_is_zero_mask by name: 1 passed.
  • cargo test -p victory-shader --lib structure::: green.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

The program is s_and_saveexec_b32 s0, null followed by a restore from s0; the new arm decodes the NULL scalar as Bool::FALSE rather than falling through to the mask lookup, so the guard comes out Some(Bool::FALSE) instead of opaque. Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 22:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3369#issuecomment-7204719002) Windows 11, `63bcca4` + this PR: - `structure::tests::null_scalar_operand_is_zero_mask` by name: 1 passed. - `cargo test -p victory-shader --lib structure::`: green. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. The program is `s_and_saveexec_b32 s0, null` followed by a restore from `s0`; the new arm decodes the NULL scalar as `Bool::FALSE` rather than falling through to the mask lookup, so the guard comes out `Some(Bool::FALSE)` instead of opaque. Synthetic only. AI-assisted.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 01:23 UTC · original

Independent local verification of PR #3369 (head 9ff1d512c446acf1c861708c4d0285a4519dc3e2), Windows / Rust 1.100.0 / MSVC, worktree-local CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2, synthetic source only, no game data.

Command:
cargo test --locked -p victory-shader --lib -- structure::tests::null_scalar_operand_is_zero_mask --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out.

git diff --check 63bcca43c6a00a758510398fa43096ce7e4f7df0 HEAD (the real merge base) exits 0. The new test name is absent from origin/main (git grep found 0 hits), confirming the test is added by this PR. Against current origin/main an unrelated trailing blank line in crates/victory-formats/src/xma/tables.rs pollutes diff --check, so the merge base was used.

Only the named test was run; the full crate suite was not exercised. GPU/driver: N/A (CPU-only lane-mask analysis). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM were used.

**@⁠cloph-dsp** on GitHub · 2026-11-27 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3369#issuecomment-7207246273) Independent local verification of PR #3369 (head `9ff1d512c446acf1c861708c4d0285a4519dc3e2`), Windows / Rust 1.100.0 / MSVC, worktree-local `CARGO_TARGET_DIR`, `CARGO_BUILD_JOBS=2`, synthetic source only, no game data. Command: `cargo test --locked -p victory-shader --lib -- structure::tests::null_scalar_operand_is_zero_mask --exact --test-threads=1 --quiet` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out`. `git diff --check 63bcca43c6a00a758510398fa43096ce7e4f7df0 HEAD` (the real merge base) exits 0. The new test name is absent from `origin/main` (`git grep` found 0 hits), confirming the test is added by this PR. Against current `origin/main` an unrelated trailing blank line in `crates/victory-formats/src/xma/tables.rs` pollutes `diff --check`, so the merge base was used. Only the named test was run; the full crate suite was not exercised. GPU/driver: N/A (CPU-only lane-mask analysis). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM were used.
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.