diff options
| author | Anders Leino <aleino@nvidia.com> | 2024-12-02 17:51:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-02 23:51:03 +0800 |
| commit | 4003d337a7e9b84a8c0609bb8069460f82f5d673 (patch) | |
| tree | 42eace8c314ec22c86bac89797e265f66668dd5a | |
| parent | 0d92d72981b7883f7aab509a640b4f52dc55a819 (diff) | |
Add WebGPU target doc (#5708)
* Add WebGPU target doc
This closes #5698.
* Update ToC
| -rw-r--r-- | docs/user-guide/09-targets.md | 41 | ||||
| -rw-r--r-- | docs/user-guide/toc.html | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/docs/user-guide/09-targets.md b/docs/user-guide/09-targets.md index 4f25aa600..f2ae76718 100644 --- a/docs/user-guide/09-targets.md +++ b/docs/user-guide/09-targets.md @@ -412,6 +412,47 @@ Slang's CPU compute target supports only a compute pipeline. Because CPU target support flexible pointer-based addressing and large low-latency caches, a compute kernel can simply be passed a small fixed number of pointers and be relied upon to load parameter values of any types via indirection through those pointers. +## WebGPU + +> #### Note +> +> Slang support for WebGPU is work in progress. + +WebGPU is a graphics and compute API. +It is similar in spirit to modern APIs, like Metal, Direct3D 12 and Vulkan, but with concessions to portability and privacy. + +WebGPU is available both in browsers as a JavaScript API, and natively as a C/C++ API. +[Dawn](https://github.com/google/dawn), is a native WebGPU implementation used by the Chrome browser. + +By combining Slang, [Dawn](https://github.com/google/dawn) and [Emscripten](https://emscripten.org/), +an application can easily target any native API, and the web, with a single codebase consisting of C++ and Slang code. + +WebGPU shader modules are created from WGSL (WebGPU Shading Language) source files. +WebGPU does not use an intermediate representation - WGSL code is compiled to backend-specific code by +compilers provided by the WebGPU implementation. + +### Pipelines + +WebGPU supports render and compute pipelines. + +The WebGPU render pipeline includes the following programmable stages: + +- The vertex stage outputs vertex data + +- The fragment stage outputs fragments + +### Parameter Passing + +WebGPU uses groups of bindings called bind groups to bind things like textures, buffers and samplers. +Bind group objects are passed as arguments when encoding bind group setting commands. + +There is a notion of equivalence for bind groups, and a notion of equivalence for pipelines defined in +terms of bind group equivalence. +This equivalence allows an application to save some bind group setting commands, when switching between +pipelines, if bindings are grouped together appropriately. + +Which bindings are grouped together can be controlled using Slang's `ParameterBlock` generic type. + ## Summary This chapter has reviewed the main target platforms supported by the Slang compiler and runtime system. diff --git a/docs/user-guide/toc.html b/docs/user-guide/toc.html index 7ab3b5b91..e827a821b 100644 --- a/docs/user-guide/toc.html +++ b/docs/user-guide/toc.html @@ -135,6 +135,7 @@ <li data-link="targets#metal"><span>Metal</span></li> <li data-link="targets#cuda-and-optix"><span>CUDA and OptiX</span></li> <li data-link="targets#cpu-compute"><span>CPU Compute</span></li> +<li data-link="targets#webgpu"><span>WebGPU</span></li> <li data-link="targets#summary"><span>Summary</span></li> </ul> </li> |
