Skip to content

๐Ÿš€ A minimal WebGPU example written in Zig, compiled to WebAssembly (wasm). ๐Ÿ› ๏ธ Ideal for experimenting and preparing for native development without install dependencies (dawn, wgpu-rs).

License

Notifications You must be signed in to change notification settings

seyhajin/webgpu-wasm-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

webgpu-wasm-zig

A minimal WebGPU example written in Zig, compiled to WebAssembly (wasm).

๐Ÿ‘๏ธ

Getting started

Clone

git clone https://github.com/seyhajin/webgpu-wasm-zig.git

Alternatively, download zip from Github repository and extract wherever you want.

Build

Build the example with zig build command, which will generate 3 new files (.html, .js, .wasm).

Command

zig build --sysroot [path/to/emsdk]/upstream/emscripten/cache/sysroot

Example with Emscripten installed with Homebrew (brew install emscripten, v3.1.51) on macOS :

zig build --sysroot /usr/local/Cellar/emscripten/3.1.51/libexec/cache/sysroot

Note

build.zig is preconfigured to build to wasm32-emscripten target only.

Caution

Must provide Emscripten sysroot via --sysroot argument.

Run

Launch a web server to run example before open it to WebGPU compatible web browser (Chrome Canary, Brave Nightly, etc.).

e.g. : launch python3 -m http.server and open web browser to localhost:8000.

Tip

Use Live Server extension in Visual Studio Code to open the HTML file. This extension will update automatically page in real-time when you rebuild the example.

Prerequisites

  • zig, works with Zig 0.12+dev version
  • emscripten, version 3.1+
  • git (optional)
  • python3 (optional)

About

๐Ÿš€ A minimal WebGPU example written in Zig, compiled to WebAssembly (wasm). ๐Ÿ› ๏ธ Ideal for experimenting and preparing for native development without install dependencies (dawn, wgpu-rs).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published