react-native-wgpu 0.1.20 → 0.1.21

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 CHANGED
@@ -11,15 +11,21 @@ Please note that the package name is `react-native-wgpu`.
11
11
  npm install react-native-wgpu
12
12
  ```
13
13
 
14
- Below are some examples from the [example app](/package/example/).
14
+ Below are some examples from the [example app](/apps/example/).
15
15
 
16
16
  https://github.com/user-attachments/assets/116a41b2-2cf8-49f1-9f16-a5c83637c198
17
17
 
18
18
  Starting from `r168`, Three.js runs out of the box with React Native WebGPU.
19
- You need to have a slight modification of [the metro config](/package/example/metro.config.js) to resolve Three.js to the WebGPU build.
19
+ You need to have a slight modification of [the metro config](/apps/example/metro.config.js) to resolve Three.js to the WebGPU build.
20
+ We also support [three-fiber](/apps/example/src/ThreeJS/Fiber.tsx).
21
+ For model loading, we also need [the following polyfill](/apps/example/src/App.tsx#29).
20
22
 
21
23
  https://github.com/user-attachments/assets/5b49ef63-0a3c-4679-aeb5-e4b4dddfcc1d
22
24
 
25
+ We also provide prebuilt binaries for visionOS and macOS.
26
+
27
+ https://github.com/user-attachments/assets/2d5c618e-5b15-4cef-8558-d4ddf8c70667
28
+
23
29
  ## Usage
24
30
 
25
31
  Currently we recommend to use the `useCanvasEffect` to access the WebGPU context.
@@ -123,13 +129,7 @@ const style = StyleSheet.create({
123
129
 
124
130
  ## Example App
125
131
 
126
- To run the example app you first need to build Dawn.
127
-
128
- ```sh
129
- $ git submodule update --init
130
- $ cd package && yarn
131
- $ yarn build-dawn
132
- ```
132
+ To run the example app you first need to [build Dawn or download the prebuilt binaries](#building-dawn).
133
133
 
134
134
  From there you will be able to run the example app properly.
135
135
 
@@ -184,57 +184,3 @@ device.queue.copyExternalImageToTexture(
184
184
  [imageBitmap.width, imageBitmap.height],
185
185
  );
186
186
  ```
187
-
188
- ## Troubleshooting
189
-
190
- ### iOS
191
-
192
- To run the React Native WebGPU project on the iOS simulator, you need to disable the Metal validation API.
193
- In "Edit Scheme," uncheck "Metal Validation."
194
-
195
- <img width="1052" alt="Uncheck 'Metal Validation'" src="https://github.com/user-attachments/assets/2676e5cc-e351-4a97-bdc8-22cbd7df2ef2">
196
-
197
- ### Android
198
-
199
- On an Android simulator, a CPU emulation layer is used which may result in very slow performance.
200
-
201
- ## Library Development
202
-
203
- Make sure to check out the submodules:
204
-
205
- ```
206
- git submodule update --init
207
- ```
208
-
209
- Make sure you have all the tools required for building the Skia libraries (Android Studio, XCode, Ninja, CMake, Android NDK/build tools).
210
-
211
- ### Building
212
-
213
- * `cd packages/webgpu && yarn`
214
- * `yarn build-dawn`
215
-
216
- ### Upgrading
217
-
218
- 1. `git submodule update --remote`
219
- 2. `yarn clean-dawn`
220
- 3. `yarn build-dawn`
221
-
222
- ### Codegen
223
-
224
- * `cd packages/webgpu && yarn codegen`
225
-
226
- ### Testing
227
-
228
- In the `package` folder, to run the test against Chrome for reference:
229
-
230
- ```
231
- yarn test:ref
232
- ```
233
-
234
- To run the e2e test, open the example app on the e2e screen.
235
- By default, it will try to connect to a localhost test server.
236
- If you want to run the test suite on a physical device, you can modify the address [here](/package/example/src/useClient.ts#L4).
237
-
238
- ```
239
- yarn test
240
- ```
@@ -82,7 +82,20 @@ add_library(webgpu_dawn SHARED IMPORTED)
82
82
  set_property(TARGET webgpu_dawn PROPERTY IMPORTED_LOCATION "${WEBGPU_LIBS_PATH}/libwebgpu_dawn.so")
83
83
 
84
84
  # Link
85
- target_link_libraries(
85
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
86
+ target_link_libraries(
87
+ ${PACKAGE_NAME}
88
+ ${FBJNI_LIBRARY}
89
+ log
90
+ jnigraphics
91
+ android
92
+ fbjni::fbjni
93
+ ReactAndroid::jsi
94
+ ReactAndroid::reactnative
95
+ webgpu_dawn
96
+ )
97
+ else()
98
+ target_link_libraries(
86
99
  ${PACKAGE_NAME}
87
100
  ${FBJNI_LIBRARY}
88
101
  log
@@ -93,3 +106,4 @@ target_link_libraries(
93
106
  ReactAndroid::reactnativejni
94
107
  webgpu_dawn
95
108
  )
109
+ endif()
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAOA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAMA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAOlD;AACA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeWebGPUModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAMlD;AACA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
2
2
  export interface Spec extends TurboModule {
3
3
  install: () => boolean;
4
- createSurfaceContext: (contextId: number) => boolean;
5
4
  }
6
5
  declare const _default: Spec;
7
6
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeWebGPUModule.d.ts","sourceRoot":"","sources":["../../../src/NativeWebGPUModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAGhF,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CACtD;;AAGD,wBAAsE"}
1
+ {"version":3,"file":"NativeWebGPUModule.d.ts","sourceRoot":"","sources":["../../../src/NativeWebGPUModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAGhF,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB;;AAGD,wBAAsE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wgpu",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -26,7 +26,6 @@
26
26
  "tsc": "tsc --noEmit",
27
27
  "build": "bob build",
28
28
  "build-dawn": "ts-node scripts/build/dawn.ts",
29
- "copy-headers": "ts-node scripts/build/copy-headers.ts",
30
29
  "clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out",
31
30
  "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
32
31
  "clang-format-ios": "find apple/ -iname \"*.h\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
@@ -3,7 +3,6 @@ import { TurboModuleRegistry } from "react-native";
3
3
 
4
4
  export interface Spec extends TurboModule {
5
5
  install: () => boolean;
6
- createSurfaceContext: (contextId: number) => boolean;
7
6
  }
8
7
 
9
8
  // eslint-disable-next-line import/no-default-export