cpp-migration: lower v_cvt_pk_u8_f32 in the direct C++ compute path #2997
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2997
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@legacy-code-archaeologist on GitHub · 2026-11-27 03:45 UTC · original
Target branch
cpp-migration. Part of #2935 (instruction coverage: f32 ALU). I am taking this; please say if you already have it locally and I will drop it.Gap: the direct compute path refuses
v_cvt_pk_u8_f32withdirect DXIL lowering for v_cvt_pk_u8_f32. I found this with the same per-opcode VOP3 probe as #2985, oncpp-migration05438d65.gfx2hlsl.pylowers it (op_v_cvt_pk_u8_f32): D = (S2 & ~(0xff << 8 * S1[1:0])) | (flt32_to_uint8(S0) << 8 * S1[1:0]). Its conversion is the one measured on RDNA 2 hardware (seedocs/experiments.md): round to nearest even, saturate to [0, 255]; NaN, both zeros and negatives give 0, and +inf gives 255. The positive test is the integer comparison (bits - 1) < 0x7f800000, which avoids a float compare that fast-math could fold.Plan:
FMinwith 255.0,Round_ne, thenfptouiand the byte merge into S2.gfx2hlsl.py.AI-assisted.
@akimfomin on GitHub · 2026-11-27 04:23 UTC · original · edited 2026-11-27 04:46 UTC
PortBridge Radar independently surfaced a useful control for your direct DXIL probe: the AnyPS5 team already recorded the expected packed words for this opcode on gfx1035. The pinned fixture and expected rows cover all four byte positions and retention of the other bytes.
I replayed the 32 recorded expectations with a small CPU model. Round-to-nearest-even with saturation matches 32/32, truncation fails two rows and half-up fails one. For example, input 1.5 with prior word
0xbf800000and byte selector 2 yields0xbf020000; input 2.5 with prior word0x3f000002and selector 3 yields0x02000002.The smallest next check is to add those two expected words to your existing DXIL dispatch as independent controls. The reference values belong to AnyPS5; the CPU replay is from PortBridge and does not predict a pass for the DXIL implementation. Both sources are linked from the public Radar.
Update after #2998 merged: the new implementation uses Xbox2Windows’s own reference. The merged controls cover the rounding distinctions already. The reported GPU readback was SKIP on the Quadro. PortBridge Lab #121 now links the exact merged revision and asks for one run of that existing fixture on a Wave32 adapter.
@MasterDomino on GitHub · 2026-11-27 04:36 UTC · original
Completed by #2998, merged into
cpp-migrationasaf6d255f. Merges into a non-default branch do not close issues automatically.@Leyukaka on GitHub · 2026-11-27 05:41 UTC · original
Second hardware readback for the
v_cvt_pk_u8_f32lowering of #2998. It passed on the RX 9070 XT in the #2998 review; it fails here on NVIDIA.Setup:
cpp-migration999e17cd, Release.ctest --test-dir <build> -R '^native_cvt_pk_u8_hardware$'fails.Result:
S0 = 0.5with byte select 0. The first mismatch is word 8 (lane 0). Every lane of both groups writes0xa5a5a501where round to nearest even expects0xa5a5a500.1e30, both infinities, both zeros, NaN, -1.0, the smallest denormal, 127.4999, 3.0 and 255.0.So on this driver
0.5rounds to 1 while the other ties round to even.FMin(x, 255.0),Round_ne,fptouiand the byte merge, with no other rounding step. So this looks likeRound_ne(0.5)giving 1 here.v_movliteral, so the driver compiler may also have folded it as a constant.Round_ne(0.5)in isolation. The same fixture passed on AMD in the #2998 review, so this is specific to this adapter or driver.AI-assisted.