react-native-webgpu 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +319 -0
- package/android/CMakeLists.txt +108 -0
- package/android/build.gradle +138 -0
- package/android/cpp/AndroidPlatformContext.h +207 -0
- package/android/cpp/cpp-adapter.cpp +71 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +298 -0
- package/android/src/main/java/com/webgpu/WebGPUAPI.java +20 -0
- package/android/src/main/java/com/webgpu/WebGPUBaseView.java +61 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +50 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceView.java +41 -0
- package/android/src/main/java/com/webgpu/WebGPUSurfaceViewWithSC.java +79 -0
- package/android/src/main/java/com/webgpu/WebGPUTextureView.java +46 -0
- package/android/src/main/java/com/webgpu/WebGPUView.java +108 -0
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +38 -0
- package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +50 -0
- package/android/src/newarch/com/webgpu/WebGPUViewManagerSpec.java +24 -0
- package/apple/ApplePlatformContext.h +31 -0
- package/apple/ApplePlatformContext.mm +157 -0
- package/apple/MetalView.h +13 -0
- package/apple/MetalView.mm +50 -0
- package/apple/RNWGUIKit.h +16 -0
- package/apple/WebGPUModule.h +13 -0
- package/apple/WebGPUModule.mm +89 -0
- package/apple/WebGPUView.h +12 -0
- package/apple/WebGPUView.mm +66 -0
- package/cpp/WGPULogger.h +100 -0
- package/cpp/dawn_logging.cpp +119 -0
- package/cpp/jsi/EnumMapper.h +45 -0
- package/cpp/jsi/JSIConverter.h +473 -0
- package/cpp/jsi/NativeObject.h +607 -0
- package/cpp/jsi/Promise.cpp +44 -0
- package/cpp/jsi/Promise.h +35 -0
- package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
- package/cpp/jsi/RuntimeAwareCache.h +100 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
- package/cpp/rnwgpu/ArrayBuffer.h +73 -0
- package/cpp/rnwgpu/PlatformContext.h +46 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +225 -0
- package/cpp/rnwgpu/RNWebGPUManager.h +46 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +230 -0
- package/cpp/rnwgpu/api/Canvas.h +57 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +127 -0
- package/cpp/rnwgpu/api/GPU.h +58 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +191 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +67 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +66 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +492 -0
- package/cpp/rnwgpu/api/GPUDevice.h +259 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +203 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +81 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +162 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +71 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +40 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +199 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +78 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +98 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +76 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +68 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +100 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +70 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +44 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +102 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +93 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +111 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +63 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +74 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1969 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +215 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +53 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/cpp/webgpu/webgpu.h +4918 -0
- package/cpp/webgpu/webgpu_cpp.h +10294 -0
- package/cpp/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/webgpu/webgpu_cpp_print.h +2755 -0
- package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/lib/commonjs/Canvas.js +55 -0
- package/lib/commonjs/Canvas.js.map +1 -0
- package/lib/commonjs/NativeWebGPUModule.js +10 -0
- package/lib/commonjs/NativeWebGPUModule.js.map +1 -0
- package/lib/commonjs/Offscreen.js +103 -0
- package/lib/commonjs/Offscreen.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js +10 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js +103 -0
- package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/WebPolyfillGPUModule.js +40 -0
- package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -0
- package/lib/commonjs/external/ModuleProxy.js +36 -0
- package/lib/commonjs/external/ModuleProxy.js.map +1 -0
- package/lib/commonjs/external/index.js +17 -0
- package/lib/commonjs/external/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/index.js +21 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +49 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/commonjs/hooks.js +83 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/main/index.js +91 -0
- package/lib/commonjs/main/index.js.map +1 -0
- package/lib/commonjs/main/index.web.js +51 -0
- package/lib/commonjs/main/index.web.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +11 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/Canvas.js +46 -0
- package/lib/module/Canvas.js.map +1 -0
- package/lib/module/NativeWebGPUModule.js +4 -0
- package/lib/module/NativeWebGPUModule.js.map +1 -0
- package/lib/module/Offscreen.js +96 -0
- package/lib/module/Offscreen.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.js +4 -0
- package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.web.js +96 -0
- package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/module/WebPolyfillGPUModule.js +38 -0
- package/lib/module/WebPolyfillGPUModule.js.map +1 -0
- package/lib/module/external/ModuleProxy.js +28 -0
- package/lib/module/external/ModuleProxy.js.map +1 -0
- package/lib/module/external/index.js +2 -0
- package/lib/module/external/index.js.map +1 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/module/external/reanimated/index.js +3 -0
- package/lib/module/external/reanimated/index.js.map +1 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js +42 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/module/hooks.js +70 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/main/index.js +33 -0
- package/lib/module/main/index.js.map +1 -0
- package/lib/module/main/index.web.js +8 -0
- package/lib/module/main/index.web.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +5 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +3 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/eslint.config.d.mts +3 -0
- package/lib/typescript/eslint.config.d.mts.map +1 -0
- package/lib/typescript/jest.config.d.ts +9 -0
- package/lib/typescript/jest.config.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts +7 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts +5 -0
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts +26 -0
- package/lib/typescript/lib/commonjs/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +5 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts +4 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/commonjs/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts +18 -0
- package/lib/typescript/lib/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/main/index.d.ts +3 -0
- package/lib/typescript/lib/commonjs/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts +2 -0
- package/lib/typescript/lib/commonjs/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/utils.d.ts +3 -0
- package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
- package/lib/typescript/lib/module/Canvas.d.ts +8 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts +3 -0
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/Offscreen.d.ts +25 -0
- package/lib/typescript/lib/module/Offscreen.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/lib/module/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/index.d.ts +2 -0
- package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/module/hooks.d.ts +18 -0
- package/lib/typescript/lib/module/hooks.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.d.ts +6 -0
- package/lib/typescript/lib/module/main/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.web.d.ts +5 -0
- package/lib/typescript/lib/module/main/index.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/types.d.ts +1 -0
- package/lib/typescript/lib/module/types.d.ts.map +1 -0
- package/lib/typescript/lib/module/utils.d.ts +2 -0
- package/lib/typescript/lib/module/utils.d.ts.map +1 -0
- package/lib/typescript/src/Canvas.d.ts +35 -0
- package/lib/typescript/src/Canvas.d.ts.map +1 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts +7 -0
- package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/Offscreen.d.ts +30 -0
- package/lib/typescript/src/Offscreen.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +9 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +9 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts +2 -0
- package/lib/typescript/src/WebPolyfillGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/index.d.ts +2 -0
- package/lib/typescript/src/external/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +27 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/main/index.d.ts +6 -0
- package/lib/typescript/src/main/index.d.ts.map +1 -0
- package/lib/typescript/src/main/index.web.d.ts +6 -0
- package/lib/typescript/src/main/index.web.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +19 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +59 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/package.json +139 -0
- package/react-native-wgpu.podspec +47 -0
- package/src/Canvas.tsx +91 -0
- package/src/NativeWebGPUModule.ts +9 -0
- package/src/Offscreen.ts +113 -0
- package/src/WebGPUViewNativeComponent.ts +11 -0
- package/src/WebGPUViewNativeComponent.web.ts +113 -0
- package/src/WebPolyfillGPUModule.ts +53 -0
- package/src/external/ModuleProxy.ts +30 -0
- package/src/external/index.ts +1 -0
- package/src/external/reanimated/ReanimatedProxy.ts +19 -0
- package/src/external/reanimated/index.ts +2 -0
- package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
- package/src/hooks.tsx +93 -0
- package/src/index.tsx +31 -0
- package/src/main/index.tsx +40 -0
- package/src/main/index.web.tsx +8 -0
- package/src/types.ts +20 -0
- package/src/utils.ts +4 -0
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <optional>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <variant>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
#include "webgpu/webgpu_cpp.h"
|
|
12
|
+
|
|
13
|
+
#include "GPUBindGroupDescriptor.h"
|
|
14
|
+
#include "GPUBindGroupEntry.h"
|
|
15
|
+
#include "GPUBindGroupLayoutDescriptor.h"
|
|
16
|
+
#include "GPUBindGroupLayoutEntry.h"
|
|
17
|
+
#include "GPUBlendComponent.h"
|
|
18
|
+
#include "GPUBlendState.h"
|
|
19
|
+
#include "GPUBufferBinding.h"
|
|
20
|
+
#include "GPUBufferBindingLayout.h"
|
|
21
|
+
#include "GPUBufferDescriptor.h"
|
|
22
|
+
#include "GPUColor.h"
|
|
23
|
+
#include "GPUColorTargetState.h"
|
|
24
|
+
#include "GPUCommandBufferDescriptor.h"
|
|
25
|
+
#include "GPUCommandEncoderDescriptor.h"
|
|
26
|
+
#include "GPUComputePassDescriptor.h"
|
|
27
|
+
#include "GPUComputePassTimestampWrites.h"
|
|
28
|
+
#include "GPUComputePipelineDescriptor.h"
|
|
29
|
+
#include "GPUDepthStencilState.h"
|
|
30
|
+
#include "GPUDeviceDescriptor.h"
|
|
31
|
+
#include "GPUExternalTextureBindingLayout.h"
|
|
32
|
+
#include "GPUFragmentState.h"
|
|
33
|
+
#include "GPUImageCopyBuffer.h"
|
|
34
|
+
#include "GPUImageCopyTexture.h"
|
|
35
|
+
#include "GPUImageCopyTextureTagged.h"
|
|
36
|
+
#include "GPUImageDataLayout.h"
|
|
37
|
+
#include "GPUMultisampleState.h"
|
|
38
|
+
#include "GPUPipelineLayoutDescriptor.h"
|
|
39
|
+
#include "GPUPrimitiveState.h"
|
|
40
|
+
#include "GPUProgrammableStage.h"
|
|
41
|
+
#include "GPUQuerySetDescriptor.h"
|
|
42
|
+
#include "GPUQueueDescriptor.h"
|
|
43
|
+
#include "GPURenderBundleDescriptor.h"
|
|
44
|
+
#include "GPURenderBundleEncoderDescriptor.h"
|
|
45
|
+
#include "GPURenderPassColorAttachment.h"
|
|
46
|
+
#include "GPURenderPassDepthStencilAttachment.h"
|
|
47
|
+
#include "GPURenderPassDescriptor.h"
|
|
48
|
+
#include "GPURenderPassTimestampWrites.h"
|
|
49
|
+
#include "GPURenderPipelineDescriptor.h"
|
|
50
|
+
#include "GPURequestAdapterOptions.h"
|
|
51
|
+
#include "GPUSamplerBindingLayout.h"
|
|
52
|
+
#include "GPUSamplerDescriptor.h"
|
|
53
|
+
#include "GPUShaderModuleCompilationHint.h"
|
|
54
|
+
#include "GPUShaderModuleDescriptor.h"
|
|
55
|
+
#include "GPUStencilFaceState.h"
|
|
56
|
+
#include "GPUStorageTextureBindingLayout.h"
|
|
57
|
+
#include "GPUTextureBindingLayout.h"
|
|
58
|
+
#include "GPUTextureDescriptor.h"
|
|
59
|
+
#include "GPUTextureViewDescriptor.h"
|
|
60
|
+
#include "GPUVertexAttribute.h"
|
|
61
|
+
#include "GPUVertexBufferLayout.h"
|
|
62
|
+
#include "GPUVertexState.h"
|
|
63
|
+
#include "Unions.h"
|
|
64
|
+
|
|
65
|
+
namespace rnwgpu {
|
|
66
|
+
|
|
67
|
+
class Convertor {
|
|
68
|
+
public:
|
|
69
|
+
~Convertor() {
|
|
70
|
+
for (auto &free : free_) {
|
|
71
|
+
free();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
template <typename OUT, typename IN>
|
|
76
|
+
[[nodiscard]] inline bool operator()(OUT &&out, IN &&in) {
|
|
77
|
+
return Convert(std::forward<OUT>(out), std::forward<IN>(in));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
template <typename OUT, typename IN>
|
|
81
|
+
[[nodiscard]] inline bool operator()(OUT *&out_els, size_t &out_count,
|
|
82
|
+
const std::vector<IN> &in) {
|
|
83
|
+
return Convert(out_els, out_count, in);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
template <typename OUT, typename IN>
|
|
87
|
+
[[nodiscard]] inline bool Convert(OUT *&out_els, size_t &out_count,
|
|
88
|
+
const std::optional<std::vector<IN>> &in) {
|
|
89
|
+
if (!in.has_value()) {
|
|
90
|
+
out_els = nullptr;
|
|
91
|
+
out_count = 0;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return Convert(out_els, out_count, in.value());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
template <typename OUT, typename IN>
|
|
98
|
+
[[nodiscard]] inline bool Convert(OUT *&out_els, size_t &out_count,
|
|
99
|
+
const std::vector<IN> &in) {
|
|
100
|
+
if (in.size() == 0) {
|
|
101
|
+
out_els = nullptr;
|
|
102
|
+
out_count = 0;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
auto *els = Allocate<std::remove_const_t<OUT>>(in.size());
|
|
106
|
+
for (size_t i = 0; i < in.size(); i++) {
|
|
107
|
+
if (!Convert(els[i], in[i])) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
out_els = els;
|
|
112
|
+
return Convert(out_count, in.size());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
template <typename OUT, typename IN>
|
|
116
|
+
[[nodiscard]] inline bool
|
|
117
|
+
Convert(OUT *&out_els, size_t &out_count,
|
|
118
|
+
const std::vector<std::variant<std::nullptr_t, IN>> &in) {
|
|
119
|
+
std::vector<IN> filtered;
|
|
120
|
+
filtered.reserve(in.size());
|
|
121
|
+
|
|
122
|
+
for (const auto &item : in) {
|
|
123
|
+
if (auto ptr = std::get_if<IN>(&item)) {
|
|
124
|
+
filtered.push_back(*ptr);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return Convert(out_els, out_count, filtered);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
template <typename OUT, typename INKEY, typename INVALUE>
|
|
132
|
+
[[nodiscard]] inline bool
|
|
133
|
+
Convert(OUT *&out_els, size_t &out_count,
|
|
134
|
+
const std::optional<std::map<INKEY, INVALUE>> &in) {
|
|
135
|
+
if (!in.has_value() || in.value().size() == 0) {
|
|
136
|
+
out_els = nullptr;
|
|
137
|
+
out_count = 0;
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
auto val = in.value();
|
|
141
|
+
auto *els = Allocate<std::remove_const_t<OUT>>(val.size());
|
|
142
|
+
size_t i = 0;
|
|
143
|
+
for (const auto &item : val) {
|
|
144
|
+
if (!Convert(els[i], item.first, item.second)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
i++;
|
|
148
|
+
}
|
|
149
|
+
out_els = els;
|
|
150
|
+
return Convert(out_count, val.size());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
template <typename T>
|
|
154
|
+
[[nodiscard]] auto Convert(T &out, const std::nullptr_t &in) {
|
|
155
|
+
out = nullptr;
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[[nodiscard]] bool Convert(wgpu::Bool &out, const bool &in) {
|
|
160
|
+
out = in;
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
template <typename T>
|
|
165
|
+
[[nodiscard]] typename std::enable_if<
|
|
166
|
+
(std::is_arithmetic<T>::value || std::is_enum<T>::value), bool>::type
|
|
167
|
+
Convert(T &out, const double &in) {
|
|
168
|
+
out = static_cast<T>(in);
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
template <typename T>
|
|
173
|
+
[[nodiscard]] typename std::enable_if<std::is_enum<T>::value, bool>::type
|
|
174
|
+
Convert(T &out, const T &in) {
|
|
175
|
+
out = in;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
[[nodiscard]] bool Convert(wgpu::OptionalBool &out,
|
|
180
|
+
const std::optional<bool> &in) {
|
|
181
|
+
out = in;
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
[[nodiscard]] bool Convert(wgpu::StringView &out, const std::string &in) {
|
|
186
|
+
out = {in.data(), in.size()};
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
[[nodiscard]] bool Convert(const char *&out, const std::string &in) {
|
|
191
|
+
out = in.c_str();
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
template <typename OUT, typename IN>
|
|
196
|
+
[[nodiscard]] bool Convert(OUT &out, const std::optional<IN> &in) {
|
|
197
|
+
if (in.has_value()) {
|
|
198
|
+
return Convert(out, in.value());
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
template <typename T, typename = void>
|
|
204
|
+
struct has_get_member : std::false_type {};
|
|
205
|
+
|
|
206
|
+
template <typename T>
|
|
207
|
+
struct has_get_member<T, std::void_t<decltype(std::declval<T>().get())>>
|
|
208
|
+
: std::true_type {};
|
|
209
|
+
|
|
210
|
+
template <typename OUT, typename IN>
|
|
211
|
+
[[nodiscard]] bool Convert(OUT &out, const std::shared_ptr<IN> &in) {
|
|
212
|
+
if constexpr (has_get_member<IN>::value) {
|
|
213
|
+
out = in->get();
|
|
214
|
+
return true;
|
|
215
|
+
} else {
|
|
216
|
+
return Convert(out, *in);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
template <typename OUT, typename IN,
|
|
221
|
+
typename _ = std::enable_if_t<!std::is_same_v<IN, std::string>>>
|
|
222
|
+
[[nodiscard]] inline bool Convert(OUT *&out, const std::optional<IN> &in) {
|
|
223
|
+
if (in.has_value()) {
|
|
224
|
+
auto *el = Allocate<std::remove_const_t<OUT>>();
|
|
225
|
+
if (!Convert(*el, in.value())) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
out = el;
|
|
229
|
+
} else {
|
|
230
|
+
out = nullptr;
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
template <typename OUT, typename IN>
|
|
236
|
+
[[nodiscard]] bool Convert(OUT &out,
|
|
237
|
+
const std::variant<std::nullptr_t, IN> &in) {
|
|
238
|
+
if (std::holds_alternative<std::nullptr_t>(in)) {
|
|
239
|
+
return Convert(out, std::get<std::nullptr_t>(in));
|
|
240
|
+
}
|
|
241
|
+
return Convert(out, std::get<IN>(in));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[[nodiscard]] bool Convert(wgpu::Origin3D &out, const GPUOrigin3D &in) {
|
|
245
|
+
return Convert(out.x, in.x) && Convert(out.y, in.y) && Convert(out.z, in.z);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
[[nodiscard]] bool Convert(wgpu::Extent3D &out, const GPUExtent3D &in) {
|
|
249
|
+
return Convert(out.width, in.width) && Convert(out.height, in.height) &&
|
|
250
|
+
Convert(out.depthOrArrayLayers, in.depthOrArrayLayers);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
[[nodiscard]] bool Convert(wgpu::BindGroupLayoutEntry &out,
|
|
254
|
+
const GPUBindGroupLayoutEntry &in) {
|
|
255
|
+
return Convert(out.binding, in.binding) &&
|
|
256
|
+
Convert(out.visibility, in.visibility) &&
|
|
257
|
+
Convert(out.buffer, in.buffer) && Convert(out.sampler, in.sampler) &&
|
|
258
|
+
Convert(out.texture, in.texture) &&
|
|
259
|
+
Convert(out.storageTexture, in.storageTexture);
|
|
260
|
+
// no external textures here
|
|
261
|
+
//&& Convert(out.externalTexture, in.externalTexture);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
[[nodiscard]] bool Convert(wgpu::BlendComponent &out,
|
|
265
|
+
const GPUBlendComponent &in) {
|
|
266
|
+
out = {};
|
|
267
|
+
return Convert(out.operation, in.operation) &&
|
|
268
|
+
Convert(out.dstFactor, in.dstFactor) &&
|
|
269
|
+
Convert(out.srcFactor, in.srcFactor);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[[nodiscard]] bool Convert(wgpu::BlendState &out, const GPUBlendState &in) {
|
|
273
|
+
out = {};
|
|
274
|
+
return Convert(out.alpha, in.alpha) && Convert(out.color, in.color);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
[[nodiscard]] bool Convert(wgpu::BufferBindingLayout &out,
|
|
278
|
+
const GPUBufferBindingLayout &in) {
|
|
279
|
+
// here the buffer property is set so type is set to its default value
|
|
280
|
+
if (!in.type.has_value()) {
|
|
281
|
+
out.type = wgpu::BufferBindingType::Uniform;
|
|
282
|
+
}
|
|
283
|
+
return Convert(out.type, in.type) &&
|
|
284
|
+
Convert(out.hasDynamicOffset, in.hasDynamicOffset) &&
|
|
285
|
+
Convert(out.minBindingSize, in.minBindingSize);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
[[nodiscard]] bool Convert(wgpu::BufferDescriptor &out,
|
|
289
|
+
const GPUBufferDescriptor &in) {
|
|
290
|
+
return Convert(out.size, in.size) && Convert(out.usage, in.usage) &&
|
|
291
|
+
Convert(out.mappedAtCreation, in.mappedAtCreation) &&
|
|
292
|
+
Convert(out.label, in.label);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
[[nodiscard]] bool Convert(wgpu::Color &out, const GPUColor &in) {
|
|
296
|
+
return Convert(out.r, in.r) && Convert(out.g, in.g) &&
|
|
297
|
+
Convert(out.b, in.b) && Convert(out.a, in.a);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
[[nodiscard]] bool Convert(wgpu::ColorTargetState &out,
|
|
301
|
+
const GPUColorTargetState &in) {
|
|
302
|
+
out = {};
|
|
303
|
+
return Convert(out.blend, in.blend) && Convert(out.format, in.format) &&
|
|
304
|
+
Convert(out.writeMask, in.writeMask);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
[[nodiscard]] bool Convert(wgpu::ComputePassDescriptor &out,
|
|
308
|
+
const GPUComputePassDescriptor &in) {
|
|
309
|
+
return Convert(out.timestampWrites, in.timestampWrites) &&
|
|
310
|
+
Convert(out.label, in.label);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
[[nodiscard]] bool Convert(wgpu::PassTimestampWrites &out,
|
|
314
|
+
const GPUComputePassTimestampWrites &in) {
|
|
315
|
+
return Convert(out.querySet, in.querySet) &&
|
|
316
|
+
Convert(out.beginningOfPassWriteIndex,
|
|
317
|
+
in.beginningOfPassWriteIndex) &&
|
|
318
|
+
Convert(out.endOfPassWriteIndex, in.endOfPassWriteIndex);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
[[nodiscard]] bool Convert(wgpu::ComputePipelineDescriptor &out,
|
|
322
|
+
const GPUComputePipelineDescriptor &in) {
|
|
323
|
+
return Convert(out.compute, in.compute) && Convert(out.layout, in.layout) &&
|
|
324
|
+
Convert(out.label, in.label);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
[[nodiscard]] bool Convert(wgpu::DepthStencilState &out,
|
|
328
|
+
const GPUDepthStencilState &in) {
|
|
329
|
+
return Convert(out.format, in.format) &&
|
|
330
|
+
Convert(out.depthWriteEnabled, in.depthWriteEnabled) &&
|
|
331
|
+
Convert(out.depthCompare, in.depthCompare) &&
|
|
332
|
+
Convert(out.stencilFront, in.stencilFront) &&
|
|
333
|
+
Convert(out.stencilBack, in.stencilBack) &&
|
|
334
|
+
Convert(out.stencilReadMask, in.stencilReadMask) &&
|
|
335
|
+
Convert(out.stencilWriteMask, in.stencilWriteMask) &&
|
|
336
|
+
Convert(out.depthBias, in.depthBias) &&
|
|
337
|
+
Convert(out.depthBiasSlopeScale, in.depthBiasSlopeScale) &&
|
|
338
|
+
Convert(out.depthBiasClamp, in.depthBiasClamp);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
[[nodiscard]] bool Convert(wgpu::DeviceDescriptor &out,
|
|
342
|
+
const GPUDeviceDescriptor &in) {
|
|
343
|
+
if (in.requiredFeatures.has_value()) {
|
|
344
|
+
if (!Convert(out.requiredFeatures, out.requiredFeatureCount,
|
|
345
|
+
in.requiredFeatures.value())) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (in.requiredLimits.has_value()) {
|
|
351
|
+
const auto &limits = in.requiredLimits.value();
|
|
352
|
+
auto *requiredLimits = Allocate<wgpu::Limits>();
|
|
353
|
+
for (const auto &[key, value] : limits) {
|
|
354
|
+
if (key == "maxTextureDimension1D") {
|
|
355
|
+
requiredLimits->maxTextureDimension1D = value;
|
|
356
|
+
} else if (key == "maxTextureDimension2D") {
|
|
357
|
+
requiredLimits->maxTextureDimension2D = value;
|
|
358
|
+
} else if (key == "maxTextureDimension3D") {
|
|
359
|
+
requiredLimits->maxTextureDimension3D = value;
|
|
360
|
+
} else if (key == "maxTextureArrayLayers") {
|
|
361
|
+
requiredLimits->maxTextureArrayLayers = value;
|
|
362
|
+
} else if (key == "maxBindGroups") {
|
|
363
|
+
requiredLimits->maxBindGroups = value;
|
|
364
|
+
} else if (key == "maxBindGroupsPlusVertexBuffers") {
|
|
365
|
+
requiredLimits->maxBindGroupsPlusVertexBuffers = value;
|
|
366
|
+
} else if (key == "maxBindingsPerBindGroup") {
|
|
367
|
+
requiredLimits->maxBindingsPerBindGroup = value;
|
|
368
|
+
} else if (key == "maxDynamicUniformBuffersPerPipelineLayout") {
|
|
369
|
+
requiredLimits->maxDynamicUniformBuffersPerPipelineLayout = value;
|
|
370
|
+
} else if (key == "maxDynamicStorageBuffersPerPipelineLayout") {
|
|
371
|
+
requiredLimits->maxDynamicStorageBuffersPerPipelineLayout = value;
|
|
372
|
+
} else if (key == "maxSampledTexturesPerShaderStage") {
|
|
373
|
+
requiredLimits->maxSampledTexturesPerShaderStage = value;
|
|
374
|
+
} else if (key == "maxSamplersPerShaderStage") {
|
|
375
|
+
requiredLimits->maxSamplersPerShaderStage = value;
|
|
376
|
+
} else if (key == "maxStorageBuffersPerShaderStage") {
|
|
377
|
+
requiredLimits->maxStorageBuffersPerShaderStage = value;
|
|
378
|
+
} else if (key == "maxStorageTexturesPerShaderStage") {
|
|
379
|
+
requiredLimits->maxStorageTexturesPerShaderStage = value;
|
|
380
|
+
} else if (key == "maxUniformBuffersPerShaderStage") {
|
|
381
|
+
requiredLimits->maxUniformBuffersPerShaderStage = value;
|
|
382
|
+
} else if (key == "maxUniformBufferBindingSize") {
|
|
383
|
+
requiredLimits->maxUniformBufferBindingSize = value;
|
|
384
|
+
} else if (key == "maxStorageBufferBindingSize") {
|
|
385
|
+
requiredLimits->maxStorageBufferBindingSize = value;
|
|
386
|
+
} else if (key == "minUniformBufferOffsetAlignment") {
|
|
387
|
+
requiredLimits->minUniformBufferOffsetAlignment = value;
|
|
388
|
+
} else if (key == "minStorageBufferOffsetAlignment") {
|
|
389
|
+
requiredLimits->minStorageBufferOffsetAlignment = value;
|
|
390
|
+
} else if (key == "maxVertexBuffers") {
|
|
391
|
+
requiredLimits->maxVertexBuffers = value;
|
|
392
|
+
} else if (key == "maxBufferSize") {
|
|
393
|
+
requiredLimits->maxBufferSize = value;
|
|
394
|
+
} else if (key == "maxVertexAttributes") {
|
|
395
|
+
requiredLimits->maxVertexAttributes = value;
|
|
396
|
+
} else if (key == "maxVertexBufferArrayStride") {
|
|
397
|
+
requiredLimits->maxVertexBufferArrayStride = value;
|
|
398
|
+
} else if (key == "maxInterStageShaderVariables") {
|
|
399
|
+
requiredLimits->maxInterStageShaderVariables = value;
|
|
400
|
+
} else if (key == "maxColorAttachments") {
|
|
401
|
+
requiredLimits->maxColorAttachments = value;
|
|
402
|
+
} else if (key == "maxColorAttachmentBytesPerSample") {
|
|
403
|
+
requiredLimits->maxColorAttachmentBytesPerSample = value;
|
|
404
|
+
} else if (key == "maxComputeWorkgroupStorageSize") {
|
|
405
|
+
requiredLimits->maxComputeWorkgroupStorageSize = value;
|
|
406
|
+
} else if (key == "maxComputeInvocationsPerWorkgroup") {
|
|
407
|
+
requiredLimits->maxComputeInvocationsPerWorkgroup = value;
|
|
408
|
+
} else if (key == "maxComputeWorkgroupSizeX") {
|
|
409
|
+
requiredLimits->maxComputeWorkgroupSizeX = value;
|
|
410
|
+
} else if (key == "maxComputeWorkgroupSizeY") {
|
|
411
|
+
requiredLimits->maxComputeWorkgroupSizeY = value;
|
|
412
|
+
} else if (key == "maxComputeWorkgroupSizeZ") {
|
|
413
|
+
requiredLimits->maxComputeWorkgroupSizeZ = value;
|
|
414
|
+
} else if (key == "maxComputeWorkgroupsPerDimension") {
|
|
415
|
+
requiredLimits->maxComputeWorkgroupsPerDimension = value;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
out.requiredLimits = requiredLimits;
|
|
419
|
+
}
|
|
420
|
+
return Convert(out.defaultQueue, in.defaultQueue) &&
|
|
421
|
+
Convert(out.label, in.label);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
[[nodiscard]] bool Convert(wgpu::ExternalTextureBindingLayout &out,
|
|
425
|
+
const GPUExternalTextureBindingLayout &in) {
|
|
426
|
+
// no external textures at the moment
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
[[nodiscard]] bool Convert(wgpu::ConstantEntry &out, const std::string &key,
|
|
431
|
+
const double &value) {
|
|
432
|
+
out.key = ConvertStringReplacingNull(key);
|
|
433
|
+
out.value = value;
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
[[nodiscard]] bool Convert(wgpu::FragmentState &out,
|
|
438
|
+
const GPUFragmentState &in) {
|
|
439
|
+
out = {};
|
|
440
|
+
|
|
441
|
+
// Replace nulls in the entryPoint name with another character that's
|
|
442
|
+
// disallowed in WGSL identifiers. This is so that using "main\0" doesn't
|
|
443
|
+
// match an entryPoint named "main".
|
|
444
|
+
out.entryPoint = in.entryPoint
|
|
445
|
+
? ConvertStringReplacingNull(in.entryPoint.value())
|
|
446
|
+
: nullptr;
|
|
447
|
+
return Convert(out.targets, out.targetCount, in.targets) && //
|
|
448
|
+
Convert(out.module, in.module) &&
|
|
449
|
+
Convert(out.constants, out.constantCount, in.constants);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
[[nodiscard]] bool Convert(wgpu::TexelCopyBufferInfo &out,
|
|
453
|
+
const GPUImageCopyBuffer &in) {
|
|
454
|
+
out = {};
|
|
455
|
+
out.buffer = in.buffer->get();
|
|
456
|
+
return Convert(out.layout.offset, in.offset) &&
|
|
457
|
+
Convert(out.layout.bytesPerRow, in.bytesPerRow) &&
|
|
458
|
+
Convert(out.layout.rowsPerImage, in.rowsPerImage);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
[[nodiscard]] bool Convert(wgpu::TexelCopyTextureInfo &out,
|
|
462
|
+
const GPUImageCopyTexture &in) {
|
|
463
|
+
return Convert(out.origin, in.origin) && Convert(out.texture, in.texture) &&
|
|
464
|
+
Convert(out.mipLevel, in.mipLevel) && Convert(out.aspect, in.aspect);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
[[nodiscard]] bool Convert(wgpu::TexelCopyBufferLayout &out,
|
|
468
|
+
const GPUImageDataLayout &in) {
|
|
469
|
+
out = {};
|
|
470
|
+
return Convert(out.bytesPerRow, in.bytesPerRow) &&
|
|
471
|
+
Convert(out.offset, in.offset) &&
|
|
472
|
+
Convert(out.rowsPerImage, in.rowsPerImage);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
[[nodiscard]] bool Convert(wgpu::MultisampleState &out,
|
|
476
|
+
const GPUMultisampleState &in) {
|
|
477
|
+
return Convert(out.count, in.count) && Convert(out.mask, in.mask) &&
|
|
478
|
+
Convert(out.alphaToCoverageEnabled, in.alphaToCoverageEnabled);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
[[nodiscard]] bool Convert(wgpu::PipelineLayoutDescriptor &out,
|
|
482
|
+
const GPUPipelineLayoutDescriptor &in) {
|
|
483
|
+
return Convert(out.bindGroupLayouts, out.bindGroupLayoutCount,
|
|
484
|
+
in.bindGroupLayouts) &&
|
|
485
|
+
Convert(out.label, in.label);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
[[nodiscard]] bool Convert(wgpu::PrimitiveState &out,
|
|
489
|
+
const GPUPrimitiveState &in) {
|
|
490
|
+
out = {};
|
|
491
|
+
|
|
492
|
+
if (in.unclippedDepth.has_value()) {
|
|
493
|
+
out.unclippedDepth = in.unclippedDepth.value();
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return Convert(out.topology, in.topology) &&
|
|
497
|
+
Convert(out.stripIndexFormat, in.stripIndexFormat) &&
|
|
498
|
+
Convert(out.frontFace, in.frontFace) &&
|
|
499
|
+
Convert(out.cullMode, in.cullMode);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
[[nodiscard]] bool Convert(wgpu::ComputeState &out,
|
|
503
|
+
const GPUProgrammableStage &in) {
|
|
504
|
+
out = {};
|
|
505
|
+
out.module = in.module->get();
|
|
506
|
+
|
|
507
|
+
// Replace nulls in the entryPoint name with another character that's
|
|
508
|
+
// disallowed in WGSL identifiers. This is so that using "main\0" doesn't
|
|
509
|
+
// match an entryPoint named "main".
|
|
510
|
+
out.entryPoint = in.entryPoint
|
|
511
|
+
? ConvertStringReplacingNull(in.entryPoint.value())
|
|
512
|
+
: nullptr;
|
|
513
|
+
return Convert(out.constants, out.constantCount, in.constants);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
[[nodiscard]] bool Convert(wgpu::QuerySetDescriptor &out,
|
|
517
|
+
const GPUQuerySetDescriptor &in) {
|
|
518
|
+
return Convert(out.type, in.type) && Convert(out.count, in.count) &&
|
|
519
|
+
Convert(out.label, in.label);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
[[nodiscard]] bool Convert(wgpu::RenderBundleEncoderDescriptor &out,
|
|
523
|
+
const GPURenderBundleEncoderDescriptor &in) {
|
|
524
|
+
return Convert(out.depthReadOnly, in.depthReadOnly) &&
|
|
525
|
+
Convert(out.stencilReadOnly, in.stencilReadOnly) &&
|
|
526
|
+
Convert(out.colorFormats, out.colorFormatCount, in.colorFormats) &&
|
|
527
|
+
Convert(out.depthStencilFormat, in.depthStencilFormat) &&
|
|
528
|
+
Convert(out.sampleCount, in.sampleCount) &&
|
|
529
|
+
Convert(out.label, in.label);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
[[nodiscard]] bool Convert(wgpu::RenderPassColorAttachment &out,
|
|
533
|
+
const GPURenderPassColorAttachment &in) {
|
|
534
|
+
return Convert(out.view, in.view) &&
|
|
535
|
+
Convert(out.depthSlice, in.depthSlice) &&
|
|
536
|
+
Convert(out.resolveTarget, in.resolveTarget) &&
|
|
537
|
+
Convert(out.clearValue, in.clearValue) &&
|
|
538
|
+
Convert(out.loadOp, in.loadOp) && Convert(out.storeOp, in.storeOp);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
[[nodiscard]] bool Convert(wgpu::RenderPassDepthStencilAttachment &out,
|
|
542
|
+
const GPURenderPassDepthStencilAttachment &in) {
|
|
543
|
+
return Convert(out.view, in.view) &&
|
|
544
|
+
Convert(out.depthClearValue, in.depthClearValue) &&
|
|
545
|
+
Convert(out.depthLoadOp, in.depthLoadOp) &&
|
|
546
|
+
Convert(out.depthStoreOp, in.depthStoreOp) &&
|
|
547
|
+
Convert(out.depthReadOnly, in.depthReadOnly) &&
|
|
548
|
+
Convert(out.stencilClearValue, in.stencilClearValue) &&
|
|
549
|
+
Convert(out.stencilLoadOp, in.stencilLoadOp) &&
|
|
550
|
+
Convert(out.stencilStoreOp, in.stencilStoreOp) &&
|
|
551
|
+
Convert(out.stencilReadOnly, in.stencilReadOnly);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
[[nodiscard]] bool Convert(wgpu::PassTimestampWrites &out,
|
|
555
|
+
const GPURenderPassTimestampWrites &in) {
|
|
556
|
+
return Convert(out.querySet, in.querySet) &&
|
|
557
|
+
Convert(out.beginningOfPassWriteIndex,
|
|
558
|
+
in.beginningOfPassWriteIndex) &&
|
|
559
|
+
Convert(out.endOfPassWriteIndex, in.endOfPassWriteIndex);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
[[nodiscard]] bool Convert(wgpu::RenderPipelineDescriptor &out,
|
|
563
|
+
const GPURenderPipelineDescriptor &in) {
|
|
564
|
+
return Convert(out.vertex, in.vertex) &&
|
|
565
|
+
Convert(out.primitive, in.primitive) &&
|
|
566
|
+
Convert(out.depthStencil, in.depthStencil) &&
|
|
567
|
+
Convert(out.multisample, in.multisample) &&
|
|
568
|
+
Convert(out.fragment, in.fragment) &&
|
|
569
|
+
Convert(out.layout, in.layout) && Convert(out.label, in.label);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
[[nodiscard]] bool Convert(wgpu::RequestAdapterOptions &out,
|
|
573
|
+
const GPURequestAdapterOptions &in) {
|
|
574
|
+
return Convert(out.powerPreference, in.powerPreference) &&
|
|
575
|
+
Convert(out.forceFallbackAdapter, in.forceFallbackAdapter);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
[[nodiscard]] bool Convert(wgpu::SamplerBindingLayout &out,
|
|
579
|
+
const GPUSamplerBindingLayout &in) {
|
|
580
|
+
// here the buffer property is set so type is set to its default value
|
|
581
|
+
if (!in.type.has_value()) {
|
|
582
|
+
out.type = wgpu::SamplerBindingType::Filtering;
|
|
583
|
+
}
|
|
584
|
+
return Convert(out.type, in.type);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
[[nodiscard]] bool Convert(wgpu::SamplerDescriptor &out,
|
|
588
|
+
const GPUSamplerDescriptor &in) {
|
|
589
|
+
return Convert(out.addressModeU, in.addressModeU) &&
|
|
590
|
+
Convert(out.addressModeV, in.addressModeV) &&
|
|
591
|
+
Convert(out.addressModeW, in.addressModeW) &&
|
|
592
|
+
Convert(out.magFilter, in.magFilter) &&
|
|
593
|
+
Convert(out.minFilter, in.minFilter) &&
|
|
594
|
+
Convert(out.mipmapFilter, in.mipmapFilter) &&
|
|
595
|
+
Convert(out.lodMinClamp, in.lodMinClamp) &&
|
|
596
|
+
Convert(out.lodMaxClamp, in.lodMaxClamp) &&
|
|
597
|
+
Convert(out.compare, in.compare) &&
|
|
598
|
+
Convert(out.maxAnisotropy, in.maxAnisotropy) &&
|
|
599
|
+
Convert(out.label, in.label);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
[[nodiscard]] bool Convert(wgpu::StencilFaceState &out,
|
|
603
|
+
const GPUStencilFaceState &in) {
|
|
604
|
+
return Convert(out.compare, in.compare) && Convert(out.failOp, in.failOp) &&
|
|
605
|
+
Convert(out.depthFailOp, in.depthFailOp) &&
|
|
606
|
+
Convert(out.passOp, in.passOp);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
[[nodiscard]] bool Convert(wgpu::StorageTextureBindingLayout &out,
|
|
610
|
+
const GPUStorageTextureBindingLayout &in) {
|
|
611
|
+
if (!in.access.has_value()) {
|
|
612
|
+
out.access = wgpu::StorageTextureAccess::WriteOnly;
|
|
613
|
+
}
|
|
614
|
+
return Convert(out.access, in.access) && Convert(out.format, in.format) &&
|
|
615
|
+
Convert(out.viewDimension, in.viewDimension);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
[[nodiscard]] bool Convert(wgpu::TextureBindingLayout &out,
|
|
619
|
+
const GPUTextureBindingLayout &in) {
|
|
620
|
+
if (!in.sampleType.has_value()) {
|
|
621
|
+
out.sampleType = wgpu::TextureSampleType::Float;
|
|
622
|
+
}
|
|
623
|
+
return Convert(out.sampleType, in.sampleType) &&
|
|
624
|
+
Convert(out.viewDimension, in.viewDimension) &&
|
|
625
|
+
Convert(out.multisampled, in.multisampled);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
[[nodiscard]] bool Convert(wgpu::TextureDescriptor &out,
|
|
629
|
+
const GPUTextureDescriptor &in) {
|
|
630
|
+
if (in.viewFormats.has_value()) {
|
|
631
|
+
if (!Convert(out.viewFormats, out.viewFormatCount,
|
|
632
|
+
in.viewFormats.value())) {
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return Convert(out.size, in.size) &&
|
|
637
|
+
Convert(out.mipLevelCount, in.mipLevelCount) &&
|
|
638
|
+
Convert(out.sampleCount, in.sampleCount) &&
|
|
639
|
+
Convert(out.dimension, in.dimension) &&
|
|
640
|
+
Convert(out.format, in.format) && Convert(out.usage, in.usage) &&
|
|
641
|
+
Convert(out.label, in.label);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
[[nodiscard]] bool Convert(wgpu::TextureViewDescriptor &out,
|
|
645
|
+
const GPUTextureViewDescriptor &in) {
|
|
646
|
+
return Convert(out.format, in.format) &&
|
|
647
|
+
Convert(out.dimension, in.dimension) &&
|
|
648
|
+
Convert(out.aspect, in.aspect) &&
|
|
649
|
+
Convert(out.baseMipLevel, in.baseMipLevel) &&
|
|
650
|
+
Convert(out.mipLevelCount, in.mipLevelCount) &&
|
|
651
|
+
Convert(out.baseArrayLayer, in.baseArrayLayer) &&
|
|
652
|
+
Convert(out.arrayLayerCount, in.arrayLayerCount) &&
|
|
653
|
+
Convert(out.label, in.label);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
[[nodiscard]] bool Convert(wgpu::VertexAttribute &out,
|
|
657
|
+
const GPUVertexAttribute &in) {
|
|
658
|
+
return Convert(out.format, in.format) && Convert(out.offset, in.offset) &&
|
|
659
|
+
Convert(out.shaderLocation, in.shaderLocation);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
[[nodiscard]] bool Convert(wgpu::VertexBufferLayout &out,
|
|
663
|
+
const GPUVertexBufferLayout &in) {
|
|
664
|
+
out = {};
|
|
665
|
+
/*
|
|
666
|
+
TODO:
|
|
667
|
+
- if (in.stepMode == wgpu::VertexStepMode::VertexBufferNotUsed) {
|
|
668
|
+
- return Convert(out.stepMode, in.stepMode);
|
|
669
|
+
- }
|
|
670
|
+
*/
|
|
671
|
+
return Convert(out.attributes, out.attributeCount, in.attributes) &&
|
|
672
|
+
Convert(out.arrayStride, in.arrayStride) &&
|
|
673
|
+
Convert(out.stepMode, in.stepMode);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
[[nodiscard]] bool Convert(wgpu::VertexState &out, const GPUVertexState &in) {
|
|
677
|
+
out = {};
|
|
678
|
+
// Replace nulls in the entryPoint name with another character that's
|
|
679
|
+
// disallowed in WGSL identifiers. This is so that using "main\0" doesn't
|
|
680
|
+
// match an entryPoint named "main".
|
|
681
|
+
out.entryPoint = in.entryPoint
|
|
682
|
+
? ConvertStringReplacingNull(in.entryPoint.value())
|
|
683
|
+
: nullptr;
|
|
684
|
+
return Convert(out.module, in.module) &&
|
|
685
|
+
Convert(out.buffers, out.bufferCount, in.buffers) &&
|
|
686
|
+
Convert(out.constants, out.constantCount, in.constants);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
[[nodiscard]] bool Convert(wgpu::CommandBufferDescriptor &out,
|
|
690
|
+
const GPUCommandBufferDescriptor &in) {
|
|
691
|
+
return Convert(out.label, in.label);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
[[nodiscard]] bool Convert(wgpu::CommandEncoderDescriptor &out,
|
|
695
|
+
const GPUCommandEncoderDescriptor &in) {
|
|
696
|
+
return Convert(out.label, in.label);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
[[nodiscard]] bool Convert(wgpu::QueueDescriptor &out,
|
|
700
|
+
const GPUQueueDescriptor &in) {
|
|
701
|
+
return Convert(out.label, in.label);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
[[nodiscard]] bool Convert(wgpu::RenderBundleDescriptor &out,
|
|
705
|
+
const GPURenderBundleDescriptor &in) {
|
|
706
|
+
return Convert(out.label, in.label);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
[[nodiscard]] bool Convert(wgpu::BindGroupEntry &out,
|
|
710
|
+
const GPUBindGroupEntry &in) {
|
|
711
|
+
out = {};
|
|
712
|
+
if (!Convert(out.binding, in.binding)) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
if (in.sampler != nullptr) {
|
|
717
|
+
return Convert(out.sampler, in.sampler);
|
|
718
|
+
}
|
|
719
|
+
if (in.textureView != nullptr) {
|
|
720
|
+
return Convert(out.textureView, in.textureView);
|
|
721
|
+
}
|
|
722
|
+
if (in.buffer != nullptr) {
|
|
723
|
+
auto buffer = in.buffer->buffer;
|
|
724
|
+
out.size = wgpu::kWholeSize;
|
|
725
|
+
if (!buffer || !Convert(out.offset, in.buffer->offset) ||
|
|
726
|
+
!Convert(out.size, in.buffer->size)) {
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
out.buffer = buffer->get();
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
// Not external textures at the moment
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
private:
|
|
737
|
+
char *ConvertStringReplacingNull(std::string_view in) {
|
|
738
|
+
char *out = Allocate<char>(in.size() + 1);
|
|
739
|
+
out[in.size()] = '\0';
|
|
740
|
+
|
|
741
|
+
for (size_t i = 0; i < in.size(); i++) {
|
|
742
|
+
if (in[i] == '\0') {
|
|
743
|
+
out[i] = '#';
|
|
744
|
+
} else {
|
|
745
|
+
out[i] = in[i];
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return out;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
template <typename T> T *Allocate(size_t n = 1) {
|
|
753
|
+
auto *ptr = new T[n]{};
|
|
754
|
+
free_.emplace_back([ptr] { delete[] ptr; });
|
|
755
|
+
return ptr;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
std::vector<std::function<void()>> free_;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
} // namespace rnwgpu
|