LDC

Constant buffer, local, shared and global memory instructions

fixed bit field field the encoding fixes should be

LDC

6362616059585756555453525150494847464544434241403938373635343332
1110111110010sizedynamic_bankbankoff
313029282726252423222120191817161514131211109876543210
offpred.notpredRaRd

bits 63:48: 1110 1111 1001 0---

Runs execute_LDC with Form() 0.

Fields

FieldBitsFrom
size50:48execute_LDC
dynamic_bank44execute_LDC
bank40:36execute_LDC
off35:20execute_LDC
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

LDC: the constant buffer word at the register at 8 plus the signed offset at 20, of bank 36 (bit 44: the register's high half added to the bank, its low half the address), a byte or halfword of it (48-50) or a pair. It loads the handle of a texture that is indexed: the element it picks, the address register over the stride, stored

let off = Bits32(SignExtend(Field(20, 16), 32)); /* made before the register's read, as the translator made it */
let a = R_read(RegA());
let bank = UInt(Field(36, 5));
let dynamic_bank = Field(44, 1) == 0b1;
let picked = if dynamic_bank then to_bits(32, bank) + (a >> 16) else 0x00000000;
let source = if dynamic_bank then a & 0x0000ffff else a;
let address = source + off;
let word = if dynamic_bank then CbufReadBank(bank, picked, address) else CbufReadDynamic(bank, address);
let size = UInt(Field(48, 3));
foreach (k from 0 to TextureCount() - 1) {
    if TexIndexedBy(k) then TexIndexStore(k, R_read(RegA()) >> TexIndexShift(k))
};
if size < 4 then {
    let byte_offset = address & (if size < 2 then 0x00000003 else 0x00000002);
    let bit_offset = byte_offset << 3;
    R_write(Dst(), SubwordExtract(word, bit_offset, SubwordWidth(size), size))
} else R_write(Dst(), word);
if size == 5 then {
    let next = address + 0x00000004;
    R_write(Dst() + 1, if dynamic_bank then CbufReadBank(bank, picked, next) else CbufReadDynamic(bank, next))
}

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).