I've been interested in a cross platform gpu compute option for a while now. I've previously tried vulkan, but even running the most basic computation requires a ton of boilerplate. A project called https://github.com/AnswerDotAI/gpu.cpp recently popped up on hacker news which uses webgpu. Despite the name, webgpu can also run outside the browser and it was relatively easy to make a working example. I've created a small wrapper API inspired by gpu.cpp, https://github.com/phronmophobic/clj-webgpu. I'm not totally settled on the wrapper API, but it should be usable. Does anyone have any benchmarks or workloads that might benefit from running on the GPU? My toy examples seem to be much faster, but it would be interesting to try compare the numbers with some more realistic use cases.
Tagging in @lambdacoder so he knows about convo.
thank you for this! Do you plan to add compilation of a subset of Clojure to shader source ? It would be nice to be able to write shaders in Clojure too
@octo221, the coupling between shaders and the programs that use them is annoying. I did investigate options for bridging the divide (like a clj->shader compiler), but I think that's currently beyond the scope of what I'm trying to do for now. There are options like https://github.com/markus-wa/lssl, Spir-v, and https://github.com/gfx-rs/naga so maybe that will be worth revisiting in the future.
Amazing. I have had my eyes on WebGPU outside the browser for a bit. For both compute and rendering
Thanks for taking the lead on this initiative!
I've only tried a few compute examples, but the low level API is comprehensive and can do the rendering side as well.
@grounded_sage Do you have any particular use cases in mind?
Native application UI’s generally.
Render target for Humble/Membrane etc
Both humble ui and membrane use skia which uses the GPU. Is there anything in particular that you don't think is covered?
Humble UI exposes more of skia's functionality which I think includes their own shading language.
Not really. Just having more of the stack in Clojure.
Cool. Just trying to keep in mind what use cases folks might be interested in.
Having access to lower level abstractions without leaving Clojure would open up possibilities that are unclear at present.
This is super interesting. Is the shader source code plain WGSL? (like this one: https://github.com/phronmophobic/clj-webgpu/blob/a171dfac26099a35f78ea811e148e91153b1dc05/examples/basic/src/basic/core.clj#L4)
Webgpu supports wgsl. There's also a project called https://github.com/gfx-rs/wgpu/tree/trunk/naga that can translate between various shader languages. Among the shader languages, there is a standard intermediate language called spir-v which can serve as a target for higher level languages. Basically, there are options.
Currently there is 2D, 3D interfaces, games, VR, AR. The tools to implement these are often radically different and I believe the simplicity Clojure often brings could bridge some gaps.
Interesting 👀 Possibly it is worth sharing at the #uncomplicate channel, where some users of https://neanderthal.uncomplicate.org/ may have an idea about use cases.