F2ipPart

sm86.sail

F2IP.U8.F32.NTZ d, a, b, c: the floats a and b each rounded to an integer and saturated to 8 bits, a NaN 0 (.NTZ), packed as PTX's cvt.pack packs I2IP's: d = c << 16 | a' << 8 | b'. Bits 72-79 (CuAssembler's sm_86 records): 0x04 .U8.F32.NTZ, bit 76 .S8 (-128 to 127), bit 75 .RELU (0 to 127). Bits 78-79 are the rounding, in F2I's place and order: CuAssembler records none but the nearest, and one game's mesh programs give 3 to F2IP.U8 of a float times 255, as a shader's uint() truncates. Its compute programs pack colours with F2IP.U8 then PRMT

function F2ipPart(r : int, s8 : bool, lo : bits(32), hi : bits(32), rounding : int) -> bits(32) = {
    let x = Float32(R_read(r));
    let nan = FIsNaN(x);
    let rounded = FRound(rounding, x);
    let clamped = FMinN(FMaxN(rounded, FConst(lo)), FConst(hi));
    let i = if s8 then Bits32(FToS32(clamped)) else FToU32(clamped);
    let byte = i & 0x000000ff;
    if nan then 0x00000000 else byte
}

Used by


Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Mesa's NAK (sm70_encode.rs, MIT) and CuAssembler's sm_86 records.