FSWZADD

Floating point instructions

fixed bit field field the encoding fixes should be

FSWZADD

6362616059585756555453525150494847464544434241403938373635343332
0101000011111soft_ftz
313029282726252423222120191817161514131211109876543210
lanepred.notpredRaRd

bits 63:48: 0101 0000 1111 1---

Runs execute_FSWZADD with Form() 0.

Fields

FieldBitsFrom
soft_ftz44execute_FSWZADD
lane29:28execute_FSWZADD
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

FSWZADD: Each lane of a quad (0 the upper left, 1 the upper right, 2 the lower left, 3 the lower right) does the mode in its bits of the swizzle (shader_fswzadd_lanes): a + b (0), b - a (1), a - b (2) or b (3). Nothing crosses lanes: compilers read the neighbour with SHFL.BFLY first, and dFdx is FSWZADD of it and x with 0x99 (nouveau's handleDFDX, NAK's ddx). Nouveau's manual TXD fixes the order of the lanes and the modes: 0xcc adds the gradient in a to b on the right lanes and keeps b on the left ones. Eden and Ryujinx count the lanes from the low bits, and Eden negates every mode. The rounding mode (39-40) is round to nearest, as FADD's is, and NDV (38) changes nothing computed

let left0 = RegF(RegA());
let right0 = RegF(RegB());
let soft_ftz = Field(44, 1) == 0b1 & SoftFtz();
let left = if soft_ftz then FloatFtz(left0) else left0;
let right = if soft_ftz then FloatFtz(right0) else right0;
/* without subgroups, the place FragCoord gives */
let lane = if FswzMask(UInt(Field(28, 2))) != 15 then QuadLane() else 0x00000000;
/* pick k: whether this lane's mode is k + 1, where some lanes' are and others' aren't */
let m1 = FswzMask(1);
let m2 = FswzMask(2);
let m3 = FswzMask(3);
let some1 = m1 != 0 & m1 != 15;
let some2 = m2 != 0 & m2 != 15;
let some3 = m3 != 0 & m3 != 15;
let pick1 = if some1 then ((to_bits(32, m1) >> lane) & 0x00000001) != 0x00000000 else false;
let pick2 = if some2 then ((to_bits(32, m2) >> lane) & 0x00000001) != 0x00000000 else false;
let pick3 = if some3 then ((to_bits(32, m3) >> lane) & 0x00000001) != 0x00000000 else false;
if m3 == 15 then R_writeF(Dst(), right) else {
    let lhs0 = if m1 == 15 then FNeg(left) else left;
    let lhs = if some1 then (if pick1 then FNeg(left) else left) else lhs0;
    let rhs0 = if m2 == 15 then FNeg(right) else right;
    let rhs = if some2 then (if pick2 then FNeg(right) else right) else rhs0;
    let sum = FAddNC(lhs, rhs);
    let flushed = if soft_ftz then FloatFtz(sum) else sum;
    R_writeF(Dst(), if some3 then (if pick3 then right else flushed) else flushed)
}

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 Eden's maxwell.inc (GPL-2.0-or-later).