react-native-wgpu 0.4.1 → 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 (197) hide show
  1. package/README.md +59 -14
  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/Canvas.js +9 -14
  120. package/lib/commonjs/Canvas.js.map +1 -1
  121. package/lib/commonjs/external/ModuleProxy.js +36 -0
  122. package/lib/commonjs/external/ModuleProxy.js.map +1 -0
  123. package/lib/commonjs/external/index.js +17 -0
  124. package/lib/commonjs/external/index.js.map +1 -0
  125. package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
  126. package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
  127. package/lib/commonjs/external/reanimated/index.js +21 -0
  128. package/lib/commonjs/external/reanimated/index.js.map +1 -0
  129. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js +50 -0
  130. package/lib/commonjs/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  131. package/lib/commonjs/main/index.js +2 -142
  132. package/lib/commonjs/main/index.js.map +1 -1
  133. package/lib/module/Canvas.js +10 -16
  134. package/lib/module/Canvas.js.map +1 -1
  135. package/lib/module/external/ModuleProxy.js +28 -0
  136. package/lib/module/external/ModuleProxy.js.map +1 -0
  137. package/lib/module/external/index.js +2 -0
  138. package/lib/module/external/index.js.map +1 -0
  139. package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
  140. package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
  141. package/lib/module/external/reanimated/index.js +3 -0
  142. package/lib/module/external/reanimated/index.js.map +1 -0
  143. package/lib/module/external/reanimated/registerWebGPUForReanimated.js +43 -0
  144. package/lib/module/external/reanimated/registerWebGPUForReanimated.js.map +1 -0
  145. package/lib/module/main/index.js +2 -141
  146. package/lib/module/main/index.js.map +1 -1
  147. package/lib/typescript/babel.config.d.ts +1 -0
  148. package/lib/typescript/lib/commonjs/Canvas.d.ts +5 -1
  149. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
  150. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts +12 -0
  151. package/lib/typescript/lib/commonjs/external/ModuleProxy.d.ts.map +1 -0
  152. package/lib/typescript/lib/commonjs/external/index.d.ts +2 -0
  153. package/lib/typescript/lib/commonjs/external/index.d.ts.map +1 -0
  154. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +6 -0
  155. package/lib/typescript/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  156. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts +4 -0
  157. package/lib/typescript/lib/commonjs/external/reanimated/index.d.ts.map +1 -0
  158. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts +9 -0
  159. package/lib/typescript/lib/commonjs/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  160. package/lib/typescript/lib/module/Canvas.d.ts +6 -1
  161. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  162. package/lib/typescript/lib/module/external/ModuleProxy.d.ts +7 -0
  163. package/lib/typescript/lib/module/external/ModuleProxy.d.ts.map +1 -0
  164. package/lib/typescript/lib/module/external/index.d.ts +2 -0
  165. package/lib/typescript/lib/module/external/index.d.ts.map +1 -0
  166. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts +5 -0
  167. package/lib/typescript/lib/module/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  168. package/lib/typescript/lib/module/external/reanimated/index.d.ts +3 -0
  169. package/lib/typescript/lib/module/external/reanimated/index.d.ts.map +1 -0
  170. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts +2 -0
  171. package/lib/typescript/lib/module/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  172. package/lib/typescript/src/Canvas.d.ts +4 -2
  173. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  174. package/lib/typescript/src/external/ModuleProxy.d.ts +11 -0
  175. package/lib/typescript/src/external/ModuleProxy.d.ts.map +1 -0
  176. package/lib/typescript/src/external/index.d.ts +2 -0
  177. package/lib/typescript/src/external/index.d.ts.map +1 -0
  178. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +4 -0
  179. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts.map +1 -0
  180. package/lib/typescript/src/external/reanimated/index.d.ts +3 -0
  181. package/lib/typescript/src/external/reanimated/index.d.ts.map +1 -0
  182. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts +8 -0
  183. package/lib/typescript/src/external/reanimated/registerWebGPUForReanimated.d.ts.map +1 -0
  184. package/package.json +15 -2
  185. package/src/Canvas.tsx +16 -22
  186. package/src/external/ModuleProxy.ts +30 -0
  187. package/src/external/index.ts +1 -0
  188. package/src/external/reanimated/ReanimatedProxy.ts +19 -0
  189. package/src/external/reanimated/index.ts +2 -0
  190. package/src/external/reanimated/registerWebGPUForReanimated.ts +43 -0
  191. package/src/main/index.tsx +3 -170
  192. package/cpp/jsi/RNFHybridObject.cpp +0 -150
  193. package/cpp/jsi/RNFHybridObject.h +0 -181
  194. package/cpp/jsi/RNFJSIHelper.h +0 -51
  195. package/cpp/jsi/RNFPointerHolder.h +0 -95
  196. package/cpp/jsi/RNFRuntimeState.cpp +0 -18
  197. package/cpp/jsi/RNFRuntimeState.h +0 -106
@@ -0,0 +1,32 @@
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 GPUValidationError : public NativeObject<GPUValidationError> {
12
+ public:
13
+ static constexpr const char *CLASS_NAME = "GPUValidationError";
14
+
15
+ explicit GPUValidationError(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", &GPUValidationError::getBrand);
24
+ installGetter(runtime, prototype, "message",
25
+ &GPUValidationError::getMessage);
26
+ }
27
+
28
+ private:
29
+ std::string _message;
30
+ };
31
+
32
+ } // namespace rnwgpu
@@ -4,15 +4,19 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
+ #include "NativeObject.h"
7
8
  #include "PlatformContext.h"
8
- #include "RNFHybridObject.h"
9
9
 
10
10
  namespace rnwgpu {
11
11
 
12
- class ImageBitmap : public margelo::HybridObject {
12
+ namespace jsi = facebook::jsi;
13
+
14
+ class ImageBitmap : public NativeObject<ImageBitmap> {
13
15
  public:
16
+ static constexpr const char *CLASS_NAME = "ImageBitmap";
17
+
14
18
  explicit ImageBitmap(ImageData &imageData)
15
- : HybridObject("ImageBitmap"), _imageData(imageData) {}
19
+ : NativeObject(CLASS_NAME), _imageData(imageData) {}
16
20
 
17
21
  size_t getWidth() { return _imageData.width; }
18
22
 
@@ -22,9 +26,9 @@ public:
22
26
 
23
27
  size_t getSize() { return _imageData.data.size(); }
24
28
 
25
- void loadHybridMethods() override {
26
- registerHybridGetter("width", &ImageBitmap::getWidth, this);
27
- registerHybridGetter("height", &ImageBitmap::getHeight, this);
29
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
30
+ installGetter(runtime, prototype, "width", &ImageBitmap::getWidth);
31
+ installGetter(runtime, prototype, "height", &ImageBitmap::getHeight);
28
32
  }
29
33
 
30
34
  size_t getMemoryPressure() override { return getSize(); }
@@ -3,6 +3,8 @@
3
3
  #include <memory>
4
4
  #include <string>
5
5
 
6
+ #include "NativeObject.h"
7
+
6
8
  #include "Canvas.h"
7
9
  #include "GPU.h"
8
10
  #include "GPUCanvasContext.h"
@@ -11,7 +13,7 @@
11
13
 
12
14
  namespace rnwgpu {
13
15
 
14
- namespace m = margelo;
16
+ namespace jsi = facebook::jsi;
15
17
 
16
18
  struct Blob {
17
19
  std::string blobId;
@@ -21,11 +23,13 @@ struct Blob {
21
23
  std::string name;
22
24
  };
23
25
 
24
- class RNWebGPU : public m::HybridObject {
26
+ class RNWebGPU : public NativeObject<RNWebGPU> {
25
27
  public:
28
+ static constexpr const char *CLASS_NAME = "RNWebGPU";
29
+
26
30
  explicit RNWebGPU(std::shared_ptr<GPU> gpu,
27
31
  std::shared_ptr<PlatformContext> platformContext)
28
- : HybridObject("RNWebGPU"), _gpu(gpu), _platformContext(platformContext) {
32
+ : NativeObject(CLASS_NAME), _gpu(gpu), _platformContext(platformContext) {
29
33
  }
30
34
 
31
35
  std::shared_ptr<GPU> getGPU() { return _gpu; }
@@ -57,14 +61,15 @@ public:
57
61
  nativeInfo.height);
58
62
  }
59
63
 
60
- void loadHybridMethods() override {
61
- registerHybridGetter("fabric", &RNWebGPU::getFabric, this);
62
- registerHybridGetter("gpu", &RNWebGPU::getGPU, this);
63
- registerHybridMethod("createImageBitmap", &RNWebGPU::createImageBitmap,
64
- this);
65
- registerHybridMethod("getNativeSurface", &RNWebGPU::getNativeSurface, this);
66
- registerHybridMethod("MakeWebGPUCanvasContext",
67
- &RNWebGPU::MakeWebGPUCanvasContext, this);
64
+ static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
65
+ installGetter(runtime, prototype, "fabric", &RNWebGPU::getFabric);
66
+ installGetter(runtime, prototype, "gpu", &RNWebGPU::getGPU);
67
+ installMethod(runtime, prototype, "createImageBitmap",
68
+ &RNWebGPU::createImageBitmap);
69
+ installMethod(runtime, prototype, "getNativeSurface",
70
+ &RNWebGPU::getNativeSurface);
71
+ installMethod(runtime, prototype, "MakeWebGPUCanvasContext",
72
+ &RNWebGPU::MakeWebGPUCanvasContext);
68
73
  }
69
74
 
70
75
  private:
@@ -72,15 +77,11 @@ private:
72
77
  std::shared_ptr<PlatformContext> _platformContext;
73
78
  };
74
79
 
75
- } // namespace rnwgpu
76
-
77
- namespace margelo {
78
-
79
- template <> struct JSIConverter<std::shared_ptr<rnwgpu::Blob>> {
80
- static std::shared_ptr<rnwgpu::Blob>
80
+ template <> struct JSIConverter<std::shared_ptr<Blob>> {
81
+ static std::shared_ptr<Blob>
81
82
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
82
83
  if (!outOfBounds && arg.isObject()) {
83
- auto result = std::make_unique<rnwgpu::Blob>();
84
+ auto result = std::make_unique<Blob>();
84
85
  auto val = arg.asObject(runtime);
85
86
  if (val.hasProperty(runtime, "_data")) {
86
87
  auto value = val.getPropertyAsObject(runtime, "_data");
@@ -100,10 +101,9 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::Blob>> {
100
101
  throw std::runtime_error("Invalid Blob::fromJSI()");
101
102
  }
102
103
  }
103
- static jsi::Value toJSI(jsi::Runtime &runtime,
104
- std::shared_ptr<rnwgpu::Blob> arg) {
104
+ static jsi::Value toJSI(jsi::Runtime &runtime, std::shared_ptr<Blob> arg) {
105
105
  throw std::runtime_error("Invalid Blob::toJSI()");
106
106
  }
107
107
  };
108
108
 
109
- } // namespace margelo
109
+ } // namespace rnwgpu
@@ -6,15 +6,13 @@
6
6
 
7
7
  #include "webgpu/webgpu_cpp.h"
8
8
 
9
- #include "RNFJSIConverter.h"
9
+ #include "JSIConverter.h"
10
10
  #include "WGPULogger.h"
11
11
 
12
12
  #include "GPUBindGroupEntry.h"
13
13
  #include "GPUBindGroupLayout.h"
14
- #include "RNFHybridObject.h"
15
14
 
16
15
  namespace jsi = facebook::jsi;
17
- namespace m = margelo;
18
16
 
19
17
  namespace rnwgpu {
20
18
 
@@ -27,9 +25,7 @@ struct GPUBindGroupDescriptor {
27
25
 
28
26
  } // namespace rnwgpu
29
27
 
30
- namespace margelo {
31
-
32
- using namespace rnwgpu; // NOLINT(build/namespaces)
28
+ namespace rnwgpu {
33
29
 
34
30
  template <>
35
31
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
@@ -66,4 +62,4 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
66
62
  }
67
63
  };
68
64
 
69
- } // namespace margelo
65
+ } // namespace rnwgpu
@@ -9,12 +9,10 @@
9
9
  #include "GPUExternalTexture.h"
10
10
  #include "GPUSampler.h"
11
11
  #include "GPUTextureView.h"
12
- #include "RNFHybridObject.h"
13
- #include "RNFJSIConverter.h"
12
+ #include "JSIConverter.h"
14
13
  #include "WGPULogger.h"
15
14
 
16
15
  namespace jsi = facebook::jsi;
17
- namespace m = margelo;
18
16
 
19
17
  namespace rnwgpu {
20
18
 
@@ -28,9 +26,7 @@ struct GPUBindGroupEntry {
28
26
 
29
27
  } // namespace rnwgpu
30
28
 
31
- namespace margelo {
32
-
33
- using namespace rnwgpu; // NOLINT(build/namespaces)
29
+ namespace rnwgpu {
34
30
 
35
31
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
36
32
  static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
@@ -45,11 +41,11 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
45
41
  auto prop = value.getProperty(runtime, "resource");
46
42
  if (prop.isObject()) {
47
43
  auto obj = prop.getObject(runtime);
48
- if (obj.isHostObject<rnwgpu::GPUSampler>(runtime)) {
49
- result->sampler = obj.getHostObject<rnwgpu::GPUSampler>(runtime);
50
- } else if (obj.isHostObject<rnwgpu::GPUTextureView>(runtime)) {
44
+ if (obj.hasNativeState<rnwgpu::GPUSampler>(runtime)) {
45
+ result->sampler = obj.getNativeState<rnwgpu::GPUSampler>(runtime);
46
+ } else if (obj.hasNativeState<rnwgpu::GPUTextureView>(runtime)) {
51
47
  result->textureView =
52
- obj.getHostObject<rnwgpu::GPUTextureView>(runtime);
48
+ obj.getNativeState<rnwgpu::GPUTextureView>(runtime);
53
49
  } else {
54
50
  result->buffer = JSIConverter<
55
51
  std::shared_ptr<rnwgpu::GPUBufferBinding>>::fromJSI(runtime,
@@ -73,4 +69,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
73
69
  }
74
70
  };
75
71
 
76
- } // namespace margelo
72
+ } // namespace rnwgpu
@@ -6,14 +6,12 @@
6
6
 
7
7
  #include "webgpu/webgpu_cpp.h"
8
8
 
9
- #include "RNFJSIConverter.h"
9
+ #include "JSIConverter.h"
10
10
  #include "WGPULogger.h"
11
11
 
12
12
  #include "GPUBindGroupLayoutEntry.h"
13
- #include "RNFHybridObject.h"
14
13
 
15
14
  namespace jsi = facebook::jsi;
16
- namespace m = margelo;
17
15
 
18
16
  namespace rnwgpu {
19
17
 
@@ -25,9 +23,7 @@ struct GPUBindGroupLayoutDescriptor {
25
23
 
26
24
  } // namespace rnwgpu
27
25
 
28
- namespace margelo {
29
-
30
- using namespace rnwgpu; // NOLINT(build/namespaces)
26
+ namespace rnwgpu {
31
27
 
32
28
  template <>
33
29
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>> {
@@ -58,4 +54,4 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>> {
58
54
  }
59
55
  };
60
56
 
61
- } // namespace margelo
57
+ } // namespace rnwgpu
@@ -4,7 +4,7 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
10
  #include "GPUBufferBindingLayout.h"
@@ -12,10 +12,8 @@
12
12
  #include "GPUSamplerBindingLayout.h"
13
13
  #include "GPUStorageTextureBindingLayout.h"
14
14
  #include "GPUTextureBindingLayout.h"
15
- #include "RNFHybridObject.h"
16
15
 
17
16
  namespace jsi = facebook::jsi;
18
- namespace m = margelo;
19
17
 
20
18
  namespace rnwgpu {
21
19
 
@@ -36,9 +34,7 @@ struct GPUBindGroupLayoutEntry {
36
34
 
37
35
  } // namespace rnwgpu
38
36
 
39
- namespace margelo {
40
-
41
- using namespace rnwgpu; // NOLINT(build/namespaces)
37
+ namespace rnwgpu {
42
38
 
43
39
  template <>
44
40
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>> {
@@ -99,4 +95,4 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>> {
99
95
  }
100
96
  };
101
97
 
102
- } // namespace margelo
98
+ } // namespace rnwgpu
@@ -4,13 +4,10 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
- #include "RNFHybridObject.h"
11
-
12
10
  namespace jsi = facebook::jsi;
13
- namespace m = margelo;
14
11
 
15
12
  namespace rnwgpu {
16
13
 
@@ -22,9 +19,7 @@ struct GPUBlendComponent {
22
19
 
23
20
  } // namespace rnwgpu
24
21
 
25
- namespace margelo {
26
-
27
- using namespace rnwgpu; // NOLINT(build/namespaces)
22
+ namespace rnwgpu {
28
23
 
29
24
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendComponent>> {
30
25
  static std::shared_ptr<rnwgpu::GPUBlendComponent>
@@ -60,4 +55,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendComponent>> {
60
55
  }
61
56
  };
62
57
 
63
- } // namespace margelo
58
+ } // namespace rnwgpu
@@ -4,14 +4,12 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
10
  #include "GPUBlendComponent.h"
11
- #include "RNFHybridObject.h"
12
11
 
13
12
  namespace jsi = facebook::jsi;
14
- namespace m = margelo;
15
13
 
16
14
  namespace rnwgpu {
17
15
 
@@ -22,9 +20,7 @@ struct GPUBlendState {
22
20
 
23
21
  } // namespace rnwgpu
24
22
 
25
- namespace margelo {
26
-
27
- using namespace rnwgpu; // NOLINT(build/namespaces)
23
+ namespace rnwgpu {
28
24
 
29
25
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendState>> {
30
26
  static std::shared_ptr<rnwgpu::GPUBlendState>
@@ -54,4 +50,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendState>> {
54
50
  }
55
51
  };
56
52
 
57
- } // namespace margelo
53
+ } // namespace rnwgpu
@@ -4,14 +4,12 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
10
  #include "GPUBuffer.h"
11
- #include "RNFHybridObject.h"
12
11
 
13
12
  namespace jsi = facebook::jsi;
14
- namespace m = margelo;
15
13
 
16
14
  namespace rnwgpu {
17
15
 
@@ -23,9 +21,7 @@ struct GPUBufferBinding {
23
21
 
24
22
  } // namespace rnwgpu
25
23
 
26
- namespace margelo {
27
-
28
- using namespace rnwgpu; // NOLINT(build/namespaces)
24
+ namespace rnwgpu {
29
25
 
30
26
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBinding>> {
31
27
  static std::shared_ptr<rnwgpu::GPUBufferBinding>
@@ -58,4 +54,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBinding>> {
58
54
  }
59
55
  };
60
56
 
61
- } // namespace margelo
57
+ } // namespace rnwgpu
@@ -4,13 +4,10 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
- #include "RNFHybridObject.h"
11
-
12
10
  namespace jsi = facebook::jsi;
13
- namespace m = margelo;
14
11
 
15
12
  namespace rnwgpu {
16
13
 
@@ -22,9 +19,7 @@ struct GPUBufferBindingLayout {
22
19
 
23
20
  } // namespace rnwgpu
24
21
 
25
- namespace margelo {
26
-
27
- using namespace rnwgpu; // NOLINT(build/namespaces)
22
+ namespace rnwgpu {
28
23
 
29
24
  template <>
30
25
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBindingLayout>> {
@@ -59,4 +54,4 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBindingLayout>> {
59
54
  }
60
55
  };
61
56
 
62
- } // namespace margelo
57
+ } // namespace rnwgpu
@@ -5,13 +5,10 @@
5
5
 
6
6
  #include "webgpu/webgpu_cpp.h"
7
7
 
8
- #include "RNFJSIConverter.h"
8
+ #include "JSIConverter.h"
9
9
  #include "WGPULogger.h"
10
10
 
11
- #include "RNFHybridObject.h"
12
-
13
11
  namespace jsi = facebook::jsi;
14
- namespace m = margelo;
15
12
 
16
13
  namespace rnwgpu {
17
14
 
@@ -24,9 +21,7 @@ struct GPUBufferDescriptor {
24
21
 
25
22
  } // namespace rnwgpu
26
23
 
27
- namespace margelo {
28
-
29
- using namespace rnwgpu; // NOLINT(build/namespaces)
24
+ namespace rnwgpu {
30
25
 
31
26
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferDescriptor>> {
32
27
  static std::shared_ptr<rnwgpu::GPUBufferDescriptor>
@@ -62,4 +57,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferDescriptor>> {
62
57
  }
63
58
  };
64
59
 
65
- } // namespace margelo
60
+ } // namespace rnwgpu
@@ -1,43 +1,39 @@
1
1
  #pragma once
2
- #include <string>
3
2
 
4
- #include <RNFHybridObject.h>
3
+ #include <jsi/jsi.h>
5
4
 
6
5
  #include "webgpu/webgpu_cpp.h"
7
6
 
8
7
  namespace rnwgpu {
9
8
 
10
- namespace m = margelo;
9
+ namespace jsi = facebook::jsi;
11
10
 
12
- class GPUBufferUsage : public m::HybridObject {
11
+ class GPUBufferUsage {
13
12
  public:
14
- GPUBufferUsage() : HybridObject("GPUBufferUsage") {}
15
-
16
- public:
17
- double MapRead() { return static_cast<double>(wgpu::BufferUsage::MapRead); }
18
- double MapWrite() { return static_cast<double>(wgpu::BufferUsage::MapWrite); }
19
- double CopySrc() { return static_cast<double>(wgpu::BufferUsage::CopySrc); }
20
- double CopyDst() { return static_cast<double>(wgpu::BufferUsage::CopyDst); }
21
- double Index() { return static_cast<double>(wgpu::BufferUsage::Index); }
22
- double Vertex() { return static_cast<double>(wgpu::BufferUsage::Vertex); }
23
- double Uniform() { return static_cast<double>(wgpu::BufferUsage::Uniform); }
24
- double Storage() { return static_cast<double>(wgpu::BufferUsage::Storage); }
25
- double Indirect() { return static_cast<double>(wgpu::BufferUsage::Indirect); }
26
- double QueryResolve() {
27
- return static_cast<double>(wgpu::BufferUsage::QueryResolve);
28
- }
29
-
30
- void loadHybridMethods() override {
31
- registerHybridGetter("MAP_READ", &GPUBufferUsage::MapRead, this);
32
- registerHybridGetter("MAP_WRITE", &GPUBufferUsage::MapWrite, this);
33
- registerHybridGetter("COPY_SRC", &GPUBufferUsage::CopySrc, this);
34
- registerHybridGetter("COPY_DST", &GPUBufferUsage::CopyDst, this);
35
- registerHybridGetter("INDEX", &GPUBufferUsage::Index, this);
36
- registerHybridGetter("VERTEX", &GPUBufferUsage::Vertex, this);
37
- registerHybridGetter("UNIFORM", &GPUBufferUsage::Uniform, this);
38
- registerHybridGetter("STORAGE", &GPUBufferUsage::Storage, this);
39
- registerHybridGetter("INDIRECT", &GPUBufferUsage::Indirect, this);
40
- registerHybridGetter("QUERY_RESOLVE", &GPUBufferUsage::QueryResolve, this);
13
+ static jsi::Object create(jsi::Runtime &runtime) {
14
+ jsi::Object obj(runtime);
15
+ obj.setProperty(runtime, "MAP_READ",
16
+ static_cast<double>(wgpu::BufferUsage::MapRead));
17
+ obj.setProperty(runtime, "MAP_WRITE",
18
+ static_cast<double>(wgpu::BufferUsage::MapWrite));
19
+ obj.setProperty(runtime, "COPY_SRC",
20
+ static_cast<double>(wgpu::BufferUsage::CopySrc));
21
+ obj.setProperty(runtime, "COPY_DST",
22
+ static_cast<double>(wgpu::BufferUsage::CopyDst));
23
+ obj.setProperty(runtime, "INDEX",
24
+ static_cast<double>(wgpu::BufferUsage::Index));
25
+ obj.setProperty(runtime, "VERTEX",
26
+ static_cast<double>(wgpu::BufferUsage::Vertex));
27
+ obj.setProperty(runtime, "UNIFORM",
28
+ static_cast<double>(wgpu::BufferUsage::Uniform));
29
+ obj.setProperty(runtime, "STORAGE",
30
+ static_cast<double>(wgpu::BufferUsage::Storage));
31
+ obj.setProperty(runtime, "INDIRECT",
32
+ static_cast<double>(wgpu::BufferUsage::Indirect));
33
+ obj.setProperty(runtime, "QUERY_RESOLVE",
34
+ static_cast<double>(wgpu::BufferUsage::QueryResolve));
35
+ return obj;
41
36
  }
42
37
  };
43
- } // namespace rnwgpu
38
+
39
+ } // namespace rnwgpu
@@ -5,13 +5,11 @@
5
5
 
6
6
  #include "webgpu/webgpu_cpp.h"
7
7
 
8
- #include "RNFJSIConverter.h"
8
+ #include "JSIConverter.h"
9
9
 
10
10
  #include "GPUDevice.h"
11
- #include "RNFHybridObject.h"
12
11
 
13
12
  namespace jsi = facebook::jsi;
14
- namespace m = margelo;
15
13
 
16
14
  namespace rnwgpu {
17
15
 
@@ -26,9 +24,7 @@ struct GPUCanvasConfiguration {
26
24
 
27
25
  } // namespace rnwgpu
28
26
 
29
- namespace margelo {
30
-
31
- using namespace rnwgpu; // NOLINT(build/namespaces) // NOLINT(build/namespaces)
27
+ namespace rnwgpu {
32
28
 
33
29
  template <>
34
30
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
@@ -77,4 +73,4 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
77
73
  }
78
74
  };
79
75
 
80
- } // namespace margelo
76
+ } // namespace rnwgpu
@@ -4,13 +4,10 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
- #include "RNFHybridObject.h"
11
-
12
10
  namespace jsi = facebook::jsi;
13
- namespace m = margelo;
14
11
 
15
12
  namespace rnwgpu {
16
13
 
@@ -23,9 +20,7 @@ struct GPUColor {
23
20
 
24
21
  } // namespace rnwgpu
25
22
 
26
- namespace margelo {
27
-
28
- using namespace rnwgpu; // NOLINT(build/namespaces)
23
+ namespace rnwgpu {
29
24
 
30
25
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColor>> {
31
26
  static std::shared_ptr<rnwgpu::GPUColor>
@@ -69,4 +64,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColor>> {
69
64
  }
70
65
  };
71
66
 
72
- } // namespace margelo
67
+ } // namespace rnwgpu
@@ -4,14 +4,12 @@
4
4
 
5
5
  #include "webgpu/webgpu_cpp.h"
6
6
 
7
- #include "RNFJSIConverter.h"
7
+ #include "JSIConverter.h"
8
8
  #include "WGPULogger.h"
9
9
 
10
10
  #include "GPUBlendState.h"
11
- #include "RNFHybridObject.h"
12
11
 
13
12
  namespace jsi = facebook::jsi;
14
- namespace m = margelo;
15
13
 
16
14
  namespace rnwgpu {
17
15
 
@@ -23,9 +21,7 @@ struct GPUColorTargetState {
23
21
 
24
22
  } // namespace rnwgpu
25
23
 
26
- namespace margelo {
27
-
28
- using namespace rnwgpu; // NOLINT(build/namespaces)
24
+ namespace rnwgpu {
29
25
 
30
26
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColorTargetState>> {
31
27
  static std::shared_ptr<rnwgpu::GPUColorTargetState>
@@ -60,4 +56,4 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUColorTargetState>> {
60
56
  }
61
57
  };
62
58
 
63
- } // namespace margelo
59
+ } // namespace rnwgpu