This repository contains C headers equivalent to the WebGPU API and (soon) documentation on the native specificities of the headers.
While WebGPU is a JavaScript API made for the Web, it is a good tradeoff of ergonomic, efficient and portable graphics API. Almost all of its concepts are not specific to the Web platform and the headers replicate them exactly, while adding capabilities to interact with native concepts (like windows).
All of the API is defined in the webgpu.h header.
Implementations of this header include:
- Dawn, Chromium's C++ WebGPU implementation library
- wgpu-native, Firefox's Rust WebGPU implementation library
- Emscripten translates webgpu.h calls to JavaScript WebGPU calls when compiling to WASM
Here are some details about the structure of this repository.
-
webgpu.his the one and only header file that defines the WebGPU C API. Only this needs to be integrated in a C project that links against a WebGPU implementation. -
webgpu.ymlis the main machine-readable source of truth for the C API and its documentation (in YAML format). It is used to generate the officialwebgpu.hheader present in this repository, (will be used) to generate the official documentation, and may be used by any other third party to design tools and wrappers around WebGPU-Native. -
schema.jsonis the JSON schema that formally specifies the structure ofwebgpu.yml.
-
Makefiledefines the rules to automatically generatewebgpu.hfromwebgpu.ymland check the result. -
gen/and thego.*files are the source code of the generator called by theMakefile. -
tests/compileis used to check that the generated C header is indeed valid C/C++ code.
.github/workflowsdefines the automated processes that run upon new commits/PR, to check that changes inwebgpu.ymlandwebgpu.hare consistent.
Important When submitting a change, one must modify both the webgpu.yml and webgpu.h files in a consistent way. One should first edit webgpu.yml (the source of truth), then run make gen to update webgpu.h and finally commit both changes together.