tree: 258a5fc28f59ea559b4733cf58ea66357a53bc71 [path history] [tgz]
  1. pkg/
  2. snippets/
  3. tests/
  4. BUILD.gn
  5. CMakeLists.txt
  6. concat.py
  7. InitOnlySample.cpp
  8. OWNERS
  9. README.md
  10. test_code_size.sh
src/emdawnwebgpu/README.md

Building Emdawnwebgpu

Emdawnwebgpu is easiest to use as a pre-built package from https://github.com/google/dawn/releases. For information on using those, and other general information, read pkg/README.md instead.

This README discusses building the pre-packaged emdawnwebgpu_pkg, building the in-tree Dawn samples/tests for Wasm, and using our CMake or GN build files to link either Dawn (for native) or Emdawnwebgpu (for Wasm).

Setting up a CMake project that automatically chooses Dawn or Emdawnwebgpu

Please read https://developer.chrome.com/docs/web-platform/webgpu/build-app.

Building emdawnwebgpu and emdawnwebgpu_pkg

First, get the Dawn code and its dependencies. See building.md.

To build the package, you‘ll build Dawn’s emdawnwebgpu_pkg target using Emscripten. out/yourbuild/emdawnwebgpu_pkg combines files from:

  • src/emdawnwebgpu
  • third_party/emdawnwebgpu
  • out/yourbuild/gen

Set up Emscripten

Get an emsdk toolchain (at least Emscripten 4.0.3, which includes the necessary tools in the package release). There are two options to do this:

  • Set the dawn_wasm gclient variable (use standalone-with-wasm.gclient as your .gclient), and gclient sync. This installs emsdk in //third_party/emsdk.
  • Install it manually following the official instructions.

Standalone with CMake

Set up the build directory using emcmake:

mkdir out/cmake-wasm
cd out/cmake-wasm

path/to/emsdk/upstream/emscripten/emcmake cmake ../..

# Package
make -j8 emdawnwebgpu_pkg

Samples and tests:

# Samples (for a list of samples, see ENABLE_EMSCRIPTEN targets in src/dawn/samples/CMakeLists.txt)
make -j8 HelloTriangle

# Tests
make -j8 emdawnwebgpu_tests_asyncify emdawnwebgpu_tests_jspi

(To use Ninja instead of Make, for better parallelism, add -GNinja to the cmake invocation, and build using ninja.)

Samples and tests produce HTML files which can be served and viewed in a compatible browser.

Standalone with GN

  • Set up Emscripten as per instructions above using dawn_wasm.

  • Build the emdawnwebgpu and samples GN build targets.

Samples and tests produce HTML files in out/<dir>/wasm which can be served and viewed in a compatible browser.