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
@@ -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 GPURenderPassEncoder : public m::HybridObject {
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
- : HybridObject("GPURenderPassEncoder"), _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
  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 loadHybridMethods() override {
79
- registerHybridGetter("__brand", &GPURenderPassEncoder::getBrand, this);
80
- registerHybridMethod("setViewport", &GPURenderPassEncoder::setViewport,
81
- this);
82
- registerHybridMethod("setScissorRect",
83
- &GPURenderPassEncoder::setScissorRect, this);
84
- registerHybridMethod("setBlendConstant",
85
- &GPURenderPassEncoder::setBlendConstant, this);
86
- registerHybridMethod("setStencilReference",
87
- &GPURenderPassEncoder::setStencilReference, this);
88
- registerHybridMethod("beginOcclusionQuery",
89
- &GPURenderPassEncoder::beginOcclusionQuery, this);
90
- registerHybridMethod("endOcclusionQuery",
91
- &GPURenderPassEncoder::endOcclusionQuery, this);
92
- registerHybridMethod("executeBundles",
93
- &GPURenderPassEncoder::executeBundles, this);
94
- registerHybridMethod("end", &GPURenderPassEncoder::end, this);
95
- registerHybridMethod("pushDebugGroup",
96
- &GPURenderPassEncoder::pushDebugGroup, this);
97
- registerHybridMethod("popDebugGroup", &GPURenderPassEncoder::popDebugGroup,
98
- this);
99
- registerHybridMethod("insertDebugMarker",
100
- &GPURenderPassEncoder::insertDebugMarker, this);
101
- registerHybridMethod("setBindGroup", &GPURenderPassEncoder::setBindGroup,
102
- this);
103
- registerHybridMethod("setPipeline", &GPURenderPassEncoder::setPipeline,
104
- this);
105
- registerHybridMethod("setIndexBuffer",
106
- &GPURenderPassEncoder::setIndexBuffer, this);
107
- registerHybridMethod("setVertexBuffer",
108
- &GPURenderPassEncoder::setVertexBuffer, this);
109
- registerHybridMethod("draw", &GPURenderPassEncoder::draw, this);
110
- registerHybridMethod("drawIndexed", &GPURenderPassEncoder::drawIndexed,
111
- this);
112
- registerHybridMethod("drawIndirect", &GPURenderPassEncoder::drawIndirect,
113
- this);
114
- registerHybridMethod("drawIndexedIndirect",
115
- &GPURenderPassEncoder::drawIndexedIndirect, this);
116
-
117
- registerHybridGetter("label", &GPURenderPassEncoder::getLabel, this);
118
- registerHybridSetter("label", &GPURenderPassEncoder::setLabel, this);
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 "RNFHybridObject.h"
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 m = margelo;
16
+ namespace jsi = facebook::jsi;
17
17
 
18
- class GPURenderPipeline : public m::HybridObject {
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
- : HybridObject("GPURenderPipeline"), _instance(instance), _label(label) {}
23
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
22
24
 
23
25
  public:
24
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
35
- registerHybridGetter("__brand", &GPURenderPipeline::getBrand, this);
36
- registerHybridMethod("getBindGroupLayout",
37
- &GPURenderPipeline::getBindGroupLayout, this);
38
-
39
- registerHybridGetter("label", &GPURenderPipeline::getLabel, this);
40
- registerHybridSetter("label", &GPURenderPipeline::setLabel, this);
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 "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 GPUSampler : public m::HybridObject {
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
- : HybridObject("GPUSampler"), _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", &GPUSampler::getBrand, this);
31
-
32
- registerHybridGetter("label", &GPUSampler::getLabel, this);
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 "RNFJSIConverter.h"
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
- GPUCompilationMessage message;
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
- [result = std::move(result)](jsi::Runtime &runtime) mutable {
44
- return margelo::JSIConverter<
45
- std::shared_ptr<GPUCompilationInfo>>::toJSI(runtime,
46
- result);
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 "RNFHybridObject.h"
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 m = margelo;
19
+ namespace jsi = facebook::jsi;
20
20
 
21
- class GPUShaderModule : public m::HybridObject {
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
- : HybridObject("GPUShaderModule"), _instance(instance), _async(async),
28
+ : NativeObject(CLASS_NAME), _instance(instance), _async(async),
27
29
  _label(label) {}
28
30
 
29
31
  public:
30
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
41
- registerHybridGetter("__brand", &GPUShaderModule::getBrand, this);
42
- registerHybridMethod("getCompilationInfo",
43
- &GPUShaderModule::getCompilationInfo, this);
44
-
45
- registerHybridGetter("label", &GPUShaderModule::getLabel, this);
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 "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 GPUSupportedLimits : public m::HybridObject {
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
- : HybridObject("GPUSupportedLimits"), _instance(instance) {}
20
+ : NativeObject(CLASS_NAME), _instance(instance) {}
19
21
 
20
22
  public:
21
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
56
- registerHybridGetter("__brand", &GPUSupportedLimits::getBrand, this);
57
-
58
- registerHybridGetter("maxTextureDimension1D",
59
- &GPUSupportedLimits::getMaxTextureDimension1D, this);
60
- registerHybridGetter("maxTextureDimension2D",
61
- &GPUSupportedLimits::getMaxTextureDimension2D, this);
62
- registerHybridGetter("maxTextureDimension3D",
63
- &GPUSupportedLimits::getMaxTextureDimension3D, this);
64
- registerHybridGetter("maxTextureArrayLayers",
65
- &GPUSupportedLimits::getMaxTextureArrayLayers, this);
66
- registerHybridGetter("maxBindGroups", &GPUSupportedLimits::getMaxBindGroups,
67
- this);
68
- registerHybridGetter("maxBindGroupsPlusVertexBuffers",
69
- &GPUSupportedLimits::getMaxBindGroupsPlusVertexBuffers,
70
- this);
71
- registerHybridGetter("maxBindingsPerBindGroup",
72
- &GPUSupportedLimits::getMaxBindingsPerBindGroup, this);
73
- registerHybridGetter(
74
- "maxDynamicUniformBuffersPerPipelineLayout",
75
- &GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout,
76
- this);
77
- registerHybridGetter(
78
- "maxDynamicStorageBuffersPerPipelineLayout",
79
- &GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout,
80
- this);
81
- registerHybridGetter(
82
- "maxSampledTexturesPerShaderStage",
83
- &GPUSupportedLimits::getMaxSampledTexturesPerShaderStage, this);
84
- registerHybridGetter("maxSamplersPerShaderStage",
85
- &GPUSupportedLimits::getMaxSamplersPerShaderStage,
86
- this);
87
- registerHybridGetter(
88
- "maxStorageBuffersPerShaderStage",
89
- &GPUSupportedLimits::getMaxStorageBuffersPerShaderStage, this);
90
- registerHybridGetter(
91
- "maxStorageTexturesPerShaderStage",
92
- &GPUSupportedLimits::getMaxStorageTexturesPerShaderStage, this);
93
- registerHybridGetter(
94
- "maxUniformBuffersPerShaderStage",
95
- &GPUSupportedLimits::getMaxUniformBuffersPerShaderStage, this);
96
- registerHybridGetter("maxUniformBufferBindingSize",
97
- &GPUSupportedLimits::getMaxUniformBufferBindingSize,
98
- this);
99
- registerHybridGetter("maxStorageBufferBindingSize",
100
- &GPUSupportedLimits::getMaxStorageBufferBindingSize,
101
- this);
102
- registerHybridGetter(
103
- "minUniformBufferOffsetAlignment",
104
- &GPUSupportedLimits::getMinUniformBufferOffsetAlignment, this);
105
- registerHybridGetter(
106
- "minStorageBufferOffsetAlignment",
107
- &GPUSupportedLimits::getMinStorageBufferOffsetAlignment, this);
108
- registerHybridGetter("maxVertexBuffers",
109
- &GPUSupportedLimits::getMaxVertexBuffers, this);
110
- registerHybridGetter("maxBufferSize", &GPUSupportedLimits::getMaxBufferSize,
111
- this);
112
- registerHybridGetter("maxVertexAttributes",
113
- &GPUSupportedLimits::getMaxVertexAttributes, this);
114
- registerHybridGetter("maxVertexBufferArrayStride",
115
- &GPUSupportedLimits::getMaxVertexBufferArrayStride,
116
- this);
117
- registerHybridGetter("maxInterStageShaderVariables",
118
- &GPUSupportedLimits::getMaxInterStageShaderVariables,
119
- this);
120
- registerHybridGetter("maxColorAttachments",
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 "RNFHybridObject.h"
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 m = margelo;
18
+ namespace jsi = facebook::jsi;
19
19
 
20
- class GPUTexture : public m::HybridObject {
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
- : HybridObject("GPUTexture"), _instance(instance), _label(label) {}
25
+ : NativeObject(CLASS_NAME), _instance(instance), _label(label) {}
24
26
 
25
27
  public:
26
- std::string getBrand() { return _name; }
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 loadHybridMethods() override {
48
- registerHybridGetter("__brand", &GPUTexture::getBrand, this);
49
- registerHybridMethod("createView", &GPUTexture::createView, this);
50
- registerHybridMethod("destroy", &GPUTexture::destroy, this);
51
- registerHybridGetter("width", &GPUTexture::getWidth, this);
52
- registerHybridGetter("height", &GPUTexture::getHeight, this);
53
- registerHybridGetter("depthOrArrayLayers",
54
- &GPUTexture::getDepthOrArrayLayers, this);
55
- registerHybridGetter("mipLevelCount", &GPUTexture::getMipLevelCount, this);
56
- registerHybridGetter("sampleCount", &GPUTexture::getSampleCount, this);
57
- registerHybridGetter("dimension", &GPUTexture::getDimension, this);
58
- registerHybridGetter("format", &GPUTexture::getFormat, this);
59
- registerHybridGetter("usage", &GPUTexture::getUsage, this);
60
- registerHybridGetter("label", &GPUTexture::getLabel, this);
61
- registerHybridSetter("label", &GPUTexture::setLabel, this);
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 "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 GPUTextureView : public m::HybridObject {
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
- : HybridObject("GPUTextureView"), _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", &GPUTextureView::getBrand, this);
31
-
32
- registerHybridGetter("label", &GPUTextureView::getLabel, this);
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; }