{"id":25404882,"url":"https://github.com/dawn-gpu/node-webgpu","last_synced_at":"2025-10-31T00:31:33.315Z","repository":{"id":270923427,"uuid":"911859581","full_name":"dawn-gpu/node-webgpu","owner":"dawn-gpu","description":"webgpu for node.js","archived":false,"fork":false,"pushed_at":"2025-02-12T04:47:38.000Z","size":27027,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T09:14:05.721Z","etag":null,"topics":["directx","gpu","gpu-accelerated","gpu-accleration","gpu-computing","metal","opengl","vulkan","webgpu","webgpu-api","wgsl","wgsl-lang","wgsl-language","wgsl-shader"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dawn-gpu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T03:21:53.000Z","updated_at":"2025-02-12T04:20:43.000Z","dependencies_parsed_at":"2025-02-12T05:12:01.922Z","dependency_job_id":"ecb89f9e-076f-4b11-961a-4ca8cdbc6f3c","html_url":"https://github.com/dawn-gpu/node-webgpu","commit_stats":null,"previous_names":["greggman/node-webgpu","dawn-gpu/node-webgpu"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawn-gpu%2Fnode-webgpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawn-gpu%2Fnode-webgpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawn-gpu%2Fnode-webgpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawn-gpu%2Fnode-webgpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawn-gpu","download_url":"https://codeload.github.com/dawn-gpu/node-webgpu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239088378,"owners_count":19579433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directx","gpu","gpu-accelerated","gpu-accleration","gpu-computing","metal","opengl","vulkan","webgpu","webgpu-api","wgsl","wgsl-lang","wgsl-language","wgsl-shader"],"created_at":"2025-02-16T04:24:59.395Z","updated_at":"2025-10-31T00:31:33.308Z","avatar_url":"https://github.com/dawn-gpu.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webgpu - dawn.node\n\nProvides webgpu to node\n\n[Dawn](https://dawn.googlesource.com/dawn) is an implementation of \n[WebGPU](https://gpuweb.github.io/gpuweb/). It includes a node plugin\nand this repo builds that plugin and publishes it on npm.\n\n## Usage\n\n```\nnpm install --save webgpu\n```\n\nThen in your code\n\n```js\nimport { create, globals } from 'webgpu';\n\nObject.assign(globalThis, globals);\nconst navigator = { gpu: create([]) };\n\n...\n\n// do some webgpu\nconst device = await(await navigator.gpu.requestAdapter()).requestDevice();\n...\n```\n\nsee [example](https://github.com/dawn-gpu/node-webgpu/tree/main/example)\n\nYou can pass dawn options in `create`\n\n```js\nconst navigator = {\n  gpu: create([\n    \"enable-dawn-features=allow_unsafe_apis,dump_shaders,disable_symbol_renaming\",\n  ]),\n};\n```\n\nThere is both `enable-dawn-features=comma,separated,toggles` and `disable-dawn-features=comma,separated,toggles`.\n\nThe available options are listed [here](https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/native/Toggles.cpp)\n\nThere are also a few dawn node specific options\n\n* `backend`\n\n  Let's you specify the backend like 'null', 'webgpu', 'd3d11', 'd3d12', 'metal', 'vulkan', 'opengl', 'opengles'\n\n  Example:\n\n  ```js\n  const navigator = { gpu: create(['backend=opengl']) };\n  ```\n\n  Passing in a non-existent backend will print out the list of backends\n\n* `adapter`\n\n  Let's you specify which adapter to use. To get a list of adapters\n  pass in a non-existent adapter name.\n\n  ```js\n  const navigator = { gpu: create(['adapter=foo']) };\n  ```\n\n  prints something like\n\n  ```\n  Error: no suitable backends found\n  Available adapters:\n   * backend: 'metal', name: 'Apple M1 Max'\n  ```\n\n  At which point you can use something like\n\n  ```js\n  const navigator = { gpu: create(['adapter=Apple M1 Max']) };\n  ```\n\nNote: Normally you select a GPU by using the WebGPU API\n\n```js\nconst adapter = navigator.gpu.requestAdapter({\n  powerPreference: 'high-performance', // or 'low-power'\n});\n```\n\n## Notes\n\n### Lifetime\n\nThe `dawn.node` implementation exists as long as the `navigator` variable\nin the examples is in scope, or rather, as long as there is a reference to\nthe object returned by `create`. As such, if you assign it to a global\nvariable like this\n\n```js\nglobalThis.navigator = { gpu: create([]) };\n```\n\nnode will not exit because it's still running GPU code in the background.\nYou can fix that by removing the reference.\n\n```js\ndelete globalThis.navigator\n```\n\nSee: https://issues.chromium.org/issues/387965810\n\n### Software GPU\n\nSome options for running with a software based Vulkan implementation such has lavapipe are mentioned\nin [the dawn.node readme](https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/node/)\n\n### What to use this for\n\nThis package provides a WebGPU implementation it node. That said, if you are making a webpage\nand are considering using this for testing, you'd probably be better off using [puppeteer](https://pptr.dev/). You can\nfind an example of using puppeteer for testing WebGPU in [this repo](https://github.com/dawn-gpu/webgpu-debug-helper).\n\nThis package is for WebGPU in node. It provides WebGPU in node. But, it does not not provide integration\nwith the web platform. For example, importing video via `HTMLVideoElement` or `VideoFrame`. It doesn't\nprovide a way to copy an `HTMLImageElement` to a texture. It also doesn't provide a way to render to an\n`HTMLCanvasElement`. All of those only exist in the browser, not in node.\n\nI suspect you could provide many of those with polyfills without changing this repo but I have not\nlooked into it.\n\nWhat you can do is render to textures and then read them back. You can also run compute shaders\nand read their results. See the example linked above.\n\n## Bugs / Issues\n\nThis repo just publishes `dawn.node` from the dawn project [here](https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/node/).\nBugs related to dawn, WebGPU should be filed in the in the\n[chromium issue tracker](https://crbug.com/dawn)\n\n## Running the CTS\n\n```\nnpm run build\nnpm run cts\n```\n\nYou can pass a query an optional cts query. For example\n\n```\nnpm run cts 'webgpu:shader,execution,expression,call,builtin,textureDimensions:*'\n```\n\nYou can also pass the path to the CTS, for example if you want to run your own tests\n\n```\nnpm run cts --cts=/Users/me/src/cts\n```\n\nNote: this is no different than running the CTS in dawn itself. \n\n## Updating\n\nThis updates to the latest dawn and depot_tools\n\n```sh\nnpm ci\nnpm run update\n```\n\n## Building on all supported platforms\n\nPush a new version. Check the github actions. You should see build artifacts\nadded to the bottom of the latest action run. \n\n## Building\n\nThis builds for the local OS (win64,macOS-intel,macOS-arm,linux)\n\n```sh\nnpm ci\nnpm run build\n```\n\n### Prerequisites\n\n#### Windows\n\nBefore running the build script above you must have\nVisual Studio C++ installed and have run the `vcvars64.bat` file.\nI've tested with Visual Studio Community Edition 2022\n\nFurther you must have [cmake installed](https://cmake.org/download/)\nand either in your path or at it's standard place of `C:\\Program Files\\CMake`\n\nYou must have `go` installed. Get it at https://go.dev/\n\nAnd you must have `node.js` installed, at least version 18. \nI recommend using [nvm-windows](https://github.com/coreybutler/nvm-windows) to install it\nas it makes it easy to switch version\n\n#### MacOS\n\nBefore running the build script above you must have\nXCode installed and its command line tools\n\nFurther you must have [cmake installed](https://cmake.org/download/)\nand either in your path or at it's standard place of `/Applications/CMake.app`\n\nYou must have `go` installed. Get it at https://go.dev/\n\nAnd you must have `node.js` installed, at least version 18. \nI recommend using [nvm](https://github.com/nvm-sh/nvm) to install it\nas it makes it easy to switch versions.\n\n#### Linux (Ubuntu)\n\nBefore running the build script above you need to install\nthe following dependencies\n\n```sh\nsudo apt-get install cmake libxrandr-dev libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev pkg-config nodejs npm\n```\n\nYou must have `go` installed. Get it at https://go.dev/\n\nAnd you must have `node.js` installed, at least version 18. \nI recommend using [nvm](https://github.com/nvm-sh/nvm) to install it\nas it makes it easy to switch versions.\n\n## Publishing\n\nSee [PUBLISHING.md](PUBLISHING.md).\n\n## License\n\nMIT: https://dawn.googlesource.com/dawn/+/HEAD/LICENSE\n\n## Thanks!\n\nSpecial thanks to Felix Maier who originally published a dawn plugin for node\n[here](https://github.com/maierfelix/webgpu/) and who graciously let me\npublish this repo under the same npm package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawn-gpu%2Fnode-webgpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawn-gpu%2Fnode-webgpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawn-gpu%2Fnode-webgpu/lists"}