Shaders: lower v_cvt_pknorm_{i16,u16}_{f32,f16} in pure 32-bit DXIL #2100
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!2100
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2100"
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?
@geiyiliyabumo on GitHub · 2026-11-25 04:59 UTC · original
geiyiliyabumo:feat/shader-v-cvt-pknorm→main· +192 −0 · 2 files · 1 commits · openSummary
v_cvt_pknorm_i16_f32(0x368),v_cvt_pknorm_u16_f32(0x369),v_cvt_pknorm_i16_f16(0x312), andv_cvt_pknorm_u16_f16(0x313) incrates/victory-shader/src/emit/lower.rsusing pure 32-bit DXIL without enablingInt64/WIDE_OPS.f32clamping ([-1.0, 1.0]->32767.0fori16,[0.0, 1.0]->65535.0foru16), ties-to-even rounding, NaN ->0, VOP3abs/negsource modifiers, andop_selhalf selection for_f16, while rejecting unsupportedclampandomod.crates/victory-shader/src/emit/valu_tests.rscovering boundary values (0.0,-0.0,±1.0,±0.5,±2.0,±inf,NaN),abs/negmodifiers,op_selhalf selection, output modifier rejection, and verifyingInt64is not set.Verification
cargo xtask policy: passedcargo clippy -p victory-shader --tests -- -D warnings: passedcargo test -p victory-shader --lib v_cvt_pknorm -- --test-threads=1with Microsoftdxil.dll: 3/3 passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)@upipibi on GitHub · 2026-11-25 05:05 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
de026e8.victory-shader: 247 passed, 3 failed, 3 ignored. The newv_cvt_pknorm_rounds_clamps_and_packs,v_cvt_pknorm_honors_source_modifiersandv_cvt_pknorm_rejects_output_modifierspass. The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware.Overlap, from reading: #596 (open, conflicting with
main) lowers the same fourv_cvt_pknorm_{i16,u16}_{f32,f16}instructions with exact rounding.AI-assisted (Claude Code).
@Dathinel on GitHub · 2026-11-25 05:08 UTC · original · edited 2026-11-25 05:14 UTC
I replayed two of Lyrnc's native gfx1036 measurements on
de026e8with synthetic VOP3 programs. Set both source registers to the input bits and read back the packed destination. RTX 3050 Laptop and WARP returned the same words:v_cvt_pknorm_i16_f323f7334e6799a799a79997999v_cvt_pknorm_u16_f323e2abaab2aae2aae2aaf2aafThese two inputs would make regression cases for a 32-bit implementation that preserves the native result. Rounding the product to f32 first changes each converted half by one.
For the f16 forms, the 422-input native sample in #596 did not distinguish the rounding rules. I compared both models over all 65,536 half encodings on CPU; only four encodings per signedness distinguish them. If someone still has the native probe, one input covers both forms: put half
0x3801in both sources. For signed/unsigned the exact-product predictions are400f400f/801f801f. This PR returned40104010/80208020on both backends. A native readback of those two words would settle this fixture's expectation.AI-assisted. Synthetic inputs only.
Tested f32-only alternative that keeps Int64 off. After NaN handling and clamping, take the magnitude
mand setPto 32768 (signed) or 65536 (unsigned). In f32, computea = m * Pandq = roundEven(a). The integer magnitude isint(q) - int((a - (q - 0.5)) < m); then restore the sign for SNORM. Keep the subtractions in that order. Scaling by the power of two is exact. The only exact halfway input magnitude is 0.5, for which q is even.I checked every nonnegative binary32 encoding from 0 through 1 against an exact-product reference for each scale. An experimental lowering passed 94 packed readbacks each on RTX 3050 Laptop and WARP, including the two native f32 witnesses above. SFI0 Int64 stayed clear. The same probe failed on the unmodified PR at the first native witness. This experiment leaves the f16 decision open.
@steven-seagull27 on GitHub · 2026-11-25 08:38 UTC · original
Confirmed the two packed f32 rounding differences on an RTX 5080 (driver 621.40) at
de026e8418ef97cf3531888e4a77204a86f5e5a6. Built-in WARP 10.0.26100.10068 returned the same words on Windows 11 build 26300.10075.Both adapters passed all 56 round/clamp/pack readbacks and all 8 source-modifier readbacks in the PR. I then ran the two additional inputs below, putting the same f32 bit pattern in both source registers and reading back the packed 32-bit destination.
v_cvt_pknorm_i16_f32(0x368)0x3f7334e60x799a799a0x799a799a0x79997999v_cvt_pknorm_u16_f32(0x369)0x3e2abaab0x2aae2aae0x2aae2aae0x2aaf2aafEach adapter completed both extra dispatches. Relative to the native measurements, each signed half is one high and each unsigned half is one low. This reproduces the earlier RTX 3050 Laptop result on Blackwell. Native Radeon measurements · Earlier RTX 3050 Laptop replay
@sinan-cmyk on GitHub · 2026-11-25 08:50 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head de026e84 onto
main940d32f(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: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 10:38 UTC · original · edited 2026-11-25 22:21 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-shader/src/emit/lower.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
@geiyiliyabumo on GitHub · 2026-11-25 13:23 UTC · original
Updated \cvt_pknorm{i16,u16}_{f32,f16}\ (head $sha) to round from the exact product in pure 32-bit DXIL using @Dathinel's power-of-two scaling method (\ = |x| * P, \q = roundEven(a), \mag = int(q) - int((a - (q - 0.5)) < |x|), keeping \SFI0 Int64\ clear). Added the native RDNA2 f32 witnesses (\
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.