SMP

Loads, texture reads and special instructions

fixed bit field field the encoding fixes should be

Encoding

6362616059585756555453525150494847464544434241403938373635343332
11100predskipinvnoschedsyncstartminpacksrc0_extsrc1_extsrc2_extfconvmask_countdimlod_modeuse_pasb_modesrc0_typesrc0_bankdest_bank
313029282726252423222120191817161514131211109876543210
src1_banksrc2_bankdest_nsrc0_nsrc1_nsrc2_n

bits 63:0: 1110 0xxx xx-x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx

It is in a group of patterns that may match the same word: the decoder tries them in this order, and the first that matches decodes it: SMP, PHAS, NOP, BR, SMLSI, SMBO, KILL, LIMM, DEPTHF, SPEC, VLDST.

Runs execute_SMP with Form() 0.

Fields

FieldBitsThe Sail reads it in
pred58:56
skipinv55
nosched54
syncstart52
minpack51
src0_ext50Bit(50)
src1_ext49Bit(49)
src2_ext48Bit(48)
fconv47:46execute_SMP
mask_count45:44
dim43:42execute_SMP
lod_mode41:40execute_SMP
use_pa39Bit(39)
sb_mode38:37execute_SMP
src0_type36:35execute_SMP
src0_bank34Bit(34)
dest_bank33:32
src1_bank31:30execute_SMP
src2_bank29:28execute_SMP
dest_n27:21execute_SMP
src0_n20:14execute_SMP
src1_n13:7execute_SMP
src2_n6:0execute_SMP

Operation Sail

SMP: the texture of the dependent sampler src1 names, read at src0 (one, two or three components: a cube's), its level of detail from src2 where lod_mode says (1 a bias in a fragment program, 2 the level, 3 the gradients), into registers from dest (PA with use_pa, else the temporaries); sb_mode 1 and 3 its texels' gather (3 with the bilinear weights)

let dim = UInt(Field(42, 2)) + 1;
Src0(SRC0, UInt(Field(14, 7)), Bit(34), Bit(50), 1, 8);
Src12(SRC1, UInt(Field(7, 7)), UInt(Field(30, 2)), Bit(49), 1, 8);
let src0_type = UInt(Field(35, 2));
let coord_type = if src0_type == 0 then T_F32 else if src0_type == 1 then T_F16 else T_C10;
SetType(SRC0, coord_type);
let dependent = if BankOf(SRC1) == B_SA then Dependent(NumOf(SRC1)) else 0;
if dependent == 0 then throw(Refuse("an SMP whose sampler isn't a dependent one"));
let sb_mode = UInt(Field(37, 2));
if sb_mode == 2 then throw(Refuse("SMP queries"));
if dim > 3 then throw(Refuse("SMP dimension %u", dim));
let resource = dependent - 1;
if resource >= 16 then throw(Refuse("SMP sampler %u", resource));
let format = TextureFormat(resource);
let fconv = UInt(Field(46, 2));
let type = if fconv == 2 then T_F16 else if fconv == 3 then T_F32 else TextureType(format);
Load(A, SRC0, if dim == 1 then 1 else if dim == 2 then 3 else 7, 0);
if Failed() then throw(Stop());
if KindOf(A) != K_FLOAT then ToFloat(A, coord_type, 1);
let coord = if dim == 3 then V3Of(At(A, 0), At(A, 1), At(A, 2))
            else V2Of(At(A, 0), if dim == 1 then Zero() else At(A, 1));
let sampler = Sampler(resource, if dim == 3 then 1 else 0);
let bank = if Bit(39) == 1 then (if Secondary() then B_SA else B_PA) else B_TEMP;
if sb_mode == 3 & dim == 3 then throw(Refuse("SMP cube gather with UV coefficients"));
let dest = UInt(Field(21, 7));
if sb_mode != 0 then {
    /* the four texels' components: each component of the four, then the next component's */
    Gather(sampler, coord, format, type, bank, dest, if sb_mode == 3 then 1 else 0)
} else {
    Src12(SRC2, UInt(Field(0, 7)), UInt(Field(28, 2)), Bit(48), 1, 8);
    SetType(SRC2, coord_type);
    let lod_mode = UInt(Field(40, 2));
    let implicit = Fragment() & (lod_mode == 0 | lod_mode == 1);
    let sampled = if lod_mode == 3 then {
        /* the gradients */
        if dim == 3 then {
            Load(B, SRC2, 7, 0);
            Load(C, SRC2, 7, 1)
        } else {
            Load(B, SRC2, 3, 0);
            Load(C, SRC2, 12, 0)
        };
        if Failed() then throw(Stop());
        let gx = if dim == 3 then V3Of(At(B, 0), At(B, 1), At(B, 2)) else V2Of(At(B, 0), At(B, 1));
        let gy = if dim == 3 then V3Of(At(C, 0), At(C, 1), At(C, 2)) else V2Of(At(C, 0), At(C, 1));
        SampleGrad(sampler, coord, gx, gy)
    } else if lod_mode != 0 then {
        Load(B, SRC2, 1, 0);
        if Failed() then throw(Stop());
        let lod = At(B, 0);
        if implicit then SampleBias(sampler, coord, lod)
        else SampleLod(sampler, coord, if lod_mode == 1 then Zero() else lod)
    } else {
        if implicit then SampleImplicit(sampler, coord) else SampleLod(sampler, coord, Zero())
    };
    StoreInput(bank, dest, type, sampled, TextureComponents(format))
}

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 Vita3K's usse_translator_entry.cpp (GPL-2.0-or-later).