Shaders: skip f32 flushes in packed f16 min and max #3739

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

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


Use the existing min/max helper for values already free of f32 subnormals in v_pk_min_f16 and v_pk_max_f16. Both halves widen their f16 inputs before the comparison. Even the smallest f16 subnormal is normal in f32, so the f32 subnormal checks are redundant. f16-to-f32 conversion.

For one packed min or max in a generated compute shader, DXIL went from 178 to 154 instructions and from 3,268 to 3,144 bytes. With per-half negation, it went from 180 to 156 instructions and from 3,288 to 3,168 bytes.

Microsoft WARP 1.0.22 with Agility 1.620.2 produced the same 524,288 output words on both revisions. The generated inputs cover every half bit pattern, both result halves, cross-selected source halves, per-half negation and clamp. The existing f16 model and packed input selector tests passed. Strict all-feature shader Clippy and the asset policy passed.

#3738 applies the same reasoning in the separate unpacked lowering. This change covers packed min/max. 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:5540664072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3739). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:36:15Z. --- Use the existing min/max helper for values already free of f32 subnormals in `v_pk_min_f16` and `v_pk_max_f16`. Both halves widen their f16 inputs before the comparison. Even the smallest f16 subnormal is normal in f32, so the f32 subnormal checks are redundant. [f16-to-f32 conversion](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/f16tof32). For one packed min or max in a generated compute shader, DXIL went from 178 to 154 instructions and from 3,268 to 3,144 bytes. With per-half negation, it went from 180 to 156 instructions and from 3,288 to 3,168 bytes. Microsoft WARP 1.0.22 with Agility 1.620.2 produced the same 524,288 output words on both revisions. The generated inputs cover every half bit pattern, both result halves, cross-selected source halves, per-half negation and clamp. The existing f16 model and packed input selector tests passed. Strict all-feature shader Clippy and the asset policy passed. #3738 applies the same reasoning in the separate unpacked lowering. This change covers packed min/max. 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:40:12 +00:00 (Migrated from github.com)

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


Windows CI passed on 6e47acf, including the workspace tests and both Clippy configurations. The integration with #2825 also verified that the widened f16 path gives identical WARP results and that the native modules are byte-identical. 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:7240100580 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3739#issuecomment-7240100580). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:40:12Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46150445375/job/140995698458) passed on `6e47acf`, including the workspace tests and both Clippy configurations. The integration with #2825 also verified that the widened f16 path gives identical WARP results and that the native modules are byte-identical. [Combined result](https://github.com/Marvisak/VIctory/pull/2825#issuecomment-7240095101). 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/3739:upstream-pr/3739'
git switch 'upstream-pr/3739'

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