Repository navigation
fix(shader): compute v_cvt_pknorm_*_f32, v_ldexp_f32 and v_pack_b32_f16 on the bits - #596
Conversation
…16 on the bits
v_pack_b32_f16 applied neg/abs to bit 31 of the source dword instead of the
selected half. v_cvt_pknorm_{i16,u16}_f32 and v_ldexp_f32 used GLSL
PackSnorm2x16/PackUnorm2x16/Ldexp, which leave NaN, rounding ties and
denormals to the driver. Compute them on the bits as measured on RDNA2.
Co-Authored-By: Claude <noreply@anthropic.com>
fd487f4 to
a4482e0
Compare
|
Thanks, this checks out. I disassembled the test kernel with
One note for the merge order rather than the code: PPSA21564 uses Ready to merge from my side once that run is done. |
|
Gated on PPSA21564: no visual or FPS change. |
Conflicts resolved: - libSceAudioPropagation/Export.cpp: upstream's boykopovar#482 + boykopovar#489 version taken; it is the same no-propagation model as astrobot's stand-in, with SourceRender and the handle-only UnregisterMaterial already in it. - State.cpp (boykopovar#453): astrobot's resident depth model kept; it already skips the tests of an absent plane (boykopovar#453's test is on astrobot since e087a4f). - Graphics.cpp, State.hpp, ShaderResources.cpp: astrobot's DepthTarget model kept (exportIndex, no DepthSurface.hpp), upstream's ThreadOwned include added. - BdaResources.cpp: astrobot's form with boykopovar#390's message. - VulkanDevice.cpp, Context.hpp, PacketExecution.cpp: both sides kept (calibrated timestamps, host query reset, GDS, memory budget; pipeline stats). - Spirv: astrobot's split-wave rules first, then boykopovar#608's wave-mask ballot and boykopovar#587's host subgroup lane; astrobot's function LDS sizing and boykopovar#573's LDS lock both kept; conditionalDepth kept in the atomic update loops; upstream's buffer atomics (boykopovar#321 boykopovar#332 boykopovar#594) and 64-bit LDS atomics taken. - TechnicalDebt.md: both sides, duplicate lines dropped. Build fixes folded in: the upstream boykopovar#453 test block duplicated next to astrobot's adapted copy removed; a lost closing brace after the host query reset block restored; lookupLog() is a function since boykopovar#590; the duplicate MUTEX_TYPE_ADAPTIVE constant (astrobot's 93b2d0e equals boykopovar#156) removed; the ops boykopovar#596 drops removed from the masked-select list and the BDA test message updated (the gate-batch-2 integ commits 559e4fab6 and 2ec968fb5).
What
Found by running decoded-but-never-executed VOP3 ops against the hardware.
v_pack_b32_f16: neg/abs were applied to bit 31 of the source dword, not to the selected half. On the low half they were ignored (fails on RADV and lavapipe). The halves are now read withreadF16Bits, as the other f16 ops do.v_cvt_pknorm_i16_f32/v_cvt_pknorm_u16_f32used GLSLPackSnorm2x16/PackUnorm2x16. The spec leaves the rounding to the driver (round()), and NaN is undefined there. Lavapipe gives0x8001for NaN and rounds some ties the other way. Now done on the bits bynormF32, the f32 version ofnormF16: exactmantissa * scalein 64 bits, round to nearest even, NaN to 0, saturate at |x| >= 1.v_ldexp_f32used GLSLLdexp, whose NaN payload and denormal results are up to the driver. Lavapipe quiets sNaN and drops the sign of-|NaN|. Now the exponent field is rewritten on the bits.FPLdexp,PackSnorm2x16andPackUnorm2x16had no other users, so this PR removes them from the IR and the SPIR-V backend.Behaviour measured on HW
Measured on an RDNA2 GPU (gfx1035) with 4096 rows, in the mode the recompiler assumes (IEEE=0, f32 denormals flushed). The Python model matches all 4096 rows:
0x8001). The rest isx * 32767orx * 65535rounded once to nearest even. The product is not rounded to f32 first: 376 of the rows differ if it is.With IEEE=1 and denormals on, the HW quiets sNaN and returns denormal ldexp results. That mode isn't modelled, same as for the other f32 ops.
Tested
New
agc_driver_vop3_pack_ldexp(tests/execution/Vop3PackLdexp.cpp). It runs 32 lanes with the expected values from the HW. The rows cover NaN/sNaN, ±0, denormals, inf, ±1 boundaries, exact rounding ties for both scales, and ldexp exponents reaching 255 and 0. It also runsv_lerp_u8andv_mul_lo_i32, which no test executed. Both were already correct. gfx1035 has nov_mul_lo_i32, so its expected values are the low 32 bits of the product.mainthe test fails: on RADV forv_pack_b32_f16with neg/abs (lane 0 pack_b32_f169 is 0x0001d40f, expected 0x0001540f), and on lavapipe also for pknorm and ldexp NaN rows. Each piece (pack modifiers, norm sticky bit, tie rule, NaN, ldexp overflow, underflow, NaN, denormal input and exponent clamp) was mutated, and each mutation makes the test fail.agc_driver_global_load_addtid,agc_driver_pixel_helper_lanesandagc_driver_vop3_carry_out. Those fail on local RADV onmaintoo (wave32 on RADV's 64-wide subgroup).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)