Loads, texture reads and special instructions
fixed bit field field the encoding fixes should be
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| 1 | 1 | 1 | 0 | 0 | pred | skipinv | nosched | syncstart | minpack | src0_ext | src1_ext | src2_ext | fconv | mask_count | dim | lod_mode | use_pa | sb_mode | src0_type | src0_bank | dest_bank | ||||||||||
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| src1_bank | src2_bank | dest_n | src0_n | src1_n | src2_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.
| Field | Bits | The Sail reads it in |
|---|---|---|
| pred | 58:56 | |
| skipinv | 55 | |
| nosched | 54 | |
| syncstart | 52 | |
| minpack | 51 | |
| src0_ext | 50 | Bit(50) |
| src1_ext | 49 | Bit(49) |
| src2_ext | 48 | Bit(48) |
| fconv | 47:46 | execute_SMP |
| mask_count | 45:44 | |
| dim | 43:42 | execute_SMP |
| lod_mode | 41:40 | execute_SMP |
| use_pa | 39 | Bit(39) |
| sb_mode | 38:37 | execute_SMP |
| src0_type | 36:35 | execute_SMP |
| src0_bank | 34 | Bit(34) |
| dest_bank | 33:32 | |
| src1_bank | 31:30 | execute_SMP |
| src2_bank | 29:28 | execute_SMP |
| dest_n | 27:21 | execute_SMP |
| src0_n | 20:14 | execute_SMP |
| src1_n | 13:7 | execute_SMP |
| src2_n | 6:0 | execute_SMP |
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).