react-native-wgpu 0.1.0 → 0.1.2

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 (269) hide show
  1. package/README.md +221 -13
  2. package/android/CMakeLists.txt +15 -1
  3. package/android/build.gradle +0 -18
  4. package/android/cpp/AndroidPlatformContext.h +26 -0
  5. package/android/cpp/cpp-adapter.cpp +66 -3
  6. package/android/src/main/java/com/webgpu/WebGPUModule.java +64 -22
  7. package/android/src/main/java/com/webgpu/WebGPUView.java +63 -8
  8. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +5 -6
  9. package/android/src/newarch/{WgpuViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +5 -5
  10. package/android/src/oldarch/com/webgpu/NativeWebGPUModuleSpec.java +23 -0
  11. package/android/src/oldarch/{WebGPUViewManagerSpec.java → com/webgpu/WebGPUViewManagerSpec.java} +1 -1
  12. package/cpp/{Logger.h → WGPULogger.h} +13 -6
  13. package/cpp/dawn/webgpu.h +9 -0
  14. package/cpp/dawn/webgpu_cpp.h +95 -43
  15. package/cpp/dawn/webgpu_cpp_print.h +6 -0
  16. package/cpp/dawn/wire/client/webgpu_cpp.h +80 -43
  17. package/cpp/jsi/RNFHybridObject.cpp +1 -1
  18. package/cpp/jsi/RNFHybridObject.h +4 -4
  19. package/cpp/jsi/RNFJSIConverter.h +204 -17
  20. package/cpp/rnwgpu/ArrayBuffer.h +72 -0
  21. package/cpp/rnwgpu/PlatformContext.h +16 -0
  22. package/cpp/rnwgpu/RNWebGPUManager.cpp +14 -9
  23. package/cpp/rnwgpu/RNWebGPUManager.h +12 -1
  24. package/cpp/rnwgpu/SurfaceRegistry.h +36 -0
  25. package/cpp/rnwgpu/api/AsyncRunner.h +30 -0
  26. package/cpp/rnwgpu/api/Canvas.h +55 -0
  27. package/cpp/rnwgpu/api/Convertors.h +765 -0
  28. package/cpp/rnwgpu/api/External.h +12 -0
  29. package/cpp/rnwgpu/api/GPU.cpp +100 -23
  30. package/cpp/rnwgpu/api/GPU.h +24 -6
  31. package/cpp/rnwgpu/api/GPUAdapter.cpp +122 -8
  32. package/cpp/rnwgpu/api/GPUAdapter.h +24 -5
  33. package/cpp/rnwgpu/api/GPUAdapterInfo.h +19 -7
  34. package/cpp/rnwgpu/api/GPUBindGroup.cpp +3 -0
  35. package/cpp/rnwgpu/api/GPUBindGroup.h +11 -4
  36. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +11 -4
  37. package/cpp/rnwgpu/api/GPUBuffer.cpp +82 -7
  38. package/cpp/rnwgpu/api/GPUBuffer.h +43 -7
  39. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +63 -0
  40. package/cpp/rnwgpu/api/GPUCanvasContext.h +51 -8
  41. package/cpp/rnwgpu/api/GPUCommandBuffer.h +11 -4
  42. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +177 -0
  43. package/cpp/rnwgpu/api/GPUCommandEncoder.h +75 -3
  44. package/cpp/rnwgpu/api/GPUCompilationInfo.h +65 -8
  45. package/cpp/rnwgpu/api/GPUCompilationMessage.h +6 -4
  46. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +58 -0
  47. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +49 -3
  48. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +11 -0
  49. package/cpp/rnwgpu/api/GPUComputePipeline.h +18 -3
  50. package/cpp/rnwgpu/api/GPUDevice.cpp +330 -3
  51. package/cpp/rnwgpu/api/GPUDevice.h +119 -5
  52. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +6 -0
  53. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +14 -7
  54. package/cpp/rnwgpu/api/GPUError.h +42 -0
  55. package/cpp/rnwgpu/api/GPUExtent3D.h +69 -0
  56. package/cpp/rnwgpu/api/GPUExternalTexture.h +11 -4
  57. package/cpp/rnwgpu/api/GPUFeatures.h +221 -0
  58. package/cpp/rnwgpu/api/GPUOrigin2D.h +59 -0
  59. package/cpp/rnwgpu/api/GPUOrigin3D.h +66 -0
  60. package/cpp/rnwgpu/api/GPUPipelineLayout.h +11 -4
  61. package/cpp/rnwgpu/api/GPUQuerySet.cpp +11 -0
  62. package/cpp/rnwgpu/api/GPUQuerySet.h +19 -5
  63. package/cpp/rnwgpu/api/GPUQueue.cpp +110 -0
  64. package/cpp/rnwgpu/api/GPUQueue.h +45 -4
  65. package/cpp/rnwgpu/api/GPURenderBundle.h +11 -4
  66. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +128 -0
  67. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +72 -3
  68. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +161 -0
  69. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +93 -3
  70. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +13 -0
  71. package/cpp/rnwgpu/api/GPURenderPipeline.h +18 -3
  72. package/cpp/rnwgpu/api/GPUSampler.h +11 -4
  73. package/cpp/rnwgpu/api/GPUShaderModule.cpp +39 -0
  74. package/cpp/rnwgpu/api/GPUShaderModule.h +23 -4
  75. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +133 -0
  76. package/cpp/rnwgpu/api/GPUSupportedLimits.h +128 -4
  77. package/cpp/rnwgpu/api/GPUTexture.cpp +47 -0
  78. package/cpp/rnwgpu/api/GPUTexture.h +38 -4
  79. package/cpp/rnwgpu/api/GPUTextureView.h +11 -4
  80. package/cpp/rnwgpu/api/ImageData.h +50 -0
  81. package/cpp/rnwgpu/api/Navigator.h +46 -0
  82. package/cpp/rnwgpu/api/WebGPUCanvasContextFactory.h +59 -0
  83. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +31 -43
  84. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +40 -31
  85. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +24 -32
  86. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +56 -49
  87. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +27 -20
  88. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +23 -31
  89. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +25 -36
  90. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +25 -25
  91. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +26 -46
  92. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +31 -53
  93. package/cpp/rnwgpu/api/descriptors/GPUColor.h +72 -0
  94. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +27 -33
  95. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +51 -0
  96. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +51 -0
  97. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +24 -25
  98. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +25 -42
  99. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +32 -42
  100. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +58 -76
  101. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +38 -30
  102. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +11 -11
  103. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +43 -34
  104. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +39 -46
  105. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +29 -45
  106. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +25 -34
  107. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +32 -36
  108. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +42 -44
  109. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +24 -34
  110. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +24 -32
  111. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +25 -35
  112. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +35 -26
  113. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +29 -35
  114. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +23 -43
  115. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +49 -0
  116. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +51 -0
  117. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +41 -57
  118. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +42 -61
  119. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +54 -66
  120. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +52 -55
  121. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +25 -42
  122. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +60 -56
  123. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +21 -20
  124. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +17 -14
  125. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +63 -63
  126. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +28 -27
  127. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +28 -49
  128. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +32 -23
  129. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +27 -29
  130. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +27 -20
  131. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +49 -76
  132. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +48 -64
  133. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +29 -31
  134. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +23 -44
  135. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +30 -36
  136. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +39 -38
  137. package/cpp/rnwgpu/api/descriptors/Unions.h +57 -2
  138. package/ios/IOSPlatformContext.h +16 -0
  139. package/ios/IOSPlatformContext.mm +18 -0
  140. package/ios/MetalView.h +10 -0
  141. package/ios/MetalView.mm +27 -0
  142. package/ios/SurfaceUtils.h +13 -0
  143. package/ios/SurfaceUtils.mm +24 -0
  144. package/ios/WebGPUModule.h +8 -7
  145. package/ios/WebGPUModule.mm +47 -14
  146. package/ios/WebGPUView.h +6 -3
  147. package/ios/WebGPUView.mm +36 -24
  148. package/ios/WebGPUViewComponentDescriptor.h +61 -0
  149. package/ios/WebGPUViewManager.mm +6 -4
  150. package/lib/commonjs/Canvas.js +49 -0
  151. package/lib/commonjs/Canvas.js.map +1 -0
  152. package/lib/commonjs/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
  153. package/lib/commonjs/{WebGPUNativeModule.js.map → NativeWebGPUModule.js.map} +1 -1
  154. package/lib/commonjs/WebGPUView.js +2 -0
  155. package/lib/commonjs/WebGPUView.js.map +1 -0
  156. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -1
  157. package/lib/commonjs/index.js +158 -19
  158. package/lib/commonjs/index.js.map +1 -1
  159. package/lib/module/Canvas.js +42 -0
  160. package/lib/module/Canvas.js.map +1 -0
  161. package/lib/module/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
  162. package/lib/module/NativeWebGPUModule.js.map +1 -0
  163. package/lib/module/WebGPUView.js +2 -0
  164. package/lib/module/WebGPUView.js.map +1 -0
  165. package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
  166. package/lib/module/index.js +144 -6
  167. package/lib/module/index.js.map +1 -1
  168. package/lib/typescript/example/src/Triangle/triangle.d.ts +3 -0
  169. package/lib/typescript/example/src/Triangle/triangle.d.ts.map +1 -0
  170. package/lib/typescript/example/src/Wireframe/Shaders.d.ts +3 -0
  171. package/lib/typescript/example/src/Wireframe/Shaders.d.ts.map +1 -0
  172. package/lib/typescript/example/src/Wireframe/models.d.ts +29 -0
  173. package/lib/typescript/example/src/Wireframe/models.d.ts.map +1 -0
  174. package/lib/typescript/example/src/components/DrawingContext.d.ts +13 -0
  175. package/lib/typescript/example/src/components/DrawingContext.d.ts.map +1 -0
  176. package/lib/typescript/example/src/components/cube.d.ts +7 -0
  177. package/lib/typescript/example/src/components/cube.d.ts.map +1 -0
  178. package/lib/typescript/example/src/components/meshes/sphere.d.ts +12 -0
  179. package/lib/typescript/example/src/components/meshes/sphere.d.ts.map +1 -0
  180. package/lib/typescript/example/src/components/meshes/teapot.d.ts +6 -0
  181. package/lib/typescript/example/src/components/meshes/teapot.d.ts.map +1 -0
  182. package/lib/typescript/example/src/components/meshes/utils.d.ts +10 -0
  183. package/lib/typescript/example/src/components/meshes/utils.d.ts.map +1 -0
  184. package/lib/typescript/jest.config.d.ts +4 -0
  185. package/lib/typescript/lib/commonjs/Canvas.d.ts +4 -0
  186. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
  187. package/lib/typescript/lib/commonjs/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  188. package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
  189. package/lib/typescript/lib/commonjs/WebGPUView.d.ts +1 -0
  190. package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +1 -0
  191. package/lib/typescript/lib/commonjs/index.d.ts +0 -2
  192. package/lib/typescript/lib/module/Canvas.d.ts +2 -0
  193. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
  194. package/lib/typescript/lib/module/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  195. package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
  196. package/lib/typescript/lib/module/WebGPUView.d.ts +1 -0
  197. package/lib/typescript/lib/module/WebGPUView.d.ts.map +1 -0
  198. package/lib/typescript/lib/module/index.d.ts +2 -3
  199. package/lib/typescript/src/Canvas.d.ts +22 -0
  200. package/lib/typescript/src/Canvas.d.ts.map +1 -0
  201. package/lib/typescript/src/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +2 -1
  202. package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
  203. package/lib/typescript/src/WebGPUView.d.ts +1 -0
  204. package/lib/typescript/src/WebGPUView.d.ts.map +1 -0
  205. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -1
  206. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  207. package/lib/typescript/src/index.d.ts +2 -7
  208. package/lib/typescript/src/index.d.ts.map +1 -1
  209. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  210. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  211. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  212. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  213. package/libs/dawn.json +4597 -0
  214. package/libs/ios/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  215. package/libs/ios/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  216. package/libs/ios/libwebgpu_dawn.a +0 -0
  217. package/libs/ios/libwebgpu_dawn.xcframework/Info.plist +44 -0
  218. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  219. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  220. package/libs/ios/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  221. package/package.json +25 -8
  222. package/{react-native-webgpu.podspec → react-native-wgpu.podspec} +6 -9
  223. package/src/Canvas.tsx +68 -0
  224. package/src/{WebGPUNativeModule.ts → NativeWebGPUModule.ts} +1 -0
  225. package/src/WebGPUView.tsx +0 -0
  226. package/src/WebGPUViewNativeComponent.ts +2 -1
  227. package/src/index.tsx +172 -8
  228. package/android/src/main/AndroidManifestNew.xml +0 -2
  229. package/cpp/rnwgpu/MutableBuffer.h +0 -48
  230. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -33
  231. package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +0 -81
  232. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +0 -76
  233. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +0 -91
  234. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +0 -61
  235. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +0 -75
  236. package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +0 -71
  237. package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +0 -54
  238. package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +0 -83
  239. package/ios/RNFAppleLogger.mm +0 -22
  240. package/ios/Utils.h +0 -5
  241. package/ios/Utils.m +0 -26
  242. package/lib/module/WebGPUNativeModule.js.map +0 -1
  243. package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +0 -1
  244. package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +0 -1
  245. package/lib/typescript/scripts/build/copy-artifacts.d.ts +0 -2
  246. package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +0 -1
  247. package/lib/typescript/scripts/build/dawn.d.ts +0 -2
  248. package/lib/typescript/scripts/build/dawn.d.ts.map +0 -1
  249. package/lib/typescript/scripts/build/util.d.ts +0 -13
  250. package/lib/typescript/scripts/build/util.d.ts.map +0 -1
  251. package/lib/typescript/scripts/codegen/codegen.d.ts +0 -2
  252. package/lib/typescript/scripts/codegen/codegen.d.ts.map +0 -1
  253. package/lib/typescript/scripts/codegen/model/dawn.d.ts +0 -2
  254. package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +0 -1
  255. package/lib/typescript/scripts/codegen/model/model.d.ts +0 -8
  256. package/lib/typescript/scripts/codegen/model/model.d.ts.map +0 -1
  257. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +0 -4
  258. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +0 -1
  259. package/lib/typescript/scripts/codegen/templates/Enum.d.ts +0 -3
  260. package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +0 -1
  261. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +0 -3
  262. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +0 -1
  263. package/lib/typescript/scripts/codegen/templates/Unions.d.ts +0 -6
  264. package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +0 -1
  265. package/lib/typescript/scripts/codegen/templates/common.d.ts +0 -9
  266. package/lib/typescript/scripts/codegen/templates/common.d.ts.map +0 -1
  267. package/lib/typescript/scripts/codegen/util.d.ts +0 -2
  268. package/lib/typescript/scripts/codegen/util.d.ts.map +0 -1
  269. package/lib/typescript/src/WebGPUNativeModule.d.ts.map +0 -1
@@ -1,28 +1,37 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
- #include <string>
5
4
 
6
5
  #include "webgpu/webgpu_cpp.h"
7
6
 
8
- #include "Logger.h"
9
7
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
8
+ #include "WGPULogger.h"
9
+
10
+ #include "External.h"
11
+ #include "GPUOrigin3D.h"
12
+ #include "GPUTexture.h"
13
+ #include "RNFHybridObject.h"
11
14
 
12
15
  namespace jsi = facebook::jsi;
16
+ namespace m = margelo;
13
17
 
14
18
  namespace rnwgpu {
15
19
 
16
- class GPUImageCopyTextureTagged {
17
- public:
18
- wgpu::ImageCopyTextureTagged *getInstance() { return &_instance; }
19
-
20
- wgpu::ImageCopyTextureTagged _instance;
20
+ struct GPUImageCopyTextureTagged {
21
+ std::optional<PredefinedColorSpace> colorSpace; // PredefinedColorSpace
22
+ std::optional<bool> premultipliedAlpha; // boolean
23
+ std::shared_ptr<GPUTexture> texture; // GPUTexture
24
+ std::optional<double> mipLevel; // GPUIntegerCoordinate
25
+ std::optional<std::shared_ptr<GPUOrigin3D>> origin; // GPUOrigin3D
26
+ std::optional<wgpu::TextureAspect> aspect; // GPUTextureAspect
21
27
  };
28
+
22
29
  } // namespace rnwgpu
23
30
 
24
31
  namespace margelo {
25
32
 
33
+ using namespace rnwgpu; // NOLINT(build/namespaces)
34
+
26
35
  template <>
27
36
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged>> {
28
37
  static std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged>
@@ -31,58 +40,47 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged>> {
31
40
  if (!outOfBounds && arg.isObject()) {
32
41
  auto value = arg.getObject(runtime);
33
42
  if (value.hasProperty(runtime, "colorSpace")) {
34
- auto colorSpace = value.getProperty(runtime, "colorSpace");
43
+ auto prop = value.getProperty(runtime, "colorSpace");
44
+ result->colorSpace =
45
+ JSIConverter<std::optional<PredefinedColorSpace>>::fromJSI(
46
+ runtime, prop, false);
35
47
  }
36
48
  if (value.hasProperty(runtime, "premultipliedAlpha")) {
37
- auto premultipliedAlpha =
38
- value.getProperty(runtime, "premultipliedAlpha");
49
+ auto prop = value.getProperty(runtime, "premultipliedAlpha");
50
+ result->premultipliedAlpha =
51
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
39
52
  }
40
53
  if (value.hasProperty(runtime, "texture")) {
41
- auto texture = value.getProperty(runtime, "texture");
42
-
43
- if (texture.isUndefined()) {
44
- throw std::runtime_error(
45
- "Property GPUImageCopyTextureTagged::texture is required");
46
- }
47
- } else {
48
- throw std::runtime_error(
49
- "Property GPUImageCopyTextureTagged::texture is not defined");
54
+ auto prop = value.getProperty(runtime, "texture");
55
+ result->texture = JSIConverter<std::shared_ptr<GPUTexture>>::fromJSI(
56
+ runtime, prop, false);
50
57
  }
51
58
  if (value.hasProperty(runtime, "mipLevel")) {
52
- auto mipLevel = value.getProperty(runtime, "mipLevel");
53
-
54
- if (mipLevel.isNumber()) {
55
- result->_instance.mipLevel =
56
- static_cast<wgpu::IntegerCoordinate>(mipLevel.getNumber());
57
- }
59
+ auto prop = value.getProperty(runtime, "mipLevel");
60
+ result->mipLevel =
61
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
58
62
  }
59
63
  if (value.hasProperty(runtime, "origin")) {
60
- auto origin = value.getProperty(runtime, "origin");
64
+ auto prop = value.getProperty(runtime, "origin");
65
+ result->origin =
66
+ JSIConverter<std::optional<std::shared_ptr<GPUOrigin3D>>>::fromJSI(
67
+ runtime, prop, false);
61
68
  }
62
69
  if (value.hasProperty(runtime, "aspect")) {
63
- auto aspect = value.getProperty(runtime, "aspect");
70
+ auto prop = value.getProperty(runtime, "aspect");
71
+ result->aspect =
72
+ JSIConverter<std::optional<wgpu::TextureAspect>>::fromJSI(
73
+ runtime, prop, false);
64
74
  }
65
75
  }
66
- rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::colorSpace = %f",
67
- result->_instance.colorSpace);
68
- rnwgpu::Logger::logToConsole(
69
- "GPUImageCopyTextureTagged::premultipliedAlpha = %f",
70
- result->_instance.premultipliedAlpha);
71
- rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::texture = %f",
72
- result->_instance.texture);
73
- rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::mipLevel = %f",
74
- result->_instance.mipLevel);
75
- rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::origin = %f",
76
- result->_instance.origin);
77
- rnwgpu::Logger::logToConsole("GPUImageCopyTextureTagged::aspect = %f",
78
- result->_instance.aspect);
76
+
79
77
  return result;
80
78
  }
