Swift-webgpu - A new graphics and compute API

Hi Everybody,

Now that the spec is nearing completion, I thought I'd share swift-webgpu; a Swift interface for the upcoming WebGPU API.

Although originally intended for the web (as a successor to WebGL), a native version of WebGPU is also being worked on alongside. Under the hood, it maps to an appropriate platform API (Metal, Vulkan, Direct3D etc.). Currently, swift-webgpu is based on (and generated from) Google's Dawn implementation.

I've developed a few demos in Swift and tested on Mac, Ubuntu, and (albeit with some additional tweaks) Windows!

I am still anticipating some breaking changes to come (Dawn itself is not yet fully stable, although they are aiming for a v1 release soon). One slightly annoying thing about the Swift API at the moment is that most integers are explicitly defined as either 32 or 64 bit unsigned, so as a user, you find yourself having to perform a lot of conversions from Int. I'm not sure if there's a decent solution to this without introducing some unsafeness.

Whilst the API is fairly low level (compared to a game engine for example), it may be a useful building block for various creative / graphical projects in the future!


This is awesome stuff, thanks for sharing! Finding more use cases and implementations for hardware accelerated graphics libraries in swift is going to make it an even better viable candidate for use outside of apple's eco system


I found your library earier, great project!