Shaders: specialize common constant float class masks #3743

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3743 into main
andrewpozdnakov7-jpg commented 2026-11-28 14:04:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:04:12Z.


When the low ten bits of a float class mask are known, common masks can use a direct predicate. The zero and full masks become constants. NaN, signed zero, finite, infinity, nonfinite and non-NaN masks each use one comparison on the sign-cleared bits. Other masks continue through the general classifier. Both CMP and CMPX use the same lane-mask writer. AMD RDNA 2 instruction reference.

Generated compute shader DXIL instructions, main → change DXIL bytes, main → change
f16 NaN mask 58 → 38 2,484 → 2,356
f32 NaN mask 59 → 39 2,488 → 2,352
f32 finite mask 59 → 39 2,488 → 2,356
f32 full class mask 59 → 33 2,484 → 2,316
f32 generic mask control 59 → 59 2,488 → 2,488

The WARP and Agility comparison matched all 1,327,788 output words between builds and against a separate exponent-and-fraction model. The fixture covered all half bit patterns, generated f32 cases, VOP3 literals including unused upper bits, and CMPX with the original inactive-lane result retained. The committed immediate-mask regression also passed, along with strict all-feature shader Clippy and the asset policy.

#3742 improves the general classifier. This PR addresses the masks known during emission. Counts describe generated DXIL. Game performance was unmeasured.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5540928536 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3743). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T14:04:12Z. --- When the low ten bits of a float class mask are known, common masks can use a direct predicate. The zero and full masks become constants. NaN, signed zero, finite, infinity, nonfinite and non-NaN masks each use one comparison on the sign-cleared bits. Other masks continue through the general classifier. Both CMP and CMPX use the same lane-mask writer. [AMD RDNA 2 instruction reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf). | Generated compute shader | DXIL instructions, main → change | DXIL bytes, main → change | |---|---:|---:| | f16 NaN mask | 58 → 38 | 2,484 → 2,356 | | f32 NaN mask | 59 → 39 | 2,488 → 2,352 | | f32 finite mask | 59 → 39 | 2,488 → 2,356 | | f32 full class mask | 59 → 33 | 2,484 → 2,316 | | f32 generic mask control | 59 → 59 | 2,488 → 2,488 | The WARP and Agility comparison matched all 1,327,788 output words between builds and against a separate exponent-and-fraction model. The fixture covered all half bit patterns, generated f32 cases, VOP3 literals including unused upper bits, and CMPX with the original inactive-lane result retained. The committed immediate-mask regression also passed, along with strict all-feature shader Clippy and the asset policy. #3742 improves the general classifier. This PR addresses the masks known during emission. Counts describe generated DXIL. Game performance was unmeasured. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 14:08:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:08:08Z.


Windows CI passed on 5397722, including the workspace tests and both Clippy configurations. The integration with #1327 retained the raw source-modifier handling and matched all 2,655,576 generated WARP results. Combined result.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240442419 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3743#issuecomment-7240442419). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T14:08:08Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46152750750/job/141002717305) passed on `5397722`, including the workspace tests and both Clippy configurations. The integration with #1327 retained the raw source-modifier handling and matched all 2,655,576 generated WARP results. [Combined result](https://github.com/Marvisak/VIctory/pull/1327#issuecomment-7240434775). The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
cloph-dsp commented 2026-11-28 14:21:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T14:21:43Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3743 at head 5397722685330fa66d142a4d7c1f3c0259931d80, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::semantics_tests::immediate_class_masks_match_raw_f32_classification --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check HEAD^ HEAD clean (2 files, +56/-0).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only shader-IR test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240611398 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3743#issuecomment-7240611398). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T14:21:43Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3743 at head `5397722685330fa66d142a4d7c1f3c0259931d80`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::semantics_tests::immediate_class_masks_match_raw_f32_classification --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check HEAD^ HEAD` clean (2 files, +56/-0). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only shader-IR test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
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/3743:upstream-pr/3743'
git switch 'upstream-pr/3743'

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/3743'
git switch 'upstream-pr/3743'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3743'
git switch 'upstream-pr/3743'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3743'
git switch 'main'
git merge --squash 'upstream-pr/3743'
git switch 'main'
git merge --ff-only 'upstream-pr/3743'
git switch 'main'
git merge 'upstream-pr/3743'
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!3743
No description provided.