81
79
  static jsi::Value
82
80
  toJSI(jsi::Runtime &runtime,
83
81
  std::shared_ptr<rnwgpu::GPUImageCopyTextureTagged> arg) {
84
- // No conversions here
85
- return jsi::Value::null();
82
+ throw std::runtime_error("Invalid GPUImageCopyTextureTagged::toJSI()");
86
83
  }
87
84
  };
88
- } // namespace margelo
85
+
86
+ } // namespace margelo
@@ -1,28 +1,31 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
- #include <string>
5
4
 
6
5
  #include "webgpu/webgpu_cpp.h"
7
6
 
8
- #include "Logger.h"
9
7
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
8
+ #include "WGPULogger.h"
9
+
10
+ #include "RNFHybridObject.h"
11
11
 
12
12
  namespace jsi = facebook::jsi;
13
+ namespace m = margelo;
13
14
 
14
15
  namespace rnwgpu {
15
16
 
16
- class GPUImageDataLayout {
17
- public:
18
- wgpu::ImageDataLayout *getInstance() { return &_instance; }
19
-
20
- wgpu::ImageDataLayout _instance;
17
+ struct GPUImageDataLayout {
18
+ std::optional<double> offset; // GPUSize64
19
+ std::optional<double> bytesPerRow; // GPUSize32
20
+ std::optional<double> rowsPerImage; // GPUSize32
21
21
  };
22
+
22
23
  } // namespace rnwgpu
23
24
 
24
25
  namespace margelo {
25
26
 
27
+ using namespace rnwgpu; // NOLINT(build/namespaces)
28
+
26
29
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageDataLayout>> {
27
30
  static std::shared_ptr<rnwgpu::GPUImageDataLayout>
28
31
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,41 +33,28 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageDataLayout>> {
30
33
  if (!outOfBounds && arg.isObject()) {
31
34
  auto value = arg.getObject(runtime);
32
35
  if (value.hasProperty(runtime, "offset")) {
33
- auto offset = value.getProperty(runtime, "offset");
34
-
35
- if (offset.isNumber()) {
36
- result->_instance.offset = offset.getNumber();
37
- }
36
+ auto prop = value.getProperty(runtime, "offset");
37
+ result->offset =
38
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
38
39
  }
39
40
  if (value.hasProperty(runtime, "bytesPerRow")) {
40
- auto bytesPerRow = value.getProperty(runtime, "bytesPerRow");
41
-
42
- if (bytesPerRow.isNumber()) {
43
- result->_instance.bytesPerRow =
44
- static_cast<wgpu::Size32>(bytesPerRow.getNumber());
45
- }
41
+ auto prop = value.getProperty(runtime, "bytesPerRow");
42
+ result->bytesPerRow =
43
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
46
44
  }
47
45
  if (value.hasProperty(runtime, "rowsPerImage")) {
48
- auto rowsPerImage = value.getProperty(runtime, "rowsPerImage");
49
-
50
- if (rowsPerImage.isNumber()) {
51
- result->_instance.rowsPerImage =
52
- static_cast<wgpu::Size32>(rowsPerImage.getNumber());
53
- }
46
+ auto prop = value.getProperty(runtime, "rowsPerImage");
47
+ result->rowsPerImage =
48
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
54
49
  }
55
50
  }
56
- rnwgpu::Logger::logToConsole("GPUImageDataLayout::offset = %f",
57
- result->_instance.offset);
58
- rnwgpu::Logger::logToConsole("GPUImageDataLayout::bytesPerRow = %f",
59
- result->_instance.bytesPerRow);
60
- rnwgpu::Logger::logToConsole("GPUImageDataLayout::rowsPerImage = %f",
61
- result->_instance.rowsPerImage);
51
+
62
52
  return result;
63
53
  }
64
54
  static jsi::Value toJSI(jsi::Runtime &runtime,
65
55
  std::shared_ptr<rnwgpu::GPUImageDataLayout> arg) {
66
- // No conversions here
67
- return jsi::Value::null();
56
+ throw std::runtime_error("Invalid GPUImageDataLayout::toJSI()");
68
57
  }
69
58
  };
70
- } // namespace margelo
59
+
60
+ } // namespace margelo
@@ -1,28 +1,31 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
- #include <string>
5
4
 
