ALD

Attributes and varyings

fixed bit field field the encoding fixes should be

ALD

6362616059585756555453525150494847464544434241403938373635343332
1110111111011widthvertexoutput
313029282726252423222120191817161514131211109876543210
[31]basepred.notpredRaRd

bits 63:48: 1110 1111 1101 1---

Runs execute_ALD with Form() 0.

Fields

FieldBitsFrom
width48:47execute_ALD
vertex46:39execute_ALD
output32execute_ALD
[31]31execute_ALD
base29:20execute_ALD
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

ALD: width words (47-48) from the attribute address at 20 (plus the register at 8 when it is one), into d on. A vertex stage's own inputs by address; a stage between the vertex and fragment stages reads its input primitive's vertex (the register at 39), a control program a patch's (bit 31) or its own output vertices (bit 32)

let width = UInt(Field(47, 2)) + 1;
let between = Between();
if RegA() != RZ then {
    /* indexed: each word at the register plus addr (and 4 for the next) is a declared input's component, the
       input picked by the address's vector (0x80 the first generic one, 0x70 the position after the vertex
       stage) and the component by its word. An address of no declared input reads 0, as in Eden */
    let vertex = if between then SharedIndex(R_read(UInt(Field(39, 8))), InVertices()) else 0x00000000;
    let base = R_read(RegA()) + ZeroExtend(Field(20, 10), 32);
    foreach (k from 0 to width - 1) {
        let offset = if k != 0 then base + to_bits(32, k * 4) else base;
        let vector = offset >> 4;
        let component = (offset >> 2) & 0x00000003;
        var value : bits(32) = 0x00000000;
        foreach (v from 0 to 32) {
            if (v < 32 & HasInput(v)) | (v == 32 & between & HasInput(32)) then {
                let bits = InputBits(v, if between then 1 else 0, vertex, component);
                let at = vector == to_bits(32, if v < 32 then 8 + v else 7);
                value = if at then bits else value
            }
        };
        R_write(Dst() + k, value)
    }
} else if between | Field(31, 1) == 0b1 then {
    let addr = UInt(Field(20, 10));
    let patch = Field(31, 1) == 0b1;
    let output = Stage() == ST_TCS & Field(32, 1) == 0b1 & not_bool(patch);
    let vertex = if patch then 0x00000000
                 else SharedIndex(R_read(UInt(Field(39, 8))), if output then OutVertices() else InVertices());
    foreach (k from 0 to width - 1) {
        let location = addr + k * 4;
        let component = to_bits(32, MOD(DIV(location, 4), 4));
        if patch then {
            /* the control program reads back what it wrote */
            if location >= 32 then R_writeF(Dst() + k, PatchLoad(if Stage() == ST_TCS then 3 else 1, DIV(location - 32, 16), component))
            else if location < 24 then R_writeF(Dst() + k, TessLevelLoad(if Stage() == ST_TCS then 3 else 1, if location < 16 then 0 else 1, DIV(MOD(location, 16), 4)))
            else R_write(Dst() + k, 0x00000000)
        } else if location == 752 | location == 756 then R_writeF(Dst() + k, TessCoord(DIV(location - 752, 4)))
        else if location == 96 then R_write(Dst() + k, PrimitiveRead())
        else if location == 108 then {
            if HasPointSize(output) then R_writeF(Dst() + k, PointSizeLoad(output, vertex)) else R_write(Dst() + k, 0x00000000)
        } else if location >= 704 & location < 736 then {
            if HasClip(output) then R_writeF(Dst() + k, ClipLoad(output, vertex, DIV(location - 704, 4)))
            else R_write(Dst() + k, 0x00000000)
        } else if output then R_writeF(Dst() + k, OutputLoad(location, vertex, component))
        else R_writeF(Dst() + k, InputLoad(location, vertex, component))
    }
} else {
    let addr = UInt(Field(20, 10));
    foreach (k from 0 to width - 1) {
        let location = addr + k * 4;
        if location == 760 then R_write(Dst() + k, InstanceId())
        else if location == 764 then R_write(Dst() + k, VertexId())
        else InputComponentWrite(Dst() + k, DIV(location - 128, 16), MOD(DIV(location, 4), 4))
    }
}

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