react-native-wgpu 0.4.2 → 0.5.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.
Files changed (186) hide show
  1. package/README.md +31 -0
  2. package/android/CMakeLists.txt +3 -3
  3. package/cpp/jsi/{RNFEnumMapper.h → EnumMapper.h} +2 -6
  4. package/cpp/jsi/{RNFJSIConverter.h → JSIConverter.h} +27 -110
  5. package/cpp/jsi/NativeObject.h +607 -0
  6. package/cpp/jsi/{RNFPromise.cpp → Promise.cpp} +3 -6
  7. package/cpp/jsi/{RNFPromise.h → Promise.h} +2 -5
  8. package/cpp/jsi/RuntimeAwareCache.cpp +7 -0
  9. package/cpp/jsi/RuntimeAwareCache.h +100 -0
  10. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +72 -0
  11. package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
  12. package/cpp/rnwgpu/ArrayBuffer.h +8 -12
  13. package/cpp/rnwgpu/RNWebGPUManager.cpp +187 -28
  14. package/cpp/rnwgpu/RNWebGPUManager.h +7 -0
  15. package/cpp/rnwgpu/api/Canvas.h +14 -12
  16. package/cpp/rnwgpu/api/GPU.cpp +4 -6
  17. package/cpp/rnwgpu/api/GPU.h +13 -11
  18. package/cpp/rnwgpu/api/GPUAdapter.cpp +9 -9
  19. package/cpp/rnwgpu/api/GPUAdapter.h +14 -11
  20. package/cpp/rnwgpu/api/GPUAdapterInfo.h +17 -15
  21. package/cpp/rnwgpu/api/GPUBindGroup.h +11 -10
  22. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +12 -11
  23. package/cpp/rnwgpu/api/GPUBuffer.h +19 -16
  24. package/cpp/rnwgpu/api/GPUCanvasContext.h +17 -13
  25. package/cpp/rnwgpu/api/GPUCommandBuffer.h +12 -10
  26. package/cpp/rnwgpu/api/GPUCommandEncoder.h +35 -32
  27. package/cpp/rnwgpu/api/GPUCompilationInfo.h +19 -19
  28. package/cpp/rnwgpu/api/GPUCompilationMessage.h +10 -7
  29. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +28 -27
  30. package/cpp/rnwgpu/api/GPUComputePipeline.h +14 -13
  31. package/cpp/rnwgpu/api/GPUDevice.cpp +111 -95
  32. package/cpp/rnwgpu/api/GPUDevice.h +51 -43
  33. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +12 -10
  34. package/cpp/rnwgpu/api/GPUError.h +19 -29
  35. package/cpp/rnwgpu/api/GPUExtent3D.h +7 -10
  36. package/cpp/rnwgpu/api/GPUExternalTexture.h +12 -11
  37. package/cpp/rnwgpu/api/GPUInternalError.h +31 -0
  38. package/cpp/rnwgpu/api/GPUOrigin2D.h +6 -10
  39. package/cpp/rnwgpu/api/GPUOrigin3D.h +6 -10
  40. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +33 -0
  41. package/cpp/rnwgpu/api/GPUPipelineLayout.h +12 -10
  42. package/cpp/rnwgpu/api/GPUQuerySet.h +14 -12
  43. package/cpp/rnwgpu/api/GPUQueue.h +18 -17
  44. package/cpp/rnwgpu/api/GPURenderBundle.h +11 -10
  45. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +36 -33
  46. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +49 -47
  47. package/cpp/rnwgpu/api/GPURenderPipeline.h +14 -12
  48. package/cpp/rnwgpu/api/GPUSampler.h +11 -10
  49. package/cpp/rnwgpu/api/GPUShaderModule.cpp +7 -8
  50. package/cpp/rnwgpu/api/GPUShaderModule.h +13 -12
  51. package/cpp/rnwgpu/api/GPUSupportedLimits.h +73 -93
  52. package/cpp/rnwgpu/api/GPUTexture.h +24 -20
  53. package/cpp/rnwgpu/api/GPUTextureView.h +11 -10
  54. package/cpp/rnwgpu/api/GPUValidationError.h +32 -0
  55. package/cpp/rnwgpu/api/ImageBitmap.h +10 -6
  56. package/cpp/rnwgpu/api/RNWebGPU.h +21 -21
  57. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +3 -7
  58. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +7 -11
  59. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +3 -7
  60. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +3 -7
  61. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +3 -8
  62. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +3 -7
  63. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +3 -7
  64. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +3 -8
  65. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +3 -8
  66. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +28 -32
  67. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +3 -7
  68. package/cpp/rnwgpu/api/descriptors/GPUColor.h +3 -8
  69. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +3 -7
  70. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +18 -20
  71. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +3 -8
  72. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +3 -8
  73. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +3 -7
  74. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +3 -7
  75. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +3 -7
  76. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +3 -7
  77. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +3 -7
  78. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +3 -8
  79. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +3 -7
  80. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +3 -7
  81. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +3 -7
  82. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +3 -7
  83. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +3 -7
  84. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +3 -7
  85. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +3 -8
  86. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +11 -14
  87. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +3 -8
  88. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +3 -7
  89. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +3 -8
  90. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +3 -7
  91. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +3 -8
  92. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +3 -8
  93. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +3 -8
  94. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +3 -8
  95. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +3 -7
  96. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +3 -7
  97. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +3 -7
  98. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +3 -7
  99. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +3 -7
  100. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +3 -8
  101. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +3 -8
  102. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +3 -8
  103. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +3 -7
  104. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +3 -7
  105. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +14 -16
  106. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +3 -8
  107. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +3 -8
  108. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +3 -8
  109. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +3 -7
  110. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +18 -29
  111. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +3 -8
  112. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +3 -7
  113. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +3 -8
  114. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +3 -7
  115. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +3 -7
  116. package/cpp/rnwgpu/api/descriptors/Unions.h +3 -3
  117. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +10 -10
  118. package/cpp/rnwgpu/async/AsyncTaskHandle.h +2 -2
  119. package/lib/commonjs/external/ModuleProxy.js +36 -0
  120. package/lib/commonjs/external/ModuleProxy.js.map +1 -0
  121. package/lib/commonjs/external/index.js +17 -0
  122. package/lib/commonjs/external/index.js.map +1 -0
  123. package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
  124. package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
  125. package/lib/commonjs/external/reanimated/index.js +21 -0
  126. package/lib/commonjs/external/reanimated/index.js.map +1 -0
  127. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +50 -0
  128. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  129. package/lib/commonjs/main/index.js +2 -142
  130. package/lib/commonjs/main/index.js.map +1 -1
  131. package/lib/module/external/ModuleProxy.js +28 -0
  132. package/lib/module/external/ModuleProxy.js.map +1 -0
  133. package/lib/module/external/index.js +2 -0
  134. package/lib/module/external/index.js.map +1 -0
  135. package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
  136. package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
  137. package/lib/module/external/reanimated/index.js +3 -0
  138. package/lib/module/external/reanimated/index.js.map +1 -0
  139. package/lib/module/external/reanimated/registerWebGPUForReanimated.js +43 -0
  140. package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  141. package/lib/module/main/index.js +2 -141
  142. package/lib/module/main/index.js.map +1 -1
  143. package/lib/typescript/babel.config.d.ts +1 -0
  144. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
  145. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
  146. package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
  147. package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
  148. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
  149. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  150. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
  151. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
  152. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
  153. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  154. package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
  155. package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
  156. package/lib/typescript/lib/module/external/index.d.ts +2 -0
  157. package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
  158. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
  159. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  160. package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
  161. package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
  162. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
  163. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  164. package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
  165. package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
  166. package/lib/typescript/src/external/index.d.ts +2 -0
  167. package/lib/typescript/src/external/index.d.ts.map +1 -0
  168. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
  169. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  170. package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
  171. package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
  172. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
  173. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  174. package/package.json +16 -3
  175. package/src/external/ModuleProxy.ts +30 -0
  176. package/src/external/index.ts +1 -0
  177. package/src/external/reanimated/ReanimatedProxy.ts +19 -0
  178. package/src/external/reanimated/index.ts +2 -0
  179. package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
  180. package/src/main/index.tsx +3 -170
  181. package/cpp/jsi/RNFHybridObject.cpp +0 -150
  182. package/cpp/jsi/RNFHybridObject.h +0 -181
  183. package/cpp/jsi/RNFJSIHelper.h +0 -51
  184. package/cpp/jsi/RNFPointerHolder.h +0 -95
  185. package/cpp/jsi/RNFRuntimeState.cpp +0 -18
  186. package/cpp/jsi/RNFRuntimeState.h +0 -106
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include <memory>
4
4
 
