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
|
@@ -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 GPURenderPassEncoder : public
|
|
25
|
+
class GPURenderPassEncoder : public NativeObject<GPURenderPassEncoder> {
|
|
26
26
|
public:
|
|
27
|
+
static constexpr const char *CLASS_NAME = "GPURenderPassEncoder";
|
|
28
|
+
|
|
27
29
|
explicit GPURenderPassEncoder(wgpu::RenderPassEncoder 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
|
void setViewport(double x, double y, double width, double height,
|
|
36
37
|
double minDepth, double maxDepth);
|
|
@@ -75,47 +76,48 @@ public:
|
|
|
75
76
|
_instance.SetLabel(_label.c_str());
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
void
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
79
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
80
|
+
installGetter(runtime, prototype, "__brand",
|
|
81
|
+
&GPURenderPassEncoder::getBrand);
|
|
82
|
+
installMethod(runtime, prototype, "setViewport",
|
|
83
|
+
&GPURenderPassEncoder::setViewport);
|
|
84
|
+
installMethod(runtime, prototype, "setScissorRect",
|
|
85
|
+
&GPURenderPassEncoder::setScissorRect);
|
|
86
|
+
installMethod(runtime, prototype, "setBlendConstant",
|
|
87
|
+
&GPURenderPassEncoder::setBlendConstant);
|
|
88
|
+
installMethod(runtime, prototype, "setStencilReference",
|
|
89
|
+
&GPURenderPassEncoder::setStencilReference);
|
|
90
|
+
installMethod(runtime, prototype, "beginOcclusionQuery",
|
|
91
|
+
&GPURenderPassEncoder::beginOcclusionQuery);
|
|
92
|
+
installMethod(runtime, prototype, "endOcclusionQuery",
|
|
93
|
+
&GPURenderPassEncoder::endOcclusionQuery);
|
|
94
|
+
installMethod(runtime, prototype, "executeBundles",
|
|
95
|
+
&GPURenderPassEncoder::executeBundles);
|
|
96
|
+
installMethod(runtime, prototype, "end", &GPURenderPassEncoder::end);
|
|
97
|
+
installMethod(runtime, prototype, "pushDebugGroup",
|
|
98
|
+
&GPURenderPassEncoder::pushDebugGroup);
|
|
99
|
+
installMethod(runtime, prototype, "popDebugGroup",
|
|
100
|
+
&GPURenderPassEncoder::popDebugGroup);
|
|
101
|
+
installMethod(runtime, prototype, "insertDebugMarker",
|
|
102
|
+
&GPURenderPassEncoder::insertDebugMarker);
|
|
103
|
+
installMethod(runtime, prototype, "setBindGroup",
|
|
104
|
+
&GPURenderPassEncoder::setBindGroup);
|
|
105
|
+
installMethod(runtime, prototype, "setPipeline",
|
|
106
|
+
&GPURenderPassEncoder::setPipeline);
|
|
107
|
+
installMethod(runtime, prototype, "setIndexBuffer",
|
|
108
|
+
&GPURenderPassEncoder::setIndexBuffer);
|
|
109
|
+
installMethod(runtime, prototype, "setVertexBuffer",
|
|
110
|
+
&GPURenderPassEncoder::setVertexBuffer);
|
|
111
|
+
installMethod(runtime, prototype, "draw", &GPURenderPassEncoder::draw);
|
|
112
|
+
installMethod(runtime, prototype, "drawIndexed",
|
|
113
|
+
&GPURenderPassEncoder::drawIndexed);
|
|
114
|
+
installMethod(runtime, prototype, "drawIndirect",
|
|
115
|
+
&GPURenderPassEncoder::drawIndirect);
|
|
116
|
+
installMethod(runtime, prototype, "drawIndexedIndirect",
|
|
117
|
+
&GPURenderPassEncoder::drawIndexedIndirect);
|
|
118
|
+
installGetterSetter(runtime, prototype, "label",
|
|
119
|
+
&GPURenderPassEncoder::getLabel,
|
|
120
|
+
&GPURenderPassEncoder::setLabel);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
inline const wgpu::RenderPassEncoder get() { return _instance; }
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include "Unions.h"
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "NativeObject.h"
|
|
9
9
|
|
|
10
10
|
#include "webgpu/webgpu_cpp.h"
|
|
11
11
|
|
|
@@ -13,15 +13,17 @@
|
|
|
13
13
|
|
|
14
14
|
namespace rnwgpu {
|
|
15
15
|
|
|
16
|
-
namespace
|
|
16
|
+
namespace jsi = facebook::jsi;
|
|
17
17
|
|
|
18
|
-
class GPURenderPipeline : public
|
|
18
|
+
class GPURenderPipeline : public NativeObject<GPURenderPipeline> {
|
|
19
19
|
public:
|
|
20
|
+
static constexpr const char *CLASS_NAME = "GPURenderPipeline";
|
|
21
|
+
|
|
20
22
|
explicit GPURenderPipeline(wgpu::RenderPipeline instance, std::string label)
|
|
21
|
-
:
|
|
23
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
22
24
|
|
|
23
25
|
public:
|
|
24
|
-
std::string getBrand() { return
|
|
26
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
25
27
|
|
|
26
28
|
std::shared_ptr<GPUBindGroupLayout> getBindGroupLayout(uint32_t index);
|
|
27
29
|
|
|
@@ -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", &GPURenderPipeline::getBrand);
|
|
38
|
+
installMethod(runtime, prototype, "getBindGroupLayout",
|
|
39
|
+
&GPURenderPipeline::getBindGroupLayout);
|
|
40
|
+
installGetterSetter(runtime, prototype, "label",
|
|
41
|
+
&GPURenderPipeline::getLabel,
|
|
42
|
+
&GPURenderPipeline::setLabel);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
inline const wgpu::RenderPipeline 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 GPUSampler : public
|
|
15
|
+
class GPUSampler : public NativeObject<GPUSampler> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUSampler";
|
|
18
|
+
|
|
17
19
|
explicit GPUSampler(wgpu::Sampler 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", &GPUSampler::setLabel, this);
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPUSampler::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label", &GPUSampler::getLabel,
|
|
34
|
+
&GPUSampler::setLabel);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
inline const wgpu::Sampler get() { return _instance; }
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <utility>
|
|
5
5
|
|
|
6
|
-
#include "
|
|
6
|
+
#include "JSIConverter.h"
|
|
7
7
|
|
|
8
8
|
namespace rnwgpu {
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ async::AsyncTaskHandle GPUShaderModule::getCompilationInfo() {
|
|
|
28
28
|
result->_messages.reserve(compilationInfo->messageCount);
|
|
29
29
|
for (size_t i = 0; i < compilationInfo->messageCount; ++i) {
|
|
30
30
|
const auto &wgpuMessage = compilationInfo->messages[i];
|
|
31
|
-
|
|
31
|
+
GPUCompilationMessageData message;
|
|
32
32
|
message.message =
|
|
33
33
|
wgpuMessage.message.length ? wgpuMessage.message.data : "";
|
|
34
34
|
message.type = wgpuMessage.type;
|
|
@@ -39,12 +39,11 @@ async::AsyncTaskHandle GPUShaderModule::getCompilationInfo() {
|
|
|
39
39
|
result->_messages.push_back(std::move(message));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
resolve(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
42
|
+
resolve([result =
|
|
43
|
+
std::move(result)](jsi::Runtime &runtime) mutable {
|
|
44
|
+
return JSIConverter<std::shared_ptr<GPUCompilationInfo>>::toJSI(
|
|
45
|
+
runtime, result);
|
|
46
|
+
});
|
|
48
47
|
});
|
|
49
48
|
});
|
|
50
49
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include "Unions.h"
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "NativeObject.h"
|
|
9
9
|
|
|
10
10
|
#include "rnwgpu/async/AsyncRunner.h"
|
|
11
11
|
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
@@ -16,18 +16,20 @@
|
|
|
16
16
|
|
|
17
17
|
namespace rnwgpu {
|
|
18
18
|
|
|
19
|
-
namespace
|
|
19
|
+
namespace jsi = facebook::jsi;
|
|
20
20
|
|
|
21
|
-
class GPUShaderModule : public
|
|
21
|
+
class GPUShaderModule : public NativeObject<GPUShaderModule> {
|
|
22
22
|
public:
|
|
23
|
+
static constexpr const char *CLASS_NAME = "GPUShaderModule";
|
|
24
|
+
|
|
23
25
|
explicit GPUShaderModule(wgpu::ShaderModule instance,
|
|
24
26
|
std::shared_ptr<async::AsyncRunner> async,
|
|
25
27
|
std::string label)
|
|
26
|
-
:
|
|
28
|
+
: NativeObject(CLASS_NAME), _instance(instance), _async(async),
|
|
27
29
|
_label(label) {}
|
|
28
30
|
|
|
29
31
|
public:
|
|
30
|
-
std::string getBrand() { return
|
|
32
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
31
33
|
|
|
32
34
|
async::AsyncTaskHandle getCompilationInfo();
|
|
33
35
|
|
|
@@ -37,13 +39,12 @@ public:
|
|
|
37
39
|
_instance.SetLabel(_label.c_str());
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
void
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
registerHybridSetter("label", &GPUShaderModule::setLabel, this);
|
|
42
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
43
|
+
installGetter(runtime, prototype, "__brand", &GPUShaderModule::getBrand);
|
|
44
|
+
installMethod(runtime, prototype, "getCompilationInfo",
|
|
45
|
+
&GPUShaderModule::getCompilationInfo);
|
|
46
|
+
installGetterSetter(runtime, prototype, "label", &GPUShaderModule::getLabel,
|
|
47
|
+
&GPUShaderModule::setLabel);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
inline const wgpu::ShaderModule 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 GPUSupportedLimits : public
|
|
15
|
+
class GPUSupportedLimits : public NativeObject<GPUSupportedLimits> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUSupportedLimits";
|
|
18
|
+
|
|
17
19
|
explicit GPUSupportedLimits(wgpu::Limits instance)
|
|
18
|
-
:
|
|
20
|
+
: NativeObject(CLASS_NAME), _instance(instance) {}
|
|
19
21
|
|
|
20
22
|
public:
|
|
21
|
-
std::string getBrand() { return
|
|
23
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
22
24
|
|
|
23
25
|
double getMaxTextureDimension1D();
|
|
24
26
|
double getMaxTextureDimension2D();
|
|
@@ -52,94 +54,72 @@ public:
|
|
|
52
54
|
double getMaxComputeWorkgroupSizeZ();
|
|
53
55
|
double getMaxComputeWorkgroupsPerDimension();
|
|
54
56
|
|
|
55
|
-
void
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
&GPUSupportedLimits::getMaxColorAttachments, this);
|
|
122
|
-
registerHybridGetter(
|
|
123
|
-
"maxColorAttachmentBytesPerSample",
|
|
124
|
-
&GPUSupportedLimits::getMaxColorAttachmentBytesPerSample, this);
|
|
125
|
-
registerHybridGetter("maxComputeWorkgroupStorageSize",
|
|
126
|
-
&GPUSupportedLimits::getMaxComputeWorkgroupStorageSize,
|
|
127
|
-
this);
|
|
128
|
-
registerHybridGetter(
|
|
129
|
-
"maxComputeInvocationsPerWorkgroup",
|
|
130
|
-
&GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup, this);
|
|
131
|
-
registerHybridGetter("maxComputeWorkgroupSizeX",
|
|
132
|
-
&GPUSupportedLimits::getMaxComputeWorkgroupSizeX,
|
|
133
|
-
this);
|
|
134
|
-
registerHybridGetter("maxComputeWorkgroupSizeY",
|
|
135
|
-
&GPUSupportedLimits::getMaxComputeWorkgroupSizeY,
|
|
136
|
-
this);
|
|
137
|
-
registerHybridGetter("maxComputeWorkgroupSizeZ",
|
|
138
|
-
&GPUSupportedLimits::getMaxComputeWorkgroupSizeZ,
|
|
139
|
-
this);
|
|
140
|
-
registerHybridGetter(
|
|
141
|
-
"maxComputeWorkgroupsPerDimension",
|
|
142
|
-
&GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension, this);
|
|
57
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
58
|
+
installGetter(runtime, prototype, "__brand", &GPUSupportedLimits::getBrand);
|
|
59
|
+
installGetter(runtime, prototype, "maxTextureDimension1D",
|
|
60
|
+
&GPUSupportedLimits::getMaxTextureDimension1D);
|
|
61
|
+
installGetter(runtime, prototype, "maxTextureDimension2D",
|
|
62
|
+
&GPUSupportedLimits::getMaxTextureDimension2D);
|
|
63
|
+
installGetter(runtime, prototype, "maxTextureDimension3D",
|
|
64
|
+
&GPUSupportedLimits::getMaxTextureDimension3D);
|
|
65
|
+
installGetter(runtime, prototype, "maxTextureArrayLayers",
|
|
66
|
+
&GPUSupportedLimits::getMaxTextureArrayLayers);
|
|
67
|
+
installGetter(runtime, prototype, "maxBindGroups",
|
|
68
|
+
&GPUSupportedLimits::getMaxBindGroups);
|
|
69
|
+
installGetter(runtime, prototype, "maxBindGroupsPlusVertexBuffers",
|
|
70
|
+
&GPUSupportedLimits::getMaxBindGroupsPlusVertexBuffers);
|
|
71
|
+
installGetter(runtime, prototype, "maxBindingsPerBindGroup",
|
|
72
|
+
&GPUSupportedLimits::getMaxBindingsPerBindGroup);
|
|
73
|
+
installGetter(
|
|
74
|
+
runtime, prototype, "maxDynamicUniformBuffersPerPipelineLayout",
|
|
75
|
+
&GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout);
|
|
76
|
+
installGetter(
|
|
77
|
+
runtime, prototype, "maxDynamicStorageBuffersPerPipelineLayout",
|
|
78
|
+
&GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout);
|
|
79
|
+
installGetter(runtime, prototype, "maxSampledTexturesPerShaderStage",
|
|
80
|
+
&GPUSupportedLimits::getMaxSampledTexturesPerShaderStage);
|
|
81
|
+
installGetter(runtime, prototype, "maxSamplersPerShaderStage",
|
|
82
|
+
&GPUSupportedLimits::getMaxSamplersPerShaderStage);
|
|
83
|
+
installGetter(runtime, prototype, "maxStorageBuffersPerShaderStage",
|
|
84
|
+
&GPUSupportedLimits::getMaxStorageBuffersPerShaderStage);
|
|
85
|
+
installGetter(runtime, prototype, "maxStorageTexturesPerShaderStage",
|
|
86
|
+
&GPUSupportedLimits::getMaxStorageTexturesPerShaderStage);
|
|
87
|
+
installGetter(runtime, prototype, "maxUniformBuffersPerShaderStage",
|
|
88
|
+
&GPUSupportedLimits::getMaxUniformBuffersPerShaderStage);
|
|
89
|
+
installGetter(runtime, prototype, "maxUniformBufferBindingSize",
|
|
90
|
+
&GPUSupportedLimits::getMaxUniformBufferBindingSize);
|
|
91
|
+
installGetter(runtime, prototype, "maxStorageBufferBindingSize",
|
|
92
|
+
&GPUSupportedLimits::getMaxStorageBufferBindingSize);
|
|
93
|
+
installGetter(runtime, prototype, "minUniformBufferOffsetAlignment",
|
|
94
|
+
&GPUSupportedLimits::getMinUniformBufferOffsetAlignment);
|
|
95
|
+
installGetter(runtime, prototype, "minStorageBufferOffsetAlignment",
|
|
96
|
+
&GPUSupportedLimits::getMinStorageBufferOffsetAlignment);
|
|
97
|
+
installGetter(runtime, prototype, "maxVertexBuffers",
|
|
98
|
+
&GPUSupportedLimits::getMaxVertexBuffers);
|
|
99
|
+
installGetter(runtime, prototype, "maxBufferSize",
|
|
100
|
+
&GPUSupportedLimits::getMaxBufferSize);
|
|
101
|
+
installGetter(runtime, prototype, "maxVertexAttributes",
|
|
102
|
+
&GPUSupportedLimits::getMaxVertexAttributes);
|
|
103
|
+
installGetter(runtime, prototype, "maxVertexBufferArrayStride",
|
|
104
|
+
&GPUSupportedLimits::getMaxVertexBufferArrayStride);
|
|
105
|
+
installGetter(runtime, prototype, "maxInterStageShaderVariables",
|
|
106
|
+
&GPUSupportedLimits::getMaxInterStageShaderVariables);
|
|
107
|
+
installGetter(runtime, prototype, "maxColorAttachments",
|
|
108
|
+
&GPUSupportedLimits::getMaxColorAttachments);
|
|
109
|
+
installGetter(runtime, prototype, "maxColorAttachmentBytesPerSample",
|
|
110
|
+
&GPUSupportedLimits::getMaxColorAttachmentBytesPerSample);
|
|
111
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupStorageSize",
|
|
112
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupStorageSize);
|
|
113
|
+
installGetter(runtime, prototype, "maxComputeInvocationsPerWorkgroup",
|
|
114
|
+
&GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup);
|
|
115
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeX",
|
|
116
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeX);
|
|
117
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeY",
|
|
118
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeY);
|
|
119
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupSizeZ",
|
|
120
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupSizeZ);
|
|
121
|
+
installGetter(runtime, prototype, "maxComputeWorkgroupsPerDimension",
|
|
122
|
+
&GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension);
|
|
143
123
|
}
|
|
144
124
|
|
|
145
125
|
inline const wgpu::Limits 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 "webgpu/webgpu_cpp.h"
|
|
12
12
|
|
|
@@ -15,15 +15,17 @@
|
|
|
15
15
|
|
|
16
16
|
namespace rnwgpu {
|
|
17
17
|
|
|
18
|
-
namespace
|
|
18
|
+
namespace jsi = facebook::jsi;
|
|
19
19
|
|
|
20
|
-
class GPUTexture : public
|
|
20
|
+
class GPUTexture : public NativeObject<GPUTexture> {
|
|
21
21
|
public:
|
|
22
|
+
static constexpr const char *CLASS_NAME = "GPUTexture";
|
|
23
|
+
|
|
22
24
|
explicit GPUTexture(wgpu::Texture instance, std::string label)
|
|
23
|
-
:
|
|
25
|
+
: NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
|
|
24
26
|
|
|
25
27
|
public:
|
|
26
|
-
std::string getBrand() { return
|
|
28
|
+
std::string getBrand() { return CLASS_NAME; }
|
|
27
29
|
|
|
28
30
|
std::shared_ptr<GPUTextureView> createView(
|
|
29
31
|
std::optional<std::shared_ptr<GPUTextureViewDescriptor>> descriptor);
|
|
@@ -44,21 +46,23 @@ public:
|
|
|
44
46
|
_instance.SetLabel(_label.c_str());
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
void
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
50
|
+
installGetter(runtime, prototype, "__brand", &GPUTexture::getBrand);
|
|
51
|
+
installMethod(runtime, prototype, "createView", &GPUTexture::createView);
|
|
52
|
+
installMethod(runtime, prototype, "destroy", &GPUTexture::destroy);
|
|
53
|
+
installGetter(runtime, prototype, "width", &GPUTexture::getWidth);
|
|
54
|
+
installGetter(runtime, prototype, "height", &GPUTexture::getHeight);
|
|
55
|
+
installGetter(runtime, prototype, "depthOrArrayLayers",
|
|
56
|
+
&GPUTexture::getDepthOrArrayLayers);
|
|
57
|
+
installGetter(runtime, prototype, "mipLevelCount",
|
|
58
|
+
&GPUTexture::getMipLevelCount);
|
|
59
|
+
installGetter(runtime, prototype, "sampleCount",
|
|
60
|
+
&GPUTexture::getSampleCount);
|
|
61
|
+
installGetter(runtime, prototype, "dimension", &GPUTexture::getDimension);
|
|
62
|
+
installGetter(runtime, prototype, "format", &GPUTexture::getFormat);
|
|
63
|
+
installGetter(runtime, prototype, "usage", &GPUTexture::getUsage);
|
|
64
|
+
installGetterSetter(runtime, prototype, "label", &GPUTexture::getLabel,
|
|
65
|
+
&GPUTexture::setLabel);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
inline const wgpu::Texture 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 GPUTextureView : public
|
|
15
|
+
class GPUTextureView : public NativeObject<GPUTextureView> {
|
|
16
16
|
public:
|
|
17
|
+
static constexpr const char *CLASS_NAME = "GPUTextureView";
|
|
18
|
+
|
|
17
19
|
explicit GPUTextureView(wgpu::TextureView 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", &GPUTextureView::setLabel, this);
|
|
31
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
32
|
+
installGetter(runtime, prototype, "__brand", &GPUTextureView::getBrand);
|
|
33
|
+
installGetterSetter(runtime, prototype, "label", &GPUTextureView::getLabel,
|
|
34
|
+
&GPUTextureView::setLabel);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
inline const wgpu::TextureView get() { return _instance; }
|