react-native-wgpu 0.1.0 → 0.1.2

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.
Files changed (269) hide show
  1. package/README.md +221 -13
  2. package/android/CMakeLists.txt +15 -1
  3. package/android/build.gradle +0 -18
  4. package/android/cpp/AndroidPlatformContext.h +26 -0
  5. package/android/cpp/cpp-adapter.cpp +66 -3
  6. package/android/src/main/java/com/webgpu/WebGPUModule.java +64 -22
  7. package/android/src/main/java/com/webgpu/WebGPUView.java +63 -8
  8. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +5 -6
  9. package/android/src/newarch/{WgpuViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +5 -5
  10. package/android/src/oldarch/com/webgpu/NativeWebGPUModuleSpec.java +23 -0
  11. package/android/src/oldarch/{WebGPUViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +1 -1
  12. package/cpp/{Logger.h → WGPULogger.h} +13 -6
  13. package/cpp/dawn/webgpu.h +9 -0
  14. package/cpp/dawn/webgpu_cpp.h +95 -43
  15. package/cpp/dawn/webgpu_cpp_print.h +6 -0
  16. package/cpp/dawn/wire/client/webgpu_cpp.h +80 -43
  17. package/cpp/jsi/RNFHybridObject.cpp +1 -1
  18. package/cpp/jsi/RNFHybridObject.h +4 -4
  19. package/cpp/jsi/RNFJSIConverter.h +204 -17
  20. package/cpp/rnwgpu/ArrayBuffer.h +72 -0
  21. package/cpp/rnwgpu/PlatformContext.h +16 -0
  22. package/cpp/rnwgpu/RNWebGPUManager.cpp +14 -9
  23. package/cpp/rnwgpu/RNWebGPUManager.h +12 -1
  24. package/cpp/rnwgpu/SurfaceRegistry.h +36 -0
  25. package/cpp/rnwgpu/api/AsyncRunner.h +30 -0
  26. package/cpp/rnwgpu/api/Canvas.h +55 -0
  27. package/cpp/rnwgpu/api/Convertors.h +765 -0
  28. package/cpp/rnwgpu/api/External.h +12 -0
  29. package/cpp/rnwgpu/api/GPU.cpp +100 -23
  30. package/cpp/rnwgpu/api/GPU.h +24 -6
  31. package/cpp/rnwgpu/api/GPUAdapter.cpp +122 -8
  32. package/cpp/rnwgpu/api/GPUAdapter.h +24 -5
  33. package/cpp/rnwgpu/api/GPUAdapterInfo.h +19 -7
  34. package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
  35. package/cpp/rnwgpu/api/GPUBindGroup.h +11 -4
  36. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +11 -4
  37. package/cpp/rnwgpu/api/GPUBuffer.cpp +82 -7
  38. package/cpp/rnwgpu/api/GPUBuffer.h +43 -7
  39. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +63 -0
  40. package/cpp/rnwgpu/api/GPUCanvasContext.h +51 -8
  41. package/cpp/rnwgpu/api/GPUCommandBuffer.h +11 -4
  42. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +177 -0
  43. package/cpp/rnwgpu/api/GPUCommandEncoder.h +75 -3
  44. package/cpp/rnwgpu/api/GPUCompilationInfo.h +65 -8
  45. package/cpp/rnwgpu/api/GPUCompilationMessage.h +6 -4
  46. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +58 -0
  47. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +49 -3
  48. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +11 -0
  49. package/cpp/rnwgpu/api/GPUComputePipeline.h +18 -3
  50. package/cpp/rnwgpu/api/GPUDevice.cpp +330 -3
  51. package/cpp/rnwgpu/api/GPUDevice.h +119 -5
  52. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +6 -0
  53. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +14 -7
  54. package/cpp/rnwgpu/api/GPUError.h +42 -0
  55. package/cpp/rnwgpu/api/GPUExtent3D.h +69 -0
  56. package/cpp/rnwgpu/api/GPUExternalTexture.h +11 -4
  57. package/cpp/rnwgpu/api/GPUFeatures.h +221 -0
  58. package/cpp/rnwgpu/api/GPUOrigin2D.h +59 -0
  59. package/cpp/rnwgpu/api/GPUOrigin3D.h +66 -0
  60. package/cpp/rnwgpu/api/GPUPipelineLayout.h +11 -4
  61. package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
  62. package/cpp/rnwgpu/api/GPUQuerySet.h +19 -5
  63. package/cpp/rnwgpu/api/GPUQueue.cpp +110 -0
  64. package/cpp/rnwgpu/api/GPUQueue.h +45 -4
  65. package/cpp/rnwgpu/api/GPURenderBundle.h +11 -4
  66. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +128 -0
  67. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +72 -3
  68. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +161 -0
  69. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +93 -3
  70. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
  71. package/cpp/rnwgpu/api/GPURenderPipeline.h +18 -3
  72. package/cpp/rnwgpu/api/GPUSampler.h +11 -4
  73. package/cpp/rnwgpu/api/GPUShaderModule.cpp +39 -0
  74. package/cpp/rnwgpu/api/GPUShaderModule.h +23 -4
  75. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +133 -0
  76. package/cpp/rnwgpu/api/GPUSupportedLimits.h +128 -4
  77. package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
  78. package/cpp/rnwgpu/api/GPUTexture.h +38 -4
  79. package/cpp/rnwgpu/api/GPUTextureView.h +11 -4
  80. package/cpp/rnwgpu/api/ImageData.h +50 -0
  81. package/cpp/rnwgpu/api/Navigator.h +46 -0
  82. package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +59 -0
  83. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +31 -43
  84. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +40 -31
  85. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +24 -32
  86. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +56 -49
  87. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +27 -20
  88. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +23 -31
  89. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +25 -36
  90. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +25 -25
  91. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +26 -46
  92. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +31 -53
  93. package/cpp/rnwgpu/api/descriptors/GPUColor.h +72 -0
  94. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +27 -33
  95. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +51 -0
  96. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +51 -0
  97. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +24 -25
  98. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +25 -42
  99. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +32 -42
  100. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +58 -76
  101. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +38 -30
  102. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +11 -11
  103. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +43 -34
  104. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +39 -46
  105. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +29 -45
  106. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +25 -34
  107. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +32 -36
  108. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +42 -44
  109. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +24 -34
  110. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +24 -32
  111. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +25 -35
  112. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +35 -26
  113. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +29 -35
  114. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +23 -43
  115. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +49 -0
  116. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +51 -0
  117. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +41 -57
  118. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +42 -61
  119. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +54 -66
  120. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +52 -55
  121. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +25 -42
  122. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +60 -56
  123. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +21 -20
  124. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +17 -14
  125. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +63 -63
  126. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +28 -27
  127. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +28 -49
  128. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +32 -23
  129. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +27 -29
  130. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +27 -20
  131. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +49 -76
  132. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +48 -64
  133. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +29 -31
  134. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +23 -44
  135. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +30 -36
  136. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +39 -38
  137. package/cpp/rnwgpu/api/descriptors/Unions.h +57 -2
  138. package/ios/IOSPlatformContext.h +16 -0
  139. package/ios/IOSPlatformContext.mm +18 -0
  140. package/ios/MetalView.h +10 -0
  141. package/ios/MetalView.mm +27 -0
  142. package/ios/SurfaceUtils.h +13 -0
  143. package/ios/SurfaceUtils.mm +24 -0
  144. package/ios/WebGPUModule.h +8 -7
  145. package/ios/WebGPUModule.mm +47 -14
  146. package/ios/WebGPUView.h +6 -3
  147. package/ios/WebGPUView.mm +36 -24
  148. package/ios/WebGPUViewComponentDescriptor.h +61 -0
  149. package/ios/WebGPUViewManager.mm +6 -4
  150. package/lib/commonjs/Canvas.js +49 -0
  151. package/lib/commonjs/Canvas.js.map +1 -0
  152. package/lib/commonjs/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
  153. package/lib/commonjs/{WebGPUNativeModule.js.map → NativeWebGPUModule.js.map} +1 -1
  154. package/lib/commonjs/WebGPUView.js +2 -0
  155. package/lib/commonjs/WebGPUView.js.map +1 -0
  156. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -1
  157. package/lib/commonjs/index.js +158 -19
  158. package/lib/commonjs/index.js.map +1 -1
  159. package/lib/module/Canvas.js +42 -0
  160. package/lib/module/Canvas.js.map +1 -0
  161. package/lib/module/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
  162. package/lib/module/NativeWebGPUModule.js.map +1 -0
  163. package/lib/module/WebGPUView.js +2 -0
  164. package/lib/module/WebGPUView.js.map +1 -0
  165. package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
  166. package/lib/module/index.js +144 -6
  167. package/lib/module/index.js.map +1 -1
  168. package/lib/typescript/example/src/Triangle/triangle.d.ts +3 -0
  169. package/lib/typescript/example/src/Triangle/triangle.d.ts.map +1 -0
  170. package/lib/typescript/example/src/Wireframe/Shaders.d.ts +3 -0
  171. package/lib/typescript/example/src/Wireframe/Shaders.d.ts.map +1 -0
  172. package/lib/typescript/example/src/Wireframe/models.d.ts +29 -0
  173. package/lib/typescript/example/src/Wireframe/models.d.ts.map +1 -0
  174. package/lib/typescript/example/src/components/DrawingContext.d.ts +13 -0
  175. package/lib/typescript/example/src/components/DrawingContext.d.ts.map +1 -0
  176. package/lib/typescript/example/src/components/cube.d.ts +7 -0
  177. package/lib/typescript/example/src/components/cube.d.ts.map +1 -0
  178. package/lib/typescript/example/src/components/meshes/sphere.d.ts +12 -0
  179. package/lib/typescript/example/src/components/meshes/sphere.d.ts.map +1 -0
  180. package/lib/typescript/example/src/components/meshes/teapot.d.ts +6 -0
  181. package/lib/typescript/example/src/components/meshes/teapot.d.ts.map +1 -0
  182. package/lib/typescript/example/src/components/meshes/utils.d.ts +10 -0
  183. package/lib/typescript/example/src/components/meshes/utils.d.ts.map +1 -0
  184. package/lib/typescript/jest.config.d.ts +4 -0
  185. package/lib/typescript/lib/commonjs/Canvas.d.ts +4 -0
  186. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
  187. package/lib/typescript/lib/commonjs/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  188. package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
  189. package/lib/typescript/lib/commonjs/WebGPUView.d.ts +1 -0
  190. package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +1 -0
  191. package/lib/typescript/lib/commonjs/index.d.ts +0 -2
  192. package/lib/typescript/lib/module/Canvas.d.ts +2 -0
  193. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
  194. package/lib/typescript/lib/module/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  195. package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
  196. package/lib/typescript/lib/module/WebGPUView.d.ts +1 -0
  197. package/lib/typescript/lib/module/WebGPUView.d.ts.map +1 -0
  198. package/lib/typescript/lib/module/index.d.ts +2 -3
  199. package/lib/typescript/src/Canvas.d.ts +22 -0
  200. package/lib/typescript/src/Canvas.d.ts.map +1 -0
  201. package/lib/typescript/src/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +2 -1
  202. package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
  203. package/lib/typescript/src/WebGPUView.d.ts +1 -0
  204. package/lib/typescript/src/WebGPUView.d.ts.map +1 -0
  205. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -1
  206. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  207. package/lib/typescript/src/index.d.ts +2 -7
  208. package/lib/typescript/src/index.d.ts.map +1 -1
  209. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  210. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  211. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  212. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  213. package/libs/dawn.json +4597 -0
  214. package/libs/ios/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  215. package/libs/ios/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  216. package/libs/ios/libwebgpu_dawn.a +0 -0
  217. package/libs/ios/libwebgpu_dawn.xcframework/Info.plist +44 -0
  218. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  219. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  220. package/libs/ios/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  221. package/package.json +25 -8
  222. package/{react-native-webgpu.podspec → react-native-wgpu.podspec} +6 -9
  223. package/src/Canvas.tsx +68 -0
  224. package/src/{WebGPUNativeModule.ts → NativeWebGPUModule.ts} +1 -0
  225. package/src/WebGPUView.tsx +0 -0
  226. package/src/WebGPUViewNativeComponent.ts +2 -1
  227. package/src/index.tsx +172 -8
  228. package/android/src/main/AndroidManifestNew.xml +0 -2
  229. package/cpp/rnwgpu/MutableBuffer.h +0 -48
  230. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -33
  231. package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +0 -81
  232. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +0 -76
  233. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +0 -91
  234. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +0 -61
  235. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +0 -75
  236. package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +0 -71
  237. package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +0 -54
  238. package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +0 -83
  239. package/ios/RNFAppleLogger.mm +0 -22
  240. package/ios/Utils.h +0 -5
  241. package/ios/Utils.m +0 -26
  242. package/lib/module/WebGPUNativeModule.js.map +0 -1
  243. package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +0 -1
  244. package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +0 -1
  245. package/lib/typescript/scripts/build/copy-artifacts.d.ts +0 -2
  246. package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +0 -1
  247. package/lib/typescript/scripts/build/dawn.d.ts +0 -2
  248. package/lib/typescript/scripts/build/dawn.d.ts.map +0 -1
  249. package/lib/typescript/scripts/build/util.d.ts +0 -13
  250. package/lib/typescript/scripts/build/util.d.ts.map +0 -1
  251. package/lib/typescript/scripts/codegen/codegen.d.ts +0 -2
  252. package/lib/typescript/scripts/codegen/codegen.d.ts.map +0 -1
  253. package/lib/typescript/scripts/codegen/model/dawn.d.ts +0 -2
  254. package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +0 -1
  255. package/lib/typescript/scripts/codegen/model/model.d.ts +0 -8
  256. package/lib/typescript/scripts/codegen/model/model.d.ts.map +0 -1
  257. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +0 -4
  258. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +0 -1
  259. package/lib/typescript/scripts/codegen/templates/Enum.d.ts +0 -3
  260. package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +0 -1
  261. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +0 -3
  262. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +0 -1
  263. package/lib/typescript/scripts/codegen/templates/Unions.d.ts +0 -6
  264. package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +0 -1
  265. package/lib/typescript/scripts/codegen/templates/common.d.ts +0 -9
  266. package/lib/typescript/scripts/codegen/templates/common.d.ts.map +0 -1
  267. package/lib/typescript/scripts/codegen/util.d.ts +0 -2
  268. package/lib/typescript/scripts/codegen/util.d.ts.map +0 -1
  269. package/lib/typescript/src/WebGPUNativeModule.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,31 +1,239 @@
1
- # react-native-wgpu
1
+ # React Native WebGPU
2
2
 
3
- React Native WebGPU
3
+ React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
4
+ This is currently a technical preview for early adopters.
4
5
 
5
6
  ## Installation
6
7
 
7
- ```sh
8
+ Please note that the package name is `react-native-wgpu`.
9
+
10
+ ```
8
11
  npm install react-native-wgpu
9
12
  ```
10
13
 
11
14
  ## Usage
12
15
 
13
- ```js
14
- import { WgpuView } from "react-native-wgpu";
16
+ You can look at the [example](/package/example) folder for working examples.
17
+
18
+ ```tsx
19
+ import React, { useEffect, useRef } from "react";
20
+ import { StyleSheet, View, PixelRatio } from "react-native";
21
+ import type { CanvasRef } from "react-native-webgpu";
22
+ import { Canvas } from "react-native-webgpu";
23
+
24
+ import { redFragWGSL, triangleVertWGSL } from "./triangle";
25
+
26
+ export function HelloTriangle() {
27
+ const ref = useRef<CanvasRef>(null);
28
+
29
+ async function demo() {
30
+ const adapter = await navigator.gpu.requestAdapter();
31
+ if (!adapter) {
32
+ throw new Error("No adapter");
33
+ }
34
+ const device = await adapter.requestDevice();
35
+ const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
36
+
37
+ const context = ref.current!.getContext("webgpu")!;
38
+ canvas.width = canvas.clientWidth * PixelRatio.get();
39
+ canvas.height = canvas.clientHeight * PixelRatio.get();
40
+
41
+ if (!context) {
42
+ throw new Error("No context");
43
+ }
44
+
45
+ context.configure({
46
+ device,
47
+ format: presentationFormat,
48
+ alphaMode: "opaque",
49
+ });
50
+
51
+ const pipeline = device.createRenderPipeline({
52
+ layout: "auto",
53
+ vertex: {
54
+ module: device.createShaderModule({
55
+ code: triangleVertWGSL,
56
+ }),
57
+ entryPoint: "main",
58
+ },
59
+ fragment: {
60
+ module: device.createShaderModule({
61
+ code: redFragWGSL,
62
+ }),
63
+ entryPoint: "main",
64
+ targets: [
65
+ {
66
+ format: presentationFormat,
67
+ },
68
+ ],
69
+ },
70
+ primitive: {
71
+ topology: "triangle-list",
72
+ },
73
+ });
74
+
75
+ const commandEncoder = device.createCommandEncoder();
76
+
77
+ const textureView = context.getCurrentTexture().createView();
78
+
79
+ const renderPassDescriptor: GPURenderPassDescriptor = {
80
+ colorAttachments: [
81
+ {
82
+ view: textureView,
83
+ clearValue: [0, 0, 0, 1],
84
+ loadOp: "clear",
85
+ storeOp: "store",
86
+ },
87
+ ],
88
+ };
89
+
90
+ const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
91
+ passEncoder.setPipeline(pipeline);
92
+ passEncoder.draw(3);
93
+ passEncoder.end();
94
+
95
+ device.queue.submit([commandEncoder.finish()]);
96
+
97
+ context.present();
98
+ }
99
+
100
+ useEffect(() => {
101
+ demo();
102
+ }, []);
103
+
104
+ return (
105
+ <View style={style.container}>
106
+ <Canvas ref={ref} style={style.webgpu} />
107
+ </View>
108
+ );
109
+ }
110
+
111
+ const style = StyleSheet.create({
112
+ container: {
113
+ flex: 1,
114
+ },
115
+ webgpu: {
116
+ flex: 1,
117
+ },
118
+ });
119
+ ```
120
+
121
+ ## Similarities and Differences with the Web
122
+
123
+ The API has been designed to be completely symmetric with the Web.
124
+ For instance, you can access the WebGPU context synchronously, as well as the canvas size.
125
+ Pixel density and canvas resizing are handled exactly like on the Web as well.
126
+
127
+ ```tsx
128
+ // The default canvas size is not scaled to the device pixel ratio
129
+ // When resizing the canvas, the clientWidth and clientHeight are updated automatically
130
+ // This behaviour is symmetric to the Web
131
+ const ctx = canvas.current.getContext("webgpu")!;
132
+ ctx.canvas.width = ctx.canvas.clientWidth * PixelRatio.get();
133
+ ctx.canvas.height = ctx.canvas.clientHeight * PixelRatio.get();
134
+ ```
135
+
136
+ However, there are two differences with the Web: frame scheduling and external textures.
137
+
138
+ ### Frame Scheduling
139
+
140
+ 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.
141
+ This means that when you are ready to present a frame, you need to call `present` on the context.
142
+
143
+ ```tsx
144
+ // draw
145
+ // submit to the queue
146
+ device.queue.submit([commandEncoder.finish()]);
147
+ // This method is React Native only
148
+ context.present();
149
+ ```
150
+
151
+ ### External Textures
152
+
153
+ External textures are not a concept that exists in React Native.
154
+ Consider the following Web example:
155
+
156
+ ```tsx
157
+ const response = await fetch('./assets/img/Di-3d.png');
158
+ const imageBitmap = await createImageBitmap(await response.blob());
159
+
160
+ device.queue.copyExternalImageToTexture(
161
+ { source: imageBitmap },
162
+ { texture: cubeTexture },
163
+ [imageBitmap.width, imageBitmap.height]
164
+ );
165
+ ```
166
+
167
+ In React Native, you would need to load the texture yourself.
168
+ For instance, we use Skia for image decoding [here](/package/example/src/components/useAssets.ts#L6).
169
+
170
+ ```tsx
171
+ const imageBitmap = await decodeImage(require("./assets/Di-3d.png"));
172
+
173
+ device.queue.writeTexture(
174
+ { texture: cubeTexture, mipLevel: 0, origin: { x: 0, y: 0, z: 0 } },
175
+ imageBitmap.data.buffer,
176
+ {
177
+ offset: 0,
178
+ bytesPerRow: 4 * imageBitmap.width,
179
+ rowsPerImage: imageBitmap.height,
180
+ },
181
+ { width: imageBitmap.width, height: imageBitmap.height },
182
+ );
183
+ ```
184
+
185
+ ## Troubleshooting
186
+
187
+ ### iOS
188
+
189
+ To run the React Native WebGPU project on the iOS simulator, you need to disable the Metal validation API.
190
+ In "Edit Scheme," uncheck "Metal Validation."
191
+
192
+ <img width="1052" alt="Uncheck 'Metal Validation'" src="https://github.com/user-attachments/assets/2676e5cc-e351-4a97-bdc8-22cbd7df2ef2">
15
193
 
16
- // ...
194
+ ### Android
17
195
 
18
- <WgpuView color="tomato" />
196
+ On a physical device, you need Android API level 26 or higher.
197
+ On a simulator, you need Android API level 34 or higher.
198
+ We are currently working on relaxing that rule for Android simulators.
199
+
200
+ ## Library Development
201
+
202
+ Make sure to check out the submodules:
203
+
204
+ ```
205
+ git submodule update --init
19
206
  ```
20
207
 
21
- ## Contributing
208
+ Make sure you have all the tools required for building the Skia libraries (Android Studio, XCode, Ninja, CMake, Android NDK/build tools).
209
+
210
+ ### Building
211
+
212
+ * `cd package && yarn`
213
+ * `yarn build-dawn`
214
+
215
+ ### Upgrading
22
216
 
23
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
217
+ 1. `git submodule update --remote`
218
+ 2. `yarn clean-dawn`
219
+ 3. `yarn build-dawn`
24
220
 
25
- ## License
221
+ ### Codegen
26
222
 
27
- MIT
223
+ * `cd package && yarn codegen`
28
224
 
29
- ---
225
+ ### Testing
30
226
 
31
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
227
+ In the `package` folder, to run the test against Chrome for reference:
228
+
229
+ ```
230
+ yarn test:ref
231
+ ```
232
+
233
+ To run the e2e test, open the example app on the e2e screen.
234
+ By default, it will try to connect to a localhost test server.
235
+ If you want to run the test suite on a physical device, you can modify the address [here](/package/example/src/useClient.ts#L4).
236
+
237
+ ```
238
+ yarn test
239
+ ```
@@ -4,7 +4,7 @@ project(RNWGPU)
4
4
  set (CMAKE_VERBOSE_MAKEFILE ON)
5
5
  set (CMAKE_CXX_STANDARD 17)
6
6
 
7
- set (PACKAGE_NAME "react-native-webgpu")
7
+ set (PACKAGE_NAME "react-native-wgpu")
8
8
 
9
9
  #link_directories(../libs/android/${ANDROID_ABI}/)
10
10
 
@@ -27,8 +27,22 @@ add_library(${PACKAGE_NAME} SHARED
27
27
  ./cpp/cpp-adapter.cpp
28
28
  ../cpp/rnwgpu/api/GPU.cpp
29
29
  ../cpp/rnwgpu/api/GPUAdapter.cpp
30
+ ../cpp/rnwgpu/api/GPUSupportedLimits.cpp
31
+ ../cpp/rnwgpu/api/GPUShaderModule.cpp
32
+ ../cpp/rnwgpu/api/GPUDeviceLostInfo.cpp
30
33
  ../cpp/rnwgpu/api/GPUDevice.cpp
31
34
  ../cpp/rnwgpu/api/GPUBuffer.cpp
35
+ ../cpp/rnwgpu/api/GPUQueue.cpp
36
+ ../cpp/rnwgpu/api/GPUCommandEncoder.cpp
37
+ ../cpp/rnwgpu/api/GPUQuerySet.cpp
38
+ ../cpp/rnwgpu/api/GPUTexture.cpp
39
+ ../cpp/rnwgpu/api/GPURenderBundleEncoder.cpp
40
+ ../cpp/rnwgpu/api/GPURenderPassEncoder.cpp
41
+ ../cpp/rnwgpu/api/GPURenderPipeline.cpp
42
+ ../cpp/rnwgpu/api/GPUBindGroup.cpp
43
+ ../cpp/rnwgpu/api/GPUComputePassEncoder.cpp
44
+ ../cpp/rnwgpu/api/GPUComputePipeline.cpp
45
+ ../cpp/rnwgpu/api/GPUCanvasContext.cpp
32
46
  ../cpp/rnwgpu/RNWebGPUManager.cpp
33
47
  ../cpp/jsi/RNFPromise.cpp
34
48
  ../cpp/jsi/RNFHybridObject.cpp
@@ -70,16 +70,6 @@ def supportsNamespace() {
70
70
  }
71
71
 
72
72
  android {
73
- if (supportsNamespace()) {
74
- namespace "com.wgpu"
75
-
76
- sourceSets {
77
- main {
78
- manifest.srcFile "src/main/AndroidManifestNew.xml"
79
- }
80
- }
81
- }
82
-
83
73
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
84
74
 
85
75
  defaultConfig {
@@ -156,11 +146,3 @@ dependencies {
156
146
  //noinspection GradleDynamicVersion
157
147
  implementation "com.facebook.react:react-native:+"
158
148
  }
159
-
160
- if (isNewArchitectureEnabled()) {
161
- react {
162
- jsRootDir = file("../src/")
163
- libraryName = "WgpuView"
164
- codegenJavaPackageName = "com.wgpu"
165
- }
166
- }
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include "webgpu/webgpu_cpp.h"
6
+
7
+ #include "PlatformContext.h"
8
+ #include "RNWebGPUManager.h"
9
+
10
+ namespace rnwgpu {
11
+ class AndroidPlatformContext : public PlatformContext {
12
+ public:
13
+ AndroidPlatformContext() = default;
14
+ ~AndroidPlatformContext() = default;
15
+
16
+ wgpu::Surface makeSurface(wgpu::Instance instance, void *window, int width,
17
+ int height) override {
18
+ wgpu::SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc;
19
+ androidSurfaceDesc.window = reinterpret_cast<ANativeWindow *>(window);
20
+ wgpu::SurfaceDescriptor surfaceDescriptor;
21
+ surfaceDescriptor.nextInChain = &androidSurfaceDesc;
22
+ return instance.CreateSurface(&surfaceDescriptor);
23
+ }
24
+ };
25
+
26
+ } // namespace rnwgpu
@@ -1,12 +1,75 @@
1
- #include "Logger.h"
2
- #include "RNWebGPUManager.h"
1
+ #include <memory>
2
+ #include <unordered_map>
3
+
3
4
  #include <fbjni/fbjni.h>
4
5
  #include <jni.h>
6
+ #include <jsi/jsi.h>
7
+
8
+ #include <android/native_window_jni.h>
9
+ #include <webgpu/webgpu_cpp.h>
10
+
11
+ #include "AndroidPlatformContext.h"
12
+ #include "GPUCanvasContext.h"
13
+ #include "RNWebGPUManager.h"
5
14
 
6
15
  #define LOG_TAG "WebGPUModule"
7
16
 
17
+ std::shared_ptr<rnwgpu::RNWebGPUManager> manager;
18
+
8
19
  extern "C" JNIEXPORT void JNICALL Java_com_webgpu_WebGPUModule_initializeNative(
9
20
  JNIEnv *env, jobject /* this */, jlong jsRuntime, jobject jsInvokerHolder) {
10
21
  auto runtime = reinterpret_cast<facebook::jsi::Runtime *>(jsRuntime);
11
- auto manager = new rnwgpu::RNWebGPUManager(runtime, nullptr);
22
+ auto platformContext = std::make_shared<rnwgpu::AndroidPlatformContext>();
23
+ manager = std::make_shared<rnwgpu::RNWebGPUManager>(runtime, nullptr,
24
+ platformContext);
25
+ }
26
+
27
+ extern "C" JNIEXPORT void JNICALL
28
+ Java_com_webgpu_WebGPUModule_createSurfaceContext(JNIEnv *env, jobject thiz,
29
+ jlong jsRuntime,
30
+ jint contextId) {
31
+ auto canvas = manager->surfacesRegistry.getSurface(contextId);
32
+ if (canvas == nullptr) {
33
+ throw std::runtime_error("Surface haven't configured yet");
34
+ }
35
+
36
+ auto runtime = reinterpret_cast<facebook::jsi::Runtime *>(jsRuntime);
37
+ auto webGPUContextRegistry = runtime->global().getPropertyAsObject(
38
+ *runtime, "__WebGPUContextRegistry");
39
+ if (webGPUContextRegistry.hasProperty(*runtime,
40
+ std::to_string(contextId).c_str())) {
41
+ // Context already exists, just update width/height
42
+ auto prop =
43
+ webGPUContextRegistry
44
+ .getPropertyAsObject(*runtime, std::to_string(contextId).c_str())
45
+ .asHostObject<rnwgpu::Canvas>(*runtime);
46
+ prop->setWidth(canvas->getWidth());
47
+ prop->setHeight(canvas->getHeight());
48
+ return;
49
+ }
50
+ webGPUContextRegistry.setProperty(
51
+ *runtime, std::to_string(contextId).c_str(),
52
+ facebook::jsi::Object::createFromHostObject(*runtime, canvas));
53
+ }
54
+
55
+ extern "C" JNIEXPORT void JNICALL Java_com_webgpu_WebGPUView_onSurfaceChanged(
56
+ JNIEnv *env, jobject thiz, jobject surface, jint contextId, jfloat width,
57
+ jfloat height) {
58
+ manager->surfacesRegistry.updateSurface(contextId, width, height);
59
+ }
60
+
61
+ extern "C" JNIEXPORT void JNICALL Java_com_webgpu_WebGPUView_onSurfaceCreate(
62
+ JNIEnv *env, jobject thiz, jobject surface, jint contextId, jfloat width,
63
+ jfloat height) {
64
+ auto window = ANativeWindow_fromSurface(env, surface);
65
+ // ANativeWindow_acquire(window);
66
+ manager->surfacesRegistry.addSurface(contextId, window, width, height);
67
+ }
68
+
69
+ extern "C" JNIEXPORT void JNICALL Java_com_webgpu_WebGPUView_onSurfaceDestroy(
70
+ JNIEnv *env, jobject thiz, jint contextId) {
71
+ auto canvas = manager->surfacesRegistry.getSurface(contextId);
72
+ ANativeWindow_release(
73
+ reinterpret_cast<ANativeWindow *>(canvas->getSurface()));
74
+ manager->surfacesRegistry.removeSurface(contextId);
12
75
  }
@@ -1,39 +1,81 @@
1
1
  package com.webgpu;
2
2
 
3
- import com.facebook.jni.HybridData;
3
+ import android.util.Log;
4
+
5
+ import androidx.annotation.OptIn;
6
+
7
+ import java.util.HashSet;
8
+ import java.util.Set;
9
+
4
10
  import com.facebook.proguard.annotations.DoNotStrip;
5
11
  import com.facebook.react.bridge.ReactApplicationContext;
6
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
12
  import com.facebook.react.bridge.JavaScriptContextHolder;
8
13
  import com.facebook.react.bridge.ReactMethod;
9
14
  import com.facebook.react.common.annotations.FrameworkAPI;
15
+ import com.facebook.react.module.annotations.ReactModule;
10
16
  import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
11
17
  import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
12
18
 
13
- @FrameworkAPI public class WebGPUModule extends ReactContextBaseJavaModule {
14
- static {
15
- System.loadLibrary("react-native-webgpu"); // Load the C++ library
16
- }
19
+ @ReactModule(name = WebGPUModule.NAME)
20
+ public class WebGPUModule extends NativeWebGPUModuleSpec {
21
+ static {
22
+ System.loadLibrary("react-native-wgpu"); // Load the C++ library
23
+ }
17
24
 
18
- public WebGPUModule(ReactApplicationContext reactContext) {
19
- super(reactContext);
20
- // Initialize the C++ module
21
- initialize();
22
- }
25
+ private final Object mContextLock = new Object();
26
+ private final Set<Integer> mSurfaceContextsIds = new HashSet<>();
27
+
28
+ public WebGPUModule(ReactApplicationContext reactContext) {
29
+ super(reactContext);
30
+ // Initialize the C++ module
31
+ initialize();
32
+ }
33
+
34
+ @OptIn(markerClass = FrameworkAPI.class)
35
+ @ReactMethod(isBlockingSynchronousMethod = true)
36
+ public boolean install() {
37
+ ReactApplicationContext context = getReactApplicationContext();
38
+ JavaScriptContextHolder jsContext = context.getJavaScriptContextHolder();
39
+ CallInvokerHolder callInvokerHolder = context.getCatalystInstance().getJSCallInvokerHolder();
40
+ initializeNative(jsContext.get(), (CallInvokerHolderImpl) callInvokerHolder);
41
+ return true;
42
+ }
43
+
44
+ @OptIn(markerClass = FrameworkAPI.class)
45
+ @DoNotStrip
46
+ private native void initializeNative(long jsRuntime, CallInvokerHolderImpl jsInvoker);
47
+
48
+ @ReactMethod(isBlockingSynchronousMethod = true)
49
+ public boolean createSurfaceContext(double contextId) {
50
+ waitForNativeSurface((int)contextId);
51
+
52
+ ReactApplicationContext context = getReactApplicationContext();
53
+ JavaScriptContextHolder jsContext = context.getJavaScriptContextHolder();
54
+ createSurfaceContext(jsContext.get(), (int)contextId);
55
+ return true;
56
+ }
57
+
58
+ @DoNotStrip
59
+ private native void createSurfaceContext(long jsRuntime, int contextId);
23
60
 
24
- @Override
25
- public String getName() {
26
- return "WebGPUModule";
61
+ private void waitForNativeSurface(Integer contextId) {
62
+ synchronized (mContextLock) {
63
+ while (!mSurfaceContextsIds.contains(contextId)) {
64
+ try {
65
+ mContextLock.wait();
66
+ } catch (InterruptedException e) {
67
+ Log.e("RNWebGPU", "Unable to create a context");
68
+ return;
69
+ }
70
+ }
27
71
  }
72
+ }
28
73
 
29
- @ReactMethod(isBlockingSynchronousMethod = true)
30
- public void install() {
31
- ReactApplicationContext context = getReactApplicationContext();
32
- JavaScriptContextHolder jsContext = context.getJavaScriptContextHolder();
33
- CallInvokerHolder callInvokerHolder = context.getCatalystInstance().getJSCallInvokerHolder();
34
- initializeNative(jsContext.get(), (CallInvokerHolderImpl) callInvokerHolder);
74
+ protected void onSurfaceCreated(Integer contextId) {
75
+ synchronized (mContextLock) {
76
+ mSurfaceContextsIds.add(contextId);
77
+ mContextLock.notifyAll();
35
78
  }
79
+ }
36
80
 
37
- @DoNotStrip
38
- private native void initializeNative(long jsRuntime, CallInvokerHolderImpl jsInvoker);
39
81
  }
@@ -1,24 +1,79 @@
1
1
  package com.webgpu;
2
2
 
3
- import androidx.annotation.Nullable;
3
+ import androidx.annotation.NonNull;
4
4
 
5
5
  import android.content.Context;
6
- import android.util.AttributeSet;
6
+ import android.view.Surface;
7
+ import android.view.SurfaceHolder;
8
+ import android.view.SurfaceView;
7
9
 
8
- import android.view.View;
10
+ import com.facebook.proguard.annotations.DoNotStrip;
11
+ import com.facebook.react.uimanager.ThemedReactContext;
9
12
 
10
- public class WebGPUView extends View {
13
+ public class WebGPUView extends SurfaceView implements SurfaceHolder.Callback {
14
+
15
+ private Integer mContextId;
16
+ private WebGPUModule mModule;
11
17
 
12
18
  public WebGPUView(Context context) {
13
19
  super(context);
20
+ getHolder().addCallback(this);
21
+ }
22
+
23
+ public void setContextId(Integer contextId) {
24
+ if (mModule == null) {
25
+ Context context = getContext();
26
+ if (context instanceof ThemedReactContext) {
27
+ mModule = ((ThemedReactContext) context).getReactApplicationContext().getNativeModule(WebGPUModule.class);
28
+ }
29
+ }
30
+ mContextId = contextId;
31
+ }
32
+
33
+ @Override
34
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
35
+ super.onLayout(changed, left, top, right, bottom);
14
36
  }
15
37
 
16
- public WebGPUView(Context context, @Nullable AttributeSet attrs) {
17
- super(context, attrs);
38
+ @Override
39
+ public void surfaceCreated(@NonNull SurfaceHolder holder) {
40
+ float density = getResources().getDisplayMetrics().density;
41
+ float width = getWidth() / density;
42
+ float height = getHeight() / density;
43
+ onSurfaceCreate(holder.getSurface(), mContextId, width, height);
44
+ mModule.onSurfaceCreated(mContextId);
18
45
  }
19
46
 
20
- public WebGPUView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
21
- super(context, attrs, defStyleAttr);
47
+ @Override
48
+ public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
49
+ float density = getResources().getDisplayMetrics().density;
50
+ float scaledWidth = width / density;
51
+ float scaledHeight = height / density;
52
+ onSurfaceChanged(holder.getSurface(), mContextId, scaledWidth, scaledHeight);
22
53
  }
23
54
 
55
+ @Override
56
+ public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
57
+ onSurfaceDestroy(mContextId);
58
+ }
59
+
60
+ @DoNotStrip
61
+ private native void onSurfaceCreate(
62
+ Surface surface,
63
+ int contextId,
64
+ float width,
65
+ float height
66
+ );
67
+
68
+ @DoNotStrip
69
+ private native void onSurfaceChanged(
70
+ Surface surface,
71
+ int contextId,
72
+ float width,
73
+ float height
74
+ );
75
+
76
+
77
+ @DoNotStrip
78
+ private native void onSurfaceDestroy(int contextId);
24
79
  }
@@ -1,8 +1,6 @@
1
1
  package com.webgpu;
2
2
 
3
- import android.graphics.Color;
4
-
5
- import androidx.annotation.Nullable;
3
+ import androidx.annotation.NonNull;
6
4
 
7
5
  import com.facebook.react.module.annotations.ReactModule;
8
6
  import com.facebook.react.uimanager.ThemedReactContext;
@@ -13,6 +11,7 @@ public class WebGPUViewManager extends WebGPUViewManagerSpec<WebGPUView> {
13
11
 
14
12
  public static final String NAME = "WebGPUView";
15
13
 
14
+ @NonNull
16
15
  @Override
17
16
  public String getName() {
18
17
  return NAME;
@@ -24,8 +23,8 @@ public class WebGPUViewManager extends WebGPUViewManagerSpec<WebGPUView> {
24
23
  }
25
24
 
26
25
  @Override
27
- @ReactProp(name = "color")
28
- public void setColor(WebGPUView view, @Nullable String color) {
29
- view.setBackgroundColor(Color.parseColor(color));
26
+ @ReactProp(name = "contextId")
27
+ public void setContextId(WebGPUView view, int value) {
28
+ view.setContextId(value);
30
29
  }
31
30
  }
@@ -6,14 +6,14 @@ import androidx.annotation.Nullable;
6
6
 
7
7
  import com.facebook.react.uimanager.SimpleViewManager;
8
8
  import com.facebook.react.uimanager.ViewManagerDelegate;
9
- import com.facebook.react.viewmanagers.WgpuViewManagerDelegate;
10
- import com.facebook.react.viewmanagers.WgpuViewManagerInterface;
9
+ import com.facebook.react.viewmanagers.WebGPUViewManagerDelegate;
10
+ import com.facebook.react.viewmanagers.WebGPUViewManagerInterface;
11
11
 
12
- public abstract class WgpuViewManagerSpec<T extends View> extends SimpleViewManager<T> implements WgpuViewManagerInterface<T> {
12
+ public abstract class WebGPUViewManagerSpec<T extends View> extends SimpleViewManager<T> implements WebGPUViewManagerInterface<T> {
13
13
  private final ViewManagerDelegate<T> mDelegate;
14
14
 
15
- public WgpuViewManagerSpec() {
16
- mDelegate = new WgpuViewManagerDelegate(this);
15
+ public WebGPUViewManagerSpec() {
16
+ mDelegate = new WebGPUViewManagerDelegate(this);
17
17
  }
18
18
 
19
19
  @Nullable
@@ -0,0 +1,23 @@
1
+ package com.webgpu;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
+
9
+ class NativeWebGPUModuleSpec extends ReactContextBaseJavaModule {
10
+
11
+ public static final String NAME = "WebGPUModule";
12
+
13
+ public NativeWebGPUModuleSpec(@Nullable ReactApplicationContext reactContext) {
14
+ super(reactContext);
15
+ }
16
+
17
+ @NonNull
18
+ @Override
19
+ public String getName() {
20
+ return NAME;
21
+ }
22
+
23
+ }