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 | op | pred | skipinv | nosched | moe_expand | syncstart | cache_ext | src0_ext | src1_ext | src2_ext | mask_count | addr_mode | mode | primattr | range_enable | data_type | inc_or_dec | src0_bank | cache_bypass | drc_sel | |||||||||
| 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: 111x xxxx xxxx 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_VLDST with Form() 0.
| Field | Bits | The Sail reads it in |
|---|---|---|
| op | 60:59 | execute_VLDST |
| pred | 58:56 | |
| skipinv | 55 | |
| nosched | 54 | |
| moe_expand | 53 | Bit(53) |
| syncstart | 52 | |
| cache_ext | 51 | |
| src0_ext | 50 | Bit(50) |
| src1_ext | 49 | Bit(49) |
| src2_ext | 48 | Bit(48) |
| mask_count | 47:44 | execute_VLDST |
| addr_mode | 43:42 | |
| mode | 41:40 | |
| primattr | 39 | Bit(39) |
| range_enable | 38 | |
| data_type | 37:36 | execute_VLDST |
| inc_or_dec | 35 | |
| src0_bank | 34 | Bit(34) |
| cache_bypass | 33 | |
| drc_sel | 32 | |
| src1_bank | 31:30 | execute_VLDST |
| src2_bank | 29:28 | execute_VLDST |
| dest_n | 27:21 | execute_VLDST |
| src0_n | 20:14 | execute_VLDST |
| src1_n | 13:7 | execute_VLDST |
| src2_n | 6:0 | execute_VLDST |
VLDST: words loaded from a uniform buffer read from memory, at src0 + src1 (+ 4 without moe expansion) + src2 bytes, src0 a register the program's uniform buffer table filled; or from the literal buffer, at a register's offset from its array, else (constant offsets, one word) from the program's bytes
let op = UInt(Field(59, 2));
if op == 2 then throw(Refuse("VLDST stores"));
if op != 1 then throw(Refuse("VLDST operation %u", op));
let data_type = UInt(Field(36, 2));
if data_type > 2 then throw(Refuse("VLDST of data type %u", data_type));
let size = if data_type == 0 then 4 else if data_type == 1 then 2 else 1;
let bytes = size * (UInt(Field(44, 4)) + 1);
Src0(SRC0, UInt(Field(14, 7)), Bit(34), Bit(50), 0, 7);
Src12(SRC1, UInt(Field(7, 7)), UInt(Field(30, 2)), Bit(49), 0, 7);
Src12(SRC2, UInt(Field(0, 7)), UInt(Field(28, 2)), Bit(48), 0, 7);
SetType(SRC0, T_I32);
SetType(SRC1, T_I32);
SetType(SRC2, T_I32);
let bank = if Secondary() then B_SA else if Bit(39) == 1 then B_PA else B_TEMP;
if BankOf(SRC1) == B_IMM then SetNum(SRC1, NumOf(SRC1) * size);
let dest = UInt(Field(21, 7));
if BankOf(SRC0) == B_SA & NumOf(SRC0) == LiteralRegister() then {
if UInt(Field(44, 4)) != 0 | BankOf(SRC1) != B_IMM | BankOf(SRC2) != B_IMM then {
/* at a register's offset: from the array */
if not_bool(HasLiterals()) then throw(Refuse("a literal buffer read past the program"));
Load(A, SRC1, 1, 0);
Load(B, SRC2, 1, 0);
if Failed() then throw(Stop());
let b1 = if BankOf(SRC1) != B_IMM then ISubT(At(A, 0), SConst(65536)) else At(A, 0);
let offset = IAddT(SConst(LiteralBase()), IAddT(b1, At(B, 0)));
let first = ShrT(AsU32(offset), UConst(2));
LiteralsBegin();
foreach (i from 0 to DIV(bytes, 4) - 1) WordStore(bank, dest + i, LiteralRead(IAddT(first, UConst(i))))
} else {
let offset = LiteralBase() + NumOf(SRC1) + NumOf(SRC2);
if not_bool(LiteralFits(offset)) then throw(Refuse("a literal past the program"));
WordStore(bank, dest, UConst(LiteralData(offset)))
}
} else {
if not_bool(HasBuffer()) then throw(Refuse("a VLDST with no uniform buffer"));
Load(A, SRC0, 1, 0);
Load(B, SRC1, 1, 0);
Load(C, SRC2, 1, 0);
if Failed() then throw(Stop());
let a1 = if BankOf(SRC1) != B_IMM then ISubT(At(B, 0), SConst(65536)) else At(B, 0);
let a2 = if Bit(53) == 0 then IAddT(a1, SConst(4)) else a1;
let address = AsU32(IAddT(At(A, 0), IAddT(a2, At(C, 0))));
let index = ShrT(address, UConst(2));
BufferBegin();
foreach (i from 0 to DIV(bytes, 4) - 1) WordStore(bank, dest + i, BufferRead(IAddT(index, UConst(i))))
}
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).