Shaders: lower v_frexp_mant_{f32,f16} and v_frexp_exp_i{32_f32,16_f16} #1190
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1190
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1190"
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?
@ESAT586 on GitHub · 2026-11-24 16:22 UTC · original
ESAT586:shader/frexp-f32-f16→main· +188 −0 · 2 files · 1 commits · openWhat's wrong
v_frexp_mant_f32(VOP1 0x40),v_frexp_exp_i32_f32(VOP1 0x3f),v_frexp_mant_f16(VOP1 0x59), andv_frexp_exp_i16_f16(VOP1 0x5a) — the RDNA2 instructions emitted for HLSLfrexp(x, exp)— are decoded ingfx10/opcodes.rsbut not lowered incrates/victory-shader/src/emit/lower.rs, causing any shader using them to fail lowering.Fix
Lower::frexp_f32incrates/victory-shader/src/emit/lower.rsusing pure 32-bit bitwise integer ops (noi64capability needed):126((-1, -0.5] U [0.5, 1)) and exponentexp_raw - 126.FirstbitHi(unaryBits.i32op33), shifting the top mantissa bit to bit 23 and returning exponent-117 - lz.±0,±inf,NaN): mantissa preserves the input bits (including-0.0sign and±inf/NaN), exponent returns0.v_frexp_mant_f32andv_frexp_exp_i32_f32invalu_op.v_frexp_mant_f16(FLOAT1) andv_frexp_exp_i16_f16(INT) invalu16/valu16_op:half_fsrcwidens every f16 (including all f16 subnormals) into an exact normal f32, runsfrexp_f32, and writes back viafloat_result/write_half(preserving the destination's other 16-bit half and honoringopsel/abs/neg).emit::valu_tests::v_frexp_f32_and_f16_match_rdna2incrates/victory-shader/src/emit/valu_tests.rscovering normals, subnormals (0x0040_0000,0x0000_0003,0x8000_0001, f160x0001,0x8003),±0,±inf,NaN, max finite f16 (0x7BFF), and upper-half preservation.Verification (Real GPU + WARP + CI Gates)
Tested on Windows 11, NVIDIA GeForce RTX 3060 Ti (driver
32.0.16.1656), Rust1.98.1:cargo test -p victory-shader --lib v_frexp_f32_and_f16_match_rdna2: ok (dxil.dllvalidator + RTX 3060 Ti hardware + Microsoft WARP)cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignoredcargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)cargo xtask policy:asset policy: 154 files okScope & Non-Overlap
v_frexp_mant_*orv_frexp_exp_*.@ghost on GitHub · 2026-11-24 16:35 UTC · original
Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head
d160854on mainffe310e. Your report lists NVIDIA and WARP, so this adds AMD hardware.v_frexp_f32_and_f16_match_rdna2passes: mant/exp for f32 and f16, including the subnormal cases, +-0, +-inf, NaN, and the f16 high half kept.stub_pipeline_is_created, fails on main too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR).Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too); whether the new test fails without the fix on this host.
AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
d160854:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:39 UTC · original · edited 2026-11-25 12:16 UTC
Automated triage for the maintainers.
Proposed close: duplicate of #1659. Thanks for the rebase. It now merges cleanly, and CI
checkpasses at05044fa.#1659 lowers the same four instructions (
v_frexp_mant_{f32,f16},v_frexp_exp_i{32_f32,16_f16}). It also merges cleanly and is already marked as a merge candidate. The two disagree on f32 denormal inputs, and #1659 matchesmainthere:mainreads a 32-bit denormal as a zero of its sign, the way the console's float mode does (Lower::ftzincrates/victory-shader/src/emit/lower.rs, whose doc comment says so). #1659 applies that flush before splitting the value.Lower::frexp_f32here normalises f32 denormals instead, andv_frexp_f32_and_f16_match_rdna2asserts those results (for example0x0000_0003→0.75,-147). On the console's float mode, those inputs read as ±0.The f16 handling (normalising denormals) agrees between the two PRs.
This PR will be closed in 48 hours unless you push a change or a maintainer removes the
triage: proposed closelabel. If you think the f32 denormal behaviour here is the right one, please point to evidence (console output or an ISA reference for the float mode the title runs in).Generated by Claude Code
@ESAT586 on GitHub · 2026-11-25 11:19 UTC · original
Rebased onto \main\ (\
940d32f) at $sha. Verified on RTX 3060 Ti + WARP: \_frexp_f32_and_f16_match_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.