You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shaders: simplify f32 min and max with literal operands - #3744
Resolve a known f32 operand's denormal handling during emission for min/max. A literal or a raw i32-to-f32 bitcast can supply its exact bits. A subnormal literal becomes a zero of the same sign. When a normalized literal has nonzero magnitude, the two operands cannot both be zero, so the result can use the ordinary DXIL min/max directly. The signed-zero rule still applies when both values can be zero. DXIL FMax and FMin semantics.
Generated compute shader
DXIL instructions, main → change
DXIL bytes, main → change
Max with a normal bound
58 → 43
2,516 → 2,452
Min with a negative-zero bound
58 → 51
2,508 → 2,492
Min with a subnormal bound
58 → 51
2,508 → 2,488
Max with two dynamic inputs
60 → 60
2,516 → 2,516
On Microsoft WARP 1.0.22 with Agility 1.620.2, both builds matched all 47,790 generated output words, including both argument orders, signed zeros, subnormals, infinities and NaNs. The existing min/max model and 13 bitcode tests passed, with the existing benchmark ignored. The new bitcode regression checks that numeric conversions and raw integer values are excluded from the literal lookup. Strict all-feature shader Clippy and the asset policy passed.
#3733 covers repeated flushing across three-way f32 selections. This change covers literal operands. 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 <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.
Windows CI passed on 6f3fa6d, including both Clippy configurations and the workspace tests. The two-operand min/max comparison on WARP with Agility 1.620.2 matched all 47,790 output words with main, including literal NaNs, signed zeros, subnormals, infinities, both operand orders and a dynamic control. The ordinary literal max went from 58 to 43 DXIL instructions (2,516 to 2,452 bytes), and the negative-zero literal min went from 58 to 51 (2,508 to 2,492 bytes). The dynamic control stayed at 60 instructions and 2,516 bytes. The committed bitcode test verifies the literal representations used by the optimization.
The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve a known f32 operand's denormal handling during emission for min/max. A literal or a raw i32-to-f32 bitcast can supply its exact bits. A subnormal literal becomes a zero of the same sign. When a normalized literal has nonzero magnitude, the two operands cannot both be zero, so the result can use the ordinary DXIL min/max directly. The signed-zero rule still applies when both values can be zero. DXIL FMax and FMin semantics.
On Microsoft WARP 1.0.22 with Agility 1.620.2, both builds matched all 47,790 generated output words, including both argument orders, signed zeros, subnormals, infinities and NaNs. The existing min/max model and 13 bitcode tests passed, with the existing benchmark ignored. The new bitcode regression checks that numeric conversions and raw integer values are excluded from the literal lookup. Strict all-feature shader Clippy and the asset policy passed.
#3733 covers repeated flushing across three-way f32 selections. This change covers literal operands. 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 <andrewpozdnakov7-jpg@users.noreply.github.com>if folding the change into another commit.AI-assisted with OpenAI Codex.