6
5
  #include "webgpu/webgpu_cpp.h"
7
6
 
8
- #include "Logger.h"
9
7
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
8
+ #include "WGPULogger.h"
9
+
10
+ #include "RNFHybridObject.h"
11
11
 
12
12
  namespace jsi = facebook::jsi;
13
+ namespace m = margelo;
13
14
 
14
15
  namespace rnwgpu {
15
16
 
16
- class GPUMultisampleState {
17
- public:
18
- wgpu::MultisampleState *getInstance() { return &_instance; }
19
-
20
- wgpu::MultisampleState _instance;
17
+ struct GPUMultisampleState {
18
+ std::optional<double> count; // GPUSize32
19
+ std::optional<double> mask; // GPUSampleMask
20
+ std::optional<bool> alphaToCoverageEnabled; // boolean
21
21
  };
22
+
22
23
  } // namespace rnwgpu
23
24
 
24
25
  namespace margelo {
25
26
 
27
+ using namespace rnwgpu; // NOLINT(build/namespaces)
28
+
26
29
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUMultisampleState>> {
27
30
  static std::shared_ptr<rnwgpu::GPUMultisampleState>
28
31
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,39 +33,28 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUMultisampleState>> {
30
33
  if (!outOfBounds && arg.isObject()) {
31
34
  auto value = arg.getObject(runtime);
32
35
  if (value.hasProperty(runtime, "count")) {
33
- auto count = value.getProperty(runtime, "count");
34
-
35
- if (count.isNumber()) {
36
- result->_instance.count =
37
- static_cast<wgpu::Size32>(count.getNumber());
38
- }
36
+ auto prop = value.getProperty(runtime, "count");
37
+ result->count =
38
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
39
39
  }
40
40
  if (value.hasProperty(runtime, "mask")) {
41
- auto mask = value.getProperty(runtime, "mask");
42
-
43
- if (mask.isNumber()) {
44
- result->_instance.mask =
45
- static_cast<wgpu::SampleMask>(mask.getNumber());
46
- }
41
+ auto prop = value.getProperty(runtime, "mask");
42
+ result->mask =
43
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
47
44
  }
48
45
  if (value.hasProperty(runtime, "alphaToCoverageEnabled")) {
49
- auto alphaToCoverageEnabled =
50
- value.getProperty(runtime, "alphaToCoverageEnabled");
46
+ auto prop = value.getProperty(runtime, "alphaToCoverageEnabled");
47
+ result->alphaToCoverageEnabled =
48
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
51
49
  }
52
50
  }
53
- rnwgpu::Logger::logToConsole("GPUMultisampleState::count = %f",
54
- result->_instance.count);
55
- rnwgpu::Logger::logToConsole("GPUMultisampleState::mask = %f",
56
- result->_instance.mask);
57
- rnwgpu::Logger::logToConsole(
58
- "GPUMultisampleState::alphaToCoverageEnabled = %f",
59
- result->_instance.alphaToCoverageEnabled);
51
+
60
52
  return result;
61
53
  }
62
54
  static jsi::Value toJSI(jsi::Runtime &runtime,
63
55
  std::shared_ptr<rnwgpu::GPUMultisampleState> arg) {
64
- // No conversions here
65
- return jsi::Value::null();
56
+ throw std::runtime_error("Invalid GPUMultisampleState::toJSI()");
66
57
  }
67
58
  };
68
- } // namespace margelo
59
+
60
+ } // namespace margelo
@@ -2,29 +2,33 @@
2
2
 