5
- #include "RNFJSIConverter.h"
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
- } // namespace rnwgpu
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<rnwgpu::GPUExtent3D>();
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<rnwgpu::GPUExtent3D> arg) {
60
+ std::shared_ptr<GPUExtent3D> arg) {
65
61
  // No conversions here
66
62
  return jsi::Value::null();
67
63
  }
68
64
  };
69
- } // namespace margelo
65
+
66
+ } // namespace rnwgpu
@@ -4,22 +4,23 @@
4
4
 
5
5
  #include "Unions.h"
6
6
 
7
- #include "RNFHybridObject.h"
7
+ #include "NativeObject.h"
8
8
 
9
9
  #include "webgpu/webgpu_cpp.h"
10
10
 
11
11
  namespace rnwgpu {
12
12
 
13
- namespace m = margelo;
13
+ namespace jsi = facebook::jsi;
14
14
 
15
- class GPUExternalTexture : public m::HybridObject {
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
- : HybridObject("GPUExternalTexture"), _instance(instance), _label(label) {
19
- }
20
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
20
21
 
21
22
  public:
22
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
31
- registerHybridGetter("__brand", &GPUExternalTexture::getBrand, this);
32
-
33
- registerHybridGetter("label", &GPUExternalTexture::getLabel, this);
34
- registerHybridSetter("label", &GPUExternalTexture::setLabel, this);
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 "RNFJSIConverter.h"
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
- } // namespace rnwgpu
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<rnwgpu::GPUOrigin2D>();
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<rnwgpu::GPUOrigin2D> arg) {
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 margelo
55
+ } // namespace rnwgpu
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include <memory>
4
4
 
