react-native-webgpu 0.5.11
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/LICENSE +20 -0
- package/README.md +319 -0
- package/android/CMakeLists.txt +108 -0
- package/android/build.gradle +138 -0
- package/android/cpp/AndroidPlatformContext.h +207 -0
- package/android/cpp/cpp-adapter.cpp +71 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +298 -0
- package/android/src/main/java/com/webgpu/WebGPUAPI.java +20 -0
- package/android/src/main/java/com/webgpu/WebGPUBaseView.java +61 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +50 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +41 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceViewWithSC.java +79 -0
- package/android/src/main/java/com/webgpu/WebGPUTextureView.java +46 -0
- package/android/src/main/java/com/webgpu/WebGPUView.java +108 -0
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +38 -0
- package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +50 -0
- package/android/src/newarch/com/webgpu/WebGPUViewManagerSpec.java +24 -0
- package/apple/ApplePlatformContext.h +31 -0
- package/apple/ApplePlatformContext.mm +157 -0
- package/apple/MetalView.h +13 -0
- package/apple/MetalView.mm +50 -0
- package/apple/RNWGUIKit.h +16 -0
- package/apple/WebGPUModule.h +13 -0
- package/apple/WebGPUModule.mm +89 -0
- package/apple/WebGPUView.h +12 -0
- package/apple/WebGPUView.mm +66 -0
- package/cpp/WGPULogger.h +100 -0
- package/cpp/dawn_logging.cpp +119 -0
- package/cpp/jsi/EnumMapper.h +45 -0
- package/cpp/jsi/JSIConverter.h +473 -0
- package/cpp/jsi/NativeObject.h +607 -0
- package/cpp/jsi/Promise.cpp +44 -0
- package/cpp/jsi/Promise.h +35 -0
- package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
- package/cpp/jsi/RuntimeAwareCache.h +100 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
- package/cpp/rnwgpu/ArrayBuffer.h +73 -0
- package/cpp/rnwgpu/PlatformContext.h +46 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +225 -0
- package/cpp/rnwgpu/RNWebGPUManager.h +46 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +230 -0
- package/cpp/rnwgpu/api/Canvas.h +57 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +127 -0
- package/cpp/rnwgpu/api/GPU.h +58 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +191 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +67 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +66 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +492 -0
- package/cpp/rnwgpu/api/GPUDevice.h +259 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +203 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +81 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +162 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +71 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +40 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +199 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +78 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +98 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +76 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +68 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +100 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +70 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +44 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +102 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +93 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +111 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1969 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +215 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +53 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/cpp/webgpu/webgpu.h +4918 -0
- package/cpp/webgpu/webgpu_cpp.h +10294 -0
- package/cpp/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/webgpu/webgpu_cpp_print.h +2755 -0
- package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/lib/commonjs/Canvas.js +55 -0
- package/lib/commonjs/Canvas.js.map +1 -0
- package/lib/commonjs/NativeWebGPUModule.js +10 -0
- package/lib/commonjs/NativeWebGPUModule.js.map +1 -0
- package/lib/commonjs/Offscreen.js +103 -0
- package/lib/commonjs/Offscreen.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js +10 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js +103 -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/external/ModuleProxy.js +36 -0
- package/lib/commonjs/external/ModuleProxy.js.map +1 -0
- package/lib/commonjs/external/index.js +17 -0
- package/lib/commonjs/external/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/index.js +21 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +49 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/commonjs/hooks.js +83 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/main/index.js +91 -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 +46 -0
- package/lib/module/Canvas.js.map +1 -0
- package/lib/module/NativeWebGPUModule.js +4 -0
- package/lib/module/NativeWebGPUModule.js.map +1 -0
- package/lib/module/Offscreen.js +96 -0
- package/lib/module/Offscreen.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.js +4 -0
- package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.web.js +96 -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/external/ModuleProxy.js +28 -0
- package/lib/module/external/ModuleProxy.js.map +1 -0
- package/lib/module/external/index.js +2 -0
- package/lib/module/external/index.js.map +1 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/module/external/reanimated/index.js +3 -0
- package/lib/module/external/reanimated/index.js.map +1 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js +42 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/module/hooks.js +70 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/main/index.js +33 -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/babel.config.d.ts +3 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/eslint.config.d.mts +3 -0
- package/lib/typescript/eslint.config.d.mts.map +1 -0
- package/lib/typescript/jest.config.d.ts +9 -0
- package/lib/typescript/jest.config.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts +7 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts +5 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts +26 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +5 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +4 -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/external/ModuleProxy.d.ts +12 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts +18 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- 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 +8 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts +3 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/Offscreen.d.ts +25 -0
- package/lib/typescript/lib/module/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +3 -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/external/ModuleProxy.d.ts +7 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/index.d.ts +2 -0
- package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks.d.ts +18 -0
- package/lib/typescript/lib/module/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- 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 +35 -0
- package/lib/typescript/src/Canvas.d.ts.map +1 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts +7 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/Offscreen.d.ts +30 -0
- package/lib/typescript/src/Offscreen.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +9 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +9 -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/external/ModuleProxy.d.ts +11 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/index.d.ts +2 -0
- package/lib/typescript/src/external/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +27 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- 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/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +59 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/package.json +139 -0
- package/react-native-wgpu.podspec +47 -0
- package/src/Canvas.tsx +91 -0
- package/src/NativeWebGPUModule.ts +9 -0
- package/src/Offscreen.ts +113 -0
- package/src/WebGPUViewNativeComponent.ts +11 -0
- package/src/WebGPUViewNativeComponent.web.ts +113 -0
- package/src/WebPolyfillGPUModule.ts +53 -0
- package/src/external/ModuleProxy.ts +30 -0
- package/src/external/index.ts +1 -0
- package/src/external/reanimated/ReanimatedProxy.ts +19 -0
- package/src/external/reanimated/index.ts +2 -0
- package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
- package/src/hooks.tsx +93 -0
- package/src/index.tsx +31 -0
- package/src/main/index.tsx +40 -0
- package/src/main/index.web.tsx +8 -0
- package/src/types.ts +20 -0
- package/src/utils.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 William Candillon
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# React Native WebGPU
|
|
2
|
+
|
|
3
|
+
React Native implementation of WebGPU using [Dawn](https://dawn.googlesource.com/dawn).
|
|
4
|
+
|
|
5
|
+
React Native WebGPU requires React Native 0.81 or newer. It doesn't support the legacy architecture.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Please note that the package name is `react-native-wgpu`.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install react-native-wgpu
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## With Expo
|
|
16
|
+
|
|
17
|
+
Expo provides a React Native WebGPU template that works with React Three Fiber.
|
|
18
|
+
The works on iOS, Android, and Web.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npx create-expo-app@latest -e with-webgpu
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
https://github.com/user-attachments/assets/efbd05f8-4ce0-46c2-919c-03e1095bc8ac
|
|
25
|
+
|
|
26
|
+
Below are some examples from the [example app](/apps/example/).
|
|
27
|
+
|
|
28
|
+
https://github.com/user-attachments/assets/116a41b2-2cf8-49f1-9f16-a5c83637c198
|
|
29
|
+
|
|
30
|
+
Starting from `r168`, Three.js runs out of the box with React Native WebGPU.
|
|
31
|
+
You need to have a slight modification of [the metro config](/apps/example/metro.config.js) to resolve Three.js to the WebGPU build.
|
|
32
|
+
We also support [react-three-fiber](/apps/example/src/ThreeJS/Fiber.tsx); to make it work, patch `node_modules/@react-three/fiber/package.json` (for instance via `patch-package`) so that it resolves to the WebGPU entry point instead of the React Native bundle:
|
|
33
|
+
|
|
34
|
+
```diff
|
|
35
|
+
diff --git a/node_modules/@react-three/fiber/package.json b/node_modules/@react-three/fiber/package.json
|
|
36
|
+
@@
|
|
37
|
+
- "react-native": "native/dist/react-three-fiber-native.cjs.js",
|
|
38
|
+
+ "react-native": "dist/react-three-fiber.cjs.js",
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For model loading, we also need [the following polyfill](/apps/example/src/App.tsx#29).
|
|
42
|
+
|
|
43
|
+
https://github.com/user-attachments/assets/5b49ef63-0a3c-4679-aeb5-e4b4dddfcc1d
|
|
44
|
+
|
|
45
|
+
We also provide prebuilt binaries for visionOS and macOS.
|
|
46
|
+
|
|
47
|
+
https://github.com/user-attachments/assets/2d5c618e-5b15-4cef-8558-d4ddf8c70667
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Usage is identical to Web.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import React from "react";
|
|
55
|
+
import { StyleSheet, View, PixelRatio } from "react-native";
|
|
56
|
+
import { Canvas, CanvasRef } from "react-native-wgpu";
|
|
57
|
+
|
|
58
|
+
import { redFragWGSL, triangleVertWGSL } from "./triangle";
|
|
59
|
+
|
|
60
|
+
export function HelloTriangle() {
|
|
61
|
+
const ref = useRef<CanvasRef>(null);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const helloTriangle = async () => {
|
|
64
|
+
const adapter = await navigator.gpu.requestAdapter();
|
|
65
|
+
if (!adapter) {
|
|
66
|
+
throw new Error("No adapter");
|
|
67
|
+
}
|
|
68
|
+
const device = await adapter.requestDevice();
|
|
69
|
+
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
70
|
+
|
|
71
|
+
const context = ref.current!.getContext("webgpu")!;
|
|
72
|
+
const canvas = context.canvas as HTMLCanvasElement;
|
|
73
|
+
canvas.width = canvas.clientWidth * PixelRatio.get();
|
|
74
|
+
canvas.height = canvas.clientHeight * PixelRatio.get();
|
|
75
|
+
|
|
76
|
+
if (!context) {
|
|
77
|
+
throw new Error("No context");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
context.configure({
|
|
81
|
+
device,
|
|
82
|
+
format: presentationFormat,
|
|
83
|
+
alphaMode: "opaque",
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const pipeline = device.createRenderPipeline({
|
|
87
|
+
layout: "auto",
|
|
88
|
+
vertex: {
|
|
89
|
+
module: device.createShaderModule({
|
|
90
|
+
code: triangleVertWGSL,
|
|
91
|
+
}),
|
|
92
|
+
entryPoint: "main",
|
|
93
|
+
},
|
|
94
|
+
fragment: {
|
|
95
|
+
module: device.createShaderModule({
|
|
96
|
+
code: redFragWGSL,
|
|
97
|
+
}),
|
|
98
|
+
entryPoint: "main",
|
|
99
|
+
targets: [
|
|
100
|
+
{
|
|
101
|
+
format: presentationFormat,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
primitive: {
|
|
106
|
+
topology: "triangle-list",
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const commandEncoder = device.createCommandEncoder();
|
|
111
|
+
|
|
112
|
+
const textureView = context.getCurrentTexture().createView();
|
|
113
|
+
|
|
114
|
+
const renderPassDescriptor: GPURenderPassDescriptor = {
|
|
115
|
+
colorAttachments: [
|
|
116
|
+
{
|
|
117
|
+
view: textureView,
|
|
118
|
+
clearValue: [0, 0, 0, 1],
|
|
119
|
+
loadOp: "clear",
|
|
120
|
+
storeOp: "store",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
126
|
+
passEncoder.setPipeline(pipeline);
|
|
127
|
+
passEncoder.draw(3);
|
|
128
|
+
passEncoder.end();
|
|
129
|
+
|
|
130
|
+
device.queue.submit([commandEncoder.finish()]);
|
|
131
|
+
|
|
132
|
+
context.present();
|
|
133
|
+
};
|
|
134
|
+
helloTriangle();
|
|
135
|
+
}, [ref]);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<View style={style.container}>
|
|
139
|
+
<Canvas ref={ref} style={style.webgpu} />
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const style = StyleSheet.create({
|
|
145
|
+
container: {
|
|
146
|
+
flex: 1,
|
|
147
|
+
},
|
|
148
|
+
webgpu: {
|
|
149
|
+
flex: 1,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Example App
|
|
155
|
+
|
|
156
|
+
To run the example app you first need to [install Dawn](#installing-dawn).
|
|
157
|
+
|
|
158
|
+
From there you will be able to run the example app properly.
|
|
159
|
+
|
|
160
|
+
## Similarities and Differences with the Web
|
|
161
|
+
|
|
162
|
+
The API has been designed to be completely symmetric with the Web.
|
|
163
|
+
For instance, you can access the WebGPU context synchronously, as well as the canvas size.
|
|
164
|
+
Pixel density and canvas resizing are handled exactly like on the Web as well.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
// The default canvas size is not scaled to the device pixel ratio
|
|
168
|
+
// When resizing the canvas, the clientWidth and clientHeight are updated automatically
|
|
169
|
+
// This behaviour is symmetric to the Web
|
|
170
|
+
const ctx = canvas.current.getContext("webgpu")!;
|
|
171
|
+
ctx.canvas.width = ctx.canvas.clientWidth * PixelRatio.get();
|
|
172
|
+
ctx.canvas.height = ctx.canvas.clientHeight * PixelRatio.get();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Frame Scheduling
|
|
176
|
+
|
|
177
|
+
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.
|
|
178
|
+
This means that when you are ready to present a frame, you need to call `present` on the context.
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
// draw
|
|
182
|
+
// submit to the queue
|
|
183
|
+
device.queue.submit([commandEncoder.finish()]);
|
|
184
|
+
// This method is React Native only
|
|
185
|
+
context.present();
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Canvas Transparency
|
|
189
|
+
|
|
190
|
+
On Android, the `alphaMode` property is ignored when configuring the canvas.
|
|
191
|
+
To have a transparent canvas by default, use the `transparent` property.
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
return (
|
|
195
|
+
<View style={style.container}>
|
|
196
|
+
<Canvas ref={ref} style={style.webgpu} transparent />
|
|
197
|
+
</View>
|
|
198
|
+
);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### External Textures
|
|
202
|
+
|
|
203
|
+
This module provides a `createImageBitmap` function that you can use in `copyExternalImageToTexture`.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
const url = Image.resolveAssetSource(require("./assets/image.png")).uri;
|
|
207
|
+
const response = await fetch(url);
|
|
208
|
+
const imageBitmap = await createImageBitmap(await response.blob());
|
|
209
|
+
|
|
210
|
+
const texture = device.createTexture({
|
|
211
|
+
size: [imageBitmap.width, imageBitmap.height, 1],
|
|
212
|
+
format: "rgba8unorm",
|
|
213
|
+
usage:
|
|
214
|
+
GPUTextureUsage.TEXTURE_BINDING |
|
|
215
|
+
GPUTextureUsage.COPY_DST |
|
|
216
|
+
GPUTextureUsage.RENDER_ATTACHMENT,
|
|
217
|
+
});
|
|
218
|
+
device.queue.copyExternalImageToTexture(
|
|
219
|
+
{ source: imageBitmap },
|
|
220
|
+
{ texture },
|
|
221
|
+
[imageBitmap.width, imageBitmap.height],
|
|
222
|
+
);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Reanimated Integration
|
|
226
|
+
|
|
227
|
+
React Native WebGPU supports running WebGPU rendering on the UI thread using [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/) and [React Native Worklets](https://github.com/margelo/react-native-worklets).
|
|
228
|
+
|
|
229
|
+
First, install the optional peer dependencies:
|
|
230
|
+
|
|
231
|
+
```sh
|
|
232
|
+
npm install react-native-reanimated react-native-worklets
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
WebGPU objects are automatically registered for Worklets serialization when the module loads. You can pass WebGPU objects like `GPUDevice` and `GPUCanvasContext` directly to worklets:
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
import { Canvas } from "react-native-wgpu";
|
|
239
|
+
import { runOnUI } from "react-native-reanimated";
|
|
240
|
+
|
|
241
|
+
const renderFrame = (device: GPUDevice, context: GPUCanvasContext) => {
|
|
242
|
+
"worklet";
|
|
243
|
+
// WebGPU rendering code runs on the UI thread
|
|
244
|
+
const commandEncoder = device.createCommandEncoder();
|
|
245
|
+
// ... render ...
|
|
246
|
+
device.queue.submit([commandEncoder.finish()]);
|
|
247
|
+
context.present();
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// Initialize WebGPU on main thread, then run on UI thread
|
|
251
|
+
const device = await adapter.requestDevice();
|
|
252
|
+
const context = canvasRef.current.getContext("webgpu");
|
|
253
|
+
runOnUI(renderFrame)(device, context);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Troubleshooting
|
|
257
|
+
|
|
258
|
+
### iOS
|
|
259
|
+
|
|
260
|
+
To run the React Native WebGPU project on the iOS simulator, you need to disable the Metal validation API.
|
|
261
|
+
In "Edit Scheme," uncheck "Metal Validation". Learn more [here](https://developer.apple.com/documentation/xcode/validating-your-apps-metal-api-usage/).
|
|
262
|
+
|
|
263
|
+
<img width="1052" alt="Uncheck 'Metal Validation'" src="https://github.com/user-attachments/assets/2676e5cc-e351-4a97-bdc8-22cbd7df2ef2">
|
|
264
|
+
|
|
265
|
+
## Library Development
|
|
266
|
+
|
|
267
|
+
Make sure to check out the submodules:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
git submodule update --init
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Make sure you have all the tools required for building the Skia libraries (Android Studio, XCode, Ninja, CMake, Android NDK/build tools).
|
|
274
|
+
|
|
275
|
+
### Installing Dawn
|
|
276
|
+
|
|
277
|
+
There is an alternative way which is to install the prebuilt binaries from GitHub.
|
|
278
|
+
|
|
279
|
+
```sh
|
|
280
|
+
$ yarn
|
|
281
|
+
$ cd packages/webgpu
|
|
282
|
+
$ yarn install-dawn
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Building Dawn
|
|
286
|
+
|
|
287
|
+
Alternatively, you can build Dawn locally.
|
|
288
|
+
|
|
289
|
+
```sh
|
|
290
|
+
yarn
|
|
291
|
+
cd packages/webgpu
|
|
292
|
+
yarn build-dawn
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Upgrading
|
|
296
|
+
|
|
297
|
+
1. `git submodule update --remote`
|
|
298
|
+
2. `yarn clean-dawn`
|
|
299
|
+
3. `yarn build-dawn`
|
|
300
|
+
|
|
301
|
+
### Codegen
|
|
302
|
+
|
|
303
|
+
* `cd packages/webgpu && yarn codegen`
|
|
304
|
+
|
|
305
|
+
### Testing
|
|
306
|
+
|
|
307
|
+
In the `package` folder, to run the test against Chrome for reference:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
yarn test:ref
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
To run the e2e test, open the example app on the e2e screen.
|
|
314
|
+
By default, it will try to connect to a localhost test server.
|
|
315
|
+
If you want to run the test suite on a physical device, you can modify the address [here](/apps/example/src/useClient.ts#L4).
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
yarn test
|
|
319
|
+
```
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
2
|
+
project(RNWGPU)
|
|
3
|
+
|
|
4
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
5
|
+
set (CMAKE_CXX_STANDARD 20)
|
|
6
|
+
set (CMAKE_CXX_STANDARD_REQUIRED True)
|
|
7
|
+
|
|
8
|
+
set (PACKAGE_NAME "react-native-wgpu")
|
|
9
|
+
|
|
10
|
+
#link_directories(../libs/android/${ANDROID_ABI}/)
|
|
11
|
+
|
|
12
|
+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
13
|
+
add_definitions(-DDEBUG=1)
|
|
14
|
+
endif()
|
|
15
|
+
|
|
16
|
+
if(RNF_ENABLE_LOGS)
|
|
17
|
+
add_definitions(-DRNF_ENABLE_LOGS=1)
|
|
18
|
+
else()
|
|
19
|
+
add_definitions(-DRNF_ENABLE_LOGS=0)
|
|
20
|
+
endif()
|
|
21
|
+
|
|
22
|
+
set (WEBGPU_LIBS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../libs/android/${ANDROID_ABI}")
|
|
23
|
+
|
|
24
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
25
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
26
|
+
|
|
27
|
+
add_library(${PACKAGE_NAME} SHARED
|
|
28
|
+
./cpp/cpp-adapter.cpp
|
|
29
|
+
../cpp/rnwgpu/api/GPU.cpp
|
|
30
|
+
../cpp/rnwgpu/api/GPUAdapter.cpp
|
|
31
|
+
../cpp/rnwgpu/api/GPUSupportedLimits.cpp
|
|
32
|
+
../cpp/rnwgpu/api/GPUShaderModule.cpp
|
|
33
|
+
../cpp/rnwgpu/api/GPUDeviceLostInfo.cpp
|
|
34
|
+
../cpp/rnwgpu/api/GPUDevice.cpp
|
|
35
|
+
../cpp/rnwgpu/api/GPUBuffer.cpp
|
|
36
|
+
../cpp/rnwgpu/api/GPUQueue.cpp
|
|
37
|
+
../cpp/rnwgpu/api/GPUCommandEncoder.cpp
|
|
38
|
+
../cpp/rnwgpu/api/GPUQuerySet.cpp
|
|
39
|
+
../cpp/rnwgpu/api/GPUTexture.cpp
|
|
40
|
+
../cpp/rnwgpu/api/GPURenderBundleEncoder.cpp
|
|
41
|
+
../cpp/rnwgpu/api/GPURenderPassEncoder.cpp
|
|
42
|
+
../cpp/rnwgpu/api/GPURenderPipeline.cpp
|
|
43
|
+
../cpp/rnwgpu/api/GPUBindGroup.cpp
|
|
44
|
+
../cpp/rnwgpu/api/GPUComputePassEncoder.cpp
|
|
45
|
+
../cpp/rnwgpu/api/GPUComputePipeline.cpp
|
|
46
|
+
../cpp/rnwgpu/api/GPUCanvasContext.cpp
|
|
47
|
+
../cpp/rnwgpu/RNWebGPUManager.cpp
|
|
48
|
+
../cpp/jsi/Promise.cpp
|
|
49
|
+
../cpp/jsi/RuntimeLifecycleMonitor.cpp
|
|
50
|
+
../cpp/jsi/RuntimeAwareCache.cpp
|
|
51
|
+
../cpp/rnwgpu/async/AsyncRunner.cpp
|
|
52
|
+
../cpp/rnwgpu/async/AsyncTaskHandle.cpp
|
|
53
|
+
../cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
target_include_directories(
|
|
57
|
+
${PACKAGE_NAME}
|
|
58
|
+
PRIVATE
|
|
59
|
+
|
|
60
|
+
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
|
|
61
|
+
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
|
|
62
|
+
"${NODE_MODULES_DIR}/react-native/ReactCommon"
|
|
63
|
+
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
|
|
64
|
+
"${NODE_MODULES_DIR}/react-native/ReactCommon/runtimeexecutor"
|
|
65
|
+
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni"
|
|
66
|
+
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
|
|
67
|
+
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
|
|
68
|
+
|
|
69
|
+
../cpp
|
|
70
|
+
../cpp/rnwgpu
|
|
71
|
+
../cpp/rnwgpu/api
|
|
72
|
+
../cpp/rnwgpu/api/descriptors
|
|
73
|
+
../cpp/jsi
|
|
74
|
+
../cpp/webgpu
|
|
75
|
+
../cpp/platform
|
|
76
|
+
|
|
77
|
+
${libfbjni_include_DIRS}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
add_library(webgpu_dawn SHARED IMPORTED)
|
|
81
|
+
set_property(TARGET webgpu_dawn PROPERTY IMPORTED_LOCATION "${WEBGPU_LIBS_PATH}/libwebgpu_dawn.so")
|
|
82
|
+
|
|
83
|
+
# Link
|
|
84
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
85
|
+
target_link_libraries(
|
|
86
|
+
${PACKAGE_NAME}
|
|
87
|
+
${FBJNI_LIBRARY}
|
|
88
|
+
log
|
|
89
|
+
jnigraphics
|
|
90
|
+
android
|
|
91
|
+
fbjni::fbjni
|
|
92
|
+
ReactAndroid::jsi
|
|
93
|
+
ReactAndroid::reactnative
|
|
94
|
+
webgpu_dawn
|
|
95
|
+
)
|
|
96
|
+
else()
|
|
97
|
+
target_link_libraries(
|
|
98
|
+
${PACKAGE_NAME}
|
|
99
|
+
${FBJNI_LIBRARY}
|
|
100
|
+
log
|
|
101
|
+
jnigraphics
|
|
102
|
+
android
|
|
103
|
+
fbjni::fbjni
|
|
104
|
+
ReactAndroid::jsi
|
|
105
|
+
ReactAndroid::reactnativejni
|
|
106
|
+
webgpu_dawn
|
|
107
|
+
)
|
|
108
|
+
endif()
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import java.nio.file.Paths
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
repositories {
|
|
5
|
+
google()
|
|
6
|
+
mavenCentral()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
dependencies {
|
|
10
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def reactNativeArchitectures() {
|
|
15
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
16
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "com.facebook.react"
|
|
21
|
+
|
|
22
|
+
static def findNodeModules(baseDir) {
|
|
23
|
+
// Check if we are building the example app:
|
|
24
|
+
// Check if ../FabricExample/node_modules exists
|
|
25
|
+
def exampleAppPath = Paths.get(baseDir.toString(), "..", "FabricExample")
|
|
26
|
+
def exampleNodeModulesPath = Paths.get(exampleAppPath.toString(), "node_modules")
|
|
27
|
+
if (exampleNodeModulesPath.toFile().exists()) {
|
|
28
|
+
return exampleNodeModulesPath.toAbsolutePath()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def basePath = baseDir.toPath().normalize()
|
|
32
|
+
// Node's module resolution algorithm searches up to the root directory,
|
|
33
|
+
// after which the base path will be null
|
|
34
|
+
while (basePath) {
|
|
35
|
+
def nodeModulesPath = Paths.get(basePath.toString(), "node_modules")
|
|
36
|
+
def reactNativePath = Paths.get(nodeModulesPath.toString(), "react-native")
|
|
37
|
+
if (nodeModulesPath.toFile().exists() && reactNativePath.toFile().exists()) {
|
|
38
|
+
return nodeModulesPath.toString()
|
|
39
|
+
}
|
|
40
|
+
basePath = basePath.getParent()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
throw new GradleException("react-native-wgpu: Failed to find node_modules/ path!")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
def nodeModules = findNodeModules(projectDir)
|
|
47
|
+
|
|
48
|
+
def getExtOrDefault(name) {
|
|
49
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Wgpu_" + name]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
def getExtOrIntegerDefault(name) {
|
|
53
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Wgpu_" + name]).toInteger()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def supportsNamespace() {
|
|
57
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
58
|
+
def major = parsed[0].toInteger()
|
|
59
|
+
def minor = parsed[1].toInteger()
|
|
60
|
+
|
|
61
|
+
// Namespace support was added in 7.3.0
|
|
62
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
android {
|
|
66
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
67
|
+
|
|
68
|
+
defaultConfig {
|
|
69
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
70
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
71
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
72
|
+
externalNativeBuild {
|
|
73
|
+
cmake {
|
|
74
|
+
cppFlags "-fexceptions", "-frtti", "-DONANDROID"
|
|
75
|
+
abiFilters (*reactNativeArchitectures())
|
|
76
|
+
arguments '-DANDROID_STL=c++_shared',
|
|
77
|
+
"-DNODE_MODULES_DIR=${nodeModules}",
|
|
78
|
+
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
packagingOptions {
|
|
84
|
+
excludes = [
|
|
85
|
+
"**/libjsi.so",
|
|
86
|
+
"**/libreactnativejni.so",
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
buildFeatures {
|
|
91
|
+
buildConfig true
|
|
92
|
+
prefab true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
buildTypes {
|
|
96
|
+
release {
|
|
97
|
+
minifyEnabled false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lintOptions {
|
|
102
|
+
disable "GradleCompatible"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
compileOptions {
|
|
106
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
107
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
sourceSets {
|
|
111
|
+
main {
|
|
112
|
+
java.srcDirs += [
|
|
113
|
+
"src/newarch",
|
|
114
|
+
// This is needed to build Kotlin project with NewArch enabled
|
|
115
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
externalNativeBuild {
|
|
121
|
+
cmake {
|
|
122
|
+
path file('CMakeLists.txt')
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
repositories {
|
|
128
|
+
mavenCentral()
|
|
129
|
+
google()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
dependencies {
|
|
134
|
+
// For < 0.71, this will be from the local maven repo
|
|
135
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
136
|
+
//noinspection GradleDynamicVersion
|
|
137
|
+
implementation "com.facebook.react:react-native:+"
|
|
138
|
+
}
|