react-native-wgpu 0.5.13 → 0.5.15
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 +4 -398
- package/lib/commonjs/index.js +7 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/{src → webgpu/src}/Canvas.d.ts +9 -0
- package/lib/typescript/webgpu/src/Canvas.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/Offscreen.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/constants.d.ts +6 -0
- package/lib/typescript/webgpu/src/constants.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/external/index.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/hooks.d.ts.map +1 -0
- package/lib/typescript/{src → webgpu/src}/index.d.ts +5 -2
- package/lib/typescript/webgpu/src/index.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/install.d.ts +34 -0
- package/lib/typescript/webgpu/src/install.d.ts.map +1 -0
- package/lib/typescript/webgpu/src/main/index.d.ts.map +1 -0
- package/lib/typescript/{src → webgpu/src}/types.d.ts +34 -2
- package/lib/typescript/webgpu/src/types.d.ts.map +1 -0
- package/lib/typescript/{eslint.config.d.mts.map → webgpu-shim/eslint.config.d.mts.map} +1 -1
- package/lib/typescript/{lib → webgpu-shim/lib}/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/webgpu-shim/lib/module/index.d.ts +2 -0
- package/lib/typescript/{lib → webgpu-shim/lib}/module/index.d.ts.map +1 -1
- package/lib/typescript/webgpu-shim/src/index.d.ts +2 -0
- package/lib/typescript/webgpu-shim/src/index.d.ts.map +1 -0
- package/package.json +12 -81
- package/src/index.ts +9 -0
- package/LICENSE +0 -20
- package/android/CMakeLists.txt +0 -110
- package/android/build.gradle +0 -138
- package/android/cpp/AndroidPlatformContext.h +0 -328
- package/android/cpp/cpp-adapter.cpp +0 -71
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +0 -298
- package/android/src/main/java/com/webgpu/WebGPUAPI.java +0 -20
- package/android/src/main/java/com/webgpu/WebGPUBaseView.java +0 -61
- package/android/src/main/java/com/webgpu/WebGPUModule.java +0 -50
- package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +0 -41
- package/android/src/main/java/com/webgpu/WebGPUSurfaceViewWithSC.java +0 -79
- package/android/src/main/java/com/webgpu/WebGPUTextureView.java +0 -46
- package/android/src/main/java/com/webgpu/WebGPUView.java +0 -108
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +0 -38
- package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +0 -50
- package/android/src/newarch/com/webgpu/WebGPUViewManagerSpec.java +0 -24
- package/apple/ApplePlatformContext.h +0 -44
- package/apple/ApplePlatformContext.mm +0 -302
- package/apple/AppleVideoPlayer.h +0 -31
- package/apple/AppleVideoPlayer.mm +0 -314
- package/apple/MetalView.h +0 -13
- package/apple/MetalView.mm +0 -50
- package/apple/RNWGUIKit.h +0 -16
- package/apple/WebGPUModule.h +0 -13
- package/apple/WebGPUModule.mm +0 -89
- package/apple/WebGPUView.h +0 -12
- package/apple/WebGPUView.mm +0 -66
- package/cpp/WGPULogger.h +0 -100
- package/cpp/dawn_logging.cpp +0 -119
- package/cpp/jsi/EnumMapper.h +0 -45
- package/cpp/jsi/JSIConverter.h +0 -473
- package/cpp/jsi/NativeObject.h +0 -607
- package/cpp/jsi/Promise.cpp +0 -44
- package/cpp/jsi/Promise.h +0 -35
- package/cpp/jsi/RuntimeAwareCache.cpp +0 -7
- package/cpp/jsi/RuntimeAwareCache.h +0 -100
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
- package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
- package/cpp/rnwgpu/ArrayBuffer.h +0 -117
- package/cpp/rnwgpu/PlatformContext.h +0 -127
- package/cpp/rnwgpu/RNWebGPUManager.cpp +0 -237
- package/cpp/rnwgpu/RNWebGPUManager.h +0 -46
- package/cpp/rnwgpu/SurfaceRegistry.h +0 -230
- package/cpp/rnwgpu/api/Canvas.h +0 -57
- package/cpp/rnwgpu/api/Convertors.h +0 -783
- package/cpp/rnwgpu/api/External.h +0 -12
- package/cpp/rnwgpu/api/GPU.cpp +0 -154
- package/cpp/rnwgpu/api/GPU.h +0 -58
- package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -267
- package/cpp/rnwgpu/api/GPUAdapter.h +0 -59
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
- package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
- package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -97
- package/cpp/rnwgpu/api/GPUBuffer.h +0 -87
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -67
- package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -66
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
- package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
- package/cpp/rnwgpu/api/GPUDevice.cpp +0 -545
- package/cpp/rnwgpu/api/GPUDevice.h +0 -265
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
- package/cpp/rnwgpu/api/GPUError.h +0 -35
- package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
- package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -335
- package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -90
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -206
- package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
- package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
- package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
- package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
- package/cpp/rnwgpu/api/GPUQueue.cpp +0 -169
- package/cpp/rnwgpu/api/GPUQueue.h +0 -81
- package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
- package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
- package/cpp/rnwgpu/api/GPUSampler.h +0 -44
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -50
- package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -80
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -71
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
- package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
- package/cpp/rnwgpu/api/GPUTexture.h +0 -162
- package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -71
- package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
- package/cpp/rnwgpu/api/ImageBitmap.h +0 -48
- package/cpp/rnwgpu/api/RNWebGPU.h +0 -241
- package/cpp/rnwgpu/api/RnFeatures.h +0 -53
- package/cpp/rnwgpu/api/VideoFrame.h +0 -76
- package/cpp/rnwgpu/api/VideoPlayer.h +0 -69
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -65
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -98
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -53
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -60
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -67
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -46
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -46
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -68
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -104
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -115
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -39
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -82
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -74
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -66
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -82
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -55
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -55
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -70
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -44
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -46
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -82
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -102
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -93
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -104
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -52
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -46
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -111
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -61
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -65
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -60
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -60
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -92
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -92
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -65
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -74
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1979
- package/cpp/rnwgpu/async/AsyncDispatcher.h +0 -28
- package/cpp/rnwgpu/async/AsyncRunner.cpp +0 -215
- package/cpp/rnwgpu/async/AsyncRunner.h +0 -53
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -181
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -55
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +0 -23
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +0 -22
- package/cpp/webgpu/webgpu.h +0 -4979
- package/cpp/webgpu/webgpu_cpp.h +0 -10059
- package/cpp/webgpu/webgpu_cpp_chained_struct.h +0 -57
- package/cpp/webgpu/webgpu_cpp_print.h +0 -2844
- package/cpp/webgpu/webgpu_enum_class_bitmasks.h +0 -161
- package/lib/commonjs/Canvas.js +0 -55
- package/lib/commonjs/Canvas.js.map +0 -1
- package/lib/commonjs/NativeWebGPUModule.js +0 -10
- package/lib/commonjs/NativeWebGPUModule.js.map +0 -1
- package/lib/commonjs/Offscreen.js +0 -103
- package/lib/commonjs/Offscreen.js.map +0 -1
- package/lib/commonjs/WebGPUViewNativeComponent.js +0 -10
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/commonjs/WebGPUViewNativeComponent.web.js +0 -103
- package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/WebPolyfillGPUModule.js +0 -40
- package/lib/commonjs/WebPolyfillGPUModule.js.map +0 -1
- package/lib/commonjs/external/ModuleProxy.js +0 -36
- package/lib/commonjs/external/ModuleProxy.js.map +0 -1
- package/lib/commonjs/external/index.js +0 -17
- package/lib/commonjs/external/index.js.map +0 -1
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +0 -18
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +0 -1
- package/lib/commonjs/external/reanimated/index.js +0 -21
- package/lib/commonjs/external/reanimated/index.js.map +0 -1
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +0 -49
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +0 -1
- package/lib/commonjs/hooks.js +0 -83
- package/lib/commonjs/hooks.js.map +0 -1
- package/lib/commonjs/main/index.js +0 -91
- package/lib/commonjs/main/index.js.map +0 -1
- package/lib/commonjs/main/index.web.js +0 -51
- package/lib/commonjs/main/index.web.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils.js +0 -11
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/module/Canvas.js +0 -46
- package/lib/module/Canvas.js.map +0 -1
- package/lib/module/NativeWebGPUModule.js +0 -4
- package/lib/module/NativeWebGPUModule.js.map +0 -1
- package/lib/module/Offscreen.js +0 -96
- package/lib/module/Offscreen.js.map +0 -1
- package/lib/module/WebGPUViewNativeComponent.js +0 -4
- package/lib/module/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/module/WebGPUViewNativeComponent.web.js +0 -96
- package/lib/module/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/module/WebPolyfillGPUModule.js +0 -38
- package/lib/module/WebPolyfillGPUModule.js.map +0 -1
- package/lib/module/external/ModuleProxy.js +0 -28
- package/lib/module/external/ModuleProxy.js.map +0 -1
- package/lib/module/external/index.js +0 -2
- package/lib/module/external/index.js.map +0 -1
- package/lib/module/external/reanimated/ReanimatedProxy.js +0 -12
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +0 -1
- package/lib/module/external/reanimated/index.js +0 -3
- package/lib/module/external/reanimated/index.js.map +0 -1
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js +0 -42
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +0 -1
- package/lib/module/hooks.js +0 -70
- package/lib/module/hooks.js.map +0 -1
- package/lib/module/main/index.js +0 -33
- package/lib/module/main/index.js.map +0 -1
- package/lib/module/main/index.web.js +0 -8
- package/lib/module/main/index.web.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils.js +0 -5
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/babel.config.d.ts +0 -3
- package/lib/typescript/babel.config.d.ts.map +0 -1
- package/lib/typescript/jest.config.d.ts +0 -9
- package/lib/typescript/jest.config.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/Canvas.d.ts +0 -7
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts +0 -5
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/Offscreen.d.ts +0 -26
- package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +0 -5
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +0 -4
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +0 -2
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +0 -12
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/external/index.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +0 -6
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +0 -4
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +0 -9
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/hooks.d.ts +0 -18
- package/lib/typescript/lib/commonjs/hooks.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/index.d.ts +0 -2
- package/lib/typescript/lib/commonjs/main/index.d.ts +0 -3
- package/lib/typescript/lib/commonjs/main/index.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/main/index.web.d.ts +0 -2
- package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/types.d.ts +0 -1
- package/lib/typescript/lib/commonjs/types.d.ts.map +0 -1
- package/lib/typescript/lib/commonjs/utils.d.ts +0 -3
- package/lib/typescript/lib/commonjs/utils.d.ts.map +0 -1
- package/lib/typescript/lib/module/Canvas.d.ts +0 -8
- package/lib/typescript/lib/module/Canvas.d.ts.map +0 -1
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts +0 -3
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +0 -1
- package/lib/typescript/lib/module/Offscreen.d.ts +0 -25
- package/lib/typescript/lib/module/Offscreen.d.ts.map +0 -1
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +0 -3
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +0 -3
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +0 -1
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +0 -2
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +0 -1
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts +0 -7
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +0 -1
- package/lib/typescript/lib/module/external/index.d.ts.map +0 -1
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +0 -5
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +0 -1
- package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +0 -1
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +0 -2
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +0 -1
- package/lib/typescript/lib/module/hooks.d.ts +0 -18
- package/lib/typescript/lib/module/hooks.d.ts.map +0 -1
- package/lib/typescript/lib/module/index.d.ts +0 -2
- package/lib/typescript/lib/module/main/index.d.ts.map +0 -1
- package/lib/typescript/lib/module/main/index.web.d.ts +0 -5
- package/lib/typescript/lib/module/main/index.web.d.ts.map +0 -1
- package/lib/typescript/lib/module/types.d.ts +0 -1
- package/lib/typescript/lib/module/types.d.ts.map +0 -1
- package/lib/typescript/lib/module/utils.d.ts +0 -2
- package/lib/typescript/lib/module/utils.d.ts.map +0 -1
- package/lib/typescript/src/Canvas.d.ts.map +0 -1
- package/lib/typescript/src/NativeWebGPUModule.d.ts.map +0 -1
- package/lib/typescript/src/Offscreen.d.ts.map +0 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +0 -9
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +0 -1
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts +0 -2
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +0 -1
- package/lib/typescript/src/external/ModuleProxy.d.ts.map +0 -1
- package/lib/typescript/src/external/index.d.ts +0 -2
- package/lib/typescript/src/external/index.d.ts.map +0 -1
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +0 -1
- package/lib/typescript/src/external/reanimated/index.d.ts +0 -3
- package/lib/typescript/src/external/reanimated/index.d.ts.map +0 -1
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +0 -1
- package/lib/typescript/src/hooks.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/main/index.d.ts +0 -6
- package/lib/typescript/src/main/index.d.ts.map +0 -1
- package/lib/typescript/src/main/index.web.d.ts +0 -6
- package/lib/typescript/src/main/index.web.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/utils.d.ts +0 -2
- package/lib/typescript/src/utils.d.ts.map +0 -1
- 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 +0 -59
- 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/react-native-wgpu.podspec +0 -47
- package/src/Canvas.tsx +0 -76
- package/src/NativeWebGPUModule.ts +0 -9
- package/src/Offscreen.ts +0 -113
- package/src/WebGPUViewNativeComponent.ts +0 -11
- package/src/WebGPUViewNativeComponent.web.ts +0 -113
- package/src/WebPolyfillGPUModule.ts +0 -53
- package/src/external/ModuleProxy.ts +0 -30
- package/src/external/index.ts +0 -1
- package/src/external/reanimated/ReanimatedProxy.ts +0 -19
- package/src/external/reanimated/index.ts +0 -2
- package/src/external/reanimated/registerWebGPUForReanimated.ts +0 -43
- package/src/hooks.tsx +0 -93
- package/src/index.tsx +0 -91
- package/src/main/index.tsx +0 -40
- package/src/main/index.web.tsx +0 -8
- package/src/types.ts +0 -102
- package/src/utils.ts +0 -4
- /package/lib/typescript/{src → webgpu/src}/NativeWebGPUModule.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/Offscreen.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/WebGPUViewNativeComponent.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/external/ModuleProxy.d.ts +0 -0
- /package/lib/typescript/{lib/module → webgpu/src}/external/index.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/external/reanimated/ReanimatedProxy.d.ts +0 -0
- /package/lib/typescript/{lib/module → webgpu/src}/external/reanimated/index.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/external/reanimated/registerWebGPUForReanimated.d.ts +0 -0
- /package/lib/typescript/{src → webgpu/src}/hooks.d.ts +0 -0
- /package/lib/typescript/{lib/module → webgpu/src}/main/index.d.ts +0 -0
- /package/lib/typescript/{eslint.config.d.mts → webgpu-shim/eslint.config.d.mts} +0 -0
- /package/lib/typescript/{lib/commonjs/external → webgpu-shim/lib/commonjs}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,403 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-native-wgpu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package has been renamed to [`react-native-webgpu`](https://www.npmjs.com/package/react-native-webgpu).
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
### Shared Texture Memory
|
|
226
|
-
|
|
227
|
-
React Native WebGPU exposes Dawn's `SharedTextureMemory` so you can import a native pixel surface (an `IOSurface`-backed `CVPixelBuffer` on iOS, an `AHardwareBuffer` on Android) as a sampleable `GPUTexture` without copying pixels through the CPU. This is the path you want for camera frames, video frames, or anything coming out of a hardware producer.
|
|
228
|
-
|
|
229
|
-
Like `importExternalTexture` on the web, this is **enabled by default**, there is nothing to request at device creation. The only thing to check is that the device supports it before importing. It always does on iOS/macOS; it can be missing on some Android drivers and emulators.
|
|
230
|
-
|
|
231
|
-
```tsx
|
|
232
|
-
import type { NativeVideoFrame } from "react-native-wgpu";
|
|
233
|
-
|
|
234
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
235
|
-
const device = await adapter!.requestDevice();
|
|
236
|
-
|
|
237
|
-
// On by default when supported; this is the only check you need.
|
|
238
|
-
if (!device.features.has("rnwebgpu/native-texture" as GPUFeatureName)) {
|
|
239
|
-
return; // rare: some Android drivers/emulators can't import native surfaces
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// `frame` here is a NativeVideoFrame whose .handle is the native surface
|
|
243
|
-
// (IOSurfaceRef / AHardwareBuffer*). NativeVideoFrames are produced by helpers
|
|
244
|
-
// like RNWebGPU.createVideoPlayer or RNWebGPU.createTestVideoFrame, or by
|
|
245
|
-
// any third-party module that hands you a compatible native pointer.
|
|
246
|
-
const memory = device.importSharedTextureMemory({
|
|
247
|
-
handle: frame.handle,
|
|
248
|
-
label: "video-frame",
|
|
249
|
-
});
|
|
250
|
-
const texture = memory.createTexture();
|
|
251
|
-
|
|
252
|
-
memory.beginAccess(texture, /* initialized */ true);
|
|
253
|
-
// ... bind `texture` into a sampler and render normally ...
|
|
254
|
-
memory.endAccess(texture);
|
|
255
|
-
|
|
256
|
-
texture.destroy();
|
|
257
|
-
frame.release();
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
`beginAccess`/`endAccess` bracket the GPU's read window on the shared surface. Pass `initialized: true` when the producer has already written meaningful pixels (the typical video/camera case) and `false` when the next pass will fully overwrite the texture.
|
|
261
|
-
|
|
262
|
-
### Importing External Textures
|
|
263
|
-
|
|
264
|
-
`GPUDevice.importExternalTexture` is the higher-level path for sampling a native surface. You hand it a `NativeVideoFrame` and get back a `GPUExternalTexture` that you bind as a `texture_external` and read with `textureSampleBaseClampToEdge`. It does two things for you on top of `SharedTextureMemory`:
|
|
265
|
-
|
|
266
|
-
- **Color conversion.** Camera and video surfaces are usually biplanar YUV (NV12), not RGB. An external texture carries the YUV→RGB matrix and the source/destination color-space transfer functions, so on the supported paths the sampler returns ready-to-use RGB in hardware. With raw `SharedTextureMemory` you would sample the luma/chroma planes and do that conversion by hand in WGSL. This is the main reason to prefer it for camera and video frames.
|
|
267
|
-
- **Lifecycle.** It owns the `SharedTextureMemory` + `createTexture` + `beginAccess`/`endAccess` sequence internally, so you just import the frame and `destroy()` the result.
|
|
268
|
-
|
|
269
|
-
It builds on the same default-on capability as Shared Texture Memory above, so feature-detect the device the same way before importing.
|
|
270
|
-
|
|
271
|
-
> **Android note:** the hardware YUV→RGB conversion is fully automatic on iOS (NV12 `IOSurface`). On Android, camera frames arrive as an _opaque_ YCbCr `AHardwareBuffer`, and Dawn's Vulkan path forces an identity (`RGB_IDENTITY`) sampler conversion, so the external sample comes back as raw `[Y, Cb, Cr]`. You still get the zero-copy import and the rotation/mirror transform, but you need to apply the YUV→RGB matrix yourself in the shader. See the `CAMERA_PRELUDE` in the [VisionCamera example](/apps/example/src/VisionCamera/shaders.ts) for a ready-made BT.709 decode.
|
|
272
|
-
|
|
273
|
-
```tsx
|
|
274
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
275
|
-
const device = await adapter!.requestDevice();
|
|
276
|
-
// Feature-detect as shown above before importing on unsupported hardware.
|
|
277
|
-
|
|
278
|
-
const render = () => {
|
|
279
|
-
// A GPUExternalTexture expires once the queue work that used it is submitted,
|
|
280
|
-
// so re-import one every frame.
|
|
281
|
-
const externalTexture = device.importExternalTexture({
|
|
282
|
-
source: frame, // a NativeVideoFrame
|
|
283
|
-
label: "video-frame",
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
const bindGroup = device.createBindGroup({
|
|
287
|
-
layout: pipeline.getBindGroupLayout(0),
|
|
288
|
-
entries: [
|
|
289
|
-
{ binding: 0, resource: externalTexture },
|
|
290
|
-
{ binding: 1, resource: sampler },
|
|
291
|
-
],
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
// ... encode a pass that samples `externalTexture`, then:
|
|
295
|
-
device.queue.submit([encoder.finish()]);
|
|
296
|
-
|
|
297
|
-
// Release the surface's access window right after the submit that sampled it.
|
|
298
|
-
externalTexture.destroy();
|
|
299
|
-
context.present();
|
|
300
|
-
};
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
Camera frames arrive in the sensor's native orientation, so `importExternalTexture` also accepts non-spec `rotation` (`0` | `90` | `180` | `270`, in degrees) and `mirrored` (horizontal flip) options. Dawn bakes them into the sampling transform, so the shader sees an upright frame. They map directly onto VisionCamera's `frame.orientation` / `frame.isMirrored`.
|
|
304
|
-
|
|
305
|
-
#### Calling `destroy()`
|
|
306
|
-
|
|
307
|
-
A `GPUExternalTexture` keeps an open access window on the underlying native surface until the wrapper is destroyed. On the Web `importExternalTexture` is core and the lifetime is handled for you; here the window is tied to the JavaScript object's lifetime. Call `externalTexture.destroy()` right after the `queue.submit()` that sampled it (never before) to release the surface back to its producer immediately. `destroy()` is idempotent, and the surface is also released when the object is garbage-collected, but relying on GC can starve a producer's buffer pool (e.g. an `AVPlayer`'s recycled `IOSurface`s) and pile up GPU resources, so prefer the explicit call in a render loop.
|
|
308
|
-
|
|
309
|
-
### Reanimated Integration
|
|
310
|
-
|
|
311
|
-
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).
|
|
312
|
-
|
|
313
|
-
First, install the optional peer dependencies:
|
|
314
|
-
|
|
315
|
-
```sh
|
|
316
|
-
npm install react-native-reanimated react-native-worklets
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
WebGPU objects are automatically registered for Worklets serialization when the module loads. You can pass WebGPU objects like `GPUDevice` and `GPUCanvasContext` directly to worklets:
|
|
320
|
-
|
|
321
|
-
```tsx
|
|
322
|
-
import { Canvas } from "react-native-wgpu";
|
|
323
|
-
import { runOnUI } from "react-native-reanimated";
|
|
324
|
-
|
|
325
|
-
const renderFrame = (device: GPUDevice, context: GPUCanvasContext) => {
|
|
326
|
-
"worklet";
|
|
327
|
-
// WebGPU rendering code runs on the UI thread
|
|
328
|
-
const commandEncoder = device.createCommandEncoder();
|
|
329
|
-
// ... render ...
|
|
330
|
-
device.queue.submit([commandEncoder.finish()]);
|
|
331
|
-
context.present();
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
// Initialize WebGPU on main thread, then run on UI thread
|
|
335
|
-
const device = await adapter.requestDevice();
|
|
336
|
-
const context = canvasRef.current.getContext("webgpu");
|
|
337
|
-
runOnUI(renderFrame)(device, context);
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
## Troubleshooting
|
|
341
|
-
|
|
342
|
-
### iOS
|
|
343
|
-
|
|
344
|
-
To run the React Native WebGPU project on the iOS simulator, you need to disable the Metal validation API.
|
|
345
|
-
In "Edit Scheme," uncheck "Metal Validation". Learn more [here](https://developer.apple.com/documentation/xcode/validating-your-apps-metal-api-usage/).
|
|
346
|
-
|
|
347
|
-
<img width="1052" alt="Uncheck 'Metal Validation'" src="https://github.com/user-attachments/assets/2676e5cc-e351-4a97-bdc8-22cbd7df2ef2">
|
|
348
|
-
|
|
349
|
-
## Library Development
|
|
350
|
-
|
|
351
|
-
Make sure to check out the submodules:
|
|
352
|
-
|
|
353
|
-
```
|
|
354
|
-
git submodule update --init
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
Make sure you have all the tools required for building the Skia libraries (Android Studio, XCode, Ninja, CMake, Android NDK/build tools).
|
|
358
|
-
|
|
359
|
-
### Installing Dawn
|
|
360
|
-
|
|
361
|
-
There is an alternative way which is to install the prebuilt binaries from GitHub.
|
|
362
|
-
|
|
363
|
-
```sh
|
|
364
|
-
$ yarn
|
|
365
|
-
$ cd packages/webgpu
|
|
366
|
-
$ yarn install-dawn
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Building Dawn
|
|
370
|
-
|
|
371
|
-
Alternatively, you can build Dawn locally.
|
|
372
|
-
|
|
373
|
-
```sh
|
|
374
|
-
yarn
|
|
375
|
-
cd packages/webgpu
|
|
376
|
-
yarn build-dawn
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
### Upgrading
|
|
380
|
-
|
|
381
|
-
1. `git submodule update --remote`
|
|
382
|
-
2. `yarn clean-dawn`
|
|
383
|
-
3. `yarn build-dawn`
|
|
384
|
-
|
|
385
|
-
### Codegen
|
|
386
|
-
|
|
387
|
-
* `cd packages/webgpu && yarn codegen`
|
|
388
|
-
|
|
389
|
-
### Testing
|
|
390
|
-
|
|
391
|
-
In the `package` folder, to run the test against Chrome for reference:
|
|
392
|
-
|
|
393
|
-
```
|
|
394
|
-
yarn test:ref
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
To run the e2e test, open the example app on the e2e screen.
|
|
398
|
-
By default, it will try to connect to a localhost test server.
|
|
399
|
-
If you want to run the test suite on a physical device, you can modify the address [here](/apps/example/src/useClient.ts#L4).
|
|
5
|
+
Please use `react-native-webgpu` instead.
|
|
400
6
|
|
|
401
7
|
```
|
|
402
|
-
|
|
8
|
+
npm install react-native-webgpu
|
|
403
9
|
```
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,15 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _reactNativeWebgpu = require("react-native-webgpu");
|
|
7
|
+
Object.keys(_reactNativeWebgpu).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _reactNativeWebgpu[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _reactNativeWebgpu[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
18
|
+
console.warn("[react-native-wgpu] This package has been renamed to 'react-native-webgpu'. " + "The 'react-native-wgpu' shim is deprecated and will be removed in a future release. " + "Please install 'react-native-webgpu' and update your imports.");
|
|
19
|
+
}
|
|
17
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNativeWebgpu","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","__DEV__","console","warn"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAQA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AARA,IAAI,OAAOK,OAAO,KAAK,WAAW,IAAIA,OAAO,EAAE;EAC7CC,OAAO,CAACC,IAAI,CACV,8EAA8E,GAC5E,sFAAsF,GACtF,+DACJ,CAAC;AACH","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
2
|
+
console.warn("[react-native-wgpu] This package has been renamed to 'react-native-webgpu'. " + "The 'react-native-wgpu' shim is deprecated and will be removed in a future release. " + "Please install 'react-native-webgpu' and update your imports.");
|
|
3
|
+
}
|
|
4
|
+
export * from "react-native-webgpu";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.
|
|
1
|
+
{"version":3,"names":["__DEV__","console","warn"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,IAAI,OAAOA,OAAO,KAAK,WAAW,IAAIA,OAAO,EAAE;EAC7CC,OAAO,CAACC,IAAI,CACV,8EAA8E,GAC5E,sFAAsF,GACtF,+DACJ,CAAC;AACH;AAEA,cAAc,qBAAqB","ignoreList":[]}
|
|
@@ -9,6 +9,15 @@ export interface NativeCanvas {
|
|
|
9
9
|
clientHeight: number;
|
|
10
10
|
}
|
|
11
11
|
export type RNCanvasContext = GPUCanvasContext & {
|
|
12
|
+
/**
|
|
13
|
+
* Present the current frame.
|
|
14
|
+
*
|
|
15
|
+
* Call this after `queue.submit()` on every runtime: the main JS runtime, the
|
|
16
|
+
* Reanimated UI runtime, and dedicated worklet runtimes (e.g.
|
|
17
|
+
* `createWorkletRuntime` / `runOnRuntime`, or a Vision Camera frame
|
|
18
|
+
* processor). It runs synchronously on the calling thread, so the frame is
|
|
19
|
+
* presented from whichever thread did the rendering.
|
|
20
|
+
*/
|
|
12
21
|
present: () => void;
|
|
13
22
|
};
|
|
14
23
|
export interface CanvasRef {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACtC;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,MAAM,GAAI,gCAAgC,WAAW,sBAuCjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeWebGPUModule.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/NativeWebGPUModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB;;AAGD,wBAAsE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Offscreen.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/Offscreen.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,OAAO,CAA4B;gBAE/B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,yBAAyB,GAAG,IAAI;IAQjE,YAAY;;;;;;CA6Bb;AAED,cAAM,yBAA0B,YAAW,gBAAgB;aAQ7B,MAAM,EAAE,GAAG;IAPvC,OAAO,EAAG,kBAAkB,CAAU;IAEtC,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAA0B;gBAGZ,MAAM,EAAE,GAAG;IAGvC,gBAAgB,IAAI,yBAAyB,GAAG,IAAI;IAIpD,OAAO;IAIP,SAAS;IAOT,UAAU;IAOV,SAAS,CAAC,MAAM,EAAE,sBAAsB;IAcxC,WAAW;IAQX,iBAAiB,IAAI,UAAU;CAMhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,KAAK,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;;AAGD,wBAAiE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const GPUBufferUsage: GPUBufferUsage;
|
|
2
|
+
export declare const GPUTextureUsage: GPUTextureUsage;
|
|
3
|
+
export declare const GPUShaderStage: GPUShaderStage;
|
|
4
|
+
export declare const GPUColorWrite: GPUColorWrite;
|
|
5
|
+
export declare const GPUMapMode: GPUMapMode;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/constants.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,cAAc,gBAA4B,CAAC;AAExD,eAAO,MAAM,eAAe,iBAA6B,CAAC;AAE1D,eAAO,MAAM,cAAc,gBAA4B,CAAC;AAExD,eAAO,MAAM,aAAa,eAA2B,CAAC;AAEtD,eAAO,MAAM,UAAU,YAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleProxy.d.ts","sourceRoot":"","sources":["../../../../../../webgpu/src/external/ModuleProxy.ts"],"names":[],"mappings":"AACA,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,EACvC,WAAW,MAAM,UAAU,KAC1B,OAcF,CAAC;AAEF,qBAAa,mCAAoC,SAAQ,KAAK;gBAChD,IAAI,EAAE,MAAM;CAGzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../webgpu/src/external/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReanimatedProxy.d.ts","sourceRoot":"","sources":["../../../../../../../webgpu/src/external/reanimated/ReanimatedProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAS5D,QAAA,MAAM,UAAU,oBAMd,CAAC;AAGH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../webgpu/src/external/reanimated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWebGPUForReanimated.d.ts","sourceRoot":"","sources":["../../../../../../../webgpu/src/external/reanimated/registerWebGPUForReanimated.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YA2BvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/hooks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,4BAA4B,GAAI,SAAS,UAAU,SAQ/D,CAAC;AAEF,UAAU,aAAa;IACrB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;CAC5B;AAED,QAAA,MAAM,aAAa,qCAA4C,CAAC;AAEhE,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED,eAAO,MAAM,iBAAiB,GAAI,iDAI/B,mBAAmB,6BAQrB,CAAC;AAEF,eAAO,MAAM,UAAU;;;CAQtB,CAAC;AAEF,eAAO,MAAM,aAAa,qBAMzB,CAAC;AAEF,eAAO,MAAM,YAAY,kCAAgC,CAAC;AAE1D,eAAO,MAAM,SAAS,GACpB,iBAAiB,wBAAwB,EACzC,mBAAmB,mBAAmB;;;CAqBvC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { GPUDawnTogglesDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
1
|
+
import type { GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
2
2
|
export * from "./main";
|
|
3
|
-
export
|
|
3
|
+
export * from "./constants";
|
|
4
|
+
export * from "./install";
|
|
5
|
+
export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUDawnTogglesDescriptor, } from "./types";
|
|
4
6
|
declare global {
|
|
5
7
|
interface Navigator {
|
|
6
8
|
gpu: GPU;
|
|
@@ -21,6 +23,7 @@ declare global {
|
|
|
21
23
|
};
|
|
22
24
|
interface GPUDevice {
|
|
23
25
|
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
26
|
+
importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
|
|
24
27
|
}
|
|
25
28
|
interface GPUDeviceDescriptor {
|
|
26
29
|
dawnToggles?: GPUDawnTogglesDescriptor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,gCAAgC,EAChC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,gCAAgC,EAChC,oCAAoC,EACpC,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,SAAS;QACjB,GAAG,EAAE,GAAG,CAAC;KACV;IAED,IAAI,SAAS,EAAE,SAAS,CAAC;IAEzB,IAAI,QAAQ,EAAE;QACZ,GAAG,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,CAAC;QACtD,uBAAuB,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,eAAe,CAAC;QACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,GAAG,WAAW,KAAK,MAAM,CAAC;QACvE,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;QAC5C,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,CAAC;QACnD,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,gBAAgB,CAAC;QAI1E,gCAAgC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,gBAAgB,CAAC;QACxE,iBAAiB,EAAE,CACjB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,sBAAsB,KACjC,WAAW,CAAC;QACjB,kBAAkB,EAAE,MAAM,MAAM,CAAC;KAClC,CAAC;IAEF,UAAU,SAAS;QACjB,yBAAyB,CACvB,UAAU,EAAE,gCAAgC,GAC3C,sBAAsB,CAAC;QAC1B,iBAAiB,CAAC,UAAU,EAAE,wBAAwB,GAAG,cAAc,CAAC;KACzE;IAID,UAAU,mBAAmB;QAC3B,WAAW,CAAC,EAAE,wBAAwB,CAAC;KACxC;IAMD,UAAU,4BAA4B;QACpC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IASD,UAAU,kBAAkB;QAC1B,OAAO,IAAI,IAAI,CAAC;KACjB;IAGD,SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,GACnC,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install WebGPU on the runtime that calls it.
|
|
3
|
+
*
|
|
4
|
+
* The native module installs the WebGPU flag constants (`GPUBufferUsage`,
|
|
5
|
+
* `GPUTextureUsage`, `GPUShaderStage`, `GPUColorWrite`, `GPUMapMode`) as globals
|
|
6
|
+
* on the main JS runtime, but worklet runtimes (Reanimated UI, dedicated worklet
|
|
7
|
+
* runtimes, Vision Camera frame processors) start without them, so referencing
|
|
8
|
+
* the bare global inside a worklet yields `undefined`.
|
|
9
|
+
*
|
|
10
|
+
* Call `installWebGPU()` once at the top of a worklet to make those globals
|
|
11
|
+
* available there, instead of importing each constant by hand:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { installWebGPU } from "react-native-webgpu";
|
|
15
|
+
*
|
|
16
|
+
* const work = (device: GPUDevice) => {
|
|
17
|
+
* "worklet";
|
|
18
|
+
* installWebGPU();
|
|
19
|
+
* device.createBuffer({
|
|
20
|
+
* usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
21
|
+
* });
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The constants are captured into the worklet by closure (the same way a shader
|
|
26
|
+
* string is), so they work on every runtime. Calling it on a runtime that
|
|
27
|
+
* already has the globals (e.g. the main JS runtime) is a safe no-op.
|
|
28
|
+
*
|
|
29
|
+
* This is the explicit entry point for runtime setup; for now it only installs
|
|
30
|
+
* the flag constants, but it is the place where other per-runtime WebGPU setup
|
|
31
|
+
* (e.g. `navigator.gpu`) can be wired in later.
|
|
32
|
+
*/
|
|
33
|
+
export declare const installWebGPU: () => void;
|
|
34
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/install.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,YAQzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../webgpu/src/main/index.tsx"],"names":[],"mappings":"AAGA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -7,6 +7,15 @@ export interface NativeCanvas {
|
|
|
7
7
|
clientHeight: number;
|
|
8
8
|
}
|
|
9
9
|
export type RNCanvasContext = GPUCanvasContext & {
|
|
10
|
+
/**
|
|
11
|
+
* Present the current frame.
|
|
12
|
+
*
|
|
13
|
+
* Call this after `queue.submit()` on every runtime: the main JS runtime, the
|
|
14
|
+
* Reanimated UI runtime, and dedicated worklet runtimes (e.g.
|
|
15
|
+
* `createWorkletRuntime` / `runOnRuntime`, or a Vision Camera frame
|
|
16
|
+
* processor). It runs synchronously on the calling thread, so the frame is
|
|
17
|
+
* presented from whichever thread did the rendering.
|
|
18
|
+
*/
|
|
10
19
|
present: () => void;
|
|
11
20
|
};
|
|
12
21
|
export interface CanvasRef {
|
|
@@ -35,6 +44,29 @@ export interface GPUSharedTextureMemoryDescriptor {
|
|
|
35
44
|
handle: bigint;
|
|
36
45
|
label?: string;
|
|
37
46
|
}
|
|
47
|
+
export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
|
|
48
|
+
export interface GPUSharedFenceDescriptor {
|
|
49
|
+
type: GPUSharedFenceType;
|
|
50
|
+
handle: bigint;
|
|
51
|
+
label?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GPUSharedFenceExportInfo {
|
|
54
|
+
type: GPUSharedFenceType;
|
|
55
|
+
handle: bigint;
|
|
56
|
+
}
|
|
57
|
+
export interface GPUSharedFence {
|
|
58
|
+
readonly __brand: "GPUSharedFence";
|
|
59
|
+
label: string;
|
|
60
|
+
export(): GPUSharedFenceExportInfo;
|
|
61
|
+
}
|
|
62
|
+
export interface GPUSharedFenceState {
|
|
63
|
+
fence: GPUSharedFence;
|
|
64
|
+
signaledValue: bigint;
|
|
65
|
+
}
|
|
66
|
+
export interface GPUSharedTextureMemoryEndAccessState {
|
|
67
|
+
initialized: boolean;
|
|
68
|
+
fences: GPUSharedFenceState[];
|
|
69
|
+
}
|
|
38
70
|
export interface GPUDawnTogglesDescriptor {
|
|
39
71
|
enabledToggles?: string[];
|
|
40
72
|
disabledToggles?: string[];
|
|
@@ -43,8 +75,8 @@ export interface GPUSharedTextureMemory {
|
|
|
43
75
|
readonly __brand: "GPUSharedTextureMemory";
|
|
44
76
|
label: string;
|
|
45
77
|
createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;
|
|
46
|
-
beginAccess(texture: GPUTexture, initialized: boolean):
|
|
47
|
-
endAccess(texture: GPUTexture):
|
|
78
|
+
beginAccess(texture: GPUTexture, initialized: boolean, fences?: GPUSharedFenceState[]): void;
|
|
79
|
+
endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
|
|
48
80
|
}
|
|
49
81
|
export {};
|
|
50
82
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../webgpu/src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACtC;AAKD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,CAAC;AAkBtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC7C,OAAO,IAAI,IAAI,CAAC;CACjB;AAKD,MAAM,WAAW,WAAW;IAC1B,eAAe,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAC3C,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IAKvC,WAAW,CAAC,EAAE,sBAAsB,CAAC;CACtC;AAED,MAAM,WAAW,gCAAgC;IAM/C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,SAAS,GACT,wBAAwB,CAAC;AAE7B,MAAM,WAAW,wBAAwB;IAGvC,IAAI,EAAE,kBAAkB,CAAC;IAGzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,kBAAkB,CAAC;IAIzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,IAAI,wBAAwB,CAAC;CACpC;AAGD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAID,MAAM,WAAW,oCAAoC;IACnD,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAQD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAMD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,UAAU,CAAC;IAM7D,WAAW,CACT,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAC7B,IAAI,CAAC;IAGR,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,oCAAoC,CAAC;CACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.config.d.mts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"eslint.config.d.mts","sourceRoot":"","sources":["../../../eslint.config.mjs"],"names":[],"mappings":""}
|