3
3
  #include <memory>
4
4
  #include <string>
5
+ #include <vector>
5
6
 
6
7
  #include "webgpu/webgpu_cpp.h"
7
8
 
8
- #include "Logger.h"
9
9
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
10
+ #include "WGPULogger.h"
11
+
12
+ #include "GPUBindGroupLayout.h"
13
+ #include "RNFHybridObject.h"
11
14
 
12
15
  namespace jsi = facebook::jsi;
16
+ namespace m = margelo;
13
17
 
14
18
  namespace rnwgpu {
15
19
 
16
- class GPUPipelineLayoutDescriptor {
17
- public:
18
- wgpu::PipelineLayoutDescriptor *getInstance() { return &_instance; }
19
-
20
- wgpu::PipelineLayoutDescriptor _instance;
21
-
22
- std::string label;
20
+ struct GPUPipelineLayoutDescriptor {
21
+ std::vector<std::shared_ptr<GPUBindGroupLayout>>
22
+ bindGroupLayouts; // Iterable<GPUBindGroupLayout>
23
+ std::optional<std::string> label; // string
23
24
  };
25
+
24
26
  } // namespace rnwgpu
25
27
 
26
28
  namespace margelo {
27
29
 
30
+ using namespace rnwgpu; // NOLINT(build/namespaces)
31
+
28
32
  template <>
29
33
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUPipelineLayoutDescriptor>> {
30
34
  static std::shared_ptr<rnwgpu::GPUPipelineLayoutDescriptor>
@@ -33,40 +37,26 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUPipelineLayoutDescriptor>> {
33
37
  if (!outOfBounds && arg.isObject()) {
34
38
  auto value = arg.getObject(runtime);
35
39
  if (value.hasProperty(runtime, "bindGroupLayouts")) {
36
- auto bindGroupLayouts = value.getProperty(runtime, "bindGroupLayouts");
37
-
38
- if (bindGroupLayouts.isUndefined()) {
39
- throw std::runtime_error(
40
- "Property GPUPipelineLayoutDescriptor::bindGroupLayouts is "
41
- "required");
42
- }
43
- } else {
44
- throw std::runtime_error(
45
- "Property GPUPipelineLayoutDescriptor::bindGroupLayouts is not "
46
- "defined");
40
+ auto prop = value.getProperty(runtime, "bindGroupLayouts");
41
+ result->bindGroupLayouts = JSIConverter<
42
+ std::vector<std::shared_ptr<GPUBindGroupLayout>>>::fromJSI(runtime,
43
+ prop,
44
+ false);
47
45
  }
48
46
  if (value.hasProperty(runtime, "label")) {
49
- auto label = value.getProperty(runtime, "label");
50
-
51
- if (label.isString()) {
52
- auto str = label.asString(runtime).utf8(runtime);
53
- result->label = str;
54
- result->_instance.label = result->label.c_str();
55
- }
47
+ auto prop = value.getProperty(runtime, "label");
48
+ result->label = JSIConverter<std::optional<std::string>>::fromJSI(
49
+ runtime, prop, false);
56
50
  }
57
51
  }
58
- rnwgpu::Logger::logToConsole(
59
- "GPUPipelineLayoutDescriptor::bindGroupLayouts = %f",
60
- result->_instance.bindGroupLayouts);
61
- rnwgpu::Logger::logToConsole("GPUPipelineLayoutDescriptor::label = %f",
62
- result->_instance.label);
52
+
63
53
  return result;
64
54
  }
65
55
  static jsi::Value
66
56
  toJSI(jsi::Runtime &runtime,
67
57
  std::shared_ptr<rnwgpu::GPUPipelineLayoutDescriptor> arg) {
68
- // No conversions here
69
- return jsi::Value::null();
58
+ throw std::runtime_error("Invalid GPUPipelineLayoutDescriptor::toJSI()");
70
59
  }
71
60
  };
72
- } // namespace margelo
61
+
62
+ } // namespace margelo
@@ -1,28 +1,33 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
- #include <string>
5
4
 
