@shopify/react-native-skia 2.10.0 → 2.11.0-next.1
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/android/CMakeLists.txt +7 -41
- package/android/build.gradle +33 -0
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
- package/cpp/api/JsiNativeBuffer.h +14 -20
- package/cpp/api/JsiSkAnimatedImage.h +13 -16
- package/cpp/api/JsiSkAnimatedImageFactory.h +9 -7
- package/cpp/api/JsiSkApi.h +94 -90
- package/cpp/api/JsiSkCanvas.h +108 -251
- package/cpp/api/JsiSkColorFilterFactory.h +45 -63
- package/cpp/api/JsiSkContourMeasure.h +19 -29
- package/cpp/api/JsiSkContourMeasureIter.h +6 -6
- package/cpp/api/JsiSkConverters.h +410 -0
- package/cpp/api/JsiSkDataFactory.h +9 -15
- package/cpp/api/JsiSkFont.h +99 -180
- package/cpp/api/JsiSkFontMgr.h +19 -21
- package/cpp/api/JsiSkFontMgrFactory.h +4 -5
- package/cpp/api/JsiSkImage.h +66 -66
- package/cpp/api/JsiSkImageFactory.h +66 -63
- package/cpp/api/JsiSkImageFilterFactory.h +354 -608
- package/cpp/api/JsiSkImageInfo.h +10 -13
- package/cpp/api/JsiSkMaskFilterFactory.h +8 -11
- package/cpp/api/JsiSkMatrix.h +36 -73
- package/cpp/api/JsiSkNativeObjects.h +60 -92
- package/cpp/api/JsiSkPaint.h +73 -131
- package/cpp/api/JsiSkParagraph.h +36 -53
- package/cpp/api/JsiSkParagraphBuilder.h +36 -64
- package/cpp/api/JsiSkParagraphBuilderFactory.h +11 -16
- package/cpp/api/JsiSkPath.h +216 -349
- package/cpp/api/JsiSkPathBuilder.h +133 -269
- package/cpp/api/JsiSkPathBuilderFactory.h +11 -11
- package/cpp/api/JsiSkPathEffectFactory.h +52 -72
- package/cpp/api/JsiSkPathFactory.h +129 -195
- package/cpp/api/JsiSkPicture.h +12 -18
- package/cpp/api/JsiSkPictureRecorder.h +14 -15
- package/cpp/api/JsiSkPoint.h +4 -4
- package/cpp/api/JsiSkRRect.h +7 -8
- package/cpp/api/JsiSkRSXform.h +10 -23
- package/cpp/api/JsiSkRect.h +23 -31
- package/cpp/api/JsiSkRuntimeEffect.h +67 -83
- package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -10
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +5 -14
- package/cpp/api/JsiSkSVG.h +4 -4
- package/cpp/api/JsiSkShaderFactory.h +153 -225
- package/cpp/api/JsiSkSkottie.h +104 -126
- package/cpp/api/JsiSkSurface.h +11 -14
- package/cpp/api/JsiSkSurfaceFactory.h +6 -7
- package/cpp/api/JsiSkTextBlobFactory.h +31 -54
- package/cpp/api/JsiSkTypeface.h +8 -12
- package/cpp/api/JsiSkTypefaceFactory.h +9 -7
- package/cpp/api/JsiSkTypefaceFontProvider.h +22 -23
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +5 -6
- package/cpp/api/JsiSkVertices.h +6 -8
- package/cpp/api/JsiSkiaContext.h +10 -11
- package/cpp/api/JsiVideo.h +31 -71
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +41 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +86 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +369 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2844 -0
- package/cpp/dawn/include/tint/tint.h +90 -0
- package/cpp/dawn/include/webgpu/webgpu.h +4987 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10080 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/jsi/JSIConverter.h +0 -31
- package/cpp/jsi/NativeObject.h +11 -6
- package/cpp/rnskia/RNDawnContext.h +18 -2
- package/cpp/rnskia/RNDawnInterop.cpp +19 -0
- package/cpp/rnskia/RNDawnUtils.h +18 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -162
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +5 -15
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +0 -1
- package/lib/commonjs/skia/types/index.js +0 -11
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +1 -4
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/views/index.d.ts +0 -1
- package/lib/commonjs/views/index.js +0 -11
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +5 -15
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +0 -1
- package/lib/module/skia/types/index.js +0 -1
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +1 -4
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/views/index.d.ts +0 -1
- package/lib/module/views/index.js +0 -1
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
- package/lib/typescript/lib/module/mock/index.d.ts +0 -2
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
- package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
- package/lib/typescript/lib/module/views/index.d.ts +0 -1
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
- package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
- package/lib/typescript/src/skia/types/index.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
- package/lib/typescript/src/views/index.d.ts +0 -1
- package/libs/.graphite +1 -0
- package/package.json +8 -9
- package/react-native-skia.podspec +38 -4
- package/src/mock/index.ts +0 -1
- package/src/skia/types/Image/ImageFactory.ts +15 -6
- package/src/skia/types/Skia.ts +5 -15
- package/src/skia/types/index.ts +0 -1
- package/src/skia/web/JsiSkImageFactory.ts +3 -3
- package/src/skia/web/JsiSkia.ts +2 -5
- package/src/views/index.ts +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +0 -112
- package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
- package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
- package/apple/SkiaPlatformContext.h +0 -20
- package/apple/SkiaPlatformContext.mm +0 -21
- package/apple/SkiaWebGPUView.mm +0 -81
- package/apple/WebGPUMetalView.mm +0 -136
- package/cpp/rnwgpu/ArrayBuffer.h +0 -116
- package/cpp/rnwgpu/Canvas.h +0 -52
- package/cpp/rnwgpu/PlatformContext.h +0 -18
- package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
- package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
- package/cpp/rnwgpu/api/Convertors.h +0 -783
- package/cpp/rnwgpu/api/External.h +0 -12
- package/cpp/rnwgpu/api/GPU.cpp +0 -162
- package/cpp/rnwgpu/api/GPU.h +0 -60
- package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -239
- package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
- 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 -107
- package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
- package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
- 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 -613
- package/cpp/rnwgpu/api/GPUDevice.h +0 -258
- 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 -139
- package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
- 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 -179
- package/cpp/rnwgpu/api/GPUQueue.h +0 -84
- 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 -56
- package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
- package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
- package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
- 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 -60
- package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
- package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
- package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
- package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
- package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
- 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 -66
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -213
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
- package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
- package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
- package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
- package/lib/commonjs/skia/types/WebGPU.js +0 -105
- package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/utils.d.ts +0 -1
- package/lib/commonjs/specs/utils.js +0 -11
- package/lib/commonjs/specs/utils.js.map +0 -1
- package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
- package/lib/commonjs/views/WebGPUCanvas.js +0 -79
- package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
- package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
- package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
- package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
- package/lib/module/skia/types/WebGPU.d.ts +0 -184
- package/lib/module/skia/types/WebGPU.js +0 -99
- package/lib/module/skia/types/WebGPU.js.map +0 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
- package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/utils.d.ts +0 -1
- package/lib/module/specs/utils.js +0 -5
- package/lib/module/specs/utils.js.map +0 -1
- package/lib/module/views/WebGPUCanvas.d.ts +0 -33
- package/lib/module/views/WebGPUCanvas.js +0 -70
- package/lib/module/views/WebGPUCanvas.js.map +0 -1
- package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
- package/lib/module/views/WebGPUCanvas.web.js +0 -12
- package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
- package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
- package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
- package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
- package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
- package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
- package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
- package/lib/typescript/src/specs/utils.d.ts +0 -1
- package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
- package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
- package/src/skia/types/WebGPU.ts +0 -226
- package/src/specs/WebGPUViewNativeComponent.ts +0 -11
- package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
- package/src/specs/utils.ts +0 -4
- package/src/views/WebGPUCanvas.tsx +0 -125
- package/src/views/WebGPUCanvas.web.tsx +0 -36
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <functional>
|
|
4
|
-
#include <map>
|
|
5
|
-
#include <memory>
|
|
6
|
-
#include <mutex>
|
|
7
|
-
#include <optional>
|
|
8
|
-
#include <string>
|
|
9
|
-
#include <unordered_set>
|
|
10
|
-
#include <utility>
|
|
11
|
-
#include <variant>
|
|
12
|
-
#include <vector>
|
|
13
|
-
|
|
14
|
-
#include "descriptors/Unions.h"
|
|
15
|
-
|
|
16
|
-
#include "jsi/NativeObject.h"
|
|
17
|
-
|
|
18
|
-
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
19
|
-
#include "rnwgpu/async/RuntimeContext.h"
|
|
20
|
-
|
|
21
|
-
#include "webgpu/webgpu_cpp.h"
|
|
22
|
-
|
|
23
|
-
#include "GPUUncapturedErrorEvent.h"
|
|
24
|
-
|
|
25
|
-
#include "GPUBindGroup.h"
|
|
26
|
-
#include "GPUBindGroupLayout.h"
|
|
27
|
-
#include "GPUBuffer.h"
|
|
28
|
-
#include "GPUCommandEncoder.h"
|
|
29
|
-
#include "GPUComputePipeline.h"
|
|
30
|
-
#include "GPUDeviceLostInfo.h"
|
|
31
|
-
#include "GPUError.h"
|
|
32
|
-
#include "GPUExternalTexture.h"
|
|
33
|
-
#include "GPUPipelineLayout.h"
|
|
34
|
-
#include "GPUQuerySet.h"
|
|
35
|
-
#include "GPUQueue.h"
|
|
36
|
-
#include "GPURenderBundleEncoder.h"
|
|
37
|
-
#include "GPURenderPipeline.h"
|
|
38
|
-
#include "GPUSampler.h"
|
|
39
|
-
#include "GPUShaderModule.h"
|
|
40
|
-
#include "GPUSharedFence.h"
|
|
41
|
-
#include "GPUSharedTextureMemory.h"
|
|
42
|
-
#include "GPUSupportedLimits.h"
|
|
43
|
-
#include "GPUTexture.h"
|
|
44
|
-
#include "descriptors/GPUBindGroupDescriptor.h"
|
|
45
|
-
#include "descriptors/GPUBindGroupLayoutDescriptor.h"
|
|
46
|
-
#include "descriptors/GPUBufferDescriptor.h"
|
|
47
|
-
#include "descriptors/GPUCommandEncoderDescriptor.h"
|
|
48
|
-
#include "descriptors/GPUComputePipelineDescriptor.h"
|
|
49
|
-
#include "descriptors/GPUExternalTextureDescriptor.h"
|
|
50
|
-
#include "descriptors/GPUPipelineLayoutDescriptor.h"
|
|
51
|
-
#include "descriptors/GPUQuerySetDescriptor.h"
|
|
52
|
-
#include "descriptors/GPURenderBundleEncoderDescriptor.h"
|
|
53
|
-
#include "descriptors/GPURenderPipelineDescriptor.h"
|
|
54
|
-
#include "descriptors/GPUSamplerDescriptor.h"
|
|
55
|
-
#include "descriptors/GPUShaderModuleDescriptor.h"
|
|
56
|
-
#include "descriptors/GPUSharedFenceDescriptor.h"
|
|
57
|
-
#include "descriptors/GPUSharedTextureMemoryDescriptor.h"
|
|
58
|
-
#include "descriptors/GPUTextureDescriptor.h"
|
|
59
|
-
|
|
60
|
-
namespace rnwgpu {
|
|
61
|
-
|
|
62
|
-
namespace jsi = facebook::jsi;
|
|
63
|
-
|
|
64
|
-
// Forward declaration
|
|
65
|
-
class GPUDevice;
|
|
66
|
-
|
|
67
|
-
// Static registry to map wgpu::Device handles to GPUDevice instances
|
|
68
|
-
class GPUDeviceRegistry {
|
|
69
|
-
public:
|
|
70
|
-
static GPUDeviceRegistry &getInstance() {
|
|
71
|
-
static GPUDeviceRegistry instance;
|
|
72
|
-
return instance;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
void registerDevice(WGPUDevice handle, GPUDevice *device) {
|
|
76
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
|
77
|
-
_devices[handle] = device;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
void unregisterDevice(WGPUDevice handle) {
|
|
81
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
|
82
|
-
_devices.erase(handle);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
GPUDevice *getDevice(WGPUDevice handle) {
|
|
86
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
|
87
|
-
auto it = _devices.find(handle);
|
|
88
|
-
return it != _devices.end() ? it->second : nullptr;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private:
|
|
92
|
-
GPUDeviceRegistry() = default;
|
|
93
|
-
std::mutex _mutex;
|
|
94
|
-
std::map<WGPUDevice, GPUDevice *> _devices;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
class GPUDevice : public NativeObject<GPUDevice> {
|
|
98
|
-
public:
|
|
99
|
-
static constexpr const char *CLASS_NAME = "GPUDevice";
|
|
100
|
-
|
|
101
|
-
explicit GPUDevice(wgpu::Device instance,
|
|
102
|
-
std::shared_ptr<async::RuntimeContext> async,
|
|
103
|
-
std::string label)
|
|
104
|
-
: NativeObject(CLASS_NAME), _instance(instance), _async(async),
|
|
105
|
-
_label(label) {
|
|
106
|
-
// Register this device in the global registry
|
|
107
|
-
GPUDeviceRegistry::getInstance().registerDevice(_instance.Get(), this);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
~GPUDevice() {
|
|
111
|
-
// Unregister from the global registry
|
|
112
|
-
GPUDeviceRegistry::getInstance().unregisterDevice(_instance.Get());
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public:
|
|
116
|
-
std::string getBrand() { return CLASS_NAME; }
|
|
117
|
-
|
|
118
|
-
void destroy();
|
|
119
|
-
std::shared_ptr<GPUBuffer>
|
|
120
|
-
createBuffer(std::shared_ptr<GPUBufferDescriptor> descriptor);
|
|
121
|
-
std::shared_ptr<GPUTexture>
|
|
122
|
-
createTexture(std::shared_ptr<GPUTextureDescriptor> descriptor);
|
|
123
|
-
std::shared_ptr<GPUSampler> createSampler(
|
|
124
|
-
std::optional<std::shared_ptr<GPUSamplerDescriptor>> descriptor);
|
|
125
|
-
std::shared_ptr<GPUExternalTexture> importExternalTexture(
|
|
126
|
-
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
127
|
-
std::shared_ptr<GPUSharedTextureMemory> importSharedTextureMemory(
|
|
128
|
-
std::shared_ptr<GPUSharedTextureMemoryDescriptor> descriptor);
|
|
129
|
-
std::shared_ptr<GPUSharedFence>
|
|
130
|
-
importSharedFence(std::shared_ptr<GPUSharedFenceDescriptor> descriptor);
|
|
131
|
-
std::shared_ptr<GPUBindGroupLayout> createBindGroupLayout(
|
|
132
|
-
std::shared_ptr<GPUBindGroupLayoutDescriptor> descriptor);
|
|
133
|
-
std::shared_ptr<GPUPipelineLayout>
|
|
134
|
-
createPipelineLayout(std::shared_ptr<GPUPipelineLayoutDescriptor> descriptor);
|
|
135
|
-
std::shared_ptr<GPUBindGroup>
|
|
136
|
-
createBindGroup(std::shared_ptr<GPUBindGroupDescriptor> descriptor);
|
|
137
|
-
std::shared_ptr<GPUShaderModule>
|
|
138
|
-
createShaderModule(std::shared_ptr<GPUShaderModuleDescriptor> descriptor);
|
|
139
|
-
std::shared_ptr<GPUComputePipeline> createComputePipeline(
|
|
140
|
-
std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
|
|
141
|
-
std::shared_ptr<GPURenderPipeline>
|
|
142
|
-
createRenderPipeline(std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
|
|
143
|
-
async::AsyncTaskHandle createComputePipelineAsync(
|
|
144
|
-
jsi::Runtime &runtime,
|
|
145
|
-
std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
|
|
146
|
-
async::AsyncTaskHandle createRenderPipelineAsync(
|
|
147
|
-
jsi::Runtime &runtime,
|
|
148
|
-
std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
|
|
149
|
-
std::shared_ptr<GPUCommandEncoder> createCommandEncoder(
|
|
150
|
-
std::optional<std::shared_ptr<GPUCommandEncoderDescriptor>> descriptor);
|
|
151
|
-
std::shared_ptr<GPURenderBundleEncoder> createRenderBundleEncoder(
|
|
152
|
-
std::shared_ptr<GPURenderBundleEncoderDescriptor> descriptor);
|
|
153
|
-
std::shared_ptr<GPUQuerySet>
|
|
154
|
-
createQuerySet(std::shared_ptr<GPUQuerySetDescriptor> descriptor);
|
|
155
|
-
void pushErrorScope(wgpu::ErrorFilter filter);
|
|
156
|
-
async::AsyncTaskHandle popErrorScope(jsi::Runtime &runtime);
|
|
157
|
-
|
|
158
|
-
std::unordered_set<std::string> getFeatures();
|
|
159
|
-
std::shared_ptr<GPUSupportedLimits> getLimits();
|
|
160
|
-
std::shared_ptr<GPUQueue> getQueue();
|
|
161
|
-
async::AsyncTaskHandle getLost();
|
|
162
|
-
void notifyDeviceLost(wgpu::DeviceLostReason reason, std::string message);
|
|
163
|
-
void forceLossForTesting();
|
|
164
|
-
|
|
165
|
-
// Event listener methods
|
|
166
|
-
void addEventListener(std::string type, jsi::Function callback);
|
|
167
|
-
void removeEventListener(std::string type, jsi::Function callback);
|
|
168
|
-
void notifyUncapturedError(GPUErrorVariant error);
|
|
169
|
-
|
|
170
|
-
std::string getLabel() { return _label; }
|
|
171
|
-
void setLabel(const std::string &label) {
|
|
172
|
-
_label = label;
|
|
173
|
-
_instance.SetLabel(_label.c_str());
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
177
|
-
installGetter(runtime, prototype, "__brand", &GPUDevice::getBrand);
|
|
178
|
-
installMethod(runtime, prototype, "destroy", &GPUDevice::destroy);
|
|
179
|
-
installMethod(runtime, prototype, "createBuffer", &GPUDevice::createBuffer);
|
|
180
|
-
installMethod(runtime, prototype, "createTexture",
|
|
181
|
-
&GPUDevice::createTexture);
|
|
182
|
-
installMethod(runtime, prototype, "createSampler",
|
|
183
|
-
&GPUDevice::createSampler);
|
|
184
|
-
installMethod(runtime, prototype, "importExternalTexture",
|
|
185
|
-
&GPUDevice::importExternalTexture);
|
|
186
|
-
installMethod(runtime, prototype, "importSharedTextureMemory",
|
|
187
|
-
&GPUDevice::importSharedTextureMemory);
|
|
188
|
-
installMethod(runtime, prototype, "importSharedFence",
|
|
189
|
-
&GPUDevice::importSharedFence);
|
|
190
|
-
installMethod(runtime, prototype, "createBindGroupLayout",
|
|
191
|
-
&GPUDevice::createBindGroupLayout);
|
|
192
|
-
installMethod(runtime, prototype, "createPipelineLayout",
|
|
193
|
-
&GPUDevice::createPipelineLayout);
|
|
194
|
-
installMethod(runtime, prototype, "createBindGroup",
|
|
195
|
-
&GPUDevice::createBindGroup);
|
|
196
|
-
installMethod(runtime, prototype, "createShaderModule",
|
|
197
|
-
&GPUDevice::createShaderModule);
|
|
198
|
-
installMethod(runtime, prototype, "createComputePipeline",
|
|
199
|
-
&GPUDevice::createComputePipeline);
|
|
200
|
-
installMethod(runtime, prototype, "createRenderPipeline",
|
|
201
|
-
&GPUDevice::createRenderPipeline);
|
|
202
|
-
installMethodWithRuntime(runtime, prototype, "createComputePipelineAsync",
|
|
203
|
-
&GPUDevice::createComputePipelineAsync);
|
|
204
|
-
installMethodWithRuntime(runtime, prototype, "createRenderPipelineAsync",
|
|
205
|
-
&GPUDevice::createRenderPipelineAsync);
|
|
206
|
-
installMethod(runtime, prototype, "createCommandEncoder",
|
|
207
|
-
&GPUDevice::createCommandEncoder);
|
|
208
|
-
installMethod(runtime, prototype, "createRenderBundleEncoder",
|
|
209
|
-
&GPUDevice::createRenderBundleEncoder);
|
|
210
|
-
installMethod(runtime, prototype, "createQuerySet",
|
|
211
|
-
&GPUDevice::createQuerySet);
|
|
212
|
-
installMethod(runtime, prototype, "pushErrorScope",
|
|
213
|
-
&GPUDevice::pushErrorScope);
|
|
214
|
-
installMethodWithRuntime(runtime, prototype, "popErrorScope",
|
|
215
|
-
&GPUDevice::popErrorScope);
|
|
216
|
-
installGetter(runtime, prototype, "features", &GPUDevice::getFeatures);
|
|
217
|
-
installGetter(runtime, prototype, "limits", &GPUDevice::getLimits);
|
|
218
|
-
installGetter(runtime, prototype, "queue", &GPUDevice::getQueue);
|
|
219
|
-
installGetter(runtime, prototype, "lost", &GPUDevice::getLost);
|
|
220
|
-
installGetterSetter(runtime, prototype, "label", &GPUDevice::getLabel,
|
|
221
|
-
&GPUDevice::setLabel);
|
|
222
|
-
installMethod(runtime, prototype, "forceLossForTesting",
|
|
223
|
-
&GPUDevice::forceLossForTesting);
|
|
224
|
-
installMethod(runtime, prototype, "addEventListener",
|
|
225
|
-
&GPUDevice::addEventListener);
|
|
226
|
-
installMethod(runtime, prototype, "removeEventListener",
|
|
227
|
-
&GPUDevice::removeEventListener);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
inline const wgpu::Device get() { return _instance; }
|
|
231
|
-
|
|
232
|
-
private:
|
|
233
|
-
friend class GPUAdapter;
|
|
234
|
-
|
|
235
|
-
// Runs the uncapturederror listeners on the creation runtime's JS thread.
|
|
236
|
-
// Invoked from notifyUncapturedError via the main CallInvoker.
|
|
237
|
-
void deliverUncapturedError(GPUErrorVariant error);
|
|
238
|
-
|
|
239
|
-
wgpu::Device _instance;
|
|
240
|
-
std::shared_ptr<async::RuntimeContext> _async;
|
|
241
|
-
std::string _label;
|
|
242
|
-
// Guards the device-lost state below. In the ProcessEvents model both
|
|
243
|
-
// notifyDeviceLost() (fired by Dawn during ProcessEvents) and getLost() run
|
|
244
|
-
// on the owning runtime's own thread, but device destruction can also trigger
|
|
245
|
-
// notifyDeviceLost() synchronously, so the mutex keeps these fields safe.
|
|
246
|
-
std::mutex _lostMutex;
|
|
247
|
-
std::optional<async::AsyncTaskHandle> _lostHandle;
|
|
248
|
-
std::shared_ptr<GPUDeviceLostInfo> _lostInfo;
|
|
249
|
-
bool _lostSettled = false;
|
|
250
|
-
std::optional<async::AsyncTaskHandle::ResolveFunction> _lostResolve;
|
|
251
|
-
|
|
252
|
-
// Event listeners storage
|
|
253
|
-
std::mutex _listenersMutex;
|
|
254
|
-
std::map<std::string, std::vector<std::shared_ptr<jsi::Function>>>
|
|
255
|
-
_eventListeners;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
} // namespace rnwgpu
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <string>
|
|
4
|
-
|
|
5
|
-
#include "descriptors/Unions.h"
|
|
6
|
-
|
|
7
|
-
#include "jsi/NativeObject.h"
|
|
8
|
-
|
|
9
|
-
#include "webgpu/webgpu_cpp.h"
|
|
10
|
-
|
|
11
|
-
namespace rnwgpu {
|
|
12
|
-
|
|
13
|
-
namespace jsi = facebook::jsi;
|
|
14
|
-
|
|
15
|
-
class GPUDeviceLostInfo : public NativeObject<GPUDeviceLostInfo> {
|
|
16
|
-
public:
|
|
17
|
-
static constexpr const char *CLASS_NAME = "GPUDeviceLostInfo";
|
|
18
|
-
|
|
19
|
-
explicit GPUDeviceLostInfo(wgpu::DeviceLostReason reason, std::string message)
|
|
20
|
-
: NativeObject(CLASS_NAME), _reason(reason), _message(message) {}
|
|
21
|
-
|
|
22
|
-
public:
|
|
23
|
-
std::string getBrand() { return CLASS_NAME; }
|
|
24
|
-
|
|
25
|
-
wgpu::DeviceLostReason getReason() { return _reason; }
|
|
26
|
-
std::string getMessage() { return _message; }
|
|
27
|
-
|
|
28
|
-
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
29
|
-
installGetter(runtime, prototype, "__brand", &GPUDeviceLostInfo::getBrand);
|
|
30
|
-
installGetter(runtime, prototype, "reason", &GPUDeviceLostInfo::getReason);
|
|
31
|
-
installGetter(runtime, prototype, "message",
|
|
32
|
-
&GPUDeviceLostInfo::getMessage);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private:
|
|
36
|
-
wgpu::DeviceLostReason _reason;
|
|
37
|
-
std::string _message;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
} // namespace rnwgpu
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <string>
|
|
4
|
-
|
|
5
|
-
#include "jsi/NativeObject.h"
|
|
6
|
-
|
|
7
|
-
namespace rnwgpu {
|
|
8
|
-
|
|
9
|
-
namespace jsi = facebook::jsi;
|
|
10
|
-
|
|
11
|
-
class GPUError : public NativeObject<GPUError> {
|
|
12
|
-
public:
|
|
13
|
-
static constexpr const char *CLASS_NAME = "GPUError";
|
|
14
|
-
|
|
15
|
-
explicit GPUError(std::string message)
|
|
16
|
-
: NativeObject(CLASS_NAME), _message(std::move(message)) {}
|
|
17
|
-
|
|
18
|
-
public:
|
|
19
|
-
std::string getBrand() { return CLASS_NAME; }
|
|
20
|
-
std::string getMessage() { return _message; }
|
|
21
|
-
|
|
22
|
-
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
23
|
-
installGetter(runtime, prototype, "__brand", &GPUError::getBrand);
|
|
24
|
-
installGetter(runtime, prototype, "message", &GPUError::getMessage);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
protected:
|
|
28
|
-
// Protected constructor for subclasses
|
|
29
|
-
GPUError(const char *className, std::string message)
|
|
30
|
-
: NativeObject(className), _message(std::move(message)) {}
|
|
31
|
-
|
|
32
|
-
std::string _message;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
} // namespace rnwgpu
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
|
|
5
|
-
#include "jsi/JSIConverter.h"
|
|
6
|
-
|
|
7
|
-
#include "webgpu/webgpu_cpp.h"
|
|
8
|
-
|
|
9
|
-
namespace rnwgpu {
|
|
10
|
-
|
|
11
|
-
struct GPUExtent3D {
|
|
12
|
-
double width;
|
|
13
|
-
double height = 1;
|
|
14
|
-
double depthOrArrayLayers = 1;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
template <> struct JSIConverter<std::shared_ptr<GPUExtent3D>> {
|
|
18
|
-
static std::shared_ptr<GPUExtent3D>
|
|
19
|
-
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
20
|
-
auto result = std::make_unique<GPUExtent3D>();
|
|
21
|
-
if (!outOfBounds && arg.isObject()) {
|
|
22
|
-
if (arg.getObject(runtime).isArray(runtime)) {
|
|
23
|
-
auto array = arg.getObject(runtime).asArray(runtime);
|
|
24
|
-
auto size = array.size(runtime);
|
|
25
|
-
if (size == 0) {
|
|
26
|
-
throw std::runtime_error(
|
|
27
|
-
"Expected an array of size >1 for GPUTExtent3D");
|
|
28
|
-
}
|
|
29
|
-
if (size > 0) {
|
|
30
|
-
result->width = array.getValueAtIndex(runtime, 0).asNumber();
|
|
31
|
-
}
|
|
32
|
-
if (size > 1) {
|
|
33
|
-
result->height = array.getValueAtIndex(runtime, 1).asNumber();
|
|
34
|
-
}
|
|
35
|
-
if (size > 2) {
|
|
36
|
-
result->depthOrArrayLayers =
|
|
37
|
-
array.getValueAtIndex(runtime, 2).asNumber();
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
auto object = arg.getObject(runtime);
|
|
41
|
-
if (object.hasProperty(runtime, "width")) {
|
|
42
|
-
result->width = object.getProperty(runtime, "width").asNumber();
|
|
43
|
-
} else {
|
|
44
|
-
throw std::runtime_error("Property GPUTExtent3D::width is required");
|
|
45
|
-
}
|
|
46
|
-
if (object.hasProperty(runtime, "height")) {
|
|
47
|
-
result->height = object.getProperty(runtime, "height").asNumber();
|
|
48
|
-
}
|
|
49
|
-
if (object.hasProperty(runtime, "depthOrArrayLayers")) {
|
|
50
|
-
result->depthOrArrayLayers =
|
|
51
|
-
object.getProperty(runtime, "depthOrArrayLayers").asNumber();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
throw std::runtime_error("Expected an object for GPUTExtent3D");
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
60
|
-
std::shared_ptr<GPUExtent3D> arg) {
|
|
61
|
-
// No conversions here
|
|
62
|
-
return jsi::Value::null();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
} // namespace rnwgpu
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#include "GPUExternalTexture.h"
|
|
2
|
-
|
|
3
|
-
#include <cmath>
|
|
4
|
-
#include <memory>
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <utility>
|
|
7
|
-
|
|
8
|
-
#include "NativeBufferUtils.h"
|
|
9
|
-
#include "descriptors/GPUExternalTextureDescriptor.h"
|
|
10
|
-
|
|
11
|
-
namespace rnwgpu {
|
|
12
|
-
|
|
13
|
-
// Identity gamut (same primaries) as a 3x3 column-major matrix.
|
|
14
|
-
static const float kIdentityGamutMatrix[9] = {
|
|
15
|
-
1.0f, 0.0f, 0.0f, //
|
|
16
|
-
0.0f, 1.0f, 0.0f, //
|
|
17
|
-
0.0f, 0.0f, 1.0f, //
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Identity transfer (y = x). The native buffers produced by Skia's NativeBuffer
|
|
21
|
-
// API are single-plane BGRA/RGBA already in the render target's color space, so
|
|
22
|
-
// no conversion is wanted. Dawn dereferences the transfer-function arrays
|
|
23
|
-
// unconditionally (ComputeExternalTextureParams), so these must be non-null.
|
|
24
|
-
static const float kIdentityTransferParams[7] = {
|
|
25
|
-
1.0f, // G
|
|
26
|
-
1.0f, // A
|
|
27
|
-
0.0f, // B
|
|
28
|
-
0.0f, // C
|
|
29
|
-
0.0f, // D
|
|
30
|
-
0.0f, // E
|
|
31
|
-
0.0f, // F
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Map a rotation in degrees (0 / 90 / 180 / 270) to Dawn's enum. Anything that
|
|
35
|
-
// isn't a clean multiple of 90 snaps to the nearest quadrant; Dawn only
|
|
36
|
-
// supports those four steps for external textures.
|
|
37
|
-
static wgpu::ExternalTextureRotation toExternalTextureRotation(double degrees) {
|
|
38
|
-
int quadrant = static_cast<int>(std::lround(degrees / 90.0));
|
|
39
|
-
quadrant = ((quadrant % 4) + 4) % 4;
|
|
40
|
-
switch (quadrant) {
|
|
41
|
-
case 1:
|
|
42
|
-
return wgpu::ExternalTextureRotation::Rotate90Degrees;
|
|
43
|
-
case 2:
|
|
44
|
-
return wgpu::ExternalTextureRotation::Rotate180Degrees;
|
|
45
|
-
case 3:
|
|
46
|
-
return wgpu::ExternalTextureRotation::Rotate270Degrees;
|
|
47
|
-
default:
|
|
48
|
-
return wgpu::ExternalTextureRotation::Rotate0Degrees;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
std::shared_ptr<GPUExternalTexture> GPUExternalTexture::Create(
|
|
53
|
-
wgpu::Device device,
|
|
54
|
-
std::shared_ptr<GPUExternalTextureDescriptor> descriptor) {
|
|
55
|
-
if (!descriptor || descriptor->source == 0) {
|
|
56
|
-
throw std::runtime_error(
|
|
57
|
-
"GPUExternalTexture::Create(): descriptor.source (a native buffer "
|
|
58
|
-
"pointer from Skia.NativeBuffer.MakeFromImage) is required");
|
|
59
|
-
}
|
|
60
|
-
void *bufferPtr =
|
|
61
|
-
reinterpret_cast<void *>(static_cast<uintptr_t>(descriptor->source));
|
|
62
|
-
std::string label = descriptor->label.value_or("external-texture");
|
|
63
|
-
|
|
64
|
-
// 1. Import the native buffer as SharedTextureMemory and read its dimensions.
|
|
65
|
-
uint32_t width = 0;
|
|
66
|
-
uint32_t height = 0;
|
|
67
|
-
wgpu::SharedTextureMemory memory = importNativeBufferAsSharedTextureMemory(
|
|
68
|
-
device, bufferPtr, label, &width, &height);
|
|
69
|
-
if (memory == nullptr) {
|
|
70
|
-
throw std::runtime_error(
|
|
71
|
-
"GPUExternalTexture::Create(): ImportSharedTextureMemory returned "
|
|
72
|
-
"null");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 2. Create the texture from the surface (Dawn picks the single-plane
|
|
76
|
-
// BGRA/RGBA format).
|
|
77
|
-
auto texture = memory.CreateTexture();
|
|
78
|
-
if (texture == nullptr) {
|
|
79
|
-
throw std::runtime_error(
|
|
80
|
-
"GPUExternalTexture::Create(): CreateTexture returned null");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 3. Begin access. The matching EndAccess runs when the GPUExternalTexture is
|
|
84
|
-
// destroyed (explicitly via destroy() or at GC).
|
|
85
|
-
wgpu::SharedTextureMemoryBeginAccessDescriptor begin{};
|
|
86
|
-
begin.initialized = true;
|
|
87
|
-
begin.concurrentRead = false;
|
|
88
|
-
#if defined(__ANDROID__)
|
|
89
|
-
// Dawn's Vulkan backend requires the acquired VkImageLayout to be chained.
|
|
90
|
-
// UNDEFINED (= 0) on both ends is the canonical "no prior GPU producer"
|
|
91
|
-
// pattern (matches GPUSharedTextureMemory::beginAccess).
|
|
92
|
-
wgpu::SharedTextureMemoryVkImageLayoutBeginState vkBegin{};
|
|
93
|
-
vkBegin.oldLayout = 0;
|
|
94
|
-
vkBegin.newLayout = 0;
|
|
95
|
-
begin.nextInChain = &vkBegin;
|
|
96
|
-
#endif
|
|
97
|
-
if (!memory.BeginAccess(texture, &begin)) {
|
|
98
|
-
throw std::runtime_error(
|
|
99
|
-
"GPUExternalTexture::Create(): BeginAccess failed");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 4. Single-plane view (the whole BGRA/RGBA surface).
|
|
103
|
-
auto plane0 = texture.CreateView();
|
|
104
|
-
|
|
105
|
-
// 5. Build the ExternalTextureDescriptor. The surface is already RGB in the
|
|
106
|
-
// target color space, so pass it through with identity transfer/gamut.
|
|
107
|
-
wgpu::ExternalTextureDescriptor extDesc{};
|
|
108
|
-
if (!label.empty()) {
|
|
109
|
-
extDesc.label = wgpu::StringView(label.c_str(), label.size());
|
|
110
|
-
}
|
|
111
|
-
extDesc.plane0 = plane0;
|
|
112
|
-
extDesc.gamutConversionMatrix = kIdentityGamutMatrix;
|
|
113
|
-
extDesc.srcTransferFunctionParameters = kIdentityTransferParams;
|
|
114
|
-
extDesc.dstTransferFunctionParameters = kIdentityTransferParams;
|
|
115
|
-
extDesc.cropOrigin = {0, 0};
|
|
116
|
-
extDesc.cropSize = {width, height};
|
|
117
|
-
extDesc.apparentSize = {width, height};
|
|
118
|
-
extDesc.mirrored = descriptor->mirrored.value_or(false);
|
|
119
|
-
extDesc.rotation =
|
|
120
|
-
toExternalTextureRotation(descriptor->rotation.value_or(0));
|
|
121
|
-
|
|
122
|
-
auto external = device.CreateExternalTexture(&extDesc);
|
|
123
|
-
if (external == nullptr) {
|
|
124
|
-
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
125
|
-
#if defined(__ANDROID__)
|
|
126
|
-
wgpu::SharedTextureMemoryVkImageLayoutEndState vkEnd{};
|
|
127
|
-
state.nextInChain = &vkEnd;
|
|
128
|
-
#endif
|
|
129
|
-
(void)memory.EndAccess(texture, &state);
|
|
130
|
-
throw std::runtime_error(
|
|
131
|
-
"GPUExternalTexture::Create(): CreateExternalTexture returned null");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return std::make_shared<GPUExternalTexture>(
|
|
135
|
-
std::move(external), std::move(memory), std::move(texture),
|
|
136
|
-
std::move(label));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
} // namespace rnwgpu
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <string>
|
|
5
|
-
#include <utility>
|
|
6
|
-
|
|
7
|
-
#include "descriptors/Unions.h"
|
|
8
|
-
|
|
9
|
-
#include "jsi/NativeObject.h"
|
|
10
|
-
|
|
11
|
-
#include "webgpu/webgpu_cpp.h"
|
|
12
|
-
|
|
13
|
-
namespace rnwgpu {
|
|
14
|
-
|
|
15
|
-
namespace jsi = facebook::jsi;
|
|
16
|
-
|
|
17
|
-
struct GPUExternalTextureDescriptor;
|
|
18
|
-
|
|
19
|
-
class GPUExternalTexture : public NativeObject<GPUExternalTexture> {
|
|
20
|
-
public:
|
|
21
|
-
static constexpr const char *CLASS_NAME = "GPUExternalTexture";
|
|
22
|
-
|
|
23
|
-
// Import a native buffer (via descriptor.source, a CVPixelBufferRef /
|
|
24
|
-
// AHardwareBuffer* from Skia's NativeBuffer API) as a GPUExternalTexture on
|
|
25
|
-
// `device`: imports the native surface as SharedTextureMemory, begins access,
|
|
26
|
-
// and wraps the resulting wgpu::ExternalTexture together with the resources
|
|
27
|
-
// whose lifetime it owns. The matching EndAccess runs in destroy() / the
|
|
28
|
-
// destructor. Defined in GPUExternalTexture.cpp.
|
|
29
|
-
static std::shared_ptr<GPUExternalTexture>
|
|
30
|
-
Create(wgpu::Device device,
|
|
31
|
-
std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
|
|
32
|
-
|
|
33
|
-
// Construct from an already-built wgpu::ExternalTexture plus the underlying
|
|
34
|
-
// shared-memory resources we need to keep alive. The wrapper takes ownership
|
|
35
|
-
// of the SharedTextureMemory + Texture and calls EndAccess on destruction so
|
|
36
|
-
// the producer (the native buffer's surface) can reclaim it.
|
|
37
|
-
GPUExternalTexture(wgpu::ExternalTexture instance,
|
|
38
|
-
wgpu::SharedTextureMemory memory, wgpu::Texture texture,
|
|
39
|
-
std::string label)
|
|
40
|
-
: NativeObject(CLASS_NAME), _instance(std::move(instance)),
|
|
41
|
-
_memory(std::move(memory)), _texture(std::move(texture)),
|
|
42
|
-
_label(std::move(label)) {}
|
|
43
|
-
|
|
44
|
-
~GPUExternalTexture() override { destroy(); }
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
std::string getBrand() { return CLASS_NAME; }
|
|
48
|
-
|
|
49
|
-
// End the shared-memory access window and release the underlying resources.
|
|
50
|
-
// Idempotent: safe to call more than once, and the destructor calls it as a
|
|
51
|
-
// garbage-collection fallback. Call it right after the queue.submit() that
|
|
52
|
-
// sampled this texture (never before): a GPUExternalTexture's access window
|
|
53
|
-
// is owned by this wrapper's lifetime, not by submit, so without an explicit
|
|
54
|
-
// destroy() the producer's surface stays claimed until GC runs. EndAccess is
|
|
55
|
-
// the designed post-submit call: Dawn keeps the texture alive for in-flight
|
|
56
|
-
// GPU work via the fences it returns.
|
|
57
|
-
void destroy() {
|
|
58
|
-
if (_memory && _texture) {
|
|
59
|
-
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
60
|
-
#if defined(__ANDROID__)
|
|
61
|
-
// Dawn's Vulkan backend requires the released VkImageLayout to be chained
|
|
62
|
-
// (matches BeginAccess in GPUExternalTexture::Create).
|
|
63
|
-
wgpu::SharedTextureMemoryVkImageLayoutEndState vkEnd{};
|
|
64
|
-
state.nextInChain = &vkEnd;
|
|
65
|
-
#endif
|
|
66
|
-
(void)_memory.EndAccess(_texture, &state);
|
|
67
|
-
}
|
|
68
|
-
_texture = nullptr;
|
|
69
|
-
_memory = nullptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
std::string getLabel() { return _label; }
|
|
73
|
-
void setLabel(const std::string &label) {
|
|
74
|
-
_label = label;
|
|
75
|
-
_instance.SetLabel(_label.c_str());
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
79
|
-
installGetter(runtime, prototype, "__brand", &GPUExternalTexture::getBrand);
|
|
80
|
-
installGetterSetter(runtime, prototype, "label",
|
|
81
|
-
&GPUExternalTexture::getLabel,
|
|
82
|
-
&GPUExternalTexture::setLabel);
|
|
83
|
-
installMethod(runtime, prototype, "destroy", &GPUExternalTexture::destroy);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
inline const wgpu::ExternalTexture get() { return _instance; }
|
|
87
|
-
|
|
88
|
-
private:
|
|
89
|
-
wgpu::ExternalTexture _instance;
|
|
90
|
-
wgpu::SharedTextureMemory _memory;
|
|
91
|
-
wgpu::Texture _texture;
|
|
92
|
-
std::string _label;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
} // namespace rnwgpu
|