Shaders: lower binary64 truncation #2598
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2600"
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-25T16:34:15Z.
v_trunc_f64(RDNA 2 VOP1 opcode0x017) is decoded but rejected by host shader lowering. Emit round-toward-zero by clearing the fractional bits in the two binary64 words. This preserves signed zeros and leaves integral values unchanged. The emitted shader uses 32-bit integer operations. AMD RDNA 2 ISA, VOP1The same two synthetic shaders are rejected as
Unsupportedon67e8ae1and execute successfully on the patch. The tests check 15 input values through both vector and scalar register pairs, both output dwords, and a negated VOP3 literal. Cases cover the 31/32/33-bit mask boundary, negative fractions, subnormals, signed zero, and large integral values. The VOP3 fixture also checks the DXIL feature bits.Windows app-local WARP 1.0.22 and Agility 1.620.2 with Microsoft DXIL validation. All 32 project VALU tests pass, plus a temporary test confirming the loaded runtime modules and validator. Strict shader Clippy and the staged asset policy pass. The lowering explicitly reports unsupported output
clamp/omod.Coordination claim
If you cherry-pick or rebase this commit, please retain its Git author. If you fold the change into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted. Verification used synthetic shaders.
Imported from Marvisak/VIctory. Originally posted by Mericas77 on 2026-11-25T17:33:52Z.
Tested on NVIDIA: RTX 4070, driver 621.01, Windows 11, rustc 1.100.0. Head
04c2d2bagainstmain67e8ae1.v_trunc_f64_rounds_toward_zero_in_both_wordsandv_trunc_f64_rounds_a_negated_vop3_literal: pass. Both go throughrun_cases, which printsno SM 6.6 … skippedwhen a host is missing; nothing was printed, so they ran on the NVIDIA hardware adapter as well as WARP.cargo test -p victory-shader --lib --locked(with--skip heap_direct_texture_reads_mark_their_heap_index, which crashes the process onmainhere too, #2571):main266 passed / 3 failed / 3 ignored, this PR 268 / 3 / 3. The 3 failures are the known NVIDIA ones onmainand are the same.So the integer-only lowering gives the same bits on NVIDIA hardware, no regression. No game data; the title was not run.
AI-assisted.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T21:56:24Z.
I resolved the merge conflicts in 32f9d85, keeping the original truncation commit and the upstream 64-bit integer compare helper and legacy multiply test.
On merged main
129a9ba, bothV_TRUNC_F64WARP fixtures pass, including the SGPR/VGPR inputs and the negated VOP3 literal. All 38 VALU checks pass including the temporary app-local WARP identity check, with DXIL validation enabled. Strict shader Clippy in both configurations and staged policy pass.git merge-treeis clean with4989260.Please retain the Git author if moving the original change, or keep this trailer if it is folded into another commit.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:18:31Z.
Automated triage for the maintainers.
This adds lowering for
v_trunc_f64(VOP1 0x17 / VOP3 0x197; it was decoded but rejected before) in the newcrates/victory-shader/src/emit/lower/trunc.rs(Lower::trunc_f64), with the RDNA 2 ISA cited as the reference. It truncates by masking the fraction bits with 32-bit integer operations. I checked the mask boundaries: exponents below 1023 give a signed zero, 1023-1042 mask the high word and zero the low word, 1043-1074 mask the low word, and 1075 or more pass through unchanged. That covers inf/NaN; NaNs are passed through bit-for-bit, not quieted. The operand handling also looks right: a literal is the high dword, float inline constants are widened to f64, and integer inline constants are sign-extended. The tests invalu_tests.rscompare againstf64::truncacross the word boundaries, signed zero, subnormals and a negated VOP3 literal. CI: passing (check). This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:02:17Z.
Review: APPROVED
Looks good. Verified merged onto
main(63bcca43) on an RTX 5090, Microsoft WARP, and Windows SDKdxil.dll:crates/victory-shader/src/emit/lower/trunc.rshandles every exponent band (< 1023,1023..1043,1043,1044..1075,>= 1075) cleanly, masks shift counts with& 31(trunc.rs:70) to avoid shift-width UB, preserves signed zeros, and avoids settingDOUBLESorINT64shader feature bits (SFI0 & 0x8021 == 0).cargo xtask policy(192 files ok;crates/victory-shader/src/emit/lower.rs= 520,632 B < 524,288 B) andcargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) pass.v_trunc_f64_rounds_toward_zero_in_both_wordsandv_trunc_f64_rounds_a_negated_vop3_literal) pass on RTX 5090 and WARP withdxil.dllvalidation.v[1:2] -> v[1:2]), and overlapping (v[1:2] -> v[2:3]) register pairs, 15 VOP3 source/modifier cases (abs,neg, high-word literal, inline floats240..=248, inline ints,NULL), and rejection ofclampandomod = 1/2/3on both RTX 5090 and WARP.(Non-blocking note: signaling NaNs pass through with their raw bit pattern unchanged rather than setting the quiet bit
0x0008_0000in the high word.)Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T18:31:42Z.
Review: APPROVED
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).v_trunc_f64using pure 32-bit bit manipulation keepsSFI0double/int64 feature bits clear while accurately rounding toward zero across subnormals, 31/32/33-bit fractional tails, negated VOP3 literals, and infinities.cargo test -p victory-shader --lib emit::valu_tests::v_trunc_f64 -- --test-threads=1: 2 passed, 0 failed on RTX 5090 and 2 passed, 0 failed onVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.