Shaders: fold literals in packed f16 conversion toward zero #3773
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3773"
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-28T18:02:32Z.
Fold direct, unmodified operands of v_cvt_pkrtz_f16_f32 when the literal is zero or has a finite normal half result. The fold preserves the sign of zero, truncates the significand and clamps finite overflow to the largest half of the same sign. The host conversion handles the other operands.
I compared 423 generated shaders on Windows WARP 1.0.22 with the DXIL validator. All 4,653 output words matched main. An independent rounding oracle checked 4,279 folded halves. The 34 control modules, including dynamic and modified operands, subnormal inputs, infinities and NaNs, stayed byte-identical.
Each of the 388 one-literal modules removes eight DXIL instructions and saves 56–64 bytes. The two-inline-operand module removes 16 instructions and saves 276 bytes. The new boundary regression, all 34 lowerer tests and 35 VALU tests, strict shader Clippy, and the asset policy passed.
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-28T18:05:52Z.
Windows CI passed on
0265559, including both Clippy configurations and the workspace tests. All 4,653 WARP output words matched. Each one-literal module removes eight DXIL instructions, the two-inline-operand module removes sixteen, and all 34 control modules remain byte-identical.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 ColorMeBoom on 2026-11-28T23:37:58Z.
Full
victory-shader --lib --features hoston AMD hardware: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head026555972on63bcca4: 303 passed; 0 failed; 3 ignored. That suite includes the GPU semantics tests, which run on the hardware adapter and WARP in turn. I didn't check which of them reach the changed code. The newpacked_rtz_literals_keep_sign_and_truncate_toward_zeropasses; it runs on the CPU.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-30T11:23:00Z.
AI-assisted verification (Hy4 flash) — Windows, Rust 1.100.0/MSVC,
cargo test --locked.emit::lower::tests::packed_rtz_literals_keep_sign_and_truncate_toward_zerofor theliteral_f16_toward_zerofolding.D:\Victory-Contrib\pr-3773-watchwith dedicatedCARGO_TARGET_DIR=D:\Victory-Contrib\target-3773.git grep -F packed_rtz_literals_keep_sign_and_truncate_toward_zero 63bcca43c6a00a758510398fa43096ce7e4f7df0 -- crates/victory-shader/src/emit/lower.rs→ exit 1 (test is new on the base).git diff --check 63bcca43c6a00a758510398fa43096ce7e4f7df0..HEAD→ exit 0.cargo test --locked -p victory-shader --lib -- emit::lower::tests::packed_rtz_literals_keep_sign_and_truncate_toward_zero --exact --test-threads=1 --quiet→1 passed; 0 failed; 305 filtered out, exit 0.GPU/driver: N/A — CPU-only synthetic test. No game data, assets, extracted shaders, DRM or decrypt were used.
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.