react-native-wgpu 0.3.1 → 0.4.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 +7 -5
- package/apple/MetalView.mm +1 -1
- package/cpp/rnwgpu/api/GPU.h +0 -1
- package/cpp/rnwgpu/api/GPUAdapter.cpp +7 -7
- package/cpp/webgpu/webgpu.h +4827 -5
- package/cpp/webgpu/webgpu_cpp.h +10140 -5
- package/cpp/webgpu/webgpu_cpp_print.h +2687 -5
- package/lib/commonjs/Canvas.js +10 -3
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/commonjs/WebGPUViewNativeComponent.web.js +99 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/WebPolyfillGPUModule.js +40 -0
- package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -0
- package/lib/commonjs/index.js +4 -208
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/main/index.js +227 -0
- package/lib/commonjs/main/index.js.map +1 -0
- package/lib/commonjs/main/index.web.js +51 -0
- package/lib/commonjs/main/index.web.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +11 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/Canvas.js +11 -4
- package/lib/module/Canvas.js.map +1 -1
- package/lib/module/WebGPUViewNativeComponent.web.js +93 -0
- package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/module/WebPolyfillGPUModule.js +38 -0
- package/lib/module/WebPolyfillGPUModule.js.map +1 -0
- package/lib/module/index.js +3 -160
- package/lib/module/index.js.map +1 -1
- package/lib/module/main/index.js +168 -0
- package/lib/module/main/index.js.map +1 -0
- package/lib/module/main/index.web.js +8 -0
- package/lib/module/main/index.web.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +5 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +5 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/main/index.d.ts +3 -0
- package/lib/typescript/lib/commonjs/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts +2 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/utils.d.ts +3 -0
- package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +2 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +1 -5
- package/lib/typescript/lib/module/main/index.d.ts +6 -0
- package/lib/typescript/lib/module/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.web.d.ts +5 -0
- package/lib/typescript/lib/module/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/types.d.ts +1 -0
- package/lib/typescript/lib/module/types.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils.d.ts +2 -0
- package/lib/typescript/lib/module/utils.d.ts.map +1 -0
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +118 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +16 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/main/index.d.ts +6 -0
- package/lib/typescript/src/main/index.d.ts.map +1 -0
- package/lib/typescript/src/main/index.web.d.ts +6 -0
- package/lib/typescript/src/main/index.web.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +19 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/Canvas.tsx +12 -4
- package/src/WebGPUViewNativeComponent.ts +1 -1
- package/src/WebGPUViewNativeComponent.web.ts +108 -0
- package/src/WebPolyfillGPUModule.ts +53 -0
- package/src/index.tsx +25 -196
- package/src/main/index.tsx +204 -0
- package/src/main/index.web.tsx +8 -0
- package/src/types.ts +20 -0
- package/src/utils.ts +4 -0
- package/cpp/dawn/dawn_proc_table.h +0 -313
- package/cpp/dawn/native/DawnNative.h +0 -361
- package/cpp/dawn/native/NullBackend.h +0 -39
- package/cpp/dawn/native/OpenGLBackend.h +0 -82
- package/cpp/dawn/native/VulkanBackend.h +0 -183
- package/cpp/dawn/native/dawn_native_export.h +0 -49
- package/cpp/dawn/webgpu.h +0 -4855
- package/cpp/dawn/webgpu_cpp.h +0 -10168
- package/cpp/dawn/webgpu_cpp_print.h +0 -2715
- package/cpp/dawn/wire/client/webgpu.h +0 -354
- package/cpp/dawn/wire/client/webgpu_cpp.h +0 -10343
- package/cpp/dawn/wire/client/webgpu_cpp_print.h +0 -2715
- package/lib/commonjs/WebGPUView.js +0 -2
- package/lib/commonjs/WebGPUView.js.map +0 -1
- package/lib/module/WebGPUView.js +0 -2
- package/lib/module/WebGPUView.js.map +0 -1
- package/lib/typescript/lib/commonjs/WebGPUView.d.ts +0 -1
- package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +0 -1
- package/lib/typescript/lib/module/WebGPUView.d.ts +0 -1
- package/lib/typescript/lib/module/WebGPUView.d.ts.map +0 -1
- package/lib/typescript/src/WebGPUView.d.ts +0 -1
- package/lib/typescript/src/WebGPUView.d.ts.map +0 -1
- package/src/WebGPUView.tsx +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# React Native WebGPU
|
|
2
2
|
|
|
3
|
-
React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
|
|
4
|
-
This is currently a technical preview for early adopters.
|
|
3
|
+
React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
|
|
4
|
+
This is currently a technical preview for early adopters.
|
|
5
5
|
|
|
6
6
|
React Native WebGPU requires React Native 0.81 or newer and doesn't run on legacy architecture.
|
|
7
7
|
|
|
@@ -13,6 +13,8 @@ Please note that the package name is `react-native-wgpu`.
|
|
|
13
13
|
npm install react-native-wgpu
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
Note that if you use pnpm, you MUST use a `node-linker = hoisted` so that the external reference to the Dawn webgpu library can successfully link it.
|
|
17
|
+
|
|
16
18
|
Below are some examples from the [example app](/apps/example/).
|
|
17
19
|
|
|
18
20
|
https://github.com/user-attachments/assets/116a41b2-2cf8-49f1-9f16-a5c83637c198
|
|
@@ -156,8 +158,8 @@ From there you will be able to run the example app properly.
|
|
|
156
158
|
|
|
157
159
|
## Similarities and Differences with the Web
|
|
158
160
|
|
|
159
|
-
The API has been designed to be completely symmetric with the Web.
|
|
160
|
-
For instance, you can access the WebGPU context synchronously, as well as the canvas size.
|
|
161
|
+
The API has been designed to be completely symmetric with the Web.
|
|
162
|
+
For instance, you can access the WebGPU context synchronously, as well as the canvas size.
|
|
161
163
|
Pixel density and canvas resizing are handled exactly like on the Web as well.
|
|
162
164
|
|
|
163
165
|
```tsx
|
|
@@ -171,7 +173,7 @@ ctx.canvas.height = ctx.canvas.clientHeight * PixelRatio.get();
|
|
|
171
173
|
|
|
172
174
|
### Frame Scheduling
|
|
173
175
|
|
|
174
|
-
In React Native, we want to keep frame presentation as a manual operation as we plan to provide more advanced rendering options that are React Native specific.
|
|
176
|
+
In React Native, we want to keep frame presentation as a manual operation as we plan to provide more advanced rendering options that are React Native specific.
|
|
175
177
|
This means that when you are ready to present a frame, you need to call `present` on the context.
|
|
176
178
|
|
|
177
179
|
```tsx
|
package/apple/MetalView.mm
CHANGED
package/cpp/rnwgpu/api/GPU.h
CHANGED
|
@@ -82,16 +82,16 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
|
|
|
82
82
|
auto creationRuntime = getCreationRuntime();
|
|
83
83
|
return _async->postTask(
|
|
84
84
|
[this, aDescriptor, descriptor, label = std::move(label),
|
|
85
|
-
deviceLostBinding,
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
deviceLostBinding, creationRuntime](
|
|
86
|
+
const async::AsyncTaskHandle::ResolveFunction &resolve,
|
|
87
|
+
const async::AsyncTaskHandle::RejectFunction &reject) {
|
|
88
88
|
(void)descriptor;
|
|
89
89
|
_instance.RequestDevice(
|
|
90
90
|
&aDescriptor, wgpu::CallbackMode::AllowProcessEvents,
|
|
91
|
-
[asyncRunner = _async, resolve, reject, label,
|
|
92
|
-
deviceLostBinding](
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
[asyncRunner = _async, resolve, reject, label,
|
|
92
|
+
creationRuntime, deviceLostBinding](
|
|
93
|
+
wgpu::RequestDeviceStatus status, wgpu::Device device,
|
|
94
|
+
wgpu::StringView message) mutable {
|
|
95
95
|
if (message.length) {
|
|
96
96
|
fprintf(stderr, "%s", message.data);
|
|
97
97
|
}
|