"""v_interp_p1ll_f16 / v_interp_p2_f16 read the low or, with `high`, the high f16 of a packed attribute channel. The producer packs two 16-bit varyings in one 32-bit param channel, low half and high half (Mesa ac_nir_prerast_utils.c, nir_pack_32_2x16_split), and the PS picks a half with the `high` bit, passed to both ops of the pair (Mesa ACO aco_isel_helpers.cpp emit_interp_instr; llvm-mc gfx1013 sets byte 5 bit 0 on both ops). A translated VS exports the channel's raw 32 bits, so each half has to be decoded per vertex and then interpolated: interpolating the packed word as one f32 gives neither. support.varyings feeds the module what Vulkan would give it for those raw per-vertex words. """ import struct import unittest import support # Barycentric weights of vertices 0, 1, 2 (AMD i = 0.25, j = 0.5). BARY = (0.25, 0.25, 0.5) LO, HI = (0.5, 1.5, 2.5), (-4.0, 8.0, 16.0) # per vertex; interpolated: 1.75 and 9.0, both exact in f16 INT_Y = (0x101, 0x102, 0x103) # attr0.y raw bits, read flat with v_interp_mov_f32 CTRL = (0.25, 0.5, 1.0) # attr1.x, f32, read with p1/p2_f32 only: 0.6875 def pack(lo, hi): return struct.unpack("