shader: lower v_cvt_pknorm_u16_f32 and v_cvt_pknorm_i16_f32 #55
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/55"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T11:35:09Z.
What this changes
A vertex and pixel pair was refused at world load with
v_cvt_pknorm_u16_f32 is not supported. This adds the instruction and its signed sibling next tov_cvt_pkrtz_f16_f32: each source is clamped to [0, 1] (signed: [-1, 1]), scaled by 65535 (32767), rounded to nearest even and masked to 16 bits; src0 goes in the low half and src1 in the high half. VOP3 abs and neg are honoured throughfsrc. The_f16forms stay refused.Sources: AMD's machine-readable RDNA2 ISA (VOP3-only on GFX10, "packed unsigned normalized short"), LLVM
VOP2Instructions.td(VOP3Only_Real_gfx10<0x369>), Mesa ACO instruction selection (operand order) and NIRpack_unorm_1x16/pack_snorm_1x16(clamp and round-to-even).One guess, marked in the code: a NaN source gives 0. No public source states the hardware result; this follows D3D's float-to-normalized rule, as the file already does for
v_cvt_pk_u8_f32.How it was tested
cargo test -p victory-shader: 220 passed, 0 failed, 2 ignored. New testnormalized_16_bit_packing_lowers_in_pixel_shader(u16, i16, abs/neg, an inline constant, both host wave sizes;_f16still refused).normalized_packing_matches_the_hardwareis Windows-only like the rest ofsemantics_tests. It was type-checked only and needs a Windows run. Its 19 known answers were derived separately from the translator.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings(clean, run on a Mac)cargo xtask policy(365 files ok)Checklist
VICTORY_*variable and documented (none added)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:51:43Z.
Review: CHANGES_REQUESTED
The half order matches the RDNA ISA, and the clamp, scale, and nearest-even rounding match Mesa's packing model. Please document NaN-to-zero in
docs/native-host.mdas a Direct3D-based assumption for this opcode. Heads-up: this conflicts with #56 ingfx_refusal_tests.rs, so whichever lands second will need a rebase.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T12:30:37Z.
Documented NaN-to-zero in
docs/native-host.mdas an assumption based on Direct3D's float-to-normalized rule, and noted which parts are not guesses (half order, clamp, scale, rounding). I mergedmainto clear the conflict with #58 ingfx_refusal_tests.rs. It will conflict with #56 in the same file again; I'll rebase whichever lands second.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:48:04Z.
Review: APPROVED
Thanks, the earlier requests are addressed and the checks pass (tests incl. Metal, Windows clippy, policy). Approved.