Shaders: lower v_ldexp_f32 (VOP3 0x362) #1341
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!1341
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1341"
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?
@AscilCH on GitHub · 2026-11-24 17:33 UTC · original
AscilCH:fix/lower-v-ldexp-f32→main· +130 −0 · 2 files · 1 commits · openGap
v_ldexp_f32(VOP3 0x362, computingsrc0.f32 * 2^src1.i32) was not lowered incrates/victory-shader/src/emit/lower.rs, failing shader translation with:Fix
v_ldexp_f32incrates/victory-shader/src/emit/lower.rsusing exact IEEE-754 exponent adjustment in pure 32-bit integer arithmetic (requiring noINT64shader feature flag):src1to[-512, 512]sobiased_exp + nnever overflowsi32(includingi32::MINandi32::MAX) while still handling full-span shifts such as2^-126 * 2^253 = 2^127without intermediate overflow.f32FTZ), preserves±0.0and±infregardless of exponent, and quietssNaNtoqNaN.abs/neg(viafsrconsrc0) and outputomod/clamp(viafloat()).dxil.dlltestemit::valu_tests::v_ldexp_f32_matches_rdna2covering normal positive/negative scaling, full-span scaling, overflow to±inf, underflow to±0.0,i32::MIN/i32::MAXexponents,±0.0/±inf/sNaN/qNaN, and VOP3abs/neg/clamp/omod.Verification
Tested on Windows 11, NVIDIA RTX 3050 6GB Laptop GPU, WARP, and Windows SDK
dxil.dll:rustfmt --edition 2024 --checkonvalu_tests.rs: cleancargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p victory-shader --locked -- v_ldexp_f32_matches_rdna2 --nocapture --test-threads=1: passed (hardware + WARP +dxil.dll)VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:121 passed, 0 failed, 1 ignored@marquezinii on GitHub · 2026-11-24 18:10 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
59e48eb.cargo test -p victory-shader --lib -- --test-threads=1gives 121 passed, 0 failed, 1 ignored.v_ldexp_f32_matches_rdna2passes on the hardware adapter and WARP.One question on the denormal cases. The lowering returns a signed zero when the result exponent is
<= 0, and it treats a denormal input (exp == 0) as zero. The test pins this down:1.0 * 2^-127should give0. That is what RDNA2 does with f32 denormals flushed (MODE.FP_DENORM). With f32 denormals enabled, the hardware returns0x0040_0000, and a denormal input is scaled rather than zeroed. Is flushing the intended mode for the console's shaders? If so, a comment saying it is an FTZ choice would help, because the test name suggests it matches RDNA2 in every mode.@shortselow-byte on GitHub · 2026-11-24 19:06 UTC · original
On the denormal question above: #157 also lowers
v_ldexp_f32and takes the other side. It multiplies by three in-range powers of two so a denormal result is kept (its note: "a result that turns denormal before the last factor is rounded twice where denormals are kept"), where this PR flushes it to signed zero. So the choice of f32 denormal mode is open in two PRs at once, and is worth settling once for both.@Marvisak on GitHub · 2026-11-25 01:23 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 01:48 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
59e48ebontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:47 UTC · original
I rebased the
v_ldexp_f32lowering and its existing readback test ontomainat940d32f. The conflict was in where the test was inserted. The lowering and test body are unchanged, and GitHub attributes the rebased commit to @AscilCH.The same test stops at
Unsupportedon940d32fand passes on the rebased branch. All 29 VALU tests passed on Windows software WARP with DXIL validation. A separate local readback probe matchedv_mul_f32by 0.5 on four inputs at the underflow boundary, including a preserved negative zero and the smallest positive normal. Strict shader Clippy and the asset policy passed.Claim. AI-assisted with Codex. Synthetic shaders only.
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.