@shopify/react-native-skia 2.4.15 → 2.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +69 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -7
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +7 -0
- package/apple/RNSkApplePlatformContext.mm +4 -0
- package/cpp/api/JsiSkApi.h +31 -0
- package/cpp/api/JsiSkImageFactory.h +69 -1
- package/cpp/api/JsiSkImageFilter.h +1 -0
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +0 -2
- package/cpp/jsi2/EnumMapper.h +45 -0
- package/cpp/jsi2/JSIConverter.h +468 -0
- package/cpp/jsi2/NativeObject.h +598 -0
- package/cpp/jsi2/Promise.cpp +44 -0
- package/cpp/jsi2/Promise.h +35 -0
- package/cpp/rnskia/RNDawnContext.h +114 -0
- package/cpp/rnskia/RNSkManager.cpp +41 -1
- package/cpp/rnwgpu/ArrayBuffer.h +68 -0
- package/cpp/rnwgpu/api/Convertors.h +761 -0
- package/cpp/rnwgpu/api/External.h +12 -0
- package/cpp/rnwgpu/api/GPU.cpp +129 -0
- package/cpp/rnwgpu/api/GPU.h +57 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +178 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +59 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +57 -0
- package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +51 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +52 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +97 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +87 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +45 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +179 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +111 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +79 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +36 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +60 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +85 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +12 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +60 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +434 -0
- package/cpp/rnwgpu/api/GPUDevice.h +174 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +7 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +40 -0
- package/cpp/rnwgpu/api/GPUError.h +35 -0
- package/cpp/rnwgpu/api/GPUExtent3D.h +66 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +45 -0
- package/cpp/rnwgpu/api/GPUFeatures.h +212 -0
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +55 -0
- package/cpp/rnwgpu/api/GPUOrigin3D.h +62 -0
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +45 -0
- package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +73 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +169 -0
- package/cpp/rnwgpu/api/GPUQueue.h +84 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +44 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +131 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +110 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +165 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +130 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +61 -0
- package/cpp/rnwgpu/api/GPUSampler.h +44 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +51 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +66 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +129 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +131 -0
- package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
- package/cpp/rnwgpu/api/GPUTexture.h +150 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +44 -0
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +97 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +52 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +39 -0
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +99 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +38 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +22 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +55 -0
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +43 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +101 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +92 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +103 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +51 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +45 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +110 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +59 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +29 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +53 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +73 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1984 -0
- package/cpp/rnwgpu/async/AsyncDispatcher.h +28 -0
- package/cpp/rnwgpu/async/AsyncRunner.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncRunner.h +56 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +181 -0
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +55 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp +23 -0
- package/cpp/rnwgpu/async/JSIMicrotaskDispatcher.h +22 -0
- package/lib/commonjs/Platform/Platform.web.js +1 -2
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -4
- package/lib/commonjs/renderer/Canvas.js +4 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +1 -2
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -2
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +17 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +6 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +4 -4
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/web/WithSkiaWeb.js +1 -2
- package/lib/commonjs/web/WithSkiaWeb.js.map +1 -1
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -4
- package/lib/module/renderer/Canvas.js +3 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/ContourMeasure.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +17 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +6 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +6 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js +4 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +3 -2
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -4
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +20 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +17 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -0
- package/package.json +20 -16
- package/react-native-skia.podspec +52 -13
- package/scripts/install-skia.mjs +99 -48
- package/src/external/reanimated/buffers.ts +1 -1
- package/src/renderer/Canvas.tsx +3 -2
- package/src/skia/types/ContourMeasure.tsx +1 -2
- package/src/skia/types/Image/ImageFactory.ts +22 -0
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -2
- package/src/skia/types/Skia.ts +17 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -0
- package/src/skia/web/JsiSkia.ts +6 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +3 -2
- package/src/sksg/Recorder/commands/ImageFilters.ts +3 -2
- package/src/sksg/Recorder/commands/PathEffects.ts +3 -2
- package/src/sksg/Recorder/commands/Shaders.ts +3 -2
- package/src/specs/SkiaPictureViewNativeComponent.ts +7 -0
- package/src/views/SkiaPictureView.web.tsx +4 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "jsi2/JSIConverter.h"
|
|
9
|
+
|
|
10
|
+
namespace jsi = facebook::jsi;
|
|
11
|
+
|
|
12
|
+
namespace rnwgpu {
|
|
13
|
+
|
|
14
|
+
struct GPUCommandEncoderDescriptor {
|
|
15
|
+
std::optional<std::string> label; // string
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
} // namespace rnwgpu
|
|
19
|
+
|
|
20
|
+
namespace rnwgpu {
|
|
21
|
+
|
|
22
|
+
template <>
|
|
23
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor>> {
|
|
24
|
+
static std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor>
|
|
25
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
26
|
+
auto result = std::make_unique<rnwgpu::GPUCommandEncoderDescriptor>();
|
|
27
|
+
if (!outOfBounds && arg.isObject()) {
|
|
28
|
+
auto value = arg.getObject(runtime);
|
|
29
|
+
if (value.hasProperty(runtime, "label")) {
|
|
30
|
+
auto prop = value.getProperty(runtime, "label");
|
|
31
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
32
|
+
runtime, prop, false);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
static jsi::Value
|
|
39
|
+
toJSI(jsi::Runtime &runtime,
|
|
40
|
+
std::shared_ptr<rnwgpu::GPUCommandEncoderDescriptor> arg) {
|
|
41
|
+
throw std::runtime_error("Invalid GPUCommandEncoderDescriptor::toJSI()");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "jsi2/JSIConverter.h"
|
|
9
|
+
|
|
10
|
+
#include "GPUComputePassTimestampWrites.h"
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
struct GPUComputePassDescriptor {
|
|
17
|
+
std::optional<std::shared_ptr<GPUComputePassTimestampWrites>>
|
|
18
|
+
timestampWrites; // GPUComputePassTimestampWrites
|
|
19
|
+
std::optional<std::string> label; // string
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace rnwgpu {
|
|
25
|
+
|
|
26
|
+
template <>
|
|
27
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePassDescriptor>> {
|
|
28
|
+
static std::shared_ptr<rnwgpu::GPUComputePassDescriptor>
|
|
29
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
30
|
+
auto result = std::make_unique<rnwgpu::GPUComputePassDescriptor>();
|
|
31
|
+
if (!outOfBounds && arg.isObject()) {
|
|
32
|
+
auto value = arg.getObject(runtime);
|
|
33
|
+
if (value.hasProperty(runtime, "timestampWrites")) {
|
|
34
|
+
auto prop = value.getProperty(runtime, "timestampWrites");
|
|
35
|
+
result->timestampWrites = JSIConverter<std::optional<
|
|
36
|
+
std::shared_ptr<GPUComputePassTimestampWrites>>>::fromJSI(runtime,
|
|
37
|
+
prop,
|
|
38
|
+
false);
|
|
39
|
+
}
|
|
40
|
+
if (value.hasProperty(runtime, "label")) {
|
|
41
|
+
auto prop = value.getProperty(runtime, "label");
|
|
42
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
43
|
+
runtime, prop, false);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
static jsi::Value
|
|
50
|
+
toJSI(jsi::Runtime &runtime,
|
|
51
|
+
std::shared_ptr<rnwgpu::GPUComputePassDescriptor> arg) {
|
|
52
|
+
throw std::runtime_error("Invalid GPUComputePassDescriptor::toJSI()");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/JSIConverter.h"
|
|
8
|
+
|
|
9
|
+
#include "rnwgpu/api/GPUQuerySet.h"
|
|
10
|
+
|
|
11
|
+
namespace jsi = facebook::jsi;
|
|
12
|
+
|
|
13
|
+
namespace rnwgpu {
|
|
14
|
+
|
|
15
|
+
struct GPUComputePassTimestampWrites {
|
|
16
|
+
std::shared_ptr<GPUQuerySet> querySet; // GPUQuerySet
|
|
17
|
+
std::optional<double> beginningOfPassWriteIndex; // GPUSize32
|
|
18
|
+
std::optional<double> endOfPassWriteIndex; // GPUSize32
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace rnwgpu
|
|
22
|
+
|
|
23
|
+
namespace rnwgpu {
|
|
24
|
+
|
|
25
|
+
template <>
|
|
26
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePassTimestampWrites>> {
|
|
27
|
+
static std::shared_ptr<rnwgpu::GPUComputePassTimestampWrites>
|
|
28
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
29
|
+
auto result = std::make_unique<rnwgpu::GPUComputePassTimestampWrites>();
|
|
30
|
+
if (!outOfBounds && arg.isObject()) {
|
|
31
|
+
auto value = arg.getObject(runtime);
|
|
32
|
+
if (value.hasProperty(runtime, "querySet")) {
|
|
33
|
+
auto prop = value.getProperty(runtime, "querySet");
|
|
34
|
+
result->querySet = JSIConverter<std::shared_ptr<GPUQuerySet>>::fromJSI(
|
|
35
|
+
runtime, prop, false);
|
|
36
|
+
}
|
|
37
|
+
if (value.hasProperty(runtime, "beginningOfPassWriteIndex")) {
|
|
38
|
+
auto prop = value.getProperty(runtime, "beginningOfPassWriteIndex");
|
|
39
|
+
result->beginningOfPassWriteIndex =
|
|
40
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
41
|
+
}
|
|
42
|
+
if (value.hasProperty(runtime, "endOfPassWriteIndex")) {
|
|
43
|
+
auto prop = value.getProperty(runtime, "endOfPassWriteIndex");
|
|
44
|
+
result->endOfPassWriteIndex =
|
|
45
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
static jsi::Value
|
|
52
|
+
toJSI(jsi::Runtime &runtime,
|
|
53
|
+
std::shared_ptr<rnwgpu::GPUComputePassTimestampWrites> arg) {
|
|
54
|
+
throw std::runtime_error("Invalid GPUComputePassTimestampWrites::toJSI()");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "jsi2/JSIConverter.h"
|
|
9
|
+
|
|
10
|
+
#include "rnwgpu/api/GPUPipelineLayout.h"
|
|
11
|
+
#include "GPUProgrammableStage.h"
|
|
12
|
+
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
|
+
|
|
15
|
+
namespace rnwgpu {
|
|
16
|
+
|
|
17
|
+
struct GPUComputePipelineDescriptor {
|
|
18
|
+
std::shared_ptr<GPUProgrammableStage> compute; // GPUProgrammableStage
|
|
19
|
+
std::variant<std::nullptr_t, std::shared_ptr<GPUPipelineLayout>>
|
|
20
|
+
layout; // | GPUPipelineLayout | GPUAutoLayoutMode
|
|
21
|
+
std::optional<std::string> label; // string
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} // namespace rnwgpu
|
|
25
|
+
|
|
26
|
+
namespace rnwgpu {
|
|
27
|
+
|
|
28
|
+
template <>
|
|
29
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor>> {
|
|
30
|
+
static std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor>
|
|
31
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
32
|
+
auto result = std::make_unique<rnwgpu::GPUComputePipelineDescriptor>();
|
|
33
|
+
if (!outOfBounds && arg.isObject()) {
|
|
34
|
+
auto value = arg.getObject(runtime);
|
|
35
|
+
if (value.hasProperty(runtime, "compute")) {
|
|
36
|
+
auto prop = value.getProperty(runtime, "compute");
|
|
37
|
+
result->compute =
|
|
38
|
+
JSIConverter<std::shared_ptr<GPUProgrammableStage>>::fromJSI(
|
|
39
|
+
runtime, prop, false);
|
|
40
|
+
}
|
|
41
|
+
if (value.hasProperty(runtime, "layout")) {
|
|
42
|
+
auto prop = value.getProperty(runtime, "layout");
|
|
43
|
+
if (prop.isNull() || prop.isString()) {
|
|
44
|
+
result->layout = nullptr;
|
|
45
|
+
} else {
|
|
46
|
+
result->layout =
|
|
47
|
+
JSIConverter<std::shared_ptr<GPUPipelineLayout>>::fromJSI(
|
|
48
|
+
runtime, prop, false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (value.hasProperty(runtime, "label")) {
|
|
52
|
+
auto prop = value.getProperty(runtime, "label");
|
|
53
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
54
|
+
runtime, prop, false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
static jsi::Value
|
|
61
|
+
toJSI(jsi::Runtime &runtime,
|
|
62
|
+
std::shared_ptr<rnwgpu::GPUComputePipelineDescriptor> arg) {
|
|
63
|
+
throw std::runtime_error("Invalid GPUComputePipelineDescriptor::toJSI()");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/JSIConverter.h"
|
|
8
|
+
|
|
9
|
+
#include "GPUStencilFaceState.h"
|
|
10
|
+
|
|
11
|
+
namespace jsi = facebook::jsi;
|
|
12
|
+
|
|
13
|
+
namespace rnwgpu {
|
|
14
|
+
|
|
15
|
+
struct GPUDepthStencilState {
|
|
16
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
17
|
+
std::optional<bool> depthWriteEnabled; // boolean
|
|
18
|
+
std::optional<wgpu::CompareFunction> depthCompare; // GPUCompareFunction
|
|
19
|
+
std::optional<std::shared_ptr<GPUStencilFaceState>>
|
|
20
|
+
stencilFront; // GPUStencilFaceState
|
|
21
|
+
std::optional<std::shared_ptr<GPUStencilFaceState>>
|
|
22
|
+
stencilBack; // GPUStencilFaceState
|
|
23
|
+
std::optional<double> stencilReadMask; // GPUStencilValue
|
|
24
|
+
std::optional<double> stencilWriteMask; // GPUStencilValue
|
|
25
|
+
std::optional<double> depthBias; // GPUDepthBias
|
|
26
|
+
std::optional<double> depthBiasSlopeScale; // number
|
|
27
|
+
std::optional<double> depthBiasClamp; // number
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace rnwgpu
|
|
31
|
+
|
|
32
|
+
namespace rnwgpu {
|
|
33
|
+
|
|
34
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDepthStencilState>> {
|
|
35
|
+
static std::shared_ptr<rnwgpu::GPUDepthStencilState>
|
|
36
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
37
|
+
auto result = std::make_unique<rnwgpu::GPUDepthStencilState>();
|
|
38
|
+
if (!outOfBounds && arg.isObject()) {
|
|
39
|
+
auto value = arg.getObject(runtime);
|
|
40
|
+
if (value.hasProperty(runtime, "format")) {
|
|
41
|
+
auto prop = value.getProperty(runtime, "format");
|
|
42
|
+
result->format =
|
|
43
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
44
|
+
}
|
|
45
|
+
if (value.hasProperty(runtime, "depthWriteEnabled")) {
|
|
46
|
+
auto prop = value.getProperty(runtime, "depthWriteEnabled");
|
|
47
|
+
result->depthWriteEnabled =
|
|
48
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
49
|
+
}
|
|
50
|
+
if (value.hasProperty(runtime, "depthCompare")) {
|
|
51
|
+
auto prop = value.getProperty(runtime, "depthCompare");
|
|
52
|
+
result->depthCompare =
|
|
53
|
+
JSIConverter<std::optional<wgpu::CompareFunction>>::fromJSI(
|
|
54
|
+
runtime, prop, false);
|
|
55
|
+
}
|
|
56
|
+
if (value.hasProperty(runtime, "stencilFront")) {
|
|
57
|
+
auto prop = value.getProperty(runtime, "stencilFront");
|
|
58
|
+
result->stencilFront =
|
|
59
|
+
JSIConverter<std::optional<std::shared_ptr<GPUStencilFaceState>>>::
|
|
60
|
+
fromJSI(runtime, prop, false);
|
|
61
|
+
}
|
|
62
|
+
if (value.hasProperty(runtime, "stencilBack")) {
|
|
63
|
+
auto prop = value.getProperty(runtime, "stencilBack");
|
|
64
|
+
result->stencilBack =
|
|
65
|
+
JSIConverter<std::optional<std::shared_ptr<GPUStencilFaceState>>>::
|
|
66
|
+
fromJSI(runtime, prop, false);
|
|
67
|
+
}
|
|
68
|
+
if (value.hasProperty(runtime, "stencilReadMask")) {
|
|
69
|
+
auto prop = value.getProperty(runtime, "stencilReadMask");
|
|
70
|
+
result->stencilReadMask =
|
|
71
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
72
|
+
}
|
|
73
|
+
if (value.hasProperty(runtime, "stencilWriteMask")) {
|
|
74
|
+
auto prop = value.getProperty(runtime, "stencilWriteMask");
|
|
75
|
+
result->stencilWriteMask =
|
|
76
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
77
|
+
}
|
|
78
|
+
if (value.hasProperty(runtime, "depthBias")) {
|
|
79
|
+
auto prop = value.getProperty(runtime, "depthBias");
|
|
80
|
+
result->depthBias =
|
|
81
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
82
|
+
}
|
|
83
|
+
if (value.hasProperty(runtime, "depthBiasSlopeScale")) {
|
|
84
|
+
auto prop = value.getProperty(runtime, "depthBiasSlopeScale");
|
|
85
|
+
result->depthBiasSlopeScale =
|
|
86
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
87
|
+
}
|
|
88
|
+
if (value.hasProperty(runtime, "depthBiasClamp")) {
|
|
89
|
+
auto prop = value.getProperty(runtime, "depthBiasClamp");
|
|
90
|
+
result->depthBiasClamp =
|
|
91
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
98
|
+
std::shared_ptr<rnwgpu::GPUDepthStencilState> arg) {
|
|
99
|
+
throw std::runtime_error("Invalid GPUDepthStencilState::toJSI()");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include "webgpu/webgpu_cpp.h"
|
|
9
|
+
|
|
10
|
+
#include "jsi2/JSIConverter.h"
|
|
11
|
+
|
|
12
|
+
#include "GPUQueueDescriptor.h"
|
|
13
|
+
|
|
14
|
+
namespace jsi = facebook::jsi;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUDeviceDescriptor {
|
|
19
|
+
std::optional<std::vector<wgpu::FeatureName>>
|
|
20
|
+
requiredFeatures; // Iterable<GPUFeatureName>
|
|
21
|
+
std::optional<std::map<std::string, double>>
|
|
22
|
+
requiredLimits; // Record< string, GPUSize64 >
|
|
23
|
+
std::optional<std::shared_ptr<GPUQueueDescriptor>>
|
|
24
|
+
defaultQueue; // GPUQueueDescriptor
|
|
25
|
+
std::optional<std::string> label; // string
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace rnwgpu
|
|
29
|
+
|
|
30
|
+
namespace rnwgpu {
|
|
31
|
+
|
|
32
|
+
// We add this extra convertor because we found so library that are sending
|
|
33
|
+
// invalid feature elements
|
|
34
|
+
template <> struct JSIConverter<std::vector<wgpu::FeatureName>> {
|
|
35
|
+
|
|
36
|
+
static std::vector<wgpu::FeatureName>
|
|
37
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
38
|
+
jsi::Array array = arg.asObject(runtime).asArray(runtime);
|
|
39
|
+
size_t length = array.size(runtime);
|
|
40
|
+
|
|
41
|
+
std::vector<wgpu::FeatureName> vector;
|
|
42
|
+
vector.reserve(length);
|
|
43
|
+
for (size_t i = 0; i < length; ++i) {
|
|
44
|
+
jsi::Value elementValue = array.getValueAtIndex(runtime, i);
|
|
45
|
+
if (elementValue.isString()) {
|
|
46
|
+
vector.emplace_back(JSIConverter<wgpu::FeatureName>::fromJSI(
|
|
47
|
+
runtime, elementValue, outOfBounds));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return vector;
|
|
51
|
+
}
|
|
52
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
53
|
+
std::shared_ptr<rnwgpu::GPUDeviceDescriptor> arg) {
|
|
54
|
+
throw std::runtime_error(
|
|
55
|
+
"Invalid JSIConverter<std::vector<wgpu::FeatureName>>::toJSI()");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
|
|
60
|
+
static std::shared_ptr<rnwgpu::GPUDeviceDescriptor>
|
|
61
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
62
|
+
auto result = std::make_unique<rnwgpu::GPUDeviceDescriptor>();
|
|
63
|
+
if (!outOfBounds && arg.isObject()) {
|
|
64
|
+
auto value = arg.getObject(runtime);
|
|
65
|
+
if (value.hasProperty(runtime, "requiredFeatures")) {
|
|
66
|
+
auto prop = value.getProperty(runtime, "requiredFeatures");
|
|
67
|
+
result->requiredFeatures = JSIConverter<
|
|
68
|
+
std::optional<std::vector<wgpu::FeatureName>>>::fromJSI(runtime,
|
|
69
|
+
prop,
|
|
70
|
+
false);
|
|
71
|
+
}
|
|
72
|
+
if (value.hasProperty(runtime, "requiredLimits")) {
|
|
73
|
+
auto prop = value.getProperty(runtime, "requiredLimits");
|
|
74
|
+
result->requiredLimits =
|
|
75
|
+
JSIConverter<std::optional<std::map<std::string, double>>>::fromJSI(
|
|
76
|
+
runtime, prop, false);
|
|
77
|
+
}
|
|
78
|
+
if (value.hasProperty(runtime, "defaultQueue")) {
|
|
79
|
+
auto prop = value.getProperty(runtime, "defaultQueue");
|
|
80
|
+
result->defaultQueue =
|
|
81
|
+
JSIConverter<std::optional<std::shared_ptr<GPUQueueDescriptor>>>::
|
|
82
|
+
fromJSI(runtime, prop, false);
|
|
83
|
+
}
|
|
84
|
+
if (value.hasProperty(runtime, "label")) {
|
|
85
|
+
auto prop = value.getProperty(runtime, "label");
|
|
86
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
87
|
+
runtime, prop, false);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
94
|
+
std::shared_ptr<rnwgpu::GPUDeviceDescriptor> arg) {
|
|
95
|
+
throw std::runtime_error("Invalid GPUDeviceDescriptor::toJSI()");
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/JSIConverter.h"
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
namespace rnwgpu {
|
|
12
|
+
|
|
13
|
+
struct GPUExternalTextureBindingLayout {};
|
|
14
|
+
|
|
15
|
+
} // namespace rnwgpu
|
|
16
|
+
|
|
17
|
+
namespace rnwgpu {
|
|
18
|
+
|
|
19
|
+
template <>
|
|
20
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout>> {
|
|
21
|
+
static std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout>
|
|
22
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
23
|
+
auto result = std::make_unique<rnwgpu::GPUExternalTextureBindingLayout>();
|
|
24
|
+
if (!outOfBounds && arg.isObject()) {
|
|
25
|
+
auto value = arg.getObject(runtime);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
static jsi::Value
|
|
31
|
+
toJSI(jsi::Runtime &runtime,
|
|
32
|
+
std::shared_ptr<rnwgpu::GPUExternalTextureBindingLayout> arg) {
|
|
33
|
+
throw std::runtime_error(
|
|
34
|
+
"Invalid GPUExternalTextureBindingLayout::toJSI()");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <variant>
|
|
7
|
+
|
|
8
|
+
#include "webgpu/webgpu_cpp.h"
|
|
9
|
+
|
|
10
|
+
#include "Convertors.h"
|
|
11
|
+
|
|
12
|
+
#include "jsi2/JSIConverter.h"
|
|
13
|
+
|
|
14
|
+
namespace jsi = facebook::jsi;
|
|
15
|
+
|
|
16
|
+
namespace rnwgpu {
|
|
17
|
+
|
|
18
|
+
struct GPUExternalTextureDescriptor {
|
|
19
|
+
// std::variant<std::shared_ptr<HTMLVideoElement>,
|
|
20
|
+
// std::shared_ptr<VideoFrame>>
|
|
21
|
+
// source; // | HTMLVideoElement | VideoFrame
|
|
22
|
+
// std::optional<wgpu::DefinedColorSpace> colorSpace; // PredefinedColorSpace
|
|
23
|
+
std::optional<std::string> label; // string
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace rnwgpu
|
|
27
|
+
|
|
28
|
+
namespace rnwgpu {
|
|
29
|
+
|
|
30
|
+
template <>
|
|
31
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>> {
|
|
32
|
+
static std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor>
|
|
33
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
34
|
+
auto result = std::make_unique<rnwgpu::GPUExternalTextureDescriptor>();
|
|
35
|
+
if (!outOfBounds && arg.isObject()) {
|
|
36
|
+
auto value = arg.getObject(runtime);
|
|
37
|
+
if (value.hasProperty(runtime, "source")) {
|
|
38
|
+
auto prop = value.getProperty(runtime, "source");
|
|
39
|
+
// result->source = JSIConverter<
|
|
40
|
+
// std::variant<std::shared_ptr<HTMLVideoElement>,
|
|
41
|
+
// std::shared_ptr<VideoFrame>>>::fromJSI(runtime,
|
|
42
|
+
// prop,
|
|
43
|
+
// false);
|
|
44
|
+
}
|
|
45
|
+
if (value.hasProperty(runtime, "colorSpace")) {
|
|
46
|
+
auto prop = value.getProperty(runtime, "colorSpace");
|
|
47
|
+
if (!prop.isUndefined()) {
|
|
48
|
+
// result->colorSpace =
|
|
49
|
+
// JSIConverter<std::optional<wgpu::definedColorSpace>>::fromJSI(
|
|
50
|
+
// runtime, prop, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (value.hasProperty(runtime, "label")) {
|
|
54
|
+
auto prop = value.getProperty(runtime, "label");
|
|
55
|
+
if (!prop.isUndefined()) {
|
|
56
|
+
result->label = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
57
|
+
runtime, prop, false);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
static jsi::Value
|
|
65
|
+
toJSI(jsi::Runtime &runtime,
|
|
66
|
+
std::shared_ptr<rnwgpu::GPUExternalTextureDescriptor> arg) {
|
|
67
|
+
throw std::runtime_error("Invalid GPUExternalTextureDescriptor::toJSI()");
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <variant>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
#include "webgpu/webgpu_cpp.h"
|
|
10
|
+
|
|
11
|
+
#include "jsi2/JSIConverter.h"
|
|
12
|
+
|
|
13
|
+
#include "GPUColorTargetState.h"
|
|
14
|
+
#include "rnwgpu/api/GPUShaderModule.h"
|
|
15
|
+
|
|
16
|
+
namespace jsi = facebook::jsi;
|
|
17
|
+
|
|
18
|
+
namespace rnwgpu {
|
|
19
|
+
|
|
20
|
+
struct GPUFragmentState {
|
|
21
|
+
std::vector<
|
|
22
|
+
std::variant<std::nullptr_t, std::shared_ptr<GPUColorTargetState>>>
|
|
23
|
+
targets; // Iterable<GPUColorTargetState | null>
|
|
24
|
+
std::shared_ptr<GPUShaderModule> module; // GPUShaderModule
|
|
25
|
+
std::optional<std::string> entryPoint; // string
|
|
26
|
+
std::optional<std::map<std::string, double>>
|
|
27
|
+
constants; // Record< string, GPUPipelineConstantValue >
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace rnwgpu
|
|
31
|
+
|
|
32
|
+
namespace rnwgpu {
|
|
33
|
+
|
|
34
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUFragmentState>> {
|
|
35
|
+
static std::shared_ptr<rnwgpu::GPUFragmentState>
|
|
36
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
37
|
+
auto result = std::make_unique<rnwgpu::GPUFragmentState>();
|
|
38
|
+
if (!outOfBounds && arg.isObject()) {
|
|
39
|
+
auto value = arg.getObject(runtime);
|
|
40
|
+
if (value.hasProperty(runtime, "targets")) {
|
|
41
|
+
auto prop = value.getProperty(runtime, "targets");
|
|
42
|
+
result->targets = JSIConverter<std::vector<std::variant<
|
|
43
|
+
std::nullptr_t, std::shared_ptr<GPUColorTargetState>>>>::
|
|
44
|
+
fromJSI(runtime, prop, false);
|
|
45
|
+
}
|
|
46
|
+
if (value.hasProperty(runtime, "module")) {
|
|
47
|
+
auto prop = value.getProperty(runtime, "module");
|
|
48
|
+
result->module =
|
|
49
|
+
JSIConverter<std::shared_ptr<GPUShaderModule>>::fromJSI(
|
|
50
|
+
runtime, prop, false);
|
|
51
|
+
}
|
|
52
|
+
if (value.hasProperty(runtime, "entryPoint")) {
|
|
53
|
+
auto prop = value.getProperty(runtime, "entryPoint");
|
|
54
|
+
result->entryPoint = JSIConverter<std::optional<std::string>>::fromJSI(
|
|
55
|
+
runtime, prop, false);
|
|
56
|
+
}
|
|
57
|
+
if (value.hasProperty(runtime, "constants")) {
|
|
58
|
+
auto prop = value.getProperty(runtime, "constants");
|
|
59
|
+
result->constants =
|
|
60
|
+
JSIConverter<std::optional<std::map<std::string, double>>>::fromJSI(
|
|
61
|
+
runtime, prop, false);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
68
|
+
std::shared_ptr<rnwgpu::GPUFragmentState> arg) {
|
|
69
|
+
throw std::runtime_error("Invalid GPUFragmentState::toJSI()");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
#include "jsi2/JSIConverter.h"
|
|
8
|
+
|
|
9
|
+
#include "rnwgpu/api/GPUBuffer.h"
|
|
10
|
+
|
|
11
|
+
namespace jsi = facebook::jsi;
|
|
12
|
+
|
|
13
|
+
namespace rnwgpu {
|
|
14
|
+
|
|
15
|
+
struct GPUImageCopyBuffer {
|
|
16
|
+
std::shared_ptr<GPUBuffer> buffer; // GPUBuffer
|
|
17
|
+
std::optional<double> offset; // GPUSize64
|
|
18
|
+
std::optional<double> bytesPerRow; // GPUSize32
|
|
19
|
+
std::optional<double> rowsPerImage; // GPUSize32
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace rnwgpu {
|
|
25
|
+
|
|
26
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyBuffer>> {
|
|
27
|
+
static std::shared_ptr<rnwgpu::GPUImageCopyBuffer>
|
|
28
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
29
|
+
auto result = std::make_unique<rnwgpu::GPUImageCopyBuffer>();
|
|
30
|
+
if (!outOfBounds && arg.isObject()) {
|
|
31
|
+
auto value = arg.getObject(runtime);
|
|
32
|
+
if (value.hasProperty(runtime, "buffer")) {
|
|
33
|
+
auto prop = value.getProperty(runtime, "buffer");
|
|
34
|
+
result->buffer = JSIConverter<std::shared_ptr<GPUBuffer>>::fromJSI(
|
|
35
|
+
runtime, prop, false);
|
|
36
|
+
}
|
|
37
|
+
if (value.hasProperty(runtime, "offset")) {
|
|
38
|
+
auto prop = value.getProperty(runtime, "offset");
|
|
39
|
+
result->offset =
|
|
40
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
41
|
+
}
|
|
42
|
+
if (value.hasProperty(runtime, "bytesPerRow")) {
|
|
43
|
+
auto prop = value.getProperty(runtime, "bytesPerRow");
|
|
44
|
+
result->bytesPerRow =
|
|
45
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
46
|
+
}
|
|
47
|
+
if (value.hasProperty(runtime, "rowsPerImage")) {
|
|
48
|
+
auto prop = value.getProperty(runtime, "rowsPerImage");
|
|
49
|
+
result->rowsPerImage =
|
|
50
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
57
|
+
std::shared_ptr<rnwgpu::GPUImageCopyBuffer> arg) {
|
|
58
|
+
throw std::runtime_error("Invalid GPUImageCopyBuffer::toJSI()");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace rnwgpu
|