6
5
  #include "webgpu/webgpu_cpp.h"
7
6
 
8
- #include "Logger.h"
9
7
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
8
+ #include "WGPULogger.h"
9
+
10
+ #include "RNFHybridObject.h"
11
11
 
12
12
  namespace jsi = facebook::jsi;
13
+ namespace m = margelo;
13
14
 
14
15
  namespace rnwgpu {
15
16
 
16
- class GPUPrimitiveState {
17
- public:
18
- wgpu::PrimitiveState *getInstance() { return &_instance; }
19
-
20
- wgpu::PrimitiveState _instance;
17
+ struct GPUPrimitiveState {
18
+ std::optional<wgpu::PrimitiveTopology> topology; // GPUPrimitiveTopology
19
+ std::optional<wgpu::IndexFormat> stripIndexFormat; // GPUIndexFormat
20
+ std::optional<wgpu::FrontFace> frontFace; // GPUFrontFace
21
+ std::optional<wgpu::CullMode> cullMode; // GPUCullMode
22
+ std::optional<bool> unclippedDepth; // boolean
21
23
  };
24
+
22
25
  } // namespace rnwgpu
23
26
 
24
27
  namespace margelo {
25
28
 
29
+ using namespace rnwgpu; // NOLINT(build/namespaces)
30
+
26
31
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUPrimitiveState>> {
27
32
  static std::shared_ptr<rnwgpu::GPUPrimitiveState>
28
33
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,37 +35,41 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUPrimitiveState>> {
30
35
  if (!outOfBounds && arg.isObject()) {
31
36
  auto value = arg.getObject(runtime);
32
37
  if (value.hasProperty(runtime, "topology")) {
33
- auto topology = value.getProperty(runtime, "topology");
38
+ auto prop = value.getProperty(runtime, "topology");
39
+ result->topology =
40
+ JSIConverter<std::optional<wgpu::PrimitiveTopology>>::fromJSI(
41
+ runtime, prop, false);
34
42
  }
35
43
  if (value.hasProperty(runtime, "stripIndexFormat")) {
36
- auto stripIndexFormat = value.getProperty(runtime, "stripIndexFormat");
44
+ auto prop = value.getProperty(runtime, "stripIndexFormat");
45
+ result->stripIndexFormat =
46
+ JSIConverter<std::optional<wgpu::IndexFormat>>::fromJSI(
47
+ runtime, prop, false);
37
48
  }
38
49
  if (value.hasProperty(runtime, "frontFace")) {
39
- auto frontFace = value.getProperty(runtime, "frontFace");
50
+ auto prop = value.getProperty(runtime, "frontFace");
51
+ result->frontFace =
52
+ JSIConverter<std::optional<wgpu::FrontFace>>::fromJSI(runtime, prop,
53
+ false);
40
54
  }
41
55
  if (value.hasProperty(runtime, "cullMode")) {
42
- auto cullMode = value.getProperty(runtime, "cullMode");
56
+ auto prop = value.getProperty(runtime, "cullMode");
57
+ result->cullMode = JSIConverter<std::optional<wgpu::CullMode>>::fromJSI(
58
+ runtime, prop, false);
43
59
  }
44
60
  if (value.hasProperty(runtime, "unclippedDepth")) {
45
- auto unclippedDepth = value.getProperty(runtime, "unclippedDepth");
61
+ auto prop = value.getProperty(runtime, "unclippedDepth");
62
+ result->unclippedDepth =
63
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
46
64
  }
47
65
  }
48
- rnwgpu::Logger::logToConsole("GPUPrimitiveState::topology = %f",
49
- result->_instance.topology);
50
- rnwgpu::Logger::logToConsole("GPUPrimitiveState::stripIndexFormat = %f",
51
- result->_instance.stripIndexFormat);
52
- rnwgpu::Logger::logToConsole("GPUPrimitiveState::frontFace = %f",
53
- result->_instance.frontFace);
54
- rnwgpu::Logger::logToConsole("GPUPrimitiveState::cullMode = %f",
55
- result->_instance.cullMode);
56
- rnwgpu::Logger::logToConsole("GPUPrimitiveState::unclippedDepth = %f",
57
- result->_instance.unclippedDepth);
66
+
58
67
  return result;
59
68
  }
60
69
  static jsi::Value toJSI(jsi::Runtime &runtime,
61
70
  std::shared_ptr<rnwgpu::GPUPrimitiveState> arg) {
62
- // No conversions here
63
- return jsi::Value::null();
71
+ throw std::runtime_error("Invalid GPUPrimitiveState::toJSI()");
64
72
  }
65
73
  };
66
- } // namespace margelo
74
+
75
+ } // namespace margelo
@@ -1,30 +1,35 @@
1
1
  #pragma once
