Repository navigation
shader: lower packed 16-bit minimum and maximum in direct DXIL - #3144
Conversation
|
LGTM! The packed 16-bit min/max lowering is correctly implemented: Key features:
Implementation notes:
This enables games using 16-bit min/max operations for compute shaders, which is essential for modern rendering pipelines that leverage half-precision math for performance. |
|
This PR now conflicts with Could you merge Command: AI-assisted; commands listed were executed locally. |
|
Fixed |
tedin7
left a comment
There was a problem hiding this comment.
Review of 3f35c1f (main merged in by the author). Comment only.
packed_minmax handles v_pk_{min,max}_{f16,i16,u16} with each lane's OP_SEL / OP_SEL_HI selector. It refuses clamp, the NEG_LO/NEG_HI fields, a third source, the unused third OP_SEL_HI bit, lane-mask SGPRs, and every inline constant except 0 and a literal, so the f32-pattern inline-float problem cannot reach it. The f16 order key maps binary16 encodings to a monotone integer key (negative half reversed, -0 below +0). NaN handling follows the existing contract: one NaN gives the other side, and two NaNs give 0x7E00. The i16/u16 keys are an XOR of the sign bit and the plain value. The f16 forms also require a known IEEE denormal mode. native_packed_minmax_pixel_warp reads the results back on WARP through the pixel path, so the lowering is checked on our host, not only through the wave32 compute leg.
src/gfx1013_direct_compute.inl is also changed on cpp-migration; this merges cleanly there, and the native sweep on that merge is in the comment below.
Commands: git diff origin/main...pull/3144/head (read), git merge-tree --write-tree origin/cpp-migration pull/3144/head, plus the Windows commands in the comment below.
AI-assisted; commands listed were executed locally.
|
Windows Server 2025 verification of
AI-assisted; commands listed were executed locally. |
Change
Fixes #3069. Refs #2935 and #2022. The direct DXIL frontend refused the six canonical VOP3P
v_pk_min/max_{i16,u16,f16}forms. Both selector groups now feed one shared lowering for Pixel and Compute. It compares signed and unsigned integer halves in their own order and compares binary16 as bit patterns, preserving the existing HLSL behavior for signed zeros, subnormals and NaNs.The lowering accepts numeric registers, literal words and inline zero. It uses the ordinary vector-write predicate and refuses unsupported modifiers and binary16 denormal modes.
Verification
Tested
f2149800a8d1aabcb3e85faa56be7f837913f854based on429f11d5. Windows 11 build 26300.10075, MSVC 19.52, Windows SDK 10.0.26100 and DXC 1.9.2602.17.10.0.26100.10068and RTX 407032.0.16.2124. Compute on RTX 4070 matched 2,064 words per type. Swapping selector groups changed 640 words and sparse EXEC preserved the inactive lanes. Native Compute requires wave32, while the local WARP adapter exposes four lanes.Evidence and provenance
On the old compiler, individual synthetic probes refused each of the six opcodes. The source-built fixture calculates expected results from signed/unsigned integers and Python binary16, checks signed-zero and NaN results bit for bit and verifies both destination halves and guard words. The two-NaN payload convention follows the existing Xbox2Windows path and remains unverified on RDNA hardware.
Behavioral reference was the public shadPS4 packed FP16 PR, merged as
34b35b526e3bfbb8a6f22c11035cb051174ac6f1, observed 2026-11-27 under GPL-2.0. Instruction semantics come from the AMD RDNA 2 ISA and the LLVM 21.1.0 GFX1030 syntax, revision3623fe661ae35c6c80ac221f14d85be76aa870f1(Apache-2.0 with LLVM exception). Implementation and fixtures were written in Xbox2Windows.Checklist
I used Codex to prepare the change and ran verification locally.