Skip to content

davreev/webgpu-sandbox

Repository files navigation

WebGPU Sandbox

Experimenting with WebGPU as a cross-platform graphics API via wgpu-native

Build

This project can be built to run natively or in a web browser. Build instructions vary slightly between the two targets.

Native Build

Build via cmake

⚠️ Currently only tested with Clang and GCC. MSVC is not supported.

mkdir build
cmake -S . -B ./build -G <generator>
cmake --build ./build [--config <config>] [--target <target-name>]

Web Build

Download the Emscripten SDK and dot source the appropriate setup script

# Bash
EMSDK_DIR="absolute/path/of/emsdk/root"
. ./emsc-setup.sh

# Powershell
$EMSDK_DIR="absolute/path/of/emsdk/root"
. ./emsc-setup.ps1

Then build via emcmake

mkdir build
emcmake cmake -S . -B ./build -G <generator>
cmake --build ./build [--config <config>] [--target <target-name>]

Output can be served locally for testing e.g.

python -m http.server

⚠️ On Linux Chrome, WebGPU isn't enabled by default. To enable it, go to chrome://flags and set Unsafe WebGPU Support and Vulkan flags to Enabled.

Refs