2
2
 
3
+ #include <map>
3
4
  #include <memory>
4
5
  #include <string>
5
6
 
6
7
  #include "webgpu/webgpu_cpp.h"
7
8
 
8
- #include "Logger.h"
9
9
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
10
+ #include "WGPULogger.h"
11
+
12
+ #include "GPUShaderModule.h"
13
+ #include "RNFHybridObject.h"
11
14
 
12
15
  namespace jsi = facebook::jsi;
16
+ namespace m = margelo;
13
17
 
14
18
  namespace rnwgpu {
15
19
 
16
- class GPUProgrammableStage {
17
- public:
18
- wgpu::ProgrammableStage *getInstance() { return &_instance; }
19
-
20
- wgpu::ProgrammableStage _instance;
21
-
22
- std::string entryPoint;
20
+ struct GPUProgrammableStage {
21
+ std::shared_ptr<GPUShaderModule> module; // GPUShaderModule
22
+ std::optional<std::string> entryPoint; // string
23
+ std::optional<std::map<std::string, double>>
24
+ constants; // Record< string, GPUPipelineConstantValue >
23
25
  };
26
+
24
27
  } // namespace rnwgpu
25
28
 
26
29
  namespace margelo {
27
30
 
31
+ using namespace rnwgpu; // NOLINT(build/namespaces)
32
+
28
33
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUProgrammableStage>> {
29
34
  static std::shared_ptr<rnwgpu::GPUProgrammableStage>
30
35
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -32,41 +37,30 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUProgrammableStage>> {
32
37
  if (!outOfBounds && arg.isObject()) {
33
38
  auto value = arg.getObject(runtime);
34
39
  if (value.hasProperty(runtime, "module")) {
35
- auto module = value.getProperty(runtime, "module");
36
-
37
- if (module.isUndefined()) {
38
- throw std::runtime_error(
39
- "Property GPUProgrammableStage::module is required");
40
- }
41
- } else {
42
- throw std::runtime_error(
43
- "Property GPUProgrammableStage::module is not defined");
40
+ auto prop = value.getProperty(runtime, "module");
41
+ result->module =
42
+ JSIConverter<std::shared_ptr<GPUShaderModule>>::fromJSI(
43
+ runtime, prop, false);
44
44
  }
45
45
  if (value.hasProperty(runtime, "entryPoint")) {
46
- auto entryPoint = value.getProperty(runtime, "entryPoint");
47
-
48
- if (entryPoint.isString()) {
49
- auto str = entryPoint.asString(runtime).utf8(runtime);
50
- result->entryPoint = str;
51
- result->_instance.entryPoint = result->entryPoint.c_str();
52
- }
46
+ auto prop = value.getProperty(runtime, "entryPoint");
47
+ result->entryPoint = JSIConverter<std::optional<std::string>>::fromJSI(
48
+ runtime, prop, false);
53
49
  }
54
50
  if (value.hasProperty(runtime, "constants")) {
55
- auto constants = value.getProperty(runtime, "constants");
51
+ auto prop = value.getProperty(runtime, "constants");
52
+ result->constants =
53
+ JSIConverter<std::optional<std::map<std::string, double>>>::fromJSI(
54
+ runtime, prop, false);
56
55
  }
57
56
  }
58
- rnwgpu::Logger::logToConsole("GPUProgrammableStage::module = %f",
59
- result->_instance.module);
60
- rnwgpu::Logger::logToConsole("GPUProgrammableStage::entryPoint = %f",
61
- result->_instance.entryPoint);
62
- rnwgpu::Logger::logToConsole("GPUProgrammableStage::constants = %f",
63
- result->_instance.constants);
57
+
64
58
  return result;
65
59
  }
66
60
  static jsi::Value toJSI(jsi::Runtime &runtime,
67
61
  std::shared_ptr<rnwgpu::GPUProgrammableStage> arg) {
68
- // No conversions here
69
- return jsi::Value::null();
62
+ throw std::runtime_error("Invalid GPUProgrammableStage::toJSI()");
70
63
  }
71
64
  };
72
- } // namespace margelo
65
+
66
+ } // namespace margelo