5
- #include "RNFJSIConverter.h"
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
- } // namespace rnwgpu
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<rnwgpu::GPUOrigin3D>();
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<rnwgpu::GPUOrigin3D> arg) {
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 margelo
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 "RNFHybridObject.h"
7
+ #include "NativeObject.h"
8
8
 
9
9
  #include "webgpu/webgpu_cpp.h"
10
10
 
11
11
  namespace rnwgpu {
12
12
 
13
- namespace m = margelo;
13
+ namespace jsi = facebook::jsi;
14
14
 
15
- class GPUPipelineLayout : public m::HybridObject {
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
- : HybridObject("GPUPipelineLayout"), _instance(instance), _label(label) {}
20
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
19
21
 
20
22
  public:
21
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
30
- registerHybridGetter("__brand", &GPUPipelineLayout::getBrand, this);
31
-
32
- registerHybridGetter("label", &GPUPipelineLayout::getLabel, this);
33
- registerHybridSetter("label", &GPUPipelineLayout::setLabel, this);
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 "RNFHybridObject.h"
7
+ #include "NativeObject.h"
8
8
 
9
9
  #include "webgpu/webgpu_cpp.h"
10
10
 
11
11
  namespace rnwgpu {
12
12
 
13
- namespace m = margelo;
13
+ namespace jsi = facebook::jsi;
14
14
 
15
- class GPUQuerySet : public m::HybridObject {
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
- : HybridObject("GPUQuerySet"), _instance(instance), _label(label) {}
20
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
19
21
 
20
22
  public:
21
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
35
- registerHybridGetter("__brand", &GPUQuerySet::getBrand, this);
36
- registerHybridMethod("destroy", &GPUQuerySet::destroy, this);
37
- registerHybridGetter("type", &GPUQuerySet::getType, this);
38
- registerHybridGetter("count", &GPUQuerySet::getCount, this);
39
- registerHybridGetter("label", &GPUQuerySet::getLabel, this);
40
- registerHybridSetter("label", &GPUQuerySet::setLabel, this);
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 "RNFHybridObject.h"
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 m = margelo;
24
+ namespace jsi = facebook::jsi;
25
25
 
26
- class GPUQueue : public m::HybridObject {
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
- : HybridObject("GPUQueue"), _instance(instance), _async(async),
33
+ : NativeObject(CLASS_NAME), _instance(instance), _async(async),
32
34
  _label(label) {}
33
35
 
34
36
  public:
35
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
59
- registerHybridGetter("__brand", &GPUQueue::getBrand, this);
60
- registerHybridMethod("submit", &GPUQueue::submit, this);
61
- registerHybridMethod("onSubmittedWorkDone", &GPUQueue::onSubmittedWorkDone,
62
- this);
63
- registerHybridMethod("writeBuffer", &GPUQueue::writeBuffer, this);
64
- registerHybridMethod("writeTexture", &GPUQueue::writeTexture, this);
65
- registerHybridMethod("copyExternalImageToTexture",
66
- &GPUQueue::copyExternalImageToTexture, this);
67
-
68
- registerHybridGetter("label", &GPUQueue::getLabel, this);
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 "RNFHybridObject.h"
7
+ #include "NativeObject.h"
8
8
 
9
9
  #include "webgpu/webgpu_cpp.h"
10
10
 
11
11
  namespace rnwgpu {
12
12
 
13
- namespace m = margelo;
13
+ namespace jsi = facebook::jsi;
14
14
 
15
- class GPURenderBundle : public m::HybridObject {
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
- : HybridObject("GPURenderBundle"), _instance(instance), _label(label) {}
20
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
19
21
 
20
22
  public:
21
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
30
- registerHybridGetter("__brand", &GPURenderBundle::getBrand, this);
31
-
32
- registerHybridGetter("label", &GPURenderBundle::getLabel, this);
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 "RNFHybridObject.h"
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 m = margelo;
23
+ namespace jsi = facebook::jsi;
24
24
 
25
- class GPURenderBundleEncoder : public m::HybridObject {
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
- : HybridObject("GPURenderBundleEncoder"), _instance(instance),
30
- _label(label) {}
31
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
31
32
 
32
33
  public:
33
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
72
- registerHybridGetter("__brand", &GPURenderBundleEncoder::getBrand, this);
73
- registerHybridMethod("finish", &GPURenderBundleEncoder::finish, this);
74
- registerHybridMethod("pushDebugGroup",
75
- &GPURenderBundleEncoder::pushDebugGroup, this);
76
- registerHybridMethod("popDebugGroup",
77
- &GPURenderBundleEncoder::popDebugGroup, this);
78
- registerHybridMethod("insertDebugMarker",
79
- &GPURenderBundleEncoder::insertDebugMarker, this);
80
- registerHybridMethod("setBindGroup", &GPURenderBundleEncoder::setBindGroup,
81
- this);
82
- registerHybridMethod("setPipeline", &GPURenderBundleEncoder::setPipeline,
83
- this);
84
- registerHybridMethod("setIndexBuffer",
85
- &GPURenderBundleEncoder::setIndexBuffer, this);
86
- registerHybridMethod("setVertexBuffer",
87
- &GPURenderBundleEncoder::setVertexBuffer, this);
88
- registerHybridMethod("draw", &GPURenderBundleEncoder::draw, this);
89
- registerHybridMethod("drawIndexed", &GPURenderBundleEncoder::drawIndexed,
90
- this);
91
- registerHybridMethod("drawIndirect", &GPURenderBundleEncoder::drawIndirect,
92
- this);
93
- registerHybridMethod("drawIndexedIndirect",
94
- &GPURenderBundleEncoder::drawIndexedIndirect, this);
95
-
96
- registerHybridGetter("label", &GPURenderBundleEncoder::getLabel, this);
97
- registerHybridSetter("label", &GPURenderBundleEncoder::setLabel, this);
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; }