react-native-wgpu 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -13
- package/android/CMakeLists.txt +15 -1
- package/android/build.gradle +0 -18
- package/android/cpp/AndroidPlatformContext.h +132 -0
- package/android/cpp/cpp-adapter.cpp +70 -4
- package/android/src/main/java/com/webgpu/WebGPUModule.java +69 -21
- package/android/src/main/java/com/webgpu/WebGPUView.java +63 -8
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +5 -6
- package/android/src/newarch/{WgpuViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +5 -5
- package/android/src/oldarch/com/webgpu/NativeWebGPUModuleSpec.java +23 -0
- package/android/src/oldarch/{WebGPUViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +1 -1
- package/cpp/{Logger.h → WGPULogger.h} +13 -6
- package/cpp/dawn/webgpu.h +9 -0
- package/cpp/dawn/webgpu_cpp.h +95 -43
- package/cpp/dawn/webgpu_cpp_print.h +6 -0
- package/cpp/dawn/wire/client/webgpu_cpp.h +80 -43
- package/cpp/jsi/RNFHybridObject.cpp +1 -1
- package/cpp/jsi/RNFHybridObject.h +4 -4
- package/cpp/jsi/RNFJSIConverter.h +204 -17
- package/cpp/rnwgpu/ArrayBuffer.h +72 -0
- package/cpp/rnwgpu/PlatformContext.h +29 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +13 -11
- package/cpp/rnwgpu/RNWebGPUManager.h +9 -1
- package/cpp/rnwgpu/SurfaceRegistry.h +36 -0
- package/cpp/rnwgpu/api/AsyncRunner.h +30 -0
- package/cpp/rnwgpu/api/Canvas.h +55 -0
- package/cpp/rnwgpu/api/Convertors.h +765 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +81 -23
- package/cpp/rnwgpu/api/GPU.h +24 -6
- package/cpp/rnwgpu/api/GPUAdapter.cpp +138 -24
- package/cpp/rnwgpu/api/GPUAdapter.h +24 -5
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +19 -7
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +11 -4
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +11 -4
- package/cpp/rnwgpu/api/GPUBuffer.cpp +82 -7
- package/cpp/rnwgpu/api/GPUBuffer.h +44 -8
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +63 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +51 -8
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +11 -4
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +177 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +75 -3
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +65 -8
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +6 -4
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +58 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +49 -3
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +11 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +18 -3
- package/cpp/rnwgpu/api/GPUDevice.cpp +330 -3
- package/cpp/rnwgpu/api/GPUDevice.h +119 -5
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +6 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +14 -7
- package/cpp/rnwgpu/api/GPUError.h +42 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +69 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +11 -4
- package/cpp/rnwgpu/api/GPUFeatures.h +221 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +59 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +66 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +11 -4
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +19 -5
- package/cpp/rnwgpu/api/GPUQueue.cpp +153 -0
- package/cpp/rnwgpu/api/GPUQueue.h +45 -4
- package/cpp/rnwgpu/api/GPURenderBundle.h +11 -4
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +128 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +72 -3
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +161 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +93 -3
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +18 -3
- package/cpp/rnwgpu/api/GPUSampler.h +11 -4
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +39 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +23 -4
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +133 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +128 -4
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +38 -4
- package/cpp/rnwgpu/api/GPUTextureView.h +11 -4
- package/cpp/rnwgpu/api/ImageBitmap.h +34 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +100 -0
- package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +31 -43
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +40 -31
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +24 -32
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +56 -49
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +27 -20
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +23 -31
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +25 -36
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +25 -25
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +26 -46
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +31 -53
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +72 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +27 -33
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +24 -25
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +25 -42
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +32 -42
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +58 -76
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +38 -30
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +11 -11
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +43 -34
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +39 -46
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +29 -45
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +32 -31
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +32 -36
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +42 -44
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +24 -34
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +24 -32
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +25 -35
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +35 -26
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +29 -35
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +23 -43
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +49 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +41 -57
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +42 -61
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +54 -66
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +52 -55
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +25 -42
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +60 -56
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +21 -20
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +17 -14
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +63 -63
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +28 -27
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +28 -49
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +32 -23
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +27 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +27 -20
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +49 -76
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +48 -64
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +29 -31
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +23 -44
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +30 -36
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +39 -38
- package/cpp/rnwgpu/api/descriptors/Unions.h +57 -2
- package/ios/IOSPlatformContext.h +19 -0
- package/ios/IOSPlatformContext.mm +68 -0
- package/ios/MetalView.h +10 -0
- package/ios/MetalView.mm +27 -0
- package/ios/SurfaceUtils.h +13 -0
- package/ios/SurfaceUtils.mm +24 -0
- package/ios/WebGPUModule.h +8 -7
- package/ios/WebGPUModule.mm +47 -14
- package/ios/WebGPUView.h +6 -3
- package/ios/WebGPUView.mm +36 -24
- package/ios/WebGPUViewComponentDescriptor.h +61 -0
- package/ios/WebGPUViewManager.mm +6 -4
- package/lib/commonjs/Canvas.js +47 -0
- package/lib/commonjs/Canvas.js.map +1 -0
- package/lib/commonjs/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
- package/lib/commonjs/{WebGPUNativeModule.js.map → NativeWebGPUModule.js.map} +1 -1
- package/lib/commonjs/WebGPUView.js +2 -0
- package/lib/commonjs/WebGPUView.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/commonjs/index.js +183 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +39 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/Canvas.js +40 -0
- package/lib/module/Canvas.js.map +1 -0
- package/lib/module/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
- package/lib/module/NativeWebGPUModule.js.map +1 -0
- package/lib/module/WebGPUView.js +2 -0
- package/lib/module/WebGPUView.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
- package/lib/module/index.js +158 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +31 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/example/src/Triangle/triangle.d.ts +3 -0
- package/lib/typescript/example/src/Triangle/triangle.d.ts.map +1 -0
- package/lib/typescript/example/src/Wireframe/Shaders.d.ts +3 -0
- package/lib/typescript/example/src/Wireframe/Shaders.d.ts.map +1 -0
- package/lib/typescript/example/src/Wireframe/models.d.ts +29 -0
- package/lib/typescript/example/src/Wireframe/models.d.ts.map +1 -0
- package/lib/typescript/example/src/components/DrawingContext.d.ts +13 -0
- package/lib/typescript/example/src/components/DrawingContext.d.ts.map +1 -0
- package/lib/typescript/example/src/components/cube.d.ts +7 -0
- package/lib/typescript/example/src/components/cube.d.ts.map +1 -0
- package/lib/typescript/example/src/components/meshes/sphere.d.ts +12 -0
- package/lib/typescript/example/src/components/meshes/sphere.d.ts.map +1 -0
- package/lib/typescript/example/src/components/meshes/teapot.d.ts +6 -0
- package/lib/typescript/example/src/components/meshes/teapot.d.ts.map +1 -0
- package/lib/typescript/example/src/components/meshes/utils.d.ts +10 -0
- package/lib/typescript/example/src/components/meshes/utils.d.ts.map +1 -0
- package/lib/typescript/jest.config.d.ts +4 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts +4 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
- package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUView.d.ts +1 -0
- package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +0 -2
- package/lib/typescript/lib/commonjs/utils.d.ts +5 -0
- package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
- package/lib/typescript/lib/module/Canvas.d.ts +2 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
- package/lib/typescript/lib/module/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
- package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUView.d.ts +1 -0
- package/lib/typescript/lib/module/WebGPUView.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +3 -3
- package/lib/typescript/lib/module/utils.d.ts +3 -0
- package/lib/typescript/lib/module/utils.d.ts.map +1 -0
- package/lib/typescript/src/Canvas.d.ts +29 -0
- package/lib/typescript/src/Canvas.d.ts.map +1 -0
- package/lib/typescript/src/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +2 -1
- package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUView.d.ts +1 -0
- package/lib/typescript/src/WebGPUView.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +7 -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/dawn.json +4597 -0
- package/libs/ios/arm64_iphoneos/libwebgpu_dawn.a +0 -0
- package/libs/ios/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/ios/libwebgpu_dawn.a +0 -0
- package/libs/ios/libwebgpu_dawn.xcframework/Info.plist +44 -0
- package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/ios/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/package.json +25 -8
- package/{react-native-webgpu.podspec → react-native-wgpu.podspec} +6 -9
- package/src/Canvas.tsx +73 -0
- package/src/{WebGPUNativeModule.ts → NativeWebGPUModule.ts} +1 -0
- package/src/WebGPUView.tsx +0 -0
- package/src/WebGPUViewNativeComponent.ts +2 -1
- package/src/index.tsx +191 -8
- package/src/utils.ts +40 -0
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/cpp/rnwgpu/MutableBuffer.h +0 -48
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -33
- package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +0 -81
- package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +0 -76
- package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +0 -91
- package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +0 -61
- package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +0 -75
- package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +0 -71
- package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +0 -54
- package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +0 -83
- package/ios/RNFAppleLogger.mm +0 -22
- package/ios/Utils.h +0 -5
- package/ios/Utils.m +0 -26
- package/lib/module/WebGPUNativeModule.js.map +0 -1
- package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +0 -1
- package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +0 -1
- package/lib/typescript/scripts/build/copy-artifacts.d.ts +0 -2
- package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +0 -1
- package/lib/typescript/scripts/build/dawn.d.ts +0 -2
- package/lib/typescript/scripts/build/dawn.d.ts.map +0 -1
- package/lib/typescript/scripts/build/util.d.ts +0 -13
- package/lib/typescript/scripts/build/util.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/codegen.d.ts +0 -2
- package/lib/typescript/scripts/codegen/codegen.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/model/dawn.d.ts +0 -2
- package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/model/model.d.ts +0 -8
- package/lib/typescript/scripts/codegen/model/model.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +0 -4
- package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/templates/Enum.d.ts +0 -3
- package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +0 -3
- package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/templates/Unions.d.ts +0 -6
- package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/templates/common.d.ts +0 -9
- package/lib/typescript/scripts/codegen/templates/common.d.ts.map +0 -1
- package/lib/typescript/scripts/codegen/util.d.ts +0 -2
- package/lib/typescript/scripts/codegen/util.d.ts.map +0 -1
- package/lib/typescript/src/WebGPUNativeModule.d.ts.map +0 -1
|
@@ -5,26 +5,36 @@
|
|
|
5
5
|
|
|
6
6
|
#include "webgpu/webgpu_cpp.h"
|
|
7
7
|
|
|
8
|
-
#include "Logger.h"
|
|
9
8
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
9
|
+
#include "WGPULogger.h"
|
|
10
|
+
|
|
11
|
+
#include "RNFHybridObject.h"
|
|
11
12
|
|
|
12
13
|
namespace jsi = facebook::jsi;
|
|
14
|
+
namespace m = margelo;
|
|
13
15
|
|
|
14
16
|
namespace rnwgpu {
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
wgpu::
|
|
21
|
-
|
|
22
|
-
std::
|
|
18
|
+
struct GPUSamplerDescriptor {
|
|
19
|
+
std::optional<wgpu::AddressMode> addressModeU; // GPUAddressMode
|
|
20
|
+
std::optional<wgpu::AddressMode> addressModeV; // GPUAddressMode
|
|
21
|
+
std::optional<wgpu::AddressMode> addressModeW; // GPUAddressMode
|
|
22
|
+
std::optional<wgpu::FilterMode> magFilter; // GPUFilterMode
|
|
23
|
+
std::optional<wgpu::FilterMode> minFilter; // GPUFilterMode
|
|
24
|
+
std::optional<wgpu::MipmapFilterMode> mipmapFilter; // GPUMipmapFilterMode
|
|
25
|
+
std::optional<double> lodMinClamp; // number
|
|
26
|
+
std::optional<double> lodMaxClamp; // number
|
|
27
|
+
std::optional<wgpu::CompareFunction> compare; // GPUCompareFunction
|
|
28
|
+
std::optional<double> maxAnisotropy; // number
|
|
29
|
+
std::optional<std::string> label; // string
|
|
23
30
|
};
|
|
31
|
+
|
|
24
32
|
} // namespace rnwgpu
|
|
25
33
|
|
|
26
34
|
namespace margelo {
|
|
27
35
|
|
|
36
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
37
|
+
|
|
28
38
|
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerDescriptor>> {
|
|
29
39
|
static std::shared_ptr<rnwgpu::GPUSamplerDescriptor>
|
|
30
40
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -32,85 +42,75 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerDescriptor>> {
|
|
|
32
42
|
if (!outOfBounds && arg.isObject()) {
|
|
33
43
|
auto value = arg.getObject(runtime);
|
|
34
44
|
if (value.hasProperty(runtime, "addressModeU")) {
|
|
35
|
-
auto
|
|
45
|
+
auto prop = value.getProperty(runtime, "addressModeU");
|
|
46
|
+
result->addressModeU =
|
|
47
|
+
JSIConverter<std::optional<wgpu::AddressMode>>::fromJSI(
|
|
48
|
+
runtime, prop, false);
|
|
36
49
|
}
|
|
37
50
|
if (value.hasProperty(runtime, "addressModeV")) {
|
|
38
|
-
auto
|
|
51
|
+
auto prop = value.getProperty(runtime, "addressModeV");
|
|
52
|
+
result->addressModeV =
|
|
53
|
+
JSIConverter<std::optional<wgpu::AddressMode>>::fromJSI(
|
|
54
|
+
runtime, prop, false);
|
|
39
55
|
}
|
|
40
56
|
if (value.hasProperty(runtime, "addressModeW")) {
|
|
41
|
-
auto
|
|
57
|
+
auto prop = value.getProperty(runtime, "addressModeW");
|
|
58
|
+
result->addressModeW =
|
|
59
|
+
JSIConverter<std::optional<wgpu::AddressMode>>::fromJSI(
|
|
60
|
+
runtime, prop, false);
|
|
42
61
|
}
|
|
43
62
|
if (value.hasProperty(runtime, "magFilter")) {
|
|
44
|
-
auto
|
|
63
|
+
auto prop = value.getProperty(runtime, "magFilter");
|
|
64
|
+
result->magFilter =
|
|
65
|
+
JSIConverter<std::optional<wgpu::FilterMode>>::fromJSI(runtime,
|
|
66
|
+
prop, false);
|
|
45
67
|
}
|
|
46
68
|
if (value.hasProperty(runtime, "minFilter")) {
|
|
47
|
-
auto
|
|
69
|
+
auto prop = value.getProperty(runtime, "minFilter");
|
|
70
|
+
result->minFilter =
|
|
71
|
+
JSIConverter<std::optional<wgpu::FilterMode>>::fromJSI(runtime,
|
|
72
|
+
prop, false);
|
|
48
73
|
}
|
|
49
74
|
if (value.hasProperty(runtime, "mipmapFilter")) {
|
|
50
|
-
auto
|
|
75
|
+
auto prop = value.getProperty(runtime, "mipmapFilter");
|
|
76
|
+
result->mipmapFilter =
|
|
77
|
+
JSIConverter<std::optional<wgpu::MipmapFilterMode>>::fromJSI(
|
|
78
|
+
runtime, prop, false);
|
|
51
79
|
}
|
|
52
80
|
if (value.hasProperty(runtime, "lodMinClamp")) {
|
|
53
|
-
auto
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
result->_instance.lodMinClamp = lodMinClamp.getNumber();
|
|
57
|
-
}
|
|
81
|
+
auto prop = value.getProperty(runtime, "lodMinClamp");
|
|
82
|
+
result->lodMinClamp =
|
|
83
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
58
84
|
}
|
|
59
85
|
if (value.hasProperty(runtime, "lodMaxClamp")) {
|
|
60
|
-
auto
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
result->_instance.lodMaxClamp = lodMaxClamp.getNumber();
|
|
64
|
-
}
|
|
86
|
+
auto prop = value.getProperty(runtime, "lodMaxClamp");
|
|
87
|
+
result->lodMaxClamp =
|
|
88
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
65
89
|
}
|
|
66
90
|
if (value.hasProperty(runtime, "compare")) {
|
|
67
|
-
auto
|
|
91
|
+
auto prop = value.getProperty(runtime, "compare");
|
|
92
|
+
result->compare =
|
|
93
|
+
JSIConverter<std::optional<wgpu::CompareFunction>>::fromJSI(
|
|
94
|
+
runtime, prop, false);
|
|
68
95
|
}
|
|
69
96
|
if (value.hasProperty(runtime, "maxAnisotropy")) {
|
|
70
|
-
auto
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
result->_instance.maxAnisotropy = maxAnisotropy.getNumber();
|
|
74
|
-
}
|
|
97
|
+
auto prop = value.getProperty(runtime, "maxAnisotropy");
|
|
98
|
+
result->maxAnisotropy =
|
|
99
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
75
100
|
}
|
|
76
101
|
if (value.hasProperty(runtime, "label")) {
|
|
77
|
-
auto
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
auto str = label.asString(runtime).utf8(runtime);
|
|
81
|
-
result->label = str;
|
|
82
|
-
result->_instance.label = result->label.c_str();
|
|
83
|
-
}
|
|
102
|
+
auto prop = value.getProperty(runtime, "label");
|
|
103
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
104
|
+
runtime, prop, false);
|
|
84
105
|
}
|
|
85
106
|
}
|
|
86
|
-
|
|
87
|
-
result->_instance.addressModeU);
|
|
88
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::addressModeV = %f",
|
|
89
|
-
result->_instance.addressModeV);
|
|
90
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::addressModeW = %f",
|
|
91
|
-
result->_instance.addressModeW);
|
|
92
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::magFilter = %f",
|
|
93
|
-
result->_instance.magFilter);
|
|
94
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::minFilter = %f",
|
|
95
|
-
result->_instance.minFilter);
|
|
96
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::mipmapFilter = %f",
|
|
97
|
-
result->_instance.mipmapFilter);
|
|
98
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::lodMinClamp = %f",
|
|
99
|
-
result->_instance.lodMinClamp);
|
|
100
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::lodMaxClamp = %f",
|
|
101
|
-
result->_instance.lodMaxClamp);
|
|
102
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::compare = %f",
|
|
103
|
-
result->_instance.compare);
|
|
104
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::maxAnisotropy = %f",
|
|
105
|
-
result->_instance.maxAnisotropy);
|
|
106
|
-
rnwgpu::Logger::logToConsole("GPUSamplerDescriptor::label = %f",
|
|
107
|
-
result->_instance.label);
|
|
107
|
+
|
|
108
108
|
return result;
|
|
109
109
|
}
|
|
110
110
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
111
111
|
std::shared_ptr<rnwgpu::GPUSamplerDescriptor> arg) {
|
|
112
|
-
|
|
113
|
-
return jsi::Value::null();
|
|
112
|
+
throw std::runtime_error("Invalid GPUSamplerDescriptor::toJSI()");
|
|
114
113
|
}
|
|
115
114
|
};
|
|
116
|
-
|
|
115
|
+
|
|
116
|
+
} // namespace margelo
|
|
@@ -5,24 +5,30 @@
|
|
|
5
5
|
|
|
6
6
|
#include "webgpu/webgpu_cpp.h"
|
|
7
7
|
|
|
8
|
-
#include "Logger.h"
|
|
9
8
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
9
|
+
#include "WGPULogger.h"
|
|
10
|
+
|
|
11
|
+
#include "GPUPipelineLayout.h"
|
|
12
|
+
#include "RNFHybridObject.h"
|
|
11
13
|
|
|
12
14
|
namespace jsi = facebook::jsi;
|
|
15
|
+
namespace m = margelo;
|
|
13
16
|
|
|
14
17
|
namespace rnwgpu {
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
struct GPUShaderModuleCompilationHint {
|
|
20
|
+
std::string entryPoint; // string
|
|
21
|
+
std::optional<
|
|
22
|
+
std::variant<std::nullptr_t, std::shared_ptr<GPUPipelineLayout>>>
|
|
23
|
+
layout; // | GPUPipelineLayout | GPUAutoLayoutMode
|
|
21
24
|
};
|
|
25
|
+
|
|
22
26
|
} // namespace rnwgpu
|
|
23
27
|
|
|
24
28
|
namespace margelo {
|
|
25
29
|
|
|
30
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
31
|
+
|
|
26
32
|
template <>
|
|
27
33
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint>> {
|
|
28
34
|
static std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint>
|
|
@@ -31,34 +37,29 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint>> {
|
|
|
31
37
|
if (!outOfBounds && arg.isObject()) {
|
|
32
38
|
auto value = arg.getObject(runtime);
|
|
33
39
|
if (value.hasProperty(runtime, "entryPoint")) {
|
|
34
|
-
auto
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw std::runtime_error(
|
|
38
|
-
"Property GPUShaderModuleCompilationHint::entryPoint is "
|
|
39
|
-
"required");
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
throw std::runtime_error(
|
|
43
|
-
"Property GPUShaderModuleCompilationHint::entryPoint is not "
|
|
44
|
-
"defined");
|
|
40
|
+
auto prop = value.getProperty(runtime, "entryPoint");
|
|
41
|
+
result->entryPoint =
|
|
42
|
+
JSIConverter<std::string>::fromJSI(runtime, prop, false);
|
|
45
43
|
}
|
|
46
44
|
if (value.hasProperty(runtime, "layout")) {
|
|
47
|
-
auto
|
|
45
|
+
auto prop = value.getProperty(runtime, "layout");
|
|
46
|
+
if (prop.isNull() || prop.isString()) {
|
|
47
|
+
result->layout = nullptr;
|
|
48
|
+
} else {
|
|
49
|
+
result->layout =
|
|
50
|
+
JSIConverter<std::shared_ptr<GPUPipelineLayout>>::fromJSI(
|
|
51
|
+
runtime, prop, false);
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
"GPUShaderModuleCompilationHint::entryPoint = %f",
|
|
52
|
-
result->_instance.entryPoint);
|
|
53
|
-
rnwgpu::Logger::logToConsole("GPUShaderModuleCompilationHint::layout = %f",
|
|
54
|
-
result->_instance.layout);
|
|
55
|
+
|
|
55
56
|
return result;
|
|
56
57
|
}
|
|
57
58
|
static jsi::Value
|
|
58
59
|
toJSI(jsi::Runtime &runtime,
|
|
59
60
|
std::shared_ptr<rnwgpu::GPUShaderModuleCompilationHint> arg) {
|
|
60
|
-
|
|
61
|
-
return jsi::Value::null();
|
|
61
|
+
throw std::runtime_error("Invalid GPUShaderModuleCompilationHint::toJSI()");
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
} // namespace margelo
|
|
@@ -2,29 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <string>
|
|
5
|
+
#include <vector>
|
|
5
6
|
|
|
6
7
|
#include "webgpu/webgpu_cpp.h"
|
|
7
8
|
|
|
8
|
-
#include "Logger.h"
|
|
9
9
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
10
|
+
#include "WGPULogger.h"
|
|
11
|
+
|
|
12
|
+
#include "GPUShaderModuleCompilationHint.h"
|
|
13
|
+
#include "RNFHybridObject.h"
|
|
11
14
|
|
|
12
15
|
namespace jsi = facebook::jsi;
|
|
16
|
+
namespace m = margelo;
|
|
13
17
|
|
|
14
18
|
namespace rnwgpu {
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
std::string label;
|
|
20
|
+
struct GPUShaderModuleDescriptor {
|
|
21
|
+
std::string code; // string
|
|
22
|
+
std::optional<std::vector<std::shared_ptr<GPUShaderModuleCompilationHint>>>
|
|
23
|
+
compilationHints; // Array<GPUShaderModuleCompilationHint>
|
|
24
|
+
std::optional<std::string> label; // string
|
|
23
25
|
};
|
|
26
|
+
|
|
24
27
|
} // namespace rnwgpu
|
|
25
28
|
|
|
26
29
|
namespace margelo {
|
|
27
30
|
|
|
31
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
32
|
+
|
|
28
33
|
template <>
|
|
29
34
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUShaderModuleDescriptor>> {
|
|
30
35
|
static std::shared_ptr<rnwgpu::GPUShaderModuleDescriptor>
|
|
@@ -33,56 +38,30 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUShaderModuleDescriptor>> {
|
|
|
33
38
|
if (!outOfBounds && arg.isObject()) {
|
|
34
39
|
auto value = arg.getObject(runtime);
|
|
35
40
|
if (value.hasProperty(runtime, "code")) {
|
|
36
|
-
auto
|
|
37
|
-
|
|
38
|
-
if (code.isUndefined()) {
|
|
39
|
-
throw std::runtime_error(
|
|
40
|
-
"Property GPUShaderModuleDescriptor::code is required");
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
throw std::runtime_error(
|
|
44
|
-
"Property GPUShaderModuleDescriptor::code is not defined");
|
|
45
|
-
}
|
|
46
|
-
if (value.hasProperty(runtime, "sourceMap")) {
|
|
47
|
-
auto sourceMap = value.getProperty(runtime, "sourceMap");
|
|
48
|
-
|
|
49
|
-
if (sourceMap.isUndefined()) {
|
|
50
|
-
throw std::runtime_error(
|
|
51
|
-
"Property GPUShaderModuleDescriptor::sourceMap is required");
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
throw std::runtime_error(
|
|
55
|
-
"Property GPUShaderModuleDescriptor::sourceMap is not defined");
|
|
41
|
+
auto prop = value.getProperty(runtime, "code");
|
|
42
|
+
result->code = JSIConverter<std::string>::fromJSI(runtime, prop, false);
|
|
56
43
|
}
|
|
57
44
|
if (value.hasProperty(runtime, "compilationHints")) {
|
|
58
|
-
auto
|
|
45
|
+
auto prop = value.getProperty(runtime, "compilationHints");
|
|
46
|
+
result->compilationHints = JSIConverter<std::optional<std::vector<
|
|
47
|
+
std::shared_ptr<GPUShaderModuleCompilationHint>>>>::fromJSI(runtime,
|
|
48
|
+
prop,
|
|
49
|
+
false);
|
|
59
50
|
}
|
|
60
51
|
if (value.hasProperty(runtime, "label")) {
|
|
61
|
-
auto
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
auto str = label.asString(runtime).utf8(runtime);
|
|
65
|
-
result->label = str;
|
|
66
|
-
result->_instance.label = result->label.c_str();
|
|
67
|
-
}
|
|
52
|
+
auto prop = value.getProperty(runtime, "label");
|
|
53
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
54
|
+
runtime, prop, false);
|
|
68
55
|
}
|
|
69
56
|
}
|
|
70
|
-
|
|
71
|
-
result->_instance.code);
|
|
72
|
-
rnwgpu::Logger::logToConsole("GPUShaderModuleDescriptor::sourceMap = %f",
|
|
73
|
-
result->_instance.sourceMap);
|
|
74
|
-
rnwgpu::Logger::logToConsole(
|
|
75
|
-
"GPUShaderModuleDescriptor::compilationHints = %f",
|
|
76
|
-
result->_instance.compilationHints);
|
|
77
|
-
rnwgpu::Logger::logToConsole("GPUShaderModuleDescriptor::label = %f",
|
|
78
|
-
result->_instance.label);
|
|
57
|
+
|
|
79
58
|
return result;
|
|
80
59
|
}
|
|
81
60
|
static jsi::Value
|
|
82
61
|
toJSI(jsi::Runtime &runtime,
|
|
83
62
|
std::shared_ptr<rnwgpu::GPUShaderModuleDescriptor> arg) {
|
|
84
|
-
|
|
85
|
-
return jsi::Value::null();
|
|
63
|
+
throw std::runtime_error("Invalid GPUShaderModuleDescriptor::toJSI()");
|
|
86
64
|
}
|
|
87
65
|
};
|
|
88
|
-
|
|
66
|
+
|
|
67
|
+
} // namespace margelo
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
-
#include <string>
|
|
5
4
|
|
|
6
5
|
#include "webgpu/webgpu_cpp.h"
|
|
7
6
|
|
|
8
|
-
#include "Logger.h"
|
|
9
7
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
8
|
+
#include "WGPULogger.h"
|
|
9
|
+
|
|
10
|
+
#include "RNFHybridObject.h"
|
|
11
11
|
|
|
12
12
|
namespace jsi = facebook::jsi;
|
|
13
|
+
namespace m = margelo;
|
|
13
14
|
|
|
14
15
|
namespace rnwgpu {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
wgpu::
|
|
17
|
+
struct GPUStencilFaceState {
|
|
18
|
+
std::optional<wgpu::CompareFunction> compare; // GPUCompareFunction
|
|
19
|
+
std::optional<wgpu::StencilOperation> failOp; // GPUStencilOperation
|
|
20
|
+
std::optional<wgpu::StencilOperation> depthFailOp; // GPUStencilOperation
|
|
21
|
+
std::optional<wgpu::StencilOperation> passOp; // GPUStencilOperation
|
|
21
22
|
};
|
|
23
|
+
|
|
22
24
|
} // namespace rnwgpu
|
|
23
25
|
|
|
24
26
|
namespace margelo {
|
|
25
27
|
|
|
28
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
29
|
+
|
|
26
30
|
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUStencilFaceState>> {
|
|
27
31
|
static std::shared_ptr<rnwgpu::GPUStencilFaceState>
|
|
28
32
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -30,32 +34,37 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUStencilFaceState>> {
|
|
|
30
34
|
if (!outOfBounds && arg.isObject()) {
|
|
31
35
|
auto value = arg.getObject(runtime);
|
|
32
36
|
if (value.hasProperty(runtime, "compare")) {
|
|
33
|
-
auto
|
|
37
|
+
auto prop = value.getProperty(runtime, "compare");
|
|
38
|
+
result->compare =
|
|
39
|
+
JSIConverter<std::optional<wgpu::CompareFunction>>::fromJSI(
|
|
40
|
+
runtime, prop, false);
|
|
34
41
|
}
|
|
35
42
|
if (value.hasProperty(runtime, "failOp")) {
|
|
36
|
-
auto
|
|
43
|
+
auto prop = value.getProperty(runtime, "failOp");
|
|
44
|
+
result->failOp =
|
|
45
|
+
JSIConverter<std::optional<wgpu::StencilOperation>>::fromJSI(
|
|
46
|
+
runtime, prop, false);
|
|
37
47
|
}
|
|
38
48
|
if (value.hasProperty(runtime, "depthFailOp")) {
|
|
39
|
-
auto
|
|
49
|
+
auto prop = value.getProperty(runtime, "depthFailOp");
|
|
50
|
+
result->depthFailOp =
|
|
51
|
+
JSIConverter<std::optional<wgpu::StencilOperation>>::fromJSI(
|
|
52
|
+
runtime, prop, false);
|
|
40
53
|
}
|
|
41
54
|
if (value.hasProperty(runtime, "passOp")) {
|
|
42
|
-
auto
|
|
55
|
+
auto prop = value.getProperty(runtime, "passOp");
|
|
56
|
+
result->passOp =
|
|
57
|
+
JSIConverter<std::optional<wgpu::StencilOperation>>::fromJSI(
|
|
58
|
+
runtime, prop, false);
|
|
43
59
|
}
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
result->_instance.compare);
|
|
47
|
-
rnwgpu::Logger::logToConsole("GPUStencilFaceState::failOp = %f",
|
|
48
|
-
result->_instance.failOp);
|
|
49
|
-
rnwgpu::Logger::logToConsole("GPUStencilFaceState::depthFailOp = %f",
|
|
50
|
-
result->_instance.depthFailOp);
|
|
51
|
-
rnwgpu::Logger::logToConsole("GPUStencilFaceState::passOp = %f",
|
|
52
|
-
result->_instance.passOp);
|
|
61
|
+
|
|
53
62
|
return result;
|
|
54
63
|
}
|
|
55
64
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
56
65
|
std::shared_ptr<rnwgpu::GPUStencilFaceState> arg) {
|
|
57
|
-
|
|
58
|
-
return jsi::Value::null();
|
|
66
|
+
throw std::runtime_error("Invalid GPUStencilFaceState::toJSI()");
|
|
59
67
|
}
|
|
60
68
|
};
|
|
61
|
-
|
|
69
|
+
|
|
70
|
+
} // namespace margelo
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
-
#include <string>
|
|
5
4
|
|
|
6
5
|
#include "webgpu/webgpu_cpp.h"
|
|
7
6
|
|
|
8
|
-
#include "Logger.h"
|
|
9
7
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
8
|
+
#include "WGPULogger.h"
|
|
9
|
+
|
|
10
|
+
#include "RNFHybridObject.h"
|
|
11
11
|
|
|
12
12
|
namespace jsi = facebook::jsi;
|
|
13
|
+
namespace m = margelo;
|
|
13
14
|
|
|
14
15
|
namespace rnwgpu {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
struct GPUStorageTextureBindingLayout {
|
|
18
|
+
std::optional<wgpu::StorageTextureAccess> access; // GPUStorageTextureAccess
|
|
19
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
20
|
+
std::optional<wgpu::TextureViewDimension>
|
|
21
|
+
viewDimension; // GPUTextureViewDimension
|
|
21
22
|
};
|
|
23
|
+
|
|
22
24
|
} // namespace rnwgpu
|
|
23
25
|
|
|
24
26
|
namespace margelo {
|
|
25
27
|
|
|
28
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
29
|
+
|
|
26
30
|
template <>
|
|
27
31
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUStorageTextureBindingLayout>> {
|
|
28
32
|
static std::shared_ptr<rnwgpu::GPUStorageTextureBindingLayout>
|
|
@@ -31,37 +35,31 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUStorageTextureBindingLayout>> {
|
|
|
31
35
|
if (!outOfBounds && arg.isObject()) {
|
|
32
36
|
auto value = arg.getObject(runtime);
|
|
33
37
|
if (value.hasProperty(runtime, "access")) {
|
|
34
|
-
auto
|
|
38
|
+
auto prop = value.getProperty(runtime, "access");
|
|
39
|
+
result->access =
|
|
40
|
+
JSIConverter<std::optional<wgpu::StorageTextureAccess>>::fromJSI(
|
|
41
|
+
runtime, prop, false);
|
|
35
42
|
}
|
|
36
43
|
if (value.hasProperty(runtime, "format")) {
|
|
37
|
-
auto
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
throw std::runtime_error(
|
|
41
|
-
"Property GPUStorageTextureBindingLayout::format is required");
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
throw std::runtime_error(
|
|
45
|
-
"Property GPUStorageTextureBindingLayout::format is not defined");
|
|
44
|
+
auto prop = value.getProperty(runtime, "format");
|
|
45
|
+
result->format =
|
|
46
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
46
47
|
}
|
|
47
48
|
if (value.hasProperty(runtime, "viewDimension")) {
|
|
48
|
-
auto
|
|
49
|
+
auto prop = value.getProperty(runtime, "viewDimension");
|
|
50
|
+
result->viewDimension =
|
|
51
|
+
JSIConverter<std::optional<wgpu::TextureViewDimension>>::fromJSI(
|
|
52
|
+
runtime, prop, false);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
|
|
52
|
-
result->_instance.access);
|
|
53
|
-
rnwgpu::Logger::logToConsole("GPUStorageTextureBindingLayout::format = %f",
|
|
54
|
-
result->_instance.format);
|
|
55
|
-
rnwgpu::Logger::logToConsole(
|
|
56
|
-
"GPUStorageTextureBindingLayout::viewDimension = %f",
|
|
57
|
-
result->_instance.viewDimension);
|
|
55
|
+
|
|
58
56
|
return result;
|
|
59
57
|
}
|
|
60
58
|
static jsi::Value
|
|
61
59
|
toJSI(jsi::Runtime &runtime,
|
|
62
60
|
std::shared_ptr<rnwgpu::GPUStorageTextureBindingLayout> arg) {
|
|
63
|
-
|
|
64
|
-
return jsi::Value::null();
|
|
61
|
+
throw std::runtime_error("Invalid GPUStorageTextureBindingLayout::toJSI()");
|
|
65
62
|
}
|
|
66
63
|
};
|
|
67
|
-
|
|
64
|
+
|
|
65
|
+
} // namespace margelo
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
-
#include <string>
|
|
5
4
|
|
|
6
5
|
#include "webgpu/webgpu_cpp.h"
|
|
7
6
|
|
|
8
|
-
#include "Logger.h"
|
|
9
7
|
#include "RNFJSIConverter.h"
|
|
10
|
-
#include
|
|
8
|
+
#include "WGPULogger.h"
|
|
9
|
+
|
|
10
|
+
#include "RNFHybridObject.h"
|
|
11
11
|
|
|
12
12
|
namespace jsi = facebook::jsi;
|
|
13
|
+
namespace m = margelo;
|
|
13
14
|
|
|
14
15
|
namespace rnwgpu {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
struct GPUTextureBindingLayout {
|
|
18
|
+
std::optional<wgpu::TextureSampleType> sampleType; // GPUTextureSampleType
|
|
19
|
+
std::optional<wgpu::TextureViewDimension>
|
|
20
|
+
viewDimension; // GPUTextureViewDimension
|
|
21
|
+
std::optional<bool> multisampled; // boolean
|
|
21
22
|
};
|
|
23
|
+
|
|
22
24
|
} // namespace rnwgpu
|
|
23
25
|
|
|
24
26
|
namespace margelo {
|
|
25
27
|
|
|
28
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
29
|
+
|
|
26
30
|
template <>
|
|
27
31
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUTextureBindingLayout>> {
|
|
28
32
|
static std::shared_ptr<rnwgpu::GPUTextureBindingLayout>
|
|
@@ -31,28 +35,31 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUTextureBindingLayout>> {
|
|
|
31
35
|
if (!outOfBounds && arg.isObject()) {
|
|
32
36
|
auto value = arg.getObject(runtime);
|
|
33
37
|
if (value.hasProperty(runtime, "sampleType")) {
|
|
34
|
-
auto
|
|
38
|
+
auto prop = value.getProperty(runtime, "sampleType");
|
|
39
|
+
result->sampleType =
|
|
40
|
+
JSIConverter<std::optional<wgpu::TextureSampleType>>::fromJSI(
|
|
41
|
+
runtime, prop, false);
|
|
35
42
|
}
|
|
36
43
|
if (value.hasProperty(runtime, "viewDimension")) {
|
|
37
|
-
auto
|
|
44
|
+
auto prop = value.getProperty(runtime, "viewDimension");
|
|
45
|
+
result->viewDimension =
|
|
46
|
+
JSIConverter<std::optional<wgpu::TextureViewDimension>>::fromJSI(
|
|
47
|
+
runtime, prop, false);
|
|
38
48
|
}
|
|
39
49
|
if (value.hasProperty(runtime, "multisampled")) {
|
|
40
|
-
auto
|
|
50
|
+
auto prop = value.getProperty(runtime, "multisampled");
|
|
51
|
+
result->multisampled =
|
|
52
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
result->_instance.sampleType);
|
|
45
|
-
rnwgpu::Logger::logToConsole("GPUTextureBindingLayout::viewDimension = %f",
|
|
46
|
-
result->_instance.viewDimension);
|
|
47
|
-
rnwgpu::Logger::logToConsole("GPUTextureBindingLayout::multisampled = %f",
|
|
48
|
-
result->_instance.multisampled);
|
|
55
|
+
|
|
49
56
|
return result;
|
|
50
57
|
}
|
|
51
58
|
static jsi::Value
|
|
52
59
|
toJSI(jsi::Runtime &runtime,
|
|
53
60
|
std::shared_ptr<rnwgpu::GPUTextureBindingLayout> arg) {
|
|
54
|
-
|
|
55
|
-
return jsi::Value::null();
|
|
61
|
+
throw std::runtime_error("Invalid GPUTextureBindingLayout::toJSI()");
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
|
-
|
|
64
|
+
|
|
65
|
+
} // namespace margelo
|