@@ -18,7 +18,7 @@ Then in your code
18
18
import { create , globals } from ' node-webgpu' ;
19
19
20
20
Object .assign (globalThis , globals);
21
- globalThis . navigator = { gpu: create ([]) };
21
+ const navigator = { gpu: create ([]) };
22
22
23
23
...
24
24
@@ -32,7 +32,7 @@ see [example](https://github.com/greggman/node-webgpu/tree/main/example)
32
32
You can pass dawn options in ` create `
33
33
34
34
``` js
35
- globalThis . navigator = {
35
+ const navigator = {
36
36
gpu: create ([
37
37
" enable-dawn-features=allow_unsafe_apis,dump_shaders,disable_symbol_renaming" ,
38
38
]),
@@ -45,8 +45,29 @@ The available options are listed [here](https://dawn.googlesource.com/dawn/+/ref
45
45
46
46
## Notes
47
47
48
+ ### Lifetime
49
+
50
+ The ` dawn.node ` implementation exists as long as the ` navigator ` variable
51
+ in the examples is in scope, or rather, as long as there is a reference to
52
+ the object returned by ` create ` . As such, if you assign it to a global
53
+ variable like this
54
+
55
+ ``` js
56
+ globalThis .navigator = { gpu: create ([]) };
57
+ ```
58
+
59
+ node will not exit because it's still running GPU code in the background.
60
+ You can fix that by removing the reference.
61
+
62
+ ``` js
63
+ delete globalThis .navigator
64
+ ```
65
+
66
+ See: https://issues.chromium.org/issues/387965810
67
+
68
+ ### What to use this for
48
69
This package provides a WebGPU implementation it node. That said, if you are making a webpage
49
- and are considering using this for testing, you'd probably be better off using puppeteer. You can
70
+ and are considering using this for testing, you'd probably be better off using [ puppeteer] ( https://pptr.dev/ ) . You can
50
71
find an example of using puppeteer for testing WebGPU in [ this repo] ( https://github.com/greggman/webgpu-debug-helper ) .
51
72
52
73
This package is for WebGPU in node. It provides WebGPU in node. But, it does not not provide integration
@@ -58,9 +79,13 @@ I suspect you could provide many of those with polyfills without changing this r
58
79
looked into it.
59
80
60
81
What you can do is render to textures and then read them back. You can also run compute shaders
61
- and read their results.
82
+ and read their results. See the example linked above.
83
+
84
+ ## Bugs / Issue
62
85
63
- ## Bugs
86
+ This repo just publishes ` dawn.node ` from the dawn project [ here] ( https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/node/ ) .
87
+ Bugs related to dawn, WebGPU should be filed in the in the
88
+ [ chromium issue tracker] ( https://crbug.com/dawn )
64
89
65
90
## Updating
66
91
0 commit comments