diff --git a/README.md b/README.md index 24dea77..bf5cd6b 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,36 @@ Template to get started with WebGPU C++ projects targetting WebAssembly via Emscripten. Easily build apps and then test and deploy with Webpack. +## Building + +The C++ code is compiled with [Emscripten](https://emscripten.org/) to +WebAssembly, and uses [CMake](https://cmake.org/) for build configuration. +Both need to be installed and in your path to build the project. +You can then run from the repo root directory: + +``` +mkdir cmake-build +cd cmake-build +emcmake cmake .. +cmake --build . +``` + +This will build the C++ code with Emscripten to produce the WebAssembly +build of the C++ code, and JavaScript files to import the Wasm into an app +and from a worker thread. The build command will also copy these files into +`./web/src/cpp/` to be used by the web app. + +## Running + +The app is a small TypeScript shim that sets up the WebGPU device +and calls into the Wasm module to run `main` to start the app. +After building the C++ code, you can run the app: + +``` +cd web +npm i +npm run serve +``` + +You can then visit `localhost:8080` in the browser to see the app running. + diff --git a/web/src/index.ts b/web/src/index.ts index 929a1fe..c994647 100644 --- a/web/src/index.ts +++ b/web/src/index.ts @@ -1,5 +1,4 @@ import WGPUApp from "./cpp/wgpu_app.js"; -//import wasm from "./cpp/wgpu_app.wasm"; function sharedArrayBufferSupport() {