Shaders: flush each three-way min and max input once #3733

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

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


Flush the three inputs to v_min3_f32 and v_max3_f32 once. The first selection already uses flushed operands, so its result can go straight into the second max_min_flushed call. That result is a normal value or infinity, a signed zero, or a NaN. Both selections still use the existing signed-zero handling. DXIL FMax and FMin semantics.

Generated compute shader DXIL instructions, main → change DXIL bytes, main → change
Single min3 or max3 84 → 78 2,632 → 2,604
12 alternating min3/max3 568 → 496 5,060 → 4,716

On Microsoft WARP 1.0.22 with Agility 1.620.2, both revisions passed the existing min/max/clamp CPU-model test. A separate exact comparison returned all 438,976 output words bit for bit, covering both opcodes across subnormals, signed zeros, NaNs, infinities, ordinary values, clamp, output scaling and source modifiers. Counts are emitted DXIL from generated programs. Game performance was unmeasured. Strict all-feature shader Clippy, formatting of the changed block, and the asset policy passed.

#3352 covers explicit NaN operand selection in the shared helper and is a separate semantic change.

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:5540359669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3733). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T12:59:25Z. --- Flush the three inputs to `v_min3_f32` and `v_max3_f32` once. The first selection already uses flushed operands, so its result can go straight into the second `max_min_flushed` call. That result is a normal value or infinity, a signed zero, or a NaN. Both selections still use the existing signed-zero handling. [DXIL FMax and FMin semantics](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#fmax). | Generated compute shader | DXIL instructions, main → change | DXIL bytes, main → change | |---|---:|---:| | Single min3 or max3 | 84 → 78 | 2,632 → 2,604 | | 12 alternating min3/max3 | 568 → 496 | 5,060 → 4,716 | On Microsoft WARP 1.0.22 with Agility 1.620.2, both revisions passed the existing min/max/clamp CPU-model test. A separate exact comparison returned all 438,976 output words bit for bit, covering both opcodes across subnormals, signed zeros, NaNs, infinities, ordinary values, clamp, output scaling and source modifiers. Counts are emitted DXIL from generated programs. Game performance was unmeasured. Strict all-feature shader Clippy, formatting of the changed block, and the asset policy passed. #3352 covers explicit NaN operand selection in the shared helper and is a separate semantic change. 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:02:51 +00:00 (Migrated from github.com)

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


Windows CI passed on c909723, including the workspace tests and both Clippy configurations. The same DXIL instruction reduction also passed the exact-output comparison with the explicit NaN selection in #3352.

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:7239650410 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3733#issuecomment-7239650410). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:02:51Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46147344098/job/140986211952) passed on `c909723`, including the workspace tests and both Clippy configurations. The same DXIL instruction reduction also passed the exact-output comparison with the explicit NaN selection in [#3352](https://github.com/Marvisak/VIctory/pull/3352#issuecomment-7239645271). 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/3733:upstream-pr/3733'
git switch 'upstream-pr/3733'

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