Shaders: classify floats with magnitude thresholds #3742

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3742 into main
andrewpozdnakov7-jpg commented 2026-11-28 13:55:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:55:44Z.


Classify f16 and f32 inputs by comparing the sign-cleared bits with zero, the smallest normal value, and infinity. The NaN quiet bit gives the index for either sign of NaN. The existing source handling and predicate mask still apply. AMD RDNA 2 instruction reference.

Generated compute shader DXIL instructions, main → change DXIL bytes, main → change
f16 class comparison 60 → 55 2,488 → 2,456
f32 class comparison 61 → 56 2,492 → 2,468

Microsoft WARP 1.0.22 with Agility 1.620.2 matched the independent exponent-and-fraction reference on both builds. It produced the same 1,030,258 results, including all 65,536 f16 bit patterns against 15 masks and 47,218 f32 cases. The f32 fixture includes all low ten-bit masks for edge inputs. The focused f16/f32 class regressions, strict all-feature shader Clippy and the asset policy passed.

#1327 handles f32 source modifiers and #2081 adds further mask and EXEC tests. This change replaces the class calculation itself. 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:5540842722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3742). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:55:44Z. --- Classify f16 and f32 inputs by comparing the sign-cleared bits with zero, the smallest normal value, and infinity. The NaN quiet bit gives the index for either sign of NaN. The existing source handling and predicate mask still apply. [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 class comparison | 60 → 55 | 2,488 → 2,456 | | f32 class comparison | 61 → 56 | 2,492 → 2,468 | Microsoft WARP 1.0.22 with Agility 1.620.2 matched the independent exponent-and-fraction reference on both builds. It produced the same 1,030,258 results, including all 65,536 f16 bit patterns against 15 masks and 47,218 f32 cases. The f32 fixture includes all low ten-bit masks for edge inputs. The focused f16/f32 class regressions, strict all-feature shader Clippy and the asset policy passed. #1327 handles f32 source modifiers and #2081 adds further mask and EXEC tests. This change replaces the class calculation itself. 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 13:59:12 +00:00 (Migrated from github.com)

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


Windows CI passed on 54c11a6, including the workspace tests and both Clippy configurations. The combined check with #2081 also passed the VOPC and CMPX EXEC regressions. 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:7240328306 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3742#issuecomment-7240328306). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:59:12Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46152044113/job/141000575173) passed on `54c11a6`, including the workspace tests and both Clippy configurations. The combined check with #2081 also passed the VOPC and CMPX EXEC regressions. [Combined result](https://github.com/Marvisak/VIctory/pull/2081#issuecomment-7240322715). 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.
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/3742:upstream-pr/3742'
git switch 'upstream-pr/3742'

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