Skip to content

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

Open
reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/shader-structure-null-operand
Open

reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/shader-structure-null-operand

Conversation

@reeledMarek

Copy link
Copy Markdown
Contributor

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

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

3 participants