Implement GPU types and methods
The exact shape of this isn't super clear, yet, but either a set of opaque types and bound functions, or pure Alan code on top of a thin wrapper over wgpu/WebGPU is needed to construct an AST to serialize to wgsl and then execute on the GPU.
This is the purpose of Alan v0.2
Remaining built-in functions of wgsl to bind using this as the reference:
- [x]
countLeadingZeros - [x]
countOneBits - [x]
countTrailingZeros - [x]
cross - [ ]
degrees - [x]
determinant - [ ]
distanceandlength(these will get different names.lengthhas becomemagnitude, not yet decided ondistance) - [x]
dot - [ ]
exp2(maybe? Not sure if I need to include this whenpowexists. I did includeexpbut only because that's actually pretty commonly used) - [x]
extractBits - [ ]
faceForward(this appears to be a composite function on its own, unsure if I should include it) - [x]
firstLeadingBit(renamedflb) - [x]
firstTrailingBit(renamedftb) - [x]
fma - [x]
fract - [ ]
frexp(including it in the list as considered, but I don't see any value in it) - [x]
insertBits - [x]
inverseSqrt - [ ]
ldexp(also doesn't seem necessary? it's the inverse offrexpbut I don't see the expressive value here) - [ ]
mix - [ ]
modf(also weird to include when the other functions already exist) - [x]
normalize - [ ]
radians - [ ]
reflect - [ ]
refract - [x]
reverseBits - [x]
round - [x]
saturate - [ ]
sign(do we need this?) - [ ]
smoothstep(also a compound function, but if its backed by hardware maybe?) - [ ]
step - [x]
transpose - [x]
pack4x8snorm - [x]
pack4x8unorm - [x]
pack2x16snorm - [x]
pack2x16unorm - [x]
pack2x16float - [x]
unpack4x8snorm - [x]
unpack4x8unorm - [x]
unpack2x16snorm - [x]
unpack2x16unorm - [x]
unpack2x16float - [x]
storageBarrierstorageBarrieris broken on ARM Macs, it's essentially equivalent toworkgroupBarriermay or may not block usage on Mac and Browser because of this. - [ ] ~~
workgroupBarrier(not including this at first, as I have no way to represent the workgroup pointer at the moment)~~ - [ ] ~~
workgroupUniformLoad(not including this at first, as I have no way to represent the workgroup pointer at the moment)~~
I am not including any of the derivative functions because they're only for pixel shaders, I'm not including any of the texture functions because I do not have any texture functionality at the moment (and I hope to get away with just the copy-buffer-to-shader functionality to do rendering), and I'm not including any atomic operations at the moment as I have no representation of atomics.
This is just the list of things I want to get done for compute shaders, which are the only shaders I'm exposing at the moment.
I also still feel like there's some work to be done on the GBuffer type and its usage, but I'm not going to consider that blocking to close this issue out.
I think I have implemented enough of this to unblock a v0.2 beta, so I'm removing that label.