react-native-wgpu 0.1.0 → 0.1.2
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 +26 -0
- package/android/cpp/cpp-adapter.cpp +66 -3
- package/android/src/main/java/com/webgpu/WebGPUModule.java +64 -22
- 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 +16 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +14 -9
- package/cpp/rnwgpu/RNWebGPUManager.h +12 -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 +100 -23
- package/cpp/rnwgpu/api/GPU.h +24 -6
- package/cpp/rnwgpu/api/GPUAdapter.cpp +122 -8
- 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 +43 -7
- 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 +110 -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/ImageData.h +50 -0
- package/cpp/rnwgpu/api/Navigator.h +46 -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 +25 -34
- 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 +16 -0
- package/ios/IOSPlatformContext.mm +18 -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 +49 -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 +158 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Canvas.js +42 -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 +144 -6
- package/lib/module/index.js.map +1 -1
- 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/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 +2 -3
- package/lib/typescript/src/Canvas.d.ts +22 -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 +2 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/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 +68 -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 +172 -8
- 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
|
@@ -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::BufferBindingLayout _instance;
|
|
17
|
+
struct GPUBufferBindingLayout {
|
|
18
|
+
std::optional<wgpu::BufferBindingType> type; // GPUBufferBindingType
|
|
19
|
+
std::optional<bool> hasDynamicOffset; // boolean
|
|
20
|
+
std::optional<double> minBindingSize; // GPUSize64
|
|
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 <>
|
|
27
30
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBindingLayout>> {
|
|
28
31
|
static std::shared_ptr<rnwgpu::GPUBufferBindingLayout>
|
|
@@ -31,32 +34,29 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBindingLayout>> {
|
|
|
31
34
|
if (!outOfBounds && arg.isObject()) {
|
|
32
35
|
auto value = arg.getObject(runtime);
|
|
33
36
|
if (value.hasProperty(runtime, "type")) {
|
|
34
|
-
auto
|
|
37
|
+
auto prop = value.getProperty(runtime, "type");
|
|
38
|
+
result->type =
|
|
39
|
+
JSIConverter<std::optional<wgpu::BufferBindingType>>::fromJSI(
|
|
40
|
+
runtime, prop, false);
|
|
35
41
|
}
|
|
36
42
|
if (value.hasProperty(runtime, "hasDynamicOffset")) {
|
|
37
|
-
auto
|
|
43
|
+
auto prop = value.getProperty(runtime, "hasDynamicOffset");
|
|
44
|
+
result->hasDynamicOffset =
|
|
45
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
38
46
|
}
|
|
39
47
|
if (value.hasProperty(runtime, "minBindingSize")) {
|
|
40
|
-
auto
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
result->_instance.minBindingSize = minBindingSize.getNumber();
|
|
44
|
-
}
|
|
48
|
+
auto prop = value.getProperty(runtime, "minBindingSize");
|
|
49
|
+
result->minBindingSize =
|
|
50
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
result->_instance.type);
|
|
49
|
-
rnwgpu::Logger::logToConsole(
|
|
50
|
-
"GPUBufferBindingLayout::hasDynamicOffset = %f",
|
|
51
|
-
result->_instance.hasDynamicOffset);
|
|
52
|
-
rnwgpu::Logger::logToConsole("GPUBufferBindingLayout::minBindingSize = %f",
|
|
53
|
-
result->_instance.minBindingSize);
|
|
53
|
+
|
|
54
54
|
return result;
|
|
55
55
|
}
|
|
56
56
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
57
57
|
std::shared_ptr<rnwgpu::GPUBufferBindingLayout> arg) {
|
|
58
|
-
|
|
59
|
-
return jsi::Value::null();
|
|
58
|
+
throw std::runtime_error("Invalid GPUBufferBindingLayout::toJSI()");
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
|
-
|
|
61
|
+
|
|
62
|
+
} // namespace margelo
|
|
@@ -5,26 +5,29 @@
|
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
std::string label;
|
|
18
|
+
struct GPUBufferDescriptor {
|
|
19
|
+
double size; // GPUSize64
|
|
20
|
+
double usage; // GPUBufferUsageFlags
|
|
21
|
+
std::optional<bool> mappedAtCreation; // boolean
|
|
22
|
+
std::optional<std::string> label; // string
|
|
23
23
|
};
|
|
24
|
+
|
|
24
25
|
} // namespace rnwgpu
|
|
25
26
|
|
|
26
27
|
namespace margelo {
|
|
27
28
|
|
|
29
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
30
|
+
|
|
28
31
|
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferDescriptor>> {
|
|
29
32
|
static std::shared_ptr<rnwgpu::GPUBufferDescriptor>
|
|
30
33
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -32,54 +35,31 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferDescriptor>> {
|
|
|
32
35
|
if (!outOfBounds && arg.isObject()) {
|
|
33
36
|
auto value = arg.getObject(runtime);
|
|
34
37
|
if (value.hasProperty(runtime, "size")) {
|
|
35
|
-
auto
|
|
36
|
-
|
|
37
|
-
if (size.isUndefined()) {
|
|
38
|
-
throw std::runtime_error(
|
|
39
|
-
"Property GPUBufferDescriptor::size is required");
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
throw std::runtime_error(
|
|
43
|
-
"Property GPUBufferDescriptor::size is not defined");
|
|
38
|
+
auto prop = value.getProperty(runtime, "size");
|
|
39
|
+
result->size = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
44
40
|
}
|
|
45
41
|
if (value.hasProperty(runtime, "usage")) {
|
|
46
|
-
auto
|
|
47
|
-
|
|
48
|
-
if (usage.isUndefined()) {
|
|
49
|
-
throw std::runtime_error(
|
|
50
|
-
"Property GPUBufferDescriptor::usage is required");
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
throw std::runtime_error(
|
|
54
|
-
"Property GPUBufferDescriptor::usage is not defined");
|
|
42
|
+
auto prop = value.getProperty(runtime, "usage");
|
|
43
|
+
result->usage = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
55
44
|
}
|
|
56
45
|
if (value.hasProperty(runtime, "mappedAtCreation")) {
|
|
57
|
-
auto
|
|
46
|
+
auto prop = value.getProperty(runtime, "mappedAtCreation");
|
|
47
|
+
result->mappedAtCreation =
|
|
48
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
58
49
|
}
|
|
59
50
|
if (value.hasProperty(runtime, "label")) {
|
|
60
|
-
auto
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
auto str = label.asString(runtime).utf8(runtime);
|
|
64
|
-
result->label = str;
|
|
65
|
-
result->_instance.label = result->label.c_str();
|
|
66
|
-
}
|
|
51
|
+
auto prop = value.getProperty(runtime, "label");
|
|
52
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
53
|
+
runtime, prop, false);
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
|
-
|
|
70
|
-
result->_instance.size);
|
|
71
|
-
rnwgpu::Logger::logToConsole("GPUBufferDescriptor::usage = %f",
|
|
72
|
-
result->_instance.usage);
|
|
73
|
-
rnwgpu::Logger::logToConsole("GPUBufferDescriptor::mappedAtCreation = %f",
|
|
74
|
-
result->_instance.mappedAtCreation);
|
|
75
|
-
rnwgpu::Logger::logToConsole("GPUBufferDescriptor::label = %f",
|
|
76
|
-
result->_instance.label);
|
|
56
|
+
|
|
77
57
|
return result;
|
|
78
58
|
}
|
|
79
59
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
80
60
|
std::shared_ptr<rnwgpu::GPUBufferDescriptor> arg) {
|
|
81
|
-
|
|
82
|
-
return jsi::Value::null();
|
|
61
|
+
throw std::runtime_error("Invalid GPUBufferDescriptor::toJSI()");
|
|
83
62
|
}
|
|
84
63
|
};
|
|
85
|
-
|
|
64
|
+
|
|
65
|
+
} // 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
|
-
|
|
9
|
+
|
|
10
|
+
#include "GPUDevice.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
|
-
wgpu::
|
|
19
|
-
|
|
20
|
-
wgpu::
|
|
18
|
+
struct GPUCanvasConfiguration {
|
|
19
|
+
std::shared_ptr<GPUDevice> device; // GPUDevice
|
|
20
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
21
|
+
std::optional<double> usage; // GPUTextureUsageFlags
|
|
22
|
+
std::optional<std::vector<wgpu::TextureFormat>>
|
|
23
|
+
viewFormats; // Iterable<GPUTextureFormat>
|
|
21
24
|
};
|
|
25
|
+
|
|
22
26
|
} // namespace rnwgpu
|
|
23
27
|
|
|
24
28
|
namespace margelo {
|
|
25
29
|
|
|
30
|
+
using namespace rnwgpu; // NOLINT(build/namespaces) // NOLINT(build/namespaces)
|
|
31
|
+
|
|
26
32
|
template <>
|
|
27
33
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
|
|
28
34
|
static std::shared_ptr<rnwgpu::GPUCanvasConfiguration>
|
|
@@ -31,63 +37,35 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
|
|
|
31
37
|
if (!outOfBounds && arg.isObject()) {
|
|
32
38
|
auto value = arg.getObject(runtime);
|
|
33
39
|
if (value.hasProperty(runtime, "device")) {
|
|
34
|
-
auto
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw std::runtime_error(
|
|
38
|
-
"Property GPUCanvasConfiguration::device is required");
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
throw std::runtime_error(
|
|
42
|
-
"Property GPUCanvasConfiguration::device is not defined");
|
|
40
|
+
auto prop = value.getProperty(runtime, "device");
|
|
41
|
+
result->device = JSIConverter<std::shared_ptr<GPUDevice>>::fromJSI(
|
|
42
|
+
runtime, prop, false);
|
|
43
43
|
}
|
|
44
44
|
if (value.hasProperty(runtime, "format")) {
|
|
45
|
-
auto
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
throw std::runtime_error(
|
|
49
|
-
"Property GPUCanvasConfiguration::format is required");
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
throw std::runtime_error(
|
|
53
|
-
"Property GPUCanvasConfiguration::format is not defined");
|
|
45
|
+
auto prop = value.getProperty(runtime, "format");
|
|
46
|
+
result->format =
|
|
47
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
54
48
|
}
|
|
55
49
|
if (value.hasProperty(runtime, "usage")) {
|
|
56
|
-
auto
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
result->_instance.usage =
|
|
60
|
-
static_cast<wgpu::TextureUsageFlags>(usage.getNumber());
|
|
61
|
-
}
|
|
50
|
+
auto prop = value.getProperty(runtime, "usage");
|
|
51
|
+
result->usage =
|
|
52
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
62
53
|
}
|
|
63
54
|
if (value.hasProperty(runtime, "viewFormats")) {
|
|
64
|
-
auto
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (value.hasProperty(runtime, "alphaMode")) {
|
|
70
|
-
auto alphaMode = value.getProperty(runtime, "alphaMode");
|
|
55
|
+
auto prop = value.getProperty(runtime, "viewFormats");
|
|
56
|
+
result->viewFormats = JSIConverter<
|
|
57
|
+
std::optional<std::vector<wgpu::TextureFormat>>>::fromJSI(runtime,
|
|
58
|
+
prop,
|
|
59
|
+
false);
|
|
71
60
|
}
|
|
72
61
|
}
|
|
73
|
-
|
|
74
|
-
result->_instance.device);
|
|
75
|
-
rnwgpu::Logger::logToConsole("GPUCanvasConfiguration::format = %f",
|
|
76
|
-
result->_instance.format);
|
|
77
|
-
rnwgpu::Logger::logToConsole("GPUCanvasConfiguration::usage = %f",
|
|
78
|
-
result->_instance.usage);
|
|
79
|
-
rnwgpu::Logger::logToConsole("GPUCanvasConfiguration::viewFormats = %f",
|
|
80
|
-
result->_instance.viewFormats);
|
|
81
|
-
rnwgpu::Logger::logToConsole("GPUCanvasConfiguration::colorSpace = %f",
|
|
82
|
-
result->_instance.colorSpace);
|
|
83
|
-
rnwgpu::Logger::logToConsole("GPUCanvasConfiguration::alphaMode = %f",
|
|
84
|
-
result->_instance.alphaMode);
|
|
62
|
+
|
|
85
63
|
return result;
|
|
86
64
|
}
|
|
87
65
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
88
66
|
std::shared_ptr<rnwgpu::GPUCanvasConfiguration> arg) {
|
|
89
|
-
|
|
90
|
-
return jsi::Value::null();
|
|
67
|
+
throw std::runtime_error("Invalid GPUCanvasConfiguration::toJSI()");
|
|
91
68
|
}
|
|
92
69
|
};
|
|
70
|
+
|
|
93
71
|
} // namespace margelo
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
#include "RNFJSIConverter.h"
|
|
8
|
+
#include "WGPULogger.h"
|
|
9
|
+
|
|
10
|
+
#include "RNFHybridObject.h"
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
namespace m = margelo;
|
|
14
|
+
|
|
15
|
+
namespace rnwgpu {
|
|
16
|
+
|
|
17
|
+
struct GPUColor {
|
|
18
|
+
double r; // number
|
|
19
|
+
double g; // number
|
|
20
|
+
double b; // number
|
|
21
|
+
double a; // number
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} // namespace rnwgpu
|
|
25
|
+
|
|
26
|
+
namespace margelo {
|
|
27
|
+
|
|
28
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
29
|
+
|
|
30
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColor>> {
|
|
31
|
+
static std::shared_ptr<rnwgpu::GPUColor>
|
|
32
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
33
|
+
auto result = std::make_unique<rnwgpu::GPUColor>();
|
|
34
|
+
if (!outOfBounds && arg.isObject()) {
|
|
35
|
+
auto value = arg.getObject(runtime);
|
|
36
|
+
if (value.isArray(runtime)) {
|
|
37
|
+
auto array = value.getArray(runtime);
|
|
38
|
+
if (array.size(runtime) >= 4) {
|
|
39
|
+
result->r = array.getValueAtIndex(runtime, 0).getNumber();
|
|
40
|
+
result->g = array.getValueAtIndex(runtime, 1).getNumber();
|
|
41
|
+
result->b = array.getValueAtIndex(runtime, 2).getNumber();
|
|
42
|
+
result->a = array.getValueAtIndex(runtime, 3).getNumber();
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
if (value.hasProperty(runtime, "r")) {
|
|
46
|
+
auto prop = value.getProperty(runtime, "r");
|
|
47
|
+
result->r = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
48
|
+
}
|
|
49
|
+
if (value.hasProperty(runtime, "g")) {
|
|
50
|
+
auto prop = value.getProperty(runtime, "g");
|
|
51
|
+
result->g = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
52
|
+
}
|
|
53
|
+
if (value.hasProperty(runtime, "b")) {
|
|
54
|
+
auto prop = value.getProperty(runtime, "b");
|
|
55
|
+
result->b = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
56
|
+
}
|
|
57
|
+
if (value.hasProperty(runtime, "a")) {
|
|
58
|
+
auto prop = value.getProperty(runtime, "a");
|
|
59
|
+
result->a = JSIConverter<double>::fromJSI(runtime, prop, false);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
67
|
+
std::shared_ptr<rnwgpu::GPUColor> arg) {
|
|
68
|
+
throw std::runtime_error("Invalid GPUColor::toJSI()");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
} // 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 "GPUBlendState.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
|
-
wgpu::ColorTargetState _instance;
|
|
18
|
+
struct GPUColorTargetState {
|
|
19
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
20
|
+
std::optional<std::shared_ptr<GPUBlendState>> blend; // GPUBlendState
|
|
21
|
+
std::optional<double> writeMask; // GPUColorWriteFlags
|
|
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::GPUColorTargetState>> {
|
|
27
31
|
static std::shared_ptr<rnwgpu::GPUColorTargetState>
|
|
28
32
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
@@ -30,40 +34,30 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColorTargetState>> {
|
|
|
30
34
|
if (!outOfBounds && arg.isObject()) {
|
|
31
35
|
auto value = arg.getObject(runtime);
|
|
32
36
|
if (value.hasProperty(runtime, "format")) {
|
|
33
|
-
auto
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw std::runtime_error(
|
|
37
|
-
"Property GPUColorTargetState::format is required");
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
throw std::runtime_error(
|
|
41
|
-
"Property GPUColorTargetState::format is not defined");
|
|
37
|
+
auto prop = value.getProperty(runtime, "format");
|
|
38
|
+
result->format =
|
|
39
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
42
40
|
}
|
|
43
41
|
if (value.hasProperty(runtime, "blend")) {
|
|
44
|
-
auto
|
|
42
|
+
auto prop = value.getProperty(runtime, "blend");
|
|
43
|
+
result->blend = JSIConverter<
|
|
44
|
+
std::optional<std::shared_ptr<GPUBlendState>>>::fromJSI(runtime,
|
|
45
|
+
prop,
|
|
46
|
+
false);
|
|
45
47
|
}
|
|
46
48
|
if (value.hasProperty(runtime, "writeMask")) {
|
|
47
|
-
auto
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
result->_instance.writeMask =
|
|
51
|
-
static_cast<wgpu::ColorWriteFlags>(writeMask.getNumber());
|
|
52
|
-
}
|
|
49
|
+
auto prop = value.getProperty(runtime, "writeMask");
|
|
50
|
+
result->writeMask =
|
|
51
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
result->_instance.format);
|
|
57
|
-
rnwgpu::Logger::logToConsole("GPUColorTargetState::blend = %f",
|
|
58
|
-
result->_instance.blend);
|
|
59
|
-
rnwgpu::Logger::logToConsole("GPUColorTargetState::writeMask = %f",
|
|
60
|
-
result->_instance.writeMask);
|
|
54
|
+
|
|
61
55
|
return result;
|
|
62
56
|
}
|
|
63
57
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
64
58
|
std::shared_ptr<rnwgpu::GPUColorTargetState> arg) {
|
|
65
|
-
|
|
66
|
-
return jsi::Value::null();
|
|
59
|
+
throw std::runtime_error("Invalid GPUColorTargetState::toJSI()");
|
|
67
60
|
}
|
|
68
61
|
};
|
|
69
|
-
|
|
62
|
+
|
|
63
|
+
} // namespace margelo
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "RNFJSIConverter.h"
|
|
9
|
+
#include "WGPULogger.h"
|
|
10
|
+
|
|
11
|
+
#include "RNFHybridObject.h"
|
|
12
|
+
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
|
+
namespace m = margelo;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUCommandBufferDescriptor {
|
|
19
|
+
std::optional<std::string> label; // string
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
27
|
+
|
|
28
|
+
template <>
|
|
29
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUCommandBufferDescriptor>> {
|
|
30
|
+
static std::shared_ptr<rnwgpu::GPUCommandBufferDescriptor>
|
|
31
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
32
|
+
auto result = std::make_unique<rnwgpu::GPUCommandBufferDescriptor>();
|
|
33
|
+
if (!outOfBounds && arg.isObject()) {
|
|
34
|
+
auto value = arg.getObject(runtime);
|
|
35
|
+
if (value.hasProperty(runtime, "label")) {
|
|
36
|
+
auto prop = value.getProperty(runtime, "label");
|
|
37
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
38
|
+
runtime, prop, false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
static jsi::Value
|
|
45
|
+
toJSI(jsi::Runtime &runtime,
|
|
46
|
+
std::shared_ptr<rnwgpu::GPUCommandBufferDescriptor> arg) {
|
|
47
|
+
throw std::runtime_error("Invalid GPUCommandBufferDescriptor::toJSI()");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace margelo
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "RNFJSIConverter.h"
|
|
9
|
+
#include "WGPULogger.h"
|
|
10
|
+
|
|
11
|
+
#include "RNFHybridObject.h"
|
|
12
|
+
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
|
+
namespace m = margelo;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUCommandEncoderDescriptor {
|
|
19
|
+
std::optional<std::string> label; // string
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
27
|
+
|
|
28
|
+
template <>
|
|
29
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor>> {
|
|
30
|
+
static std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor>
|
|
31
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
32
|
+
auto result = std::make_unique<rnwgpu::GPUCommandEncoderDescriptor>();
|
|
33
|
+
if (!outOfBounds && arg.isObject()) {
|
|
34
|
+
auto value = arg.getObject(runtime);
|
|
35
|
+
if (value.hasProperty(runtime, "label")) {
|
|
36
|
+
auto prop = value.getProperty(runtime, "label");
|
|
37
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
38
|
+
runtime, prop, false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
static jsi::Value
|
|
45
|
+
toJSI(jsi::Runtime &runtime,
|
|
46
|
+
std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor> arg) {
|
|
47
|
+
throw std::runtime_error("Invalid GPUCommandEncoderDescriptor::toJSI()");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace margelo
|
|
@@ -5,26 +5,29 @@
|
|
|
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 "GPUComputePassTimestampWrites.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
|
-
wgpu::ComputePassDescriptor _instance;
|
|
21
|
-
|
|
22
|
-
std::string label;
|
|
19
|
+
struct GPUComputePassDescriptor {
|
|
20
|
+
std::optional<std::shared_ptr<GPUComputePassTimestampWrites>>
|
|
21
|
+
timestampWrites; // GPUComputePassTimestampWrites
|
|
22
|
+
std::optional<std::string> label; // string
|
|
23
23
|
};
|
|
24
|
+
|
|
24
25
|
} // namespace rnwgpu
|
|
25
26
|
|
|
26
27
|
namespace margelo {
|
|
27
28
|
|
|
29
|
+
using namespace rnwgpu; // NOLINT(build/namespaces)
|
|
30
|
+
|
|
28
31
|
template <>
|
|
29
32
|
struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePassDescriptor>> {
|
|
30
33
|
static std::shared_ptr<rnwgpu::GPUComputePassDescriptor>
|
|
@@ -33,30 +36,26 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePassDescriptor>> {
|
|
|
33
36
|
if (!outOfBounds && arg.isObject()) {
|
|
34
37
|
auto value = arg.getObject(runtime);
|
|
35
38
|
if (value.hasProperty(runtime, "timestampWrites")) {
|
|
36
|
-
auto
|
|
39
|
+
auto prop = value.getProperty(runtime, "timestampWrites");
|
|
40
|
+
result->timestampWrites = JSIConverter<std::optional<
|
|
41
|
+
std::shared_ptr<GPUComputePassTimestampWrites>>>::fromJSI(runtime,
|
|
42
|
+
prop,
|
|
43
|
+
false);
|
|
37
44
|
}
|
|
38
45
|
if (value.hasProperty(runtime, "label")) {
|
|
39
|
-
auto
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
auto str = label.asString(runtime).utf8(runtime);
|
|
43
|
-
result->label = str;
|
|
44
|
-
result->_instance.label = result->label.c_str();
|
|
45
|
-
}
|
|
46
|
+
auto prop = value.getProperty(runtime, "label");
|
|
47
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
48
|
+
runtime, prop, false);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
"GPUComputePassDescriptor::timestampWrites = %f",
|
|
50
|
-
result->_instance.timestampWrites);
|
|
51
|
-
rnwgpu::Logger::logToConsole("GPUComputePassDescriptor::label = %f",
|
|
52
|
-
result->_instance.label);
|
|
51
|
+
|
|
53
52
|
return result;
|
|
54
53
|
}
|
|
55
54
|
static jsi::Value
|
|
56
55
|
toJSI(jsi::Runtime &runtime,
|
|
57
56
|
std::shared_ptr<rnwgpu::GPUComputePassDescriptor> arg) {
|
|
58
|
-
|
|
59
|
-
return jsi::Value::null();
|
|
57
|
+
throw std::runtime_error("Invalid GPUComputePassDescriptor::toJSI()");
|
|
60
58
|
}
|
|
61
59
|
};
|
|
62
|
-
|
|
60
|
+
|
|
61
|
+
} // namespace margelo
|