From 50c6ea93310bf0d1ad57d77b9ef5b1a6fe8eb9c9 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Wed, 11 Dec 2024 17:42:49 +0100 Subject: [PATCH] Update docs --- README.md | 5 +-- packages/webgpu/README.md | 72 +++++------------------------------- packages/webgpu/package.json | 1 - 3 files changed, 10 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 30f5e47c4..b61a27c70 100644 --- a/README.md +++ b/README.md @@ -194,10 +194,6 @@ In "Edit Scheme," uncheck "Metal Validation." Uncheck 'Metal Validation' -### Android - -On an Android simulator, a CPU emulation layer is used which may result in very slow performance. - ## Library Development Make sure to check out the submodules: @@ -235,6 +231,7 @@ You need to have the [Github CLI](https://cli.github.com/) installed: $ yarn $ cd packages/webgpu $ yarn download-artifacts +$ yarn copy-artifacts ``` Alternatively you can also download the prebuilt binaries [here](https://github.com/wcandillon/react-native-webgpu/actions/workflows/build-dawn.yml). diff --git a/packages/webgpu/README.md b/packages/webgpu/README.md index 7d5e7a943..e77d4078c 100644 --- a/packages/webgpu/README.md +++ b/packages/webgpu/README.md @@ -11,15 +11,21 @@ Please note that the package name is `react-native-wgpu`. npm install react-native-wgpu ``` -Below are some examples from the [example app](/package/example/). +Below are some examples from the [example app](/apps/example/). https://github.com/user-attachments/assets/116a41b2-2cf8-49f1-9f16-a5c83637c198 Starting from `r168`, Three.js runs out of the box with React Native WebGPU. -You need to have a slight modification of [the metro config](/package/example/metro.config.js) to resolve Three.js to the WebGPU build. +You need to have a slight modification of [the metro config](/apps/example/metro.config.js) to resolve Three.js to the WebGPU build. +We also support [three-fiber](/apps/example/src/ThreeJS/Fiber.tsx). +For model loading, we also need [the following polyfill](/apps/example/src/App.tsx#29). https://github.com/user-attachments/assets/5b49ef63-0a3c-4679-aeb5-e4b4dddfcc1d +We also provide prebuilt binaries for visionOS and macOS. + +https://github.com/user-attachments/assets/2d5c618e-5b15-4cef-8558-d4ddf8c70667 + ## Usage Currently we recommend to use the `useCanvasEffect` to access the WebGPU context. @@ -123,13 +129,7 @@ const style = StyleSheet.create({ ## Example App -To run the example app you first need to build Dawn. - -```sh -$ git submodule update --init -$ cd package && yarn -$ yarn build-dawn -``` +To run the example app you first need to [build Dawn or download the prebuilt binaries](#building-dawn). From there you will be able to run the example app properly. @@ -184,57 +184,3 @@ device.queue.copyExternalImageToTexture( [imageBitmap.width, imageBitmap.height], ); ``` - -## Troubleshooting - -### iOS - -To run the React Native WebGPU project on the iOS simulator, you need to disable the Metal validation API. -In "Edit Scheme," uncheck "Metal Validation." - -Uncheck 'Metal Validation' - -### Android - -On an Android simulator, a CPU emulation layer is used which may result in very slow performance. - -## Library Development - -Make sure to check out the submodules: - -``` -git submodule update --init -``` - -Make sure you have all the tools required for building the Skia libraries (Android Studio, XCode, Ninja, CMake, Android NDK/build tools). - -### Building - -* `cd packages/webgpu && yarn` -* `yarn build-dawn` - -### Upgrading - -1. `git submodule update --remote` -2. `yarn clean-dawn` -3. `yarn build-dawn` - -### Codegen - -* `cd packages/webgpu && yarn codegen` - -### Testing - -In the `package` folder, to run the test against Chrome for reference: - -``` -yarn test:ref -``` - -To run the e2e test, open the example app on the e2e screen. -By default, it will try to connect to a localhost test server. -If you want to run the test suite on a physical device, you can modify the address [here](/package/example/src/useClient.ts#L4). - -``` -yarn test -``` diff --git a/packages/webgpu/package.json b/packages/webgpu/package.json index 29e0b5627..97010cc71 100644 --- a/packages/webgpu/package.json +++ b/packages/webgpu/package.json @@ -26,7 +26,6 @@ "tsc": "tsc --noEmit", "build": "bob build", "build-dawn": "ts-node scripts/build/dawn.ts", - "copy-headers": "ts-node scripts/build/copy-headers.ts", "clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out", "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common", "clang-format-ios": "find apple/ -iname \"*.h\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",