Shaders: simplify f32 min and max with literal operands #3744
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3744"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:14:01Z.
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 <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:18:13Z.
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 withmain, 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 <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T14:21:42Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
6f3fa6d3130fd08186761fb38fa4bd013a00048d, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::f32_literal_bits_require_a_float_or_i32_bitcast --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the base returned no match (test is new on this PR);git diff --check HEAD^ HEADclean (2 files, +51/-1).CARGO_TARGET_DIR(never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.