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 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | width | vertex | output | ||||||||||||||||
| 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 |
| [31] | base | pred.not | pred | Ra | Rd | ||||||||||||||||||||||||||
bits 63:48: 1110 1111 1101 1---
Runs execute_ALD with Form() 0.
| Field | Bits | From |
|---|---|---|
| width | 48:47 | execute_ALD |
| vertex | 46:39 | execute_ALD |
| output | 32 | execute_ALD |
| [31] | 31 | execute_ALD |
| base | 29:20 | execute_ALD |
| pred.not | 19 | the decoder |
| pred | 18:16 | the decoder |
| Ra | 15:8 | RegA() |
| Rd | 7:0 | Dst() |
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).