SetDest: the components pattern p enables of the destination's variable d (0 none) get value's same components
function SetDest(p : bits(32), d : int, value : vec4) -> unit = {
let mask = UInt(p[3 .. 0]);
if d != 0 & mask != 0 then {
if mask != 15 then {
let old = VarLoad(d);
VarStore(d, V4Shuffle(old, value, if p[3 .. 3] == 0b1 then 4 else 0, if p[2 .. 2] == 0b1 then 5 else 1,
if p[1 .. 1] == 0b1 then 6 else 2, if p[0 .. 0] == 0b1 then 7 else 3))
} else VarStore(d, value)
}
}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 nihstro's shader_bytecode.h (BSD-3-Clause), as Azahar reads them.