react-native-wgpu 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +31 -0
- package/android/CMakeLists.txt +74 -0
- package/android/build.gradle +166 -0
- package/android/cpp/cpp-adapter.cpp +12 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +39 -0
- package/android/src/main/java/com/webgpu/WebGPUView.java +24 -0
- package/android/src/main/java/com/webgpu/WebGPUViewManager.java +31 -0
- package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +26 -0
- package/android/src/newarch/WgpuViewManagerSpec.java +24 -0
- package/android/src/oldarch/WebGPUViewManagerSpec.java +11 -0
- package/cpp/Logger.h +82 -0
- package/cpp/dawn/dawn_proc_table.h +308 -0
- package/cpp/dawn/webgpu.h +4201 -0
- package/cpp/dawn/webgpu_cpp.h +8985 -0
- package/cpp/dawn/webgpu_cpp_print.h +2460 -0
- package/cpp/dawn/wire/client/webgpu.h +339 -0
- package/cpp/dawn/wire/client/webgpu_cpp.h +9140 -0
- package/cpp/jsi/RNFEnumMapper.h +49 -0
- package/cpp/jsi/RNFHybridObject.cpp +145 -0
- package/cpp/jsi/RNFHybridObject.h +162 -0
- package/cpp/jsi/RNFJSIConverter.h +412 -0
- package/cpp/jsi/RNFJSIHelper.h +49 -0
- package/cpp/jsi/RNFPointerHolder.h +95 -0
- package/cpp/jsi/RNFPromise.cpp +45 -0
- package/cpp/jsi/RNFPromise.h +38 -0
- package/cpp/jsi/RNFRuntimeCache.cpp +57 -0
- package/cpp/jsi/RNFRuntimeCache.h +79 -0
- package/cpp/jsi/RNFWorkletRuntimeCollector.h +43 -0
- package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp +11 -0
- package/cpp/jsi/RNFWorkletRuntimeRegistry.h +44 -0
- package/cpp/rnwgpu/MutableBuffer.h +48 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +60 -0
- package/cpp/rnwgpu/RNWebGPUManager.h +30 -0
- package/cpp/rnwgpu/api/GPU.cpp +40 -0
- package/cpp/rnwgpu/api/GPU.h +43 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +33 -0
- package/cpp/rnwgpu/api/GPUAdapter.h +40 -0
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +33 -0
- package/cpp/rnwgpu/api/GPUBindGroup.h +38 -0
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +39 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +16 -0
- package/cpp/rnwgpu/api/GPUBuffer.h +44 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +33 -0
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +38 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +38 -0
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +33 -0
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +33 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +40 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.h +39 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +12 -0
- package/cpp/rnwgpu/api/GPUDevice.h +45 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +33 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +39 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +38 -0
- package/cpp/rnwgpu/api/GPUQuerySet.h +38 -0
- package/cpp/rnwgpu/api/GPUQueue.h +38 -0
- package/cpp/rnwgpu/api/GPURenderBundle.h +38 -0
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +40 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +40 -0
- package/cpp/rnwgpu/api/GPURenderPipeline.h +38 -0
- package/cpp/rnwgpu/api/GPUSampler.h +38 -0
- package/cpp/rnwgpu/api/GPUShaderModule.h +38 -0
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +33 -0
- package/cpp/rnwgpu/api/GPUTexture.h +38 -0
- package/cpp/rnwgpu/api/GPUTextureView.h +38 -0
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +33 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +95 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +65 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +72 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +85 -0
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +43 -0
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +93 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +31 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +82 -0
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +126 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +76 -0
- package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +91 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +44 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +75 -0
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +85 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +83 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +74 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +88 -0
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +70 -0
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +25 -0
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +68 -0
- package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +75 -0
- package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +54 -0
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +72 -0
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +66 -0
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +72 -0
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +81 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +102 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +105 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +118 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +100 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +83 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +104 -0
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +56 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +48 -0
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +116 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +64 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +88 -0
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +27 -0
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +61 -0
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +67 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +58 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +123 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +40 -0
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +113 -0
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +71 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +80 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +73 -0
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +77 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +1645 -0
- package/cpp/webgpu/webgpu.h +33 -0
- package/cpp/webgpu/webgpu_cpp.h +33 -0
- package/cpp/webgpu/webgpu_cpp_chained_struct.h +55 -0
- package/cpp/webgpu/webgpu_enum_class_bitmasks.h +161 -0
- package/ios/RNFAppleLogger.mm +22 -0
- package/ios/Utils.h +5 -0
- package/ios/Utils.m +26 -0
- package/ios/WebGPUModule.h +18 -0
- package/ios/WebGPUModule.mm +77 -0
- package/ios/WebGPUView.h +15 -0
- package/ios/WebGPUView.mm +58 -0
- package/ios/WebGPUViewManager.mm +21 -0
- package/lib/commonjs/WebGPUNativeModule.js +10 -0
- package/lib/commonjs/WebGPUNativeModule.js.map +1 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js +11 -0
- package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/commonjs/index.js +45 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/WebGPUNativeModule.js +4 -0
- package/lib/module/WebGPUNativeModule.js.map +1 -0
- package/lib/module/WebGPUViewNativeComponent.js +4 -0
- package/lib/module/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +2 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/jest.config.d.ts +5 -0
- package/lib/typescript/jest.config.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts +5 -0
- package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts +4 -0
- package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +5 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUNativeModule.d.ts +3 -0
- package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +1 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts +4 -0
- package/lib/typescript/lib/module/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +5 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/scripts/build/copy-artifacts.d.ts +2 -0
- package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +1 -0
- package/lib/typescript/scripts/build/dawn.d.ts +2 -0
- package/lib/typescript/scripts/build/dawn.d.ts.map +1 -0
- package/lib/typescript/scripts/build/util.d.ts +13 -0
- package/lib/typescript/scripts/build/util.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/codegen.d.ts +2 -0
- package/lib/typescript/scripts/codegen/codegen.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/model/dawn.d.ts +2 -0
- package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/model/model.d.ts +8 -0
- package/lib/typescript/scripts/codegen/model/model.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +4 -0
- package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/templates/Enum.d.ts +3 -0
- package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +3 -0
- package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/templates/Unions.d.ts +6 -0
- package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/templates/common.d.ts +9 -0
- package/lib/typescript/scripts/codegen/templates/common.d.ts.map +1 -0
- package/lib/typescript/scripts/codegen/util.d.ts +2 -0
- package/lib/typescript/scripts/codegen/util.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUNativeModule.d.ts +7 -0
- package/lib/typescript/src/WebGPUNativeModule.d.ts.map +1 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +8 -0
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +120 -0
- package/react-native-webgpu.podspec +56 -0
- package/src/WebGPUNativeModule.ts +9 -0
- package/src/WebGPUViewNativeComponent.ts +9 -0
- package/src/index.tsx +13 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPURenderPipeline : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPURenderPipeline(wgpu::RenderPipeline instance, std::string label)
|
|
21
|
+
: HybridObject("GPURenderPipeline"), _instance(instance), _label(label) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
std::string getLabel() { return _label; }
|
|
27
|
+
|
|
28
|
+
void loadHybridMethods() override {
|
|
29
|
+
registerHybridGetter("__brand", &GPURenderPipeline::getBrand, this);
|
|
30
|
+
|
|
31
|
+
registerHybridGetter("label", &GPURenderPipeline::getLabel, this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
wgpu::RenderPipeline _instance;
|
|
36
|
+
std::string _label;
|
|
37
|
+
};
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUSampler : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUSampler(wgpu::Sampler instance, std::string label)
|
|
21
|
+
: HybridObject("GPUSampler"), _instance(instance), _label(label) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
std::string getLabel() { return _label; }
|
|
27
|
+
|
|
28
|
+
void loadHybridMethods() override {
|
|
29
|
+
registerHybridGetter("__brand", &GPUSampler::getBrand, this);
|
|
30
|
+
|
|
31
|
+
registerHybridGetter("label", &GPUSampler::getLabel, this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
wgpu::Sampler _instance;
|
|
36
|
+
std::string _label;
|
|
37
|
+
};
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUShaderModule : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUShaderModule(wgpu::ShaderModule instance, std::string label)
|
|
21
|
+
: HybridObject("GPUShaderModule"), _instance(instance), _label(label) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
std::string getLabel() { return _label; }
|
|
27
|
+
|
|
28
|
+
void loadHybridMethods() override {
|
|
29
|
+
registerHybridGetter("__brand", &GPUShaderModule::getBrand, this);
|
|
30
|
+
|
|
31
|
+
registerHybridGetter("label", &GPUShaderModule::getLabel, this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
wgpu::ShaderModule _instance;
|
|
36
|
+
std::string _label;
|
|
37
|
+
};
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUSupportedLimits : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUSupportedLimits(wgpu::SupportedLimits instance)
|
|
21
|
+
: HybridObject("GPUSupportedLimits"), _instance(instance) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
void loadHybridMethods() override {
|
|
27
|
+
registerHybridGetter("__brand", &GPUSupportedLimits::getBrand, this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
wgpu::SupportedLimits _instance;
|
|
32
|
+
};
|
|
33
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUTexture : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUTexture(wgpu::Texture instance, std::string label)
|
|
21
|
+
: HybridObject("GPUTexture"), _instance(instance), _label(label) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
std::string getLabel() { return _label; }
|
|
27
|
+
|
|
28
|
+
void loadHybridMethods() override {
|
|
29
|
+
registerHybridGetter("__brand", &GPUTexture::getBrand, this);
|
|
30
|
+
|
|
31
|
+
registerHybridGetter("label", &GPUTexture::getLabel, this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
wgpu::Texture _instance;
|
|
36
|
+
std::string _label;
|
|
37
|
+
};
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUTextureView : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUTextureView(wgpu::TextureView instance, std::string label)
|
|
21
|
+
: HybridObject("GPUTextureView"), _instance(instance), _label(label) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
std::string getLabel() { return _label; }
|
|
27
|
+
|
|
28
|
+
void loadHybridMethods() override {
|
|
29
|
+
registerHybridGetter("__brand", &GPUTextureView::getBrand, this);
|
|
30
|
+
|
|
31
|
+
registerHybridGetter("label", &GPUTextureView::getLabel, this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
wgpu::TextureView _instance;
|
|
36
|
+
std::string _label;
|
|
37
|
+
};
|
|
38
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <future>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "Unions.h"
|
|
8
|
+
#include <RNFHybridObject.h>
|
|
9
|
+
|
|
10
|
+
#include "MutableBuffer.h"
|
|
11
|
+
|
|
12
|
+
#include "webgpu/webgpu_cpp.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace m = margelo;
|
|
17
|
+
|
|
18
|
+
class GPUUncapturedErrorEvent : public m::HybridObject {
|
|
19
|
+
public:
|
|
20
|
+
explicit GPUUncapturedErrorEvent(wgpu::UncapturedErrorEvent instance)
|
|
21
|
+
: HybridObject("GPUUncapturedErrorEvent"), _instance(instance) {}
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
std::string getBrand() { return _name; }
|
|
25
|
+
|
|
26
|
+
void loadHybridMethods() override {
|
|
27
|
+
registerHybridGetter("__brand", &GPUUncapturedErrorEvent::getBrand, this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
wgpu::UncapturedErrorEvent _instance;
|
|
32
|
+
};
|
|
33
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBindGroupDescriptor {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BindGroupDescriptor *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BindGroupDescriptor _instance;
|
|
21
|
+
|
|
22
|
+
std::string label;
|
|
23
|
+
};
|
|
24
|
+
} // namespace rnwgpu
|
|
25
|
+
|
|
26
|
+
namespace margelo {
|
|
27
|
+
|
|
28
|
+
template <>
|
|
29
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
|
|
30
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>
|
|
31
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
32
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupDescriptor>();
|
|
33
|
+
if (!outOfBounds && arg.isObject()) {
|
|
34
|
+
auto value = arg.getObject(runtime);
|
|
35
|
+
if (value.hasProperty(runtime, "layout")) {
|
|
36
|
+
auto layout = value.getProperty(runtime, "layout");
|
|
37
|
+
|
|
38
|
+
if (layout.isUndefined()) {
|
|
39
|
+
throw std::runtime_error(
|
|
40
|
+
"Property GPUBindGroupDescriptor::layout is required");
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
throw std::runtime_error(
|
|
44
|
+
"Property GPUBindGroupDescriptor::layout is not defined");
|
|
45
|
+
}
|
|
46
|
+
if (value.hasProperty(runtime, "entries")) {
|
|
47
|
+
auto entries = value.getProperty(runtime, "entries");
|
|
48
|
+
|
|
49
|
+
if (entries.isUndefined()) {
|
|
50
|
+
throw std::runtime_error(
|
|
51
|
+
"Property GPUBindGroupDescriptor::entries is required");
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
throw std::runtime_error(
|
|
55
|
+
"Property GPUBindGroupDescriptor::entries is not defined");
|
|
56
|
+
}
|
|
57
|
+
if (value.hasProperty(runtime, "label")) {
|
|
58
|
+
auto label = value.getProperty(runtime, "label");
|
|
59
|
+
|
|
60
|
+
if (label.isString()) {
|
|
61
|
+
auto str = label.asString(runtime).utf8(runtime);
|
|
62
|
+
result->label = str;
|
|
63
|
+
result->_instance.label = result->label.c_str();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::layout = %f",
|
|
68
|
+
result->_instance.layout);
|
|
69
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::entries = %f",
|
|
70
|
+
result->_instance.entries);
|
|
71
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::label = %f",
|
|
72
|
+
result->_instance.label);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
76
|
+
std::shared_ptr<rnwgpu::GPUBindGroupDescriptor> arg) {
|
|
77
|
+
// No conversions here
|
|
78
|
+
return jsi::Value::null();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
} // namespace margelo
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBindGroupEntry {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BindGroupEntry *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BindGroupEntry _instance;
|
|
21
|
+
};
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
|
|
27
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
|
|
28
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
29
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupEntry>();
|
|
30
|
+
if (!outOfBounds && arg.isObject()) {
|
|
31
|
+
auto value = arg.getObject(runtime);
|
|
32
|
+
if (value.hasProperty(runtime, "binding")) {
|
|
33
|
+
auto binding = value.getProperty(runtime, "binding");
|
|
34
|
+
|
|
35
|
+
if (binding.isUndefined()) {
|
|
36
|
+
throw std::runtime_error(
|
|
37
|
+
"Property GPUBindGroupEntry::binding is required");
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
throw std::runtime_error(
|
|
41
|
+
"Property GPUBindGroupEntry::binding is not defined");
|
|
42
|
+
}
|
|
43
|
+
if (value.hasProperty(runtime, "resource")) {
|
|
44
|
+
auto resource = value.getProperty(runtime, "resource");
|
|
45
|
+
|
|
46
|
+
if (resource.isUndefined()) {
|
|
47
|
+
throw std::runtime_error(
|
|
48
|
+
"Property GPUBindGroupEntry::resource is required");
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
throw std::runtime_error(
|
|
52
|
+
"Property GPUBindGroupEntry::resource is not defined");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupEntry::binding = %f",
|
|
56
|
+
result->_instance.binding);
|
|
57
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupEntry::resource = %f",
|
|
58
|
+
result->_instance.resource);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
62
|
+
std::shared_ptr<rnwgpu::GPUBindGroupEntry> arg) {
|
|
63
|
+
// No conversions here
|
|
64
|
+
return jsi::Value::null();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
} // namespace margelo
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBindGroupLayoutDescriptor {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BindGroupLayoutDescriptor *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BindGroupLayoutDescriptor _instance;
|
|
21
|
+
|
|
22
|
+
std::string label;
|
|
23
|
+
};
|
|
24
|
+
} // namespace rnwgpu
|
|
25
|
+
|
|
26
|
+
namespace margelo {
|
|
27
|
+
|
|
28
|
+
template <>
|
|
29
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>> {
|
|
30
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>
|
|
31
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
32
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupLayoutDescriptor>();
|
|
33
|
+
if (!outOfBounds && arg.isObject()) {
|
|
34
|
+
auto value = arg.getObject(runtime);
|
|
35
|
+
if (value.hasProperty(runtime, "entries")) {
|
|
36
|
+
auto entries = value.getProperty(runtime, "entries");
|
|
37
|
+
|
|
38
|
+
if (entries.isUndefined()) {
|
|
39
|
+
throw std::runtime_error(
|
|
40
|
+
"Property GPUBindGroupLayoutDescriptor::entries is required");
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
throw std::runtime_error(
|
|
44
|
+
"Property GPUBindGroupLayoutDescriptor::entries is not defined");
|
|
45
|
+
}
|
|
46
|
+
if (value.hasProperty(runtime, "label")) {
|
|
47
|
+
auto label = value.getProperty(runtime, "label");
|
|
48
|
+
|
|
49
|
+
if (label.isString()) {
|
|
50
|
+
auto str = label.asString(runtime).utf8(runtime);
|
|
51
|
+
result->label = str;
|
|
52
|
+
result->_instance.label = result->label.c_str();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutDescriptor::entries = %f",
|
|
57
|
+
result->_instance.entries);
|
|
58
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutDescriptor::label = %f",
|
|
59
|
+
result->_instance.label);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
static jsi::Value
|
|
63
|
+
toJSI(jsi::Runtime &runtime,
|
|
64
|
+
std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor> arg) {
|
|
65
|
+
// No conversions here
|
|
66
|
+
return jsi::Value::null();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
} // namespace margelo
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBindGroupLayoutEntry {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BindGroupLayoutEntry *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BindGroupLayoutEntry _instance;
|
|
21
|
+
};
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
template <>
|
|
27
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>> {
|
|
28
|
+
static std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>
|
|
29
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
30
|
+
auto result = std::make_unique<rnwgpu::GPUBindGroupLayoutEntry>();
|
|
31
|
+
if (!outOfBounds && arg.isObject()) {
|
|
32
|
+
auto value = arg.getObject(runtime);
|
|
33
|
+
if (value.hasProperty(runtime, "binding")) {
|
|
34
|
+
auto binding = value.getProperty(runtime, "binding");
|
|
35
|
+
|
|
36
|
+
if (binding.isUndefined()) {
|
|
37
|
+
throw std::runtime_error(
|
|
38
|
+
"Property GPUBindGroupLayoutEntry::binding is required");
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
throw std::runtime_error(
|
|
42
|
+
"Property GPUBindGroupLayoutEntry::binding is not defined");
|
|
43
|
+
}
|
|
44
|
+
if (value.hasProperty(runtime, "visibility")) {
|
|
45
|
+
auto visibility = value.getProperty(runtime, "visibility");
|
|
46
|
+
|
|
47
|
+
if (visibility.isUndefined()) {
|
|
48
|
+
throw std::runtime_error(
|
|
49
|
+
"Property GPUBindGroupLayoutEntry::visibility is required");
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
throw std::runtime_error(
|
|
53
|
+
"Property GPUBindGroupLayoutEntry::visibility is not defined");
|
|
54
|
+
}
|
|
55
|
+
if (value.hasProperty(runtime, "buffer")) {
|
|
56
|
+
auto buffer = value.getProperty(runtime, "buffer");
|
|
57
|
+
}
|
|
58
|
+
if (value.hasProperty(runtime, "sampler")) {
|
|
59
|
+
auto sampler = value.getProperty(runtime, "sampler");
|
|
60
|
+
}
|
|
61
|
+
if (value.hasProperty(runtime, "texture")) {
|
|
62
|
+
auto texture = value.getProperty(runtime, "texture");
|
|
63
|
+
}
|
|
64
|
+
if (value.hasProperty(runtime, "storageTexture")) {
|
|
65
|
+
auto storageTexture = value.getProperty(runtime, "storageTexture");
|
|
66
|
+
}
|
|
67
|
+
if (value.hasProperty(runtime, "externalTexture")) {
|
|
68
|
+
auto externalTexture = value.getProperty(runtime, "externalTexture");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::binding = %f",
|
|
72
|
+
result->_instance.binding);
|
|
73
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::visibility = %f",
|
|
74
|
+
result->_instance.visibility);
|
|
75
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::buffer = %f",
|
|
76
|
+
result->_instance.buffer);
|
|
77
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::sampler = %f",
|
|
78
|
+
result->_instance.sampler);
|
|
79
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::texture = %f",
|
|
80
|
+
result->_instance.texture);
|
|
81
|
+
rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::storageTexture = %f",
|
|
82
|
+
result->_instance.storageTexture);
|
|
83
|
+
rnwgpu::Logger::logToConsole(
|
|
84
|
+
"GPUBindGroupLayoutEntry::externalTexture = %f",
|
|
85
|
+
result->_instance.externalTexture);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
static jsi::Value
|
|
89
|
+
toJSI(jsi::Runtime &runtime,
|
|
90
|
+
std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry> arg) {
|
|
91
|
+
// No conversions here
|
|
92
|
+
return jsi::Value::null();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
} // namespace margelo
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBlendComponent {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BlendComponent *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BlendComponent _instance;
|
|
21
|
+
};
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendComponent>> {
|
|
27
|
+
static std::shared_ptr<rnwgpu::GPUBlendComponent>
|
|
28
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
29
|
+
auto result = std::make_unique<rnwgpu::GPUBlendComponent>();
|
|
30
|
+
if (!outOfBounds && arg.isObject()) {
|
|
31
|
+
auto value = arg.getObject(runtime);
|
|
32
|
+
if (value.hasProperty(runtime, "operation")) {
|
|
33
|
+
auto operation = value.getProperty(runtime, "operation");
|
|
34
|
+
}
|
|
35
|
+
if (value.hasProperty(runtime, "srcFactor")) {
|
|
36
|
+
auto srcFactor = value.getProperty(runtime, "srcFactor");
|
|
37
|
+
}
|
|
38
|
+
if (value.hasProperty(runtime, "dstFactor")) {
|
|
39
|
+
auto dstFactor = value.getProperty(runtime, "dstFactor");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
rnwgpu::Logger::logToConsole("GPUBlendComponent::operation = %f",
|
|
43
|
+
result->_instance.operation);
|
|
44
|
+
rnwgpu::Logger::logToConsole("GPUBlendComponent::srcFactor = %f",
|
|
45
|
+
result->_instance.srcFactor);
|
|
46
|
+
rnwgpu::Logger::logToConsole("GPUBlendComponent::dstFactor = %f",
|
|
47
|
+
result->_instance.dstFactor);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
51
|
+
std::shared_ptr<rnwgpu::GPUBlendComponent> arg) {
|
|
52
|
+
// No conversions here
|
|
53
|
+
return jsi::Value::null();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
} // namespace margelo
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "Logger.h"
|
|
9
|
+
#include "RNFJSIConverter.h"
|
|
10
|
+
#include <RNFHybridObject.h>
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
class GPUBlendState {
|
|
17
|
+
public:
|
|
18
|
+
wgpu::BlendState *getInstance() { return &_instance; }
|
|
19
|
+
|
|
20
|
+
wgpu::BlendState _instance;
|
|
21
|
+
};
|
|
22
|
+
} // namespace rnwgpu
|
|
23
|
+
|
|
24
|
+
namespace margelo {
|
|
25
|
+
|
|
26
|
+
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendState>> {
|
|
27
|
+
static std::shared_ptr<rnwgpu::GPUBlendState>
|
|
28
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
29
|
+
auto result = std::make_unique<rnwgpu::GPUBlendState>();
|
|
30
|
+
if (!outOfBounds && arg.isObject()) {
|
|
31
|
+
auto value = arg.getObject(runtime);
|
|
32
|
+
if (value.hasProperty(runtime, "color")) {
|
|
33
|
+
auto color = value.getProperty(runtime, "color");
|
|
34
|
+
|
|
35
|
+
if (color.isUndefined()) {
|
|
36
|
+
throw std::runtime_error("Property GPUBlendState::color is required");
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
throw std::runtime_error(
|
|
40
|
+
"Property GPUBlendState::color is not defined");
|
|
41
|
+
}
|
|
42
|
+
if (value.hasProperty(runtime, "alpha")) {
|
|
43
|
+
auto alpha = value.getProperty(runtime, "alpha");
|
|
44
|
+
|
|
45
|
+
if (alpha.isUndefined()) {
|
|
46
|
+
throw std::runtime_error("Property GPUBlendState::alpha is required");
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
throw std::runtime_error(
|
|
50
|
+
"Property GPUBlendState::alpha is not defined");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
rnwgpu::Logger::logToConsole("GPUBlendState::color = %f",
|
|
54
|
+
result->_instance.color);
|
|
55
|
+
rnwgpu::Logger::logToConsole("GPUBlendState::alpha = %f",
|
|
56
|
+
result->_instance.alpha);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
60
|
+
std::shared_ptr<rnwgpu::GPUBlendState> arg) {
|
|
61
|
+
// No conversions here
|
|
62
|
+
return jsi::Value::null();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
} // namespace margelo
|