Mach is still early stages - see what we have today and stay tuned.

mach/gpu: the GPU interface for Zig

Mach provides an ecosystem of WebGPU libraries and tools (leveraging Google Chrome's WebGPU implementation behind the scenes.) We do some heavy lifting to give you effortless cross-compilation and make it all 'just work' with no hassle in under 60 seconds.

WebGPU is low-level-in the future, we'll provide model rendering, text rendering, etc. as optional libraries on top: you get to pick choose what you use! You can use it merely to open a WebGPU window on every platform (with mobile and web in the future!)

Every example below shows how to use WebGPU from Zig: they're not specific to Mach engine, but do use it for setup code.

boids example

Uses a GPU compute shader to run calculations / simulate flocking behaviour of birds.

git clone
cd mach/
zig build run-example-boids
~330 lines of code

triangle example

Tells the GPU to render 3 vertices (but doesn't transfer them using a vertex buffer or anything, the vertex positions are hard-coded in the shader.)

git clone
cd mach/
zig build run-example-triangle
~130 lines of code

rotating-cube example

Uploads a basic 3D cube to the GPU and renders it. Demonstrates how to use vertex buffers to transfer a model from the CPU to GPU, how to use vertex attributes & more.

git clone
cd mach/
zig build run-example-rotating-cube
~290 lines of code

two-cubes example

Once you learn how to render one cube, two isn't much more code.

git clone
cd mach/
zig build run-example-two-cubes
~320 lines of code

textured-cube example

Loads a PNG image and uploads the texture to the GPU. Renders it on a 3D cube.

git clone
cd mach/
zig build run-example-textured-cube
~300 lines of code

instanced-cube example

Instancing lets you duplicate an object & render it in multiple places with different parameters.

git clone
cd mach/
zig build run-example-instanced-cube
~240 lines of code

advanced-gen-texture-light example

Generates a brick texture at comptime, uses Blinn-Phong lighting, and several pipelines. Move camera with arrow keys / WASD.

git clone
cd mach/
zig build run-example-advanced-gen-texture-light
~760 lines of code

Help contribute!

Eager to get started learning WebGPU in Zig? We'd love contributions for more examples!

There's lots of great learning material online, we're happy to help if you get stuck, and there is a list of samples that are just waiting to be ported to the Zig API.

Special thanks to these people who've contributed to these examples: