react-native-wgpu 0.4.2 → 0.5.1
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 +31 -0
- package/android/CMakeLists.txt +3 -3
- package/cpp/jsi/{RNFEnumMapper.h → EnumMapper.h} +2 -6
- package/cpp/jsi/{RNFJSIConverter.h → JSIConverter.h} +27 -110
- package/cpp/jsi/NativeObject.h +607 -0
- package/cpp/jsi/{RNFPromise.cpp → Promise.cpp} +3 -6
- package/cpp/jsi/{RNFPromise.h → Promise.h} +2 -5
- package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
- package/cpp/jsi/RuntimeAwareCache.h +100 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
- package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
- package/cpp/rnwgpu/ArrayBuffer.h +8 -12
- package/cpp/rnwgpu/RNWebGPUManager.cpp +187 -28
- package/cpp/rnwgpu/RNWebGPUManager.h +7 -0
- package/cpp/rnwgpu/api/Canvas.h +14 -12
- package/cpp/rnwgpu/api/GPU.cpp +4 -6
- package/cpp/rnwgpu/api/GPU.h +13 -11
- package/cpp/rnwgpu/api/GPUAdapter.cpp +9 -9
- package/cpp/rnwgpu/api/GPUAdapter.h +14 -11
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +17 -15
- package/cpp/rnwgpu/api/GPUBindGroup.h +11 -10
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +12 -11
- package/cpp/rnwgpu/api/GPUBuffer.h +19 -16
- package/cpp/rnwgpu/api/GPUCanvasContext.h +17 -13
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +12 -10
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +35 -32
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +19 -19
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +10 -7
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +28 -27
- package/cpp/rnwgpu/api/GPUComputePipeline.h +14 -13
- package/cpp/rnwgpu/api/GPUDevice.cpp +111 -95
- package/cpp/rnwgpu/api/GPUDevice.h +51 -43
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +12 -10
- package/cpp/rnwgpu/api/GPUError.h +19 -29
- package/cpp/rnwgpu/api/GPUExtent3D.h +7 -10
- package/cpp/rnwgpu/api/GPUExternalTexture.h +12 -11
- package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
- package/cpp/rnwgpu/api/GPUOrigin2D.h +6 -10
- package/cpp/rnwgpu/api/GPUOrigin3D.h +6 -10
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +12 -10
- package/cpp/rnwgpu/api/GPUQuerySet.h +14 -12
- package/cpp/rnwgpu/api/GPUQueue.h +18 -17
- package/cpp/rnwgpu/api/GPURenderBundle.h +11 -10
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +36 -33
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +49 -47
- package/cpp/rnwgpu/api/GPURenderPipeline.h +14 -12
- package/cpp/rnwgpu/api/GPUSampler.h +11 -10
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +7 -8
- package/cpp/rnwgpu/api/GPUShaderModule.h +13 -12
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +73 -93
- package/cpp/rnwgpu/api/GPUTexture.h +24 -20
- package/cpp/rnwgpu/api/GPUTextureView.h +11 -10
- package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +10 -6
- package/cpp/rnwgpu/api/RNWebGPU.h +21 -21
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +7 -11
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +28 -32
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +18 -20
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +11 -14
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +14 -16
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +18 -29
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +3 -8
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +3 -7
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +3 -7
- package/cpp/rnwgpu/api/descriptors/Unions.h +3 -3
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +10 -10
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +2 -2
- package/lib/commonjs/external/ModuleProxy.js +36 -0
- package/lib/commonjs/external/ModuleProxy.js.map +1 -0
- package/lib/commonjs/external/index.js +17 -0
- package/lib/commonjs/external/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
- package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/commonjs/external/reanimated/index.js +21 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +50 -0
- package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/commonjs/main/index.js +2 -142
- package/lib/commonjs/main/index.js.map +1 -1
- package/lib/module/external/ModuleProxy.js +28 -0
- package/lib/module/external/ModuleProxy.js.map +1 -0
- package/lib/module/external/index.js +2 -0
- package/lib/module/external/index.js.map +1 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
- package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
- package/lib/module/external/reanimated/index.js +3 -0
- package/lib/module/external/reanimated/index.js.map +1 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js +43 -0
- package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
- package/lib/module/main/index.js +2 -141
- package/lib/module/main/index.js.map +1 -1
- package/lib/typescript/babel.config.d.ts +1 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
- package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
- package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
- package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
- package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
- package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/index.d.ts +2 -0
- package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
- package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
- package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/index.d.ts +2 -0
- package/lib/typescript/src/external/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
- package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
- package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
- package/package.json +16 -3
- package/src/external/ModuleProxy.ts +30 -0
- package/src/external/index.ts +1 -0
- package/src/external/reanimated/ReanimatedProxy.ts +19 -0
- package/src/external/reanimated/index.ts +2 -0
- package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
- package/src/main/index.tsx +3 -170
- package/cpp/jsi/RNFHybridObject.cpp +0 -150
- package/cpp/jsi/RNFHybridObject.h +0 -181
- package/cpp/jsi/RNFJSIHelper.h +0 -51
- package/cpp/jsi/RNFPointerHolder.h +0 -95
- package/cpp/jsi/RNFRuntimeState.cpp +0 -18
- package/cpp/jsi/RNFRuntimeState.h +0 -106
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
|
-
#include "
|
|
5
|
+
#include "JSIConverter.h"
|
|
6
6
|
|
|
7
7
|
#include "webgpu/webgpu_cpp.h"
|
|
8
8
|
|
|
@@ -14,14 +14,10 @@ struct GPUExtent3D {
|
|
|
14
14
|
double depthOrArrayLayers = 1;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
namespace margelo {
|
|
20
|
-
|
|
21
|
-
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUExtent3D>> {
|
|
22
|
-
static std::shared_ptr<rnwgpu::GPUExtent3D>
|
|
17
|
+
template <> struct JSIConverter<std::shared_ptr<GPUExtent3D>> {
|
|
18
|
+
static std::shared_ptr<GPUExtent3D>
|
|
23
19
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
24
|
-
auto result = std::make_unique<
|
|
20
|
+
auto result = std::make_unique<GPUExtent3D>();
|
|
25
21
|
if (!outOfBounds && arg.isObject()) {
|
|
26
22
|
if (arg.getObject(runtime).isArray(runtime)) {
|
|
27
23
|
auto array = arg.getObject(runtime).asArray(runtime);
|
|
@@ -61,9 +57,10 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUExtent3D>> {
|
|
|
61
57
|
return result;
|
|
62
58
|
}
|
|
63
59
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
64
|
-
std::shared_ptr<
|
|
60
|
+
std::shared_ptr<GPUExtent3D> arg) {
|
|
65
61
|
// No conversions here
|
|
66
62
|
return jsi::Value::null();
|
|
67
63
|
}
|
|
68
64
|
};
|
|
69
|
-
|
|
65
|
+
|
|
66
|
+
} // namespace rnwgpu
|
|
@@ -4,22 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
#include "Unions.h"
|
|
6
6
|
|
|
7
|
-
#include "
|
|
7
|
+
#include "NativeObject.h"
|
|
8
8
|
|
|
9
9
|
#include "webgpu/webgpu_cpp.h"
|
|
10
10
|
|
|
11
11
|
namespace rnwgpu {
|
|
12
12
|
|
|
13
|
-
namespace
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
14
|
|
|
15
|
-
class GPUExternalTexture : public
|
|
15
|
+
class GPUExternalTexture : public NativeObject<GPUExternalTexture> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUExternalTexture";
|
|
18
|
+
|
|
17
19
|
explicit GPUExternalTexture(wgpu::ExternalTexture instance, std::string label)
|
|
18
|
-
:
|
|
19
|
-
}
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
20
21
|
|
|
21
22
|
public:
|
|
22
|
-
std::string getBrand() { return
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
23
24
|
|
|
24
25
|
std::string getLabel() { return _label; }
|
|
25
26
|
void setLabel(const std::string &label) {
|
|
@@ -27,11 +28,11 @@ public:
|
|
|
27
28
|
_instance.SetLabel(_label.c_str());
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
void
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPUExternalTexture::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label",
|
|
34
|
+
&GPUExternalTexture::getLabel,
|
|
35
|
+
&GPUExternalTexture::setLabel);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
inline const wgpu::ExternalTexture get() { return _instance; }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "NativeObject.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
class GPUInternalError : public NativeObject<GPUInternalError> {
|
|
12
|
+
public:
|
|
13
|
+
static constexpr const char *CLASS_NAME = "GPUInternalError";
|
|
14
|
+
|
|
15
|
+
explicit GPUInternalError(std::string message)
|
|
16
|
+
: NativeObject(CLASS_NAME), _message(std::move(message)) {}
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
20
|
+
std::string getMessage() { return _message; }
|
|
21
|
+
|
|
22
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
23
|
+
installGetter(runtime, prototype, "__brand", &GPUInternalError::getBrand);
|
|
24
|
+
installGetter(runtime, prototype, "message", &GPUInternalError::getMessage);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
std::string _message;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace rnwgpu
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
|
-
#include "
|
|
5
|
+
#include "JSIConverter.h"
|
|
6
6
|
|
|
7
7
|
#include "webgpu/webgpu_cpp.h"
|
|
8
8
|
|
|
@@ -13,14 +13,10 @@ struct GPUOrigin2D {
|
|
|
13
13
|
double y = 0;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
namespace margelo {
|
|
19
|
-
|
|
20
|
-
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin2D>> {
|
|
21
|
-
static std::shared_ptr<rnwgpu::GPUOrigin2D>
|
|
16
|
+
template <> struct JSIConverter<std::shared_ptr<GPUOrigin2D>> {
|
|
17
|
+
static std::shared_ptr<GPUOrigin2D>
|
|
22
18
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
23
|
-
auto result = std::make_unique<
|
|
19
|
+
auto result = std::make_unique<GPUOrigin2D>();
|
|
24
20
|
if (!outOfBounds && arg.isObject()) {
|
|
25
21
|
if (arg.getObject(runtime).isArray(runtime)) {
|
|
26
22
|
auto array = arg.getObject(runtime).asArray(runtime);
|
|
@@ -50,10 +46,10 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin2D>> {
|
|
|
50
46
|
return result;
|
|
51
47
|
}
|
|
52
48
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
53
|
-
std::shared_ptr<
|
|
49
|
+
std::shared_ptr<GPUOrigin2D> arg) {
|
|
54
50
|
// No conversions here
|
|
55
51
|
return jsi::Value::null();
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
54
|
|
|
59
|
-
} // namespace
|
|
55
|
+
} // namespace rnwgpu
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
|
-
#include "
|
|
5
|
+
#include "JSIConverter.h"
|
|
6
6
|
|
|
7
7
|
#include "webgpu/webgpu_cpp.h"
|
|
8
8
|
|
|
@@ -14,14 +14,10 @@ struct GPUOrigin3D {
|
|
|
14
14
|
double z = 0;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
namespace margelo {
|
|
20
|
-
|
|
21
|
-
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin3D>> {
|
|
22
|
-
static std::shared_ptr<rnwgpu::GPUOrigin3D>
|
|
17
|
+
template <> struct JSIConverter<std::shared_ptr<GPUOrigin3D>> {
|
|
18
|
+
static std::shared_ptr<GPUOrigin3D>
|
|
23
19
|
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
24
|
-
auto result = std::make_unique<
|
|
20
|
+
auto result = std::make_unique<GPUOrigin3D>();
|
|
25
21
|
if (!outOfBounds && arg.isObject()) {
|
|
26
22
|
if (arg.getObject(runtime).isArray(runtime)) {
|
|
27
23
|
auto array = arg.getObject(runtime).asArray(runtime);
|
|
@@ -57,10 +53,10 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin3D>> {
|
|
|
57
53
|
return result;
|
|
58
54
|
}
|
|
59
55
|
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
60
|
-
std::shared_ptr<
|
|
56
|
+
std::shared_ptr<GPUOrigin3D> arg) {
|
|
61
57
|
// No conversions here
|
|
62
58
|
return jsi::Value::null();
|
|
63
59
|
}
|
|
64
60
|
};
|
|
65
61
|
|
|
66
|
-
} // namespace
|
|
62
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "NativeObject.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
class GPUOutOfMemoryError : public NativeObject<GPUOutOfMemoryError> {
|
|
12
|
+
public:
|
|
13
|
+
static constexpr const char *CLASS_NAME = "GPUOutOfMemoryError";
|
|
14
|
+
|
|
15
|
+
explicit GPUOutOfMemoryError(std::string message)
|
|
16
|
+
: NativeObject(CLASS_NAME), _message(std::move(message)) {}
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
20
|
+
std::string getMessage() { return _message; }
|
|
21
|
+
|
|
22
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
23
|
+
installGetter(runtime, prototype, "__brand",
|
|
24
|
+
&GPUOutOfMemoryError::getBrand);
|
|
25
|
+
installGetter(runtime, prototype, "message",
|
|
26
|
+
&GPUOutOfMemoryError::getMessage);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
std::string _message;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace rnwgpu
|
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
#include "Unions.h"
|
|
6
6
|
|
|
7
|
-
#include "
|
|
7
|
+
#include "NativeObject.h"
|
|
8
8
|
|
|
9
9
|
#include "webgpu/webgpu_cpp.h"
|
|
10
10
|
|
|
11
11
|
namespace rnwgpu {
|
|
12
12
|
|
|
13
|
-
namespace
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
14
|
|
|
15
|
-
class GPUPipelineLayout : public
|
|
15
|
+
class GPUPipelineLayout : public NativeObject<GPUPipelineLayout> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUPipelineLayout";
|
|
18
|
+
|
|
17
19
|
explicit GPUPipelineLayout(wgpu::PipelineLayout instance, std::string label)
|
|
18
|
-
:
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
19
21
|
|
|
20
22
|
public:
|
|
21
|
-
std::string getBrand() { return
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
22
24
|
|
|
23
25
|
std::string getLabel() { return _label; }
|
|
24
26
|
void setLabel(const std::string &label) {
|
|
@@ -26,11 +28,11 @@ public:
|
|
|
26
28
|
_instance.SetLabel(_label.c_str());
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
void
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPUPipelineLayout::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label",
|
|
34
|
+
&GPUPipelineLayout::getLabel,
|
|
35
|
+
&GPUPipelineLayout::setLabel);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
inline const wgpu::PipelineLayout get() { return _instance; }
|
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
#include "Unions.h"
|
|
6
6
|
|
|
7
|
-
#include "
|
|
7
|
+
#include "NativeObject.h"
|
|
8
8
|
|
|
9
9
|
#include "webgpu/webgpu_cpp.h"
|
|
10
10
|
|
|
11
11
|
namespace rnwgpu {
|
|
12
12
|
|
|
13
|
-
namespace
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
14
|
|
|
15
|
-
class GPUQuerySet : public
|
|
15
|
+
class GPUQuerySet : public NativeObject<GPUQuerySet> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUQuerySet";
|
|
18
|
+
|
|
17
19
|
explicit GPUQuerySet(wgpu::QuerySet instance, std::string label)
|
|
18
|
-
:
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
19
21
|
|
|
20
22
|
public:
|
|
21
|
-
std::string getBrand() { return
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
22
24
|
|
|
23
25
|
void destroy();
|
|
24
26
|
|
|
@@ -31,13 +33,13 @@ public:
|
|
|
31
33
|
_instance.SetLabel(_label.c_str());
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
void
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
37
|
+
installGetter(runtime, prototype, "__brand", &GPUQuerySet::getBrand);
|
|
38
|
+
installMethod(runtime, prototype, "destroy", &GPUQuerySet::destroy);
|
|
39
|
+
installGetter(runtime, prototype, "type", &GPUQuerySet::getType);
|
|
40
|
+
installGetter(runtime, prototype, "count", &GPUQuerySet::getCount);
|
|
41
|
+
installGetterSetter(runtime, prototype, "label", &GPUQuerySet::getLabel,
|
|
42
|
+
&GPUQuerySet::setLabel);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
inline const wgpu::QuerySet get() { return _instance; }
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include "Unions.h"
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "NativeObject.h"
|
|
10
10
|
|
|
11
11
|
#include "rnwgpu/async/AsyncRunner.h"
|
|
12
12
|
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
@@ -21,18 +21,20 @@
|
|
|
21
21
|
|
|
22
22
|
namespace rnwgpu {
|
|
23
23
|
|
|
24
|
-
namespace
|
|
24
|
+
namespace jsi = facebook::jsi;
|
|
25
25
|
|
|
26
|
-
class GPUQueue : public
|
|
26
|
+
class GPUQueue : public NativeObject<GPUQueue> {
|
|
27
27
|
public:
|
|
28
|
+
static constexpr const char *CLASS_NAME = "GPUQueue";
|
|
29
|
+
|
|
28
30
|
explicit GPUQueue(wgpu::Queue instance,
|
|
29
31
|
std::shared_ptr<async::AsyncRunner> async,
|
|
30
32
|
std::string label)
|
|
31
|
-
:
|
|
33
|
+
: NativeObject(CLASS_NAME), _instance(instance), _async(async),
|
|
32
34
|
_label(label) {}
|
|
33
35
|
|
|
34
36
|
public:
|
|
35
|
-
std::string getBrand() { return
|
|
37
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
36
38
|
|
|
37
39
|
void submit(std::vector<std::shared_ptr<GPUCommandBuffer>> commandBuffers);
|
|
38
40
|
async::AsyncTaskHandle onSubmittedWorkDone();
|
|
@@ -55,18 +57,17 @@ public:
|
|
|
55
57
|
_instance.SetLabel(_label.c_str());
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
void
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
registerHybridSetter("label", &GPUQueue::setLabel, this);
|
|
60
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
61
|
+
installGetter(runtime, prototype, "__brand", &GPUQueue::getBrand);
|
|
62
|
+
installMethod(runtime, prototype, "submit", &GPUQueue::submit);
|
|
63
|
+
installMethod(runtime, prototype, "onSubmittedWorkDone",
|
|
64
|
+
&GPUQueue::onSubmittedWorkDone);
|
|
65
|
+
installMethod(runtime, prototype, "writeBuffer", &GPUQueue::writeBuffer);
|
|
66
|
+
installMethod(runtime, prototype, "writeTexture", &GPUQueue::writeTexture);
|
|
67
|
+
installMethod(runtime, prototype, "copyExternalImageToTexture",
|
|
68
|
+
&GPUQueue::copyExternalImageToTexture);
|
|
69
|
+
installGetterSetter(runtime, prototype, "label", &GPUQueue::getLabel,
|
|
70
|
+
&GPUQueue::setLabel);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
inline const wgpu::Queue get() { return _instance; }
|
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
#include "Unions.h"
|
|
6
6
|
|
|
7
|
-
#include "
|
|
7
|
+
#include "NativeObject.h"
|
|
8
8
|
|
|
9
9
|
#include "webgpu/webgpu_cpp.h"
|
|
10
10
|
|
|
11
11
|
namespace rnwgpu {
|
|
12
12
|
|
|
13
|
-
namespace
|
|
13
|
+
namespace jsi = facebook::jsi;
|
|
14
14
|
|
|
15
|
-
class GPURenderBundle : public
|
|
15
|
+
class GPURenderBundle : public NativeObject<GPURenderBundle> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPURenderBundle";
|
|
18
|
+
|
|
17
19
|
explicit GPURenderBundle(wgpu::RenderBundle instance, std::string label)
|
|
18
|
-
:
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
19
21
|
|
|
20
22
|
public:
|
|
21
|
-
std::string getBrand() { return
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
22
24
|
|
|
23
25
|
std::string getLabel() { return _label; }
|
|
24
26
|
void setLabel(const std::string &label) {
|
|
@@ -26,11 +28,10 @@ public:
|
|
|
26
28
|
_instance.SetLabel(_label.c_str());
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
void
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
registerHybridSetter("label", &GPURenderBundle::setLabel, this);
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPURenderBundle::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label", &GPURenderBundle::getLabel,
|
|
34
|
+
&GPURenderBundle::setLabel);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
inline const wgpu::RenderBundle get() { return _instance; }
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
#include "Unions.h"
|
|
10
10
|
|
|
11
|
-
#include "
|
|
11
|
+
#include "NativeObject.h"
|
|
12
12
|
|
|
13
13
|
#include "webgpu/webgpu_cpp.h"
|
|
14
14
|
|
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
|
|
21
21
|
namespace rnwgpu {
|
|
22
22
|
|
|
23
|
-
namespace
|
|
23
|
+
namespace jsi = facebook::jsi;
|
|
24
24
|
|
|
25
|
-
class GPURenderBundleEncoder : public
|
|
25
|
+
class GPURenderBundleEncoder : public NativeObject<GPURenderBundleEncoder> {
|
|
26
26
|
public:
|
|
27
|
+
static constexpr const char *CLASS_NAME = "GPURenderBundleEncoder";
|
|
28
|
+
|
|
27
29
|
explicit GPURenderBundleEncoder(wgpu::RenderBundleEncoder instance,
|
|
28
30
|
std::string label)
|
|
29
|
-
:
|
|
30
|
-
_label(label) {}
|
|
31
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
31
32
|
|
|
32
33
|
public:
|
|
33
|
-
std::string getBrand() { return
|
|
34
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
34
35
|
|
|
35
36
|
std::shared_ptr<GPURenderBundle>
|
|
36
37
|
finish(std::optional<std::shared_ptr<GPURenderBundleDescriptor>> descriptor);
|
|
@@ -68,33 +69,35 @@ public:
|
|
|
68
69
|
_instance.SetLabel(_label.c_str());
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
void
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
73
|
+
installGetter(runtime, prototype, "__brand",
|
|
74
|
+
&GPURenderBundleEncoder::getBrand);
|
|
75
|
+
installMethod(runtime, prototype, "finish",
|
|
76
|
+
&GPURenderBundleEncoder::finish);
|
|
77
|
+
installMethod(runtime, prototype, "pushDebugGroup",
|
|
78
|
+
&GPURenderBundleEncoder::pushDebugGroup);
|
|
79
|
+
installMethod(runtime, prototype, "popDebugGroup",
|
|
80
|
+
&GPURenderBundleEncoder::popDebugGroup);
|
|
81
|
+
installMethod(runtime, prototype, "insertDebugMarker",
|
|
82
|
+
&GPURenderBundleEncoder::insertDebugMarker);
|
|
83
|
+
installMethod(runtime, prototype, "setBindGroup",
|
|
84
|
+
&GPURenderBundleEncoder::setBindGroup);
|
|
85
|
+
installMethod(runtime, prototype, "setPipeline",
|
|
86
|
+
&GPURenderBundleEncoder::setPipeline);
|
|
87
|
+
installMethod(runtime, prototype, "setIndexBuffer",
|
|
88
|
+
&GPURenderBundleEncoder::setIndexBuffer);
|
|
89
|
+
installMethod(runtime, prototype, "setVertexBuffer",
|
|
90
|
+
&GPURenderBundleEncoder::setVertexBuffer);
|
|
91
|
+
installMethod(runtime, prototype, "draw", &GPURenderBundleEncoder::draw);
|
|
92
|
+
installMethod(runtime, prototype, "drawIndexed",
|
|
93
|
+
&GPURenderBundleEncoder::drawIndexed);
|
|
94
|
+
installMethod(runtime, prototype, "drawIndirect",
|
|
95
|
+
&GPURenderBundleEncoder::drawIndirect);
|
|
96
|
+
installMethod(runtime, prototype, "drawIndexedIndirect",
|
|
97
|
+
&GPURenderBundleEncoder::drawIndexedIndirect);
|
|
98
|
+
installGetterSetter(runtime, prototype, "label",
|
|
99
|
+
&GPURenderBundleEncoder::getLabel,
|
|
100
|
+
&GPURenderBundleEncoder::setLabel);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
inline const wgpu::RenderBundleEncoder get() { return _instance; }
|