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
|
@@ -2,29 +2,39 @@
|
|
|
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 "GPUExtent3D.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
|
-
wgpu::
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
struct GPUTextureDescriptor {
|
|
21
|
+
std::shared_ptr<GPUExtent3D> size; // GPUExtent3DStrict
|
|
22
|
+
std::optional<double> mipLevelCount; // GPUIntegerCoordinate
|
|
23
|
+
std::optional<double> sampleCount; // GPUSize32
|
|
24
|
+
std::optional<wgpu::TextureDimension> dimension; // GPUTextureDimension
|
|
25
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
26
|
+
double usage; // GPUTextureUsageFlags
|
|
27
|
+
std::optional<std::vector<wgpu::TextureFormat>>
|
|
28
|
+
viewFormats; // Iterable<GPUTextureFormat>
|
|
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::GPUTextureDescriptor>> {
|
|
29
39
|
static std::shared_ptr<rnwgpu::GPUTextureDescriptor>
|
|
30
40
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -32,92 +42,55 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUTextureDescriptor>> {
|
|
|
32
42
|
if (!outOfBounds && arg.isObject()) {
|
|
33
43
|
auto value = arg.getObject(runtime);
|
|
34
44
|
if (value.hasProperty(runtime, "size")) {
|
|
35
|
-
auto
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw std::runtime_error(
|
|
39
|
-
"Property GPUTextureDescriptor::size is required");
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
throw std::runtime_error(
|
|
43
|
-
"Property GPUTextureDescriptor::size is not defined");
|
|
45
|
+
auto prop = value.getProperty(runtime, "size");
|
|
46
|
+
result->size = JSIConverter<std::shared_ptr<GPUExtent3D>>::fromJSI(
|
|
47
|
+
runtime, prop, false);
|
|
44
48
|
}
|
|
45
49
|
if (value.hasProperty(runtime, "mipLevelCount")) {
|
|
46
|
-
auto
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
result->_instance.mipLevelCount =
|
|
50
|
-
static_cast<wgpu::IntegerCoordinate>(mipLevelCount.getNumber());
|
|
51
|
-
}
|
|
50
|
+
auto prop = value.getProperty(runtime, "mipLevelCount");
|
|
51
|
+
result->mipLevelCount =
|
|
52
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
52
53
|
}
|
|
53
54
|
if (value.hasProperty(runtime, "sampleCount")) {
|
|
54
|
-
auto
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
result->_instance.sampleCount =
|
|
58
|
-
static_cast<wgpu::Size32>(sampleCount.getNumber());
|
|
59
|
-
}
|
|
55
|
+
auto prop = value.getProperty(runtime, "sampleCount");
|
|
56
|
+
result->sampleCount =
|
|
57
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
60
58
|
}
|
|
61
59
|
if (value.hasProperty(runtime, "dimension")) {
|
|
62
|
-
auto
|
|
60
|
+
auto prop = value.getProperty(runtime, "dimension");
|
|
61
|
+
result->dimension =
|
|
62
|
+
JSIConverter<std::optional<wgpu::TextureDimension>>::fromJSI(
|
|
63
|
+
runtime, prop, false);
|
|
63
64
|
}
|
|
64
65
|
if (value.hasProperty(runtime, "format")) {
|
|
65
|
-
auto
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw std::runtime_error(
|
|
69
|
-
"Property GPUTextureDescriptor::format is required");
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
throw std::runtime_error(
|
|
73
|
-
"Property GPUTextureDescriptor::format is not defined");
|
|
66
|
+
auto prop = value.getProperty(runtime, "format");
|
|
67
|
+
result->format =
|
|
68
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
74
69
|
}
|
|
75
70
|
if (value.hasProperty(runtime, "usage")) {
|
|
76
|
-
auto
|
|
77
|
-
|
|
78
|
-
if (usage.isUndefined()) {
|
|
79
|
-
throw std::runtime_error(
|
|
80
|
-
"Property GPUTextureDescriptor::usage is required");
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
throw std::runtime_error(
|
|
84
|
-
"Property GPUTextureDescriptor::usage is not defined");
|
|
71
|
+
auto prop = value.getProperty(runtime, "usage");
|
|
72
|
+
result->usage = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
85
73
|
}
|
|
86
74
|
if (value.hasProperty(runtime, "viewFormats")) {
|
|
87
|
-
auto
|
|
75
|
+
auto prop = value.getProperty(runtime, "viewFormats");
|
|
76
|
+
result->viewFormats = JSIConverter<
|
|
77
|
+
std::optional<std::vector<wgpu::TextureFormat>>>::fromJSI(runtime,
|
|
78
|
+
prop,
|
|
79
|
+
false);
|
|
88
80
|
}
|
|
89
81
|
if (value.hasProperty(runtime, "label")) {
|
|
90
|
-
auto
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
auto str = label.asString(runtime).utf8(runtime);
|
|
94
|
-
result->label = str;
|
|
95
|
-
result->_instance.label = result->label.c_str();
|
|
96
|
-
}
|
|
82
|
+
auto prop = value.getProperty(runtime, "label");
|
|
83
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
84
|
+
runtime, prop, false);
|
|
97
85
|
}
|
|
98
86
|
}
|
|
99
|
-
|
|
100
|
-
result->_instance.size);
|
|
101
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::mipLevelCount = %f",
|
|
102
|
-
result->_instance.mipLevelCount);
|
|
103
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::sampleCount = %f",
|
|
104
|
-
result->_instance.sampleCount);
|
|
105
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::dimension = %f",
|
|
106
|
-
result->_instance.dimension);
|
|
107
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::format = %f",
|
|
108
|
-
result->_instance.format);
|
|
109
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::usage = %f",
|
|
110
|
-
result->_instance.usage);
|
|
111
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::viewFormats = %f",
|
|
112
|
-
result->_instance.viewFormats);
|
|
113
|
-
rnwgpu::Logger::logToConsole("GPUTextureDescriptor::label = %f",
|
|
114
|
-
result->_instance.label);
|
|
87
|
+
|
|
115
88
|
return result;
|
|
116
89
|
}
|
|
117
90
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
118
91
|
std::shared_ptr<rnwgpu::GPUTextureDescriptor> arg) {
|
|
119
|
-
|
|
120
|
-
return jsi::Value::null();
|
|
92
|
+
throw std::runtime_error("Invalid GPUTextureDescriptor::toJSI()");
|
|
121
93
|
}
|
|
122
94
|
};
|
|
123
|
-
|
|
95
|
+
|
|
96
|
+
} // namespace margelo
|
|
@@ -5,26 +5,34 @@
|
|
|
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 GPUTextureViewDescriptor {
|
|
19
|
+
std::optional<wgpu::TextureFormat> format; // GPUTextureFormat
|
|
20
|
+
std::optional<wgpu::TextureViewDimension>
|
|
21
|
+
dimension; // GPUTextureViewDimension
|
|
22
|
+
std::optional<wgpu::TextureAspect> aspect; // GPUTextureAspect
|
|
23
|
+
std::optional<double> baseMipLevel; // GPUIntegerCoordinate
|
|
24
|
+
std::optional<double> mipLevelCount; // GPUIntegerCoordinate
|
|
25
|
+
std::optional<double> baseArrayLayer; // GPUIntegerCoordinate
|
|
26
|
+
std::optional<double> arrayLayerCount; // GPUIntegerCoordinate
|
|
27
|
+
std::optional<std::string> label; // string
|
|
23
28
|
};
|
|
29
|
+
|
|
24
30
|
} // namespace rnwgpu
|
|
25
31
|
|
|
26
32
|
namespace margelo {
|
|
27
33
|
|
|
34
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
35
|
+
|
|
28
36
|
template <>
|
|
29
37
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUTextureViewDescriptor>> {
|
|
30
38
|
static std::shared_ptr<rnwgpu::GPUTextureViewDescriptor>
|
|
@@ -33,81 +41,57 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUTextureViewDescriptor>> {
|
|
|
33
41
|
if (!outOfBounds && arg.isObject()) {
|
|
34
42
|
auto value = arg.getObject(runtime);
|
|
35
43
|
if (value.hasProperty(runtime, "format")) {
|
|
36
|
-
auto
|
|
44
|
+
auto prop = value.getProperty(runtime, "format");
|
|
45
|
+
result->format =
|
|
46
|
+
JSIConverter<std::optional<wgpu::TextureFormat>>::fromJSI(
|
|
47
|
+
runtime, prop, false);
|
|
37
48
|
}
|
|
38
49
|
if (value.hasProperty(runtime, "dimension")) {
|
|
39
|
-
auto
|
|
50
|
+
auto prop = value.getProperty(runtime, "dimension");
|
|
51
|
+
result->dimension =
|
|
52
|
+
JSIConverter<std::optional<wgpu::TextureViewDimension>>::fromJSI(
|
|
53
|
+
runtime, prop, false);
|
|
40
54
|
}
|
|
41
55
|
if (value.hasProperty(runtime, "aspect")) {
|
|
42
|
-
auto
|
|
56
|
+
auto prop = value.getProperty(runtime, "aspect");
|
|
57
|
+
result->aspect =
|
|
58
|
+
JSIConverter<std::optional<wgpu::TextureAspect>>::fromJSI(
|
|
59
|
+
runtime, prop, false);
|
|
43
60
|
}
|
|
44
61
|
if (value.hasProperty(runtime, "baseMipLevel")) {
|
|
45
|
-
auto
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
result->_instance.baseMipLevel =
|
|
49
|
-
static_cast<wgpu::IntegerCoordinate>(baseMipLevel.getNumber());
|
|
50
|
-
}
|
|
62
|
+
auto prop = value.getProperty(runtime, "baseMipLevel");
|
|
63
|
+
result->baseMipLevel =
|
|
64
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
51
65
|
}
|
|
52
66
|
if (value.hasProperty(runtime, "mipLevelCount")) {
|
|
53
|
-
auto
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
result->_instance.mipLevelCount =
|
|
57
|
-
static_cast<wgpu::IntegerCoordinate>(mipLevelCount.getNumber());
|
|
58
|
-
}
|
|
67
|
+
auto prop = value.getProperty(runtime, "mipLevelCount");
|
|
68
|
+
result->mipLevelCount =
|
|
69
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
59
70
|
}
|
|
60
71
|
if (value.hasProperty(runtime, "baseArrayLayer")) {
|
|
61
|
-
auto
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
result->_instance.baseArrayLayer =
|
|
65
|
-
static_cast<wgpu::IntegerCoordinate>(baseArrayLayer.getNumber());
|
|
66
|
-
}
|
|
72
|
+
auto prop = value.getProperty(runtime, "baseArrayLayer");
|
|
73
|
+
result->baseArrayLayer =
|
|
74
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
67
75
|
}
|
|
68
76
|
if (value.hasProperty(runtime, "arrayLayerCount")) {
|
|
69
|
-
auto
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
result->_instance.arrayLayerCount =
|
|
73
|
-
static_cast<wgpu::IntegerCoordinate>(arrayLayerCount.getNumber());
|
|
74
|
-
}
|
|
77
|
+
auto prop = value.getProperty(runtime, "arrayLayerCount");
|
|
78
|
+
result->arrayLayerCount =
|
|
79
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
75
80
|
}
|
|
76
81
|
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
|
-
}
|
|
82
|
+
auto prop = value.getProperty(runtime, "label");
|
|
83
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
84
|
+
runtime, prop, false);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
-
result->_instance.format);
|
|
88
|
-
rnwgpu::Logger::logToConsole("GPUTextureViewDescriptor::dimension = %f",
|
|
89
|
-
result->_instance.dimension);
|
|
90
|
-
rnwgpu::Logger::logToConsole("GPUTextureViewDescriptor::aspect = %f",
|
|
91
|
-
result->_instance.aspect);
|
|
92
|
-
rnwgpu::Logger::logToConsole("GPUTextureViewDescriptor::baseMipLevel = %f",
|
|
93
|
-
result->_instance.baseMipLevel);
|
|
94
|
-
rnwgpu::Logger::logToConsole("GPUTextureViewDescriptor::mipLevelCount = %f",
|
|
95
|
-
result->_instance.mipLevelCount);
|
|
96
|
-
rnwgpu::Logger::logToConsole(
|
|
97
|
-
"GPUTextureViewDescriptor::baseArrayLayer = %f",
|
|
98
|
-
result->_instance.baseArrayLayer);
|
|
99
|
-
rnwgpu::Logger::logToConsole(
|
|
100
|
-
"GPUTextureViewDescriptor::arrayLayerCount = %f",
|
|
101
|
-
result->_instance.arrayLayerCount);
|
|
102
|
-
rnwgpu::Logger::logToConsole("GPUTextureViewDescriptor::label = %f",
|
|
103
|
-
result->_instance.label);
|
|
87
|
+
|
|
104
88
|
return result;
|
|
105
89
|
}
|
|
106
90
|
static jsi::Value
|
|
107
91
|
toJSI(jsi::Runtime &runtime,
|
|
108
92
|
std::shared_ptr<rnwgpu::GPUTextureViewDescriptor> arg) {
|
|
109
|
-
|
|
110
|
-
return jsi::Value::null();
|
|
93
|
+
throw std::runtime_error("Invalid GPUTextureViewDescriptor::toJSI()");
|
|
111
94
|
}
|
|
112
95
|
};
|
|
113
|
-
|
|
96
|
+
|
|
97
|
+
} // namespace margelo
|
|
@@ -1,28 +1,33 @@
|
|
|
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 "GPUError.h"
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
struct GPUUncapturedErrorEventInit {
|
|
19
|
+
std::shared_ptr<GPUError> error; // GPUError
|
|
20
|
+
std::optional<bool> bubbles; // boolean
|
|
21
|
+
std::optional<bool> cancelable; // boolean
|
|
22
|
+
std::optional<bool> composed; // boolean
|
|
21
23
|
};
|
|
24
|
+
|
|
22
25
|
} // namespace rnwgpu
|
|
23
26
|
|
|
24
27
|
namespace margelo {
|
|
25
28
|
|
|
29
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
30
|
+
|
|
26
31
|
template <>
|
|
27
32
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUUncapturedErrorEventInit>> {
|
|
28
33
|
static std::shared_ptr<rnwgpu::GPUUncapturedErrorEventInit>
|
|
@@ -31,41 +36,34 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUUncapturedErrorEventInit>> {
|
|
|
31
36
|
if (!outOfBounds && arg.isObject()) {
|
|
32
37
|
auto value = arg.getObject(runtime);
|
|
33
38
|
if (value.hasProperty(runtime, "error")) {
|
|
34
|
-
auto
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw std::runtime_error(
|
|
38
|
-
"Property GPUUncapturedErrorEventInit::error is required");
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
throw std::runtime_error(
|
|
42
|
-
"Property GPUUncapturedErrorEventInit::error is not defined");
|
|
39
|
+
auto prop = value.getProperty(runtime, "error");
|
|
40
|
+
result->error = JSIConverter<std::shared_ptr<GPUError>>::fromJSI(
|
|
41
|
+
runtime, prop, false);
|
|
43
42
|
}
|
|
44
43
|
if (value.hasProperty(runtime, "bubbles")) {
|
|
45
|
-
auto
|
|
44
|
+
auto prop = value.getProperty(runtime, "bubbles");
|
|
45
|
+
result->bubbles =
|
|
46
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
46
47
|
}
|
|
47
48
|
if (value.hasProperty(runtime, "cancelable")) {
|
|
48
|
-
auto
|
|
49
|
+
auto prop = value.getProperty(runtime, "cancelable");
|
|
50
|
+
result->cancelable =
|
|
51
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
49
52
|
}
|
|
50
53
|
if (value.hasProperty(runtime, "composed")) {
|
|
51
|
-
auto
|
|
54
|
+
auto prop = value.getProperty(runtime, "composed");
|
|
55
|
+
result->composed =
|
|
56
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
result->_instance.error);
|
|
56
|
-
rnwgpu::Logger::logToConsole("GPUUncapturedErrorEventInit::bubbles = %f",
|
|
57
|
-
result->_instance.bubbles);
|
|
58
|
-
rnwgpu::Logger::logToConsole("GPUUncapturedErrorEventInit::cancelable = %f",
|
|
59
|
-
result->_instance.cancelable);
|
|
60
|
-
rnwgpu::Logger::logToConsole("GPUUncapturedErrorEventInit::composed = %f",
|
|
61
|
-
result->_instance.composed);
|
|
59
|
+
|
|
62
60
|
return result;
|
|
63
61
|
}
|
|
64
62
|
static jsi::Value
|
|
65
63
|
toJSI(jsi::Runtime &runtime,
|
|
66
64
|
std::shared_ptr<rnwgpu::GPUUncapturedErrorEventInit> arg) {
|
|
67
|
-
|
|
68
|
-
return jsi::Value::null();
|
|
65
|
+
throw std::runtime_error("Invalid GPUUncapturedErrorEventInit::toJSI()");
|
|
69
66
|
}
|
|
70
67
|
};
|
|
71
|
-
|
|
68
|
+
|
|
69
|
+
} // namespace margelo
|
|
@@ -1,28 +1,31 @@
|
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
wgpu::VertexAttribute _instance;
|
|
17
|
+
struct GPUVertexAttribute {
|
|
18
|
+
wgpu::VertexFormat format; // GPUVertexFormat
|
|
19
|
+
double offset; // GPUSize64
|
|
20
|
+
double shaderLocation; // GPUIndex32
|
|
21
21
|
};
|
|
22
|
+
|
|
22
23
|
} // namespace rnwgpu
|
|
23
24
|
|
|
24
25
|
namespace margelo {
|
|
25
26
|
|
|
27
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
28
|
+
|
|
26
29
|
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexAttribute>> {
|
|
27
30
|
static std::shared_ptr<rnwgpu::GPUVertexAttribute>
|
|
28
31
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -30,51 +33,27 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexAttribute>> {
|
|
|
30
33
|
if (!outOfBounds && arg.isObject()) {
|
|
31
34
|
auto value = arg.getObject(runtime);
|
|
32
35
|
if (value.hasProperty(runtime, "format")) {
|
|
33
|
-
auto
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw std::runtime_error(
|
|
37
|
-
"Property GPUVertexAttribute::format is required");
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
throw std::runtime_error(
|
|
41
|
-
"Property GPUVertexAttribute::format is not defined");
|
|
36
|
+
auto prop = value.getProperty(runtime, "format");
|
|
37
|
+
result->format =
|
|
38
|
+
JSIConverter<wgpu::VertexFormat>::fromJSI(runtime, prop, false);
|
|
42
39
|
}
|
|
43
40
|
if (value.hasProperty(runtime, "offset")) {
|
|
44
|
-
auto
|
|
45
|
-
|
|
46
|
-
if (offset.isUndefined()) {
|
|
47
|
-
throw std::runtime_error(
|
|
48
|
-
"Property GPUVertexAttribute::offset is required");
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
throw std::runtime_error(
|
|
52
|
-
"Property GPUVertexAttribute::offset is not defined");
|
|
41
|
+
auto prop = value.getProperty(runtime, "offset");
|
|
42
|
+
result->offset = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
53
43
|
}
|
|
54
44
|
if (value.hasProperty(runtime, "shaderLocation")) {
|
|
55
|
-
auto
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw std::runtime_error(
|
|
59
|
-
"Property GPUVertexAttribute::shaderLocation is required");
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
throw std::runtime_error(
|
|
63
|
-
"Property GPUVertexAttribute::shaderLocation is not defined");
|
|
45
|
+
auto prop = value.getProperty(runtime, "shaderLocation");
|
|
46
|
+
result->shaderLocation =
|
|
47
|
+
JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
64
48
|
}
|
|
65
49
|
}
|
|
66
|
-
|
|
67
|
-
result->_instance.format);
|
|
68
|
-
rnwgpu::Logger::logToConsole("GPUVertexAttribute::offset = %f",
|
|
69
|
-
result->_instance.offset);
|
|
70
|
-
rnwgpu::Logger::logToConsole("GPUVertexAttribute::shaderLocation = %f",
|
|
71
|
-
result->_instance.shaderLocation);
|
|
50
|
+
|
|
72
51
|
return result;
|
|
73
52
|
}
|
|
74
53
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
75
54
|
std::shared_ptr<rnwgpu::GPUVertexAttribute> arg) {
|
|
76
|
-
|
|
77
|
-
return jsi::Value::null();
|
|
55
|
+
throw std::runtime_error("Invalid GPUVertexAttribute::toJSI()");
|
|
78
56
|
}
|
|
79
57
|
};
|
|
80
|
-
|
|
58
|
+
|
|
59
|
+
} // namespace margelo
|
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
|
-
#include <
|
|
4
|
+
#include <vector>
|
|
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 "GPUVertexAttribute.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
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
struct GPUVertexBufferLayout {
|
|
20
|
+
double arrayStride; // GPUSize64
|
|
21
|
+
std::optional<wgpu::VertexStepMode> stepMode; // GPUVertexStepMode
|
|
22
|
+
std::vector<std::shared_ptr<GPUVertexAttribute>>
|
|
23
|
+
attributes; // Iterable<GPUVertexAttribute>
|
|
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::GPUVertexBufferLayout>> {
|
|
28
34
|
static std::shared_ptr<rnwgpu::GPUVertexBufferLayout>
|
|
@@ -31,43 +37,31 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUVertexBufferLayout>> {
|
|
|
31
37
|
if (!outOfBounds && arg.isObject()) {
|
|
32
38
|
auto value = arg.getObject(runtime);
|
|
33
39
|
if (value.hasProperty(runtime, "arrayStride")) {
|
|
34
|
-
auto
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw std::runtime_error(
|
|
38
|
-
"Property GPUVertexBufferLayout::arrayStride is required");
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
throw std::runtime_error(
|
|
42
|
-
"Property GPUVertexBufferLayout::arrayStride is not defined");
|
|
40
|
+
auto prop = value.getProperty(runtime, "arrayStride");
|
|
41
|
+
result->arrayStride =
|
|
42
|
+
JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
43
43
|
}
|
|
44
44
|
if (value.hasProperty(runtime, "stepMode")) {
|
|
45
|
-
auto
|
|
45
|
+
auto prop = value.getProperty(runtime, "stepMode");
|
|
46
|
+
result->stepMode =
|
|
47
|
+
JSIConverter<std::optional<wgpu::VertexStepMode>>::fromJSI(
|
|
48
|
+
runtime, prop, false);
|
|
46
49
|
}
|
|
47
50
|
if (value.hasProperty(runtime, "attributes")) {
|
|
48
|
-
auto
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
throw std::runtime_error(
|
|
56
|
-
"Property GPUVertexBufferLayout::attributes is not defined");
|
|
51
|
+
auto prop = value.getProperty(runtime, "attributes");
|
|
52
|
+
result->attributes = JSIConverter<
|
|
53
|
+
std::vector<std::shared_ptr<GPUVertexAttribute>>>::fromJSI(runtime,
|
|
54
|
+
prop,
|
|
55
|
+
false);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
result->_instance.arrayStride);
|
|
61
|
-
rnwgpu::Logger::logToConsole("GPUVertexBufferLayout::stepMode = %f",
|
|
62
|
-
result->_instance.stepMode);
|
|
63
|
-
rnwgpu::Logger::logToConsole("GPUVertexBufferLayout::attributes = %f",
|
|
64
|
-
result->_instance.attributes);
|
|
58
|
+
|
|
65
59
|
return result;
|
|
66
60
|
}
|
|
67
61
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
68
62
|
std::shared_ptr<rnwgpu::GPUVertexBufferLayout> arg) {
|
|
69
|
-
|
|
70
|
-
return jsi::Value::null();
|
|
63
|
+
throw std::runtime_error("Invalid GPUVertexBufferLayout::toJSI()");
|
|
71
64
|
}
|
|
72
65
|
};
|
|
73
|
-
|
|
66
|
+
|
|
67
|
+
} // namespace margelo
|