@drawcall/webgpu 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +10 -10
- package/skills/webgpu/SKILL.md +2 -2
- package/src/gpu.js +5 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @drawcall/webgpu
|
|
2
2
|
|
|
3
|
-
Use standard Three.js rendering and WebGPU compute in browsers and
|
|
3
|
+
Use standard Three.js rendering and WebGPU compute in browsers and Node.js, with or without a GPU. Browsers use their own WebGPU implementation; Node uses the native GPU when available and falls back to bundled CPU rendering. Three.js and original assets stay unchanged.
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
6
|
import { createCanvas } from '@drawcall/webgpu';
|
|
@@ -17,6 +17,8 @@ In a browser, append the returned canvas to your container. It is a real canvas
|
|
|
17
17
|
|
|
18
18
|
For Node image export, canvas-free compute, loading assets, and cleanup, see the shipped [usage skill](skills/webgpu/SKILL.md). Compute uses `requestAdapter()` followed by standard WebGPU device and command APIs. Node does not provide DOM layout, video, or canvas-2D texture sources.
|
|
19
19
|
|
|
20
|
-
Node requires version 22+. Native packages bundle the software renderer and Vulkan loader for Linux x64/ARM64 (glibc 2.28+ or musl 1.2.5+/Alpine 3.22+), macOS 13.5+ (Intel/Apple Silicon), and Windows x64/ARM64. x64 requires SSE4.2. No GPU, browser, compiler, SDK, or system graphics packages are needed.
|
|
20
|
+
Node requires version 22+. Native packages bundle the software renderer and Vulkan loader for Linux x64/ARM64 (glibc 2.28+ or musl 1.2.5+/Alpine 3.22+), macOS 13.5+ (Intel/Apple Silicon), and Windows x64/ARM64. x64 requires SSE4.2. No GPU, browser, compiler, SDK, or system graphics packages are needed.
|
|
21
|
+
|
|
22
|
+
When present, Node uses the native GPU through Metal on macOS and installed Vulkan drivers on Linux and Windows. The default adapter is the GPU; `requestAdapter({ forceFallbackAdapter: true })` selects the bundled CPU renderer, whose output is reproducible: pass its device to `WebGPURenderer`. NVIDIA's Linux Vulkan driver needs X11 and EGL client libraries even headless (Debian/Ubuntu: `libx11-6 libxext6 libegl1`). Keep npm optional dependencies enabled. Other platform/CPU combinations are unsupported.
|
|
21
23
|
|
|
22
24
|
Run the upstream Three.js [compute-texture example](examples/compute-texture) with `npm install --prefix examples/compute-texture` and `npm run dev --prefix examples/compute-texture`. Browser and Node entry points share the same scene, compute, and camera logic, extracted from the upstream example. Render a PNG without a browser using `npm run render --prefix examples/compute-texture -- frame.png`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawcall/webgpu",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "WebGPU rendering and compute in browsers and
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "WebGPU rendering and compute in browsers and Node.js, with or without a GPU",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"sharp": "0.35.5"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@drawcall/webgpu-linux-x64": "0.
|
|
41
|
-
"@drawcall/webgpu-linux-arm64": "0.
|
|
42
|
-
"@drawcall/webgpu-darwin-x64": "0.
|
|
43
|
-
"@drawcall/webgpu-darwin-arm64": "0.
|
|
44
|
-
"@drawcall/webgpu-win32-x64": "0.
|
|
45
|
-
"@drawcall/webgpu-linuxmusl-x64": "0.
|
|
46
|
-
"@drawcall/webgpu-linuxmusl-arm64": "0.
|
|
47
|
-
"@drawcall/webgpu-win32-arm64": "0.
|
|
40
|
+
"@drawcall/webgpu-linux-x64": "0.2.0",
|
|
41
|
+
"@drawcall/webgpu-linux-arm64": "0.2.0",
|
|
42
|
+
"@drawcall/webgpu-darwin-x64": "0.2.0",
|
|
43
|
+
"@drawcall/webgpu-darwin-arm64": "0.2.0",
|
|
44
|
+
"@drawcall/webgpu-win32-x64": "0.2.0",
|
|
45
|
+
"@drawcall/webgpu-linuxmusl-x64": "0.2.0",
|
|
46
|
+
"@drawcall/webgpu-linuxmusl-arm64": "0.2.0",
|
|
47
|
+
"@drawcall/webgpu-win32-arm64": "0.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"three": "0.186.1"
|
package/skills/webgpu/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: webgpu
|
|
3
|
-
description: Use @drawcall/webgpu for portable Three.js rendering and WebGPU compute in browsers and
|
|
3
|
+
description: Use @drawcall/webgpu for portable Three.js rendering and WebGPU compute in browsers and Node.js with or without a GPU, including headless scene export with standard loaders.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Render a scene
|
|
@@ -46,6 +46,6 @@ For cold server-side rendering, launch a fresh process per task, render, encode,
|
|
|
46
46
|
|
|
47
47
|
# Compute without a canvas
|
|
48
48
|
|
|
49
|
-
Import `requestAdapter` from the package, check its result, then call the adapter’s standard `requestDevice` with the features and limits the workload requires. Use ordinary WGSL, buffers, compute passes, and queue submission. No canvas or loader host is needed. Destroy application-owned devices when finished; do not rely on garbage collection to release GPU resources.
|
|
49
|
+
Import `requestAdapter` from the package, check its result, then call the adapter’s standard `requestDevice` with the features and limits the workload requires. Use ordinary WGSL, buffers, compute passes, and queue submission. No canvas or loader host is needed. Destroy application-owned devices when finished; do not rely on garbage collection to release GPU resources. Node prefers a native GPU adapter and falls back to the bundled CPU renderer; request `{ forceFallbackAdapter: true }` to select the CPU renderer explicitly. GPU, browser, and CPU adapters can expose different capabilities. To render Three on a specific adapter, pass a device created from it to `WebGPURenderer`.
|
|
50
50
|
|
|
51
51
|
For combined raw compute and Three rendering, pass the same application-created device to `WebGPURenderer`. For Three TSL compute nodes, use the renderer’s compute API directly. Neither path requires changing Three.js.
|
package/src/gpu.js
CHANGED
|
@@ -10,7 +10,7 @@ export function getRuntime() {
|
|
|
10
10
|
const installed = globals();
|
|
11
11
|
const loaded = loadNative();
|
|
12
12
|
try {
|
|
13
|
-
const gpu = loaded.native.create([
|
|
13
|
+
const gpu = loaded.native.create([]);
|
|
14
14
|
for (const [name, value] of Object.entries(loaded.native.globals)) {
|
|
15
15
|
if (name !== 'ImageBitmap') installed.set(name, value);
|
|
16
16
|
}
|
|
@@ -26,7 +26,10 @@ export function getRuntime() {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Select an adapter using standard GPURequestAdapterOptions. Native GPUs rank first;
|
|
31
|
+
* the bundled CPU renderer is the fallback adapter (forceFallbackAdapter: true).
|
|
32
|
+
*/
|
|
30
33
|
export async function requestAdapter(options) {
|
|
31
34
|
return getRuntime().gpu.requestAdapter(options);
|
|
32
35
|
}
|