react-native-wgpu 0.1.0 → 0.1.3

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 (280) 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 +132 -0
  5. package/android/cpp/cpp-adapter.cpp +70 -4
  6. package/android/src/main/java/com/webgpu/WebGPUModule.java +69 -21
  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 +29 -0
  22. package/cpp/rnwgpu/RNWebGPUManager.cpp +13 -11
  23. package/cpp/rnwgpu/RNWebGPUManager.h +9 -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 +81 -23
  30. package/cpp/rnwgpu/api/GPU.h +24 -6
  31. package/cpp/rnwgpu/api/GPUAdapter.cpp +138 -24
  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 +44 -8
  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 +153 -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/ImageBitmap.h +34 -0
  81. package/cpp/rnwgpu/api/RNWebGPU.h +100 -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 +32 -31
  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 +19 -0
  139. package/ios/IOSPlatformContext.mm +68 -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 +47 -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 +183 -19
  158. package/lib/commonjs/index.js.map +1 -1
  159. package/lib/commonjs/utils.js +39 -0
  160. package/lib/commonjs/utils.js.map +1 -0
  161. package/lib/module/Canvas.js +40 -0
  162. package/lib/module/Canvas.js.map +1 -0
  163. package/lib/module/{WebGPUNativeModule.js → NativeWebGPUModule.js} +1 -1
  164. package/lib/module/NativeWebGPUModule.js.map +1 -0
  165. package/lib/module/WebGPUView.js +2 -0
  166. package/lib/module/WebGPUView.js.map +1 -0
  167. package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
  168. package/lib/module/index.js +158 -6
  169. package/lib/module/index.js.map +1 -1
  170. package/lib/module/utils.js +31 -0
  171. package/lib/module/utils.js.map +1 -0
  172. package/lib/typescript/example/src/Triangle/triangle.d.ts +3 -0
  173. package/lib/typescript/example/src/Triangle/triangle.d.ts.map +1 -0
  174. package/lib/typescript/example/src/Wireframe/Shaders.d.ts +3 -0
  175. package/lib/typescript/example/src/Wireframe/Shaders.d.ts.map +1 -0
  176. package/lib/typescript/example/src/Wireframe/models.d.ts +29 -0
  177. package/lib/typescript/example/src/Wireframe/models.d.ts.map +1 -0
  178. package/lib/typescript/example/src/components/DrawingContext.d.ts +13 -0
  179. package/lib/typescript/example/src/components/DrawingContext.d.ts.map +1 -0
  180. package/lib/typescript/example/src/components/cube.d.ts +7 -0
  181. package/lib/typescript/example/src/components/cube.d.ts.map +1 -0
  182. package/lib/typescript/example/src/components/meshes/sphere.d.ts +12 -0
  183. package/lib/typescript/example/src/components/meshes/sphere.d.ts.map +1 -0
  184. package/lib/typescript/example/src/components/meshes/teapot.d.ts +6 -0
  185. package/lib/typescript/example/src/components/meshes/teapot.d.ts.map +1 -0
  186. package/lib/typescript/example/src/components/meshes/utils.d.ts +10 -0
  187. package/lib/typescript/example/src/components/meshes/utils.d.ts.map +1 -0
  188. package/lib/typescript/jest.config.d.ts +4 -0
  189. package/lib/typescript/lib/commonjs/Canvas.d.ts +4 -0
  190. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -0
  191. package/lib/typescript/lib/commonjs/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  192. package/lib/typescript/lib/commonjs/NativeWebGPUModule.d.ts.map +1 -0
  193. package/lib/typescript/lib/commonjs/WebGPUView.d.ts +1 -0
  194. package/lib/typescript/lib/commonjs/WebGPUView.d.ts.map +1 -0
  195. package/lib/typescript/lib/commonjs/index.d.ts +0 -2
  196. package/lib/typescript/lib/commonjs/utils.d.ts +5 -0
  197. package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -0
  198. package/lib/typescript/lib/module/Canvas.d.ts +2 -0
  199. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -0
  200. package/lib/typescript/lib/module/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +1 -1
  201. package/lib/typescript/lib/module/NativeWebGPUModule.d.ts.map +1 -0
  202. package/lib/typescript/lib/module/WebGPUView.d.ts +1 -0
  203. package/lib/typescript/lib/module/WebGPUView.d.ts.map +1 -0
  204. package/lib/typescript/lib/module/index.d.ts +3 -3
  205. package/lib/typescript/lib/module/utils.d.ts +3 -0
  206. package/lib/typescript/lib/module/utils.d.ts.map +1 -0
  207. package/lib/typescript/src/Canvas.d.ts +29 -0
  208. package/lib/typescript/src/Canvas.d.ts.map +1 -0
  209. package/lib/typescript/src/{WebGPUNativeModule.d.ts → NativeWebGPUModule.d.ts} +2 -1
  210. package/lib/typescript/src/NativeWebGPUModule.d.ts.map +1 -0
  211. package/lib/typescript/src/WebGPUView.d.ts +1 -0
  212. package/lib/typescript/src/WebGPUView.d.ts.map +1 -0
  213. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -1
  214. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  215. package/lib/typescript/src/index.d.ts +3 -7
  216. package/lib/typescript/src/index.d.ts.map +1 -1
  217. package/lib/typescript/src/utils.d.ts +7 -0
  218. package/lib/typescript/src/utils.d.ts.map +1 -0
  219. package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
  220. package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
  221. package/libs/android/x86/libwebgpu_dawn.so +0 -0
  222. package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
  223. package/libs/dawn.json +4597 -0
  224. package/libs/ios/arm64_iphoneos/libwebgpu_dawn.a +0 -0
  225. package/libs/ios/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
  226. package/libs/ios/libwebgpu_dawn.a +0 -0
  227. package/libs/ios/libwebgpu_dawn.xcframework/Info.plist +44 -0
  228. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
  229. package/libs/ios/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
  230. package/libs/ios/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
  231. package/package.json +25 -8
  232. package/{react-native-webgpu.podspec → react-native-wgpu.podspec} +6 -9
  233. package/src/Canvas.tsx +73 -0
  234. package/src/{WebGPUNativeModule.ts → NativeWebGPUModule.ts} +1 -0
  235. package/src/WebGPUView.tsx +0 -0
  236. package/src/WebGPUViewNativeComponent.ts +2 -1
  237. package/src/index.tsx +191 -8
  238. package/src/utils.ts +40 -0
  239. package/android/src/main/AndroidManifestNew.xml +0 -2
  240. package/cpp/rnwgpu/MutableBuffer.h +0 -48
  241. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -33
  242. package/cpp/rnwgpu/api/descriptors/GPUColorDict.h +0 -81
  243. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDict.h +0 -76
  244. package/cpp/rnwgpu/api/descriptors/GPUExtent3DDictStrict.h +0 -91
  245. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDict.h +0 -61
  246. package/cpp/rnwgpu/api/descriptors/GPUOrigin2DDictStrict.h +0 -75
  247. package/cpp/rnwgpu/api/descriptors/GPUOrigin3DDict.h +0 -71
  248. package/cpp/rnwgpu/api/descriptors/GPUPipelineErrorInit.h +0 -54
  249. package/cpp/rnwgpu/api/descriptors/GPURenderPassLayout.h +0 -83
  250. package/ios/RNFAppleLogger.mm +0 -22
  251. package/ios/Utils.h +0 -5
  252. package/ios/Utils.m +0 -26
  253. package/lib/module/WebGPUNativeModule.js.map +0 -1
  254. package/lib/typescript/lib/commonjs/WebGPUNativeModule.d.ts.map +0 -1
  255. package/lib/typescript/lib/module/WebGPUNativeModule.d.ts.map +0 -1
  256. package/lib/typescript/scripts/build/copy-artifacts.d.ts +0 -2
  257. package/lib/typescript/scripts/build/copy-artifacts.d.ts.map +0 -1
  258. package/lib/typescript/scripts/build/dawn.d.ts +0 -2
  259. package/lib/typescript/scripts/build/dawn.d.ts.map +0 -1
  260. package/lib/typescript/scripts/build/util.d.ts +0 -13
  261. package/lib/typescript/scripts/build/util.d.ts.map +0 -1
  262. package/lib/typescript/scripts/codegen/codegen.d.ts +0 -2
  263. package/lib/typescript/scripts/codegen/codegen.d.ts.map +0 -1
  264. package/lib/typescript/scripts/codegen/model/dawn.d.ts +0 -2
  265. package/lib/typescript/scripts/codegen/model/dawn.d.ts.map +0 -1
  266. package/lib/typescript/scripts/codegen/model/model.d.ts +0 -8
  267. package/lib/typescript/scripts/codegen/model/model.d.ts.map +0 -1
  268. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts +0 -4
  269. package/lib/typescript/scripts/codegen/templates/Descriptor.d.ts.map +0 -1
  270. package/lib/typescript/scripts/codegen/templates/Enum.d.ts +0 -3
  271. package/lib/typescript/scripts/codegen/templates/Enum.d.ts.map +0 -1
  272. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts +0 -3
  273. package/lib/typescript/scripts/codegen/templates/HybridObject.d.ts.map +0 -1
  274. package/lib/typescript/scripts/codegen/templates/Unions.d.ts +0 -6
  275. package/lib/typescript/scripts/codegen/templates/Unions.d.ts.map +0 -1
  276. package/lib/typescript/scripts/codegen/templates/common.d.ts +0 -9
  277. package/lib/typescript/scripts/codegen/templates/common.d.ts.map +0 -1
  278. package/lib/typescript/scripts/codegen/util.d.ts +0 -2
  279. package/lib/typescript/scripts/codegen/util.d.ts.map +0 -1
  280. 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>
4
+ #include <variant>
5
5
 
6
6
  #include "webgpu/webgpu_cpp.h"
7
7
 
8
- #include "Logger.h"
8
+ #include "GPUBufferBinding.h"
9
+ #include "GPUExternalTexture.h"
10
+ #include "GPUSampler.h"
11
+ #include "GPUTextureView.h"
12
+ #include "RNFHybridObject.h"
9
13
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
14
+ #include "WGPULogger.h"
11
15
 
12
16
  namespace jsi = facebook::jsi;
17
+ namespace m = margelo;
13
18
 
14
19
  namespace rnwgpu {
15
20
 
16
- class GPUBindGroupEntry {
17
- public:
18
- wgpu::BindGroupEntry *getInstance() { return &_instance; }
19
-
20
- wgpu::BindGroupEntry _instance;
21
+ struct GPUBindGroupEntry {
22
+ double binding;
23
+ std::shared_ptr<GPUSampler> sampler = nullptr;
24
+ std::shared_ptr<GPUTextureView> textureView = nullptr;
25
+ std::shared_ptr<GPUBufferBinding> buffer = nullptr;
26
+ // external textures
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 <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
27
36
  static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
28
37
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,38 +39,38 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
30
39
  if (!outOfBounds && arg.isObject()) {
31
40
  auto value = arg.getObject(runtime);
32
41
  if (value.hasProperty(runtime, "binding")) {
33
- auto binding = value.getProperty(runtime, "binding");
34
-
35
- if (binding.isUndefined()) {
36
- throw std::runtime_error(
37
- "Property GPUBindGroupEntry::binding is required");
38
- }
39
- } else {
40
- throw std::runtime_error(
41
- "Property GPUBindGroupEntry::binding is not defined");
42
+ result->binding = value.getProperty(runtime, "binding").asNumber();
42
43
  }
43
44
  if (value.hasProperty(runtime, "resource")) {
44
- auto resource = value.getProperty(runtime, "resource");
45
-
46
- if (resource.isUndefined()) {
47
- throw std::runtime_error(
48
- "Property GPUBindGroupEntry::resource is required");
45
+ auto prop = value.getProperty(runtime, "resource");
46
+ if (prop.isObject()) {
47
+ 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)) {
51
+ result->textureView =
52
+ obj.getHostObject<rnwgpu::GPUTextureView>(runtime);
53
+ } else {
54
+ result->buffer = JSIConverter<
55
+ std::shared_ptr<rnwgpu::GPUBufferBinding>>::fromJSI(runtime,
56
+ prop,
57
+ false);
58
+ }
49
59
  }
50
- } else {
51
- throw std::runtime_error(
52
- "Property GPUBindGroupEntry::resource is not defined");
60
+ // result->resource = JSIConverter<std::variant<
61
+ // std::shared_ptr<GPUSampler>, std::shared_ptr<GPUTextureView>,
62
+ // std::shared_ptr<GPUBufferBinding>,
63
+ // std::shared_ptr<GPUExternalTexture>>>::fromJSI(runtime, prop,
64
+ // false);
53
65
  }
54
66
  }
55
- rnwgpu::Logger::logToConsole("GPUBindGroupEntry::binding = %f",
56
- result->_instance.binding);
57
- rnwgpu::Logger::logToConsole("GPUBindGroupEntry::resource = %f",
58
- result->_instance.resource);
67
+
59
68
  return result;
60
69
  }
61
70
  static jsi::Value toJSI(jsi::Runtime &runtime,
62
71
  std::shared_ptr<rnwgpu::GPUBindGroupEntry> arg) {
63
- // No conversions here
64
- return jsi::Value::null();
72
+ throw std::runtime_error("Invalid GPUBindGroupEntry::toJSI()");
65
73
  }
66
74
  };
75
+
67
76
  } // 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 "GPUBindGroupLayoutEntry.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 GPUBindGroupLayoutDescriptor {
17
- public:
18
- wgpu::BindGroupLayoutDescriptor *getInstance() { return &_instance; }
19
-
20
- wgpu::BindGroupLayoutDescriptor _instance;
21
-
22
- std::string label;
20
+ struct GPUBindGroupLayoutDescriptor {
21
+ std::vector<std::shared_ptr<GPUBindGroupLayoutEntry>>
22
+ entries; // Iterable<GPUBindGroupLayoutEntry>
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::GPUBindGroupLayoutDescriptor>> {
30
34
  static std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>
@@ -33,37 +37,25 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor>> {
33
37
  if (!outOfBounds && arg.isObject()) {
34
38
  auto value = arg.getObject(runtime);
35
39
  if (value.hasProperty(runtime, "entries")) {
36
- auto entries = value.getProperty(runtime, "entries");
37
-
38
- if (entries.isUndefined()) {
39
- throw std::runtime_error(
40
- "Property GPUBindGroupLayoutDescriptor::entries is required");
41
- }
42
- } else {
43
- throw std::runtime_error(
44
- "Property GPUBindGroupLayoutDescriptor::entries is not defined");
40
+ auto prop = value.getProperty(runtime, "entries");
41
+ result->entries = JSIConverter<std::vector<
42
+ std::shared_ptr<GPUBindGroupLayoutEntry>>>::fromJSI(runtime, prop,
43
+ false);
45
44
  }
46
45
  if (value.hasProperty(runtime, "label")) {
47
- auto label = value.getProperty(runtime, "label");
48
-
49
- if (label.isString()) {
50
- auto str = label.asString(runtime).utf8(runtime);
51
- result->label = str;
52
- result->_instance.label = result->label.c_str();
53
- }
46
+ auto prop = value.getProperty(runtime, "label");
47
+ result->label = JSIConverter<std::optional<std::string>>::fromJSI(
48
+ runtime, prop, false);
54
49
  }
55
50
  }
56
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutDescriptor::entries = %f",
57
- result->_instance.entries);
58
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutDescriptor::label = %f",
59
- result->_instance.label);
51
+
60
52
  return result;
61
53
  }
62
54
  static jsi::Value
63
55
  toJSI(jsi::Runtime &runtime,
64
56
  std::shared_ptr<rnwgpu::GPUBindGroupLayoutDescriptor> arg) {
65
- // No conversions here
66
- return jsi::Value::null();
57
+ throw std::runtime_error("Invalid GPUBindGroupLayoutDescriptor::toJSI()");
67
58
  }
68
59
  };
69
- } // namespace margelo
60
+
61
+ } // namespace margelo
@@ -1,28 +1,45 @@
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 "GPUBufferBindingLayout.h"
11
+ #include "GPUExternalTextureBindingLayout.h"
12
+ #include "GPUSamplerBindingLayout.h"
13
+ #include "GPUStorageTextureBindingLayout.h"
14
+ #include "GPUTextureBindingLayout.h"
15
+ #include "RNFHybridObject.h"
11
16
 
12
17
  namespace jsi = facebook::jsi;
18
+ namespace m = margelo;
13
19
 
14
20
  namespace rnwgpu {
15
21
 
16
- class GPUBindGroupLayoutEntry {
17
- public:
18
- wgpu::BindGroupLayoutEntry *getInstance() { return &_instance; }
19
-
20
- wgpu::BindGroupLayoutEntry _instance;
22
+ struct GPUBindGroupLayoutEntry {
23
+ double binding; // GPUIndex32
24
+ double visibility; // GPUShaderStageFlags
25
+ std::optional<std::shared_ptr<GPUBufferBindingLayout>>
26
+ buffer; // GPUBufferBindingLayout
27
+ std::optional<std::shared_ptr<GPUSamplerBindingLayout>>
28
+ sampler; // GPUSamplerBindingLayout
29
+ std::optional<std::shared_ptr<GPUTextureBindingLayout>>
30
+ texture; // GPUTextureBindingLayout
31
+ std::optional<std::shared_ptr<GPUStorageTextureBindingLayout>>
32
+ storageTexture; // GPUStorageTextureBindingLayout
33
+ std::optional<std::shared_ptr<GPUExternalTextureBindingLayout>>
34
+ externalTexture; // GPUExternalTextureBindingLayout
21
35
  };
36
+
22
37
  } // namespace rnwgpu
23
38
 
24
39
  namespace margelo {
25
40
 
41
+ using namespace rnwgpu; // NOLINT(build/namespaces)
42
+
26
43
  template <>
27
44
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>> {
28
45
  static std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>
@@ -31,65 +48,55 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry>> {
31
48
  if (!outOfBounds && arg.isObject()) {
32
49
  auto value = arg.getObject(runtime);
33
50
  if (value.hasProperty(runtime, "binding")) {
34
- auto binding = value.getProperty(runtime, "binding");
35
-
36
- if (binding.isUndefined()) {
37
- throw std::runtime_error(
38
- "Property GPUBindGroupLayoutEntry::binding is required");
39
- }
40
- } else {
41
- throw std::runtime_error(
42
- "Property GPUBindGroupLayoutEntry::binding is not defined");
51
+ auto prop = value.getProperty(runtime, "binding");
52
+ result->binding = JSIConverter<double>::fromJSI(runtime, prop, false);
43
53
  }
44
54
  if (value.hasProperty(runtime, "visibility")) {
45
- auto visibility = value.getProperty(runtime, "visibility");
46
-
47
- if (visibility.isUndefined()) {
48
- throw std::runtime_error(
49
- "Property GPUBindGroupLayoutEntry::visibility is required");
50
- }
51
- } else {
52
- throw std::runtime_error(
53
- "Property GPUBindGroupLayoutEntry::visibility is not defined");
55
+ auto prop = value.getProperty(runtime, "visibility");
56
+ result->visibility =
57
+ JSIConverter<double>::fromJSI(runtime, prop, false);
54
58
  }
55
59
  if (value.hasProperty(runtime, "buffer")) {
56
- auto buffer = value.getProperty(runtime, "buffer");
60
+ auto prop = value.getProperty(runtime, "buffer");
61
+ result->buffer = JSIConverter<std::optional<
62
+ std::shared_ptr<GPUBufferBindingLayout>>>::fromJSI(runtime, prop,
63
+ false);
57
64
  }
58
65
  if (value.hasProperty(runtime, "sampler")) {
59
- auto sampler = value.getProperty(runtime, "sampler");
66
+ auto prop = value.getProperty(runtime, "sampler");
67
+ result->sampler = JSIConverter<std::optional<
68
+ std::shared_ptr<GPUSamplerBindingLayout>>>::fromJSI(runtime, prop,
69
+ false);
60
70
  }
61
71
  if (value.hasProperty(runtime, "texture")) {
62
- auto texture = value.getProperty(runtime, "texture");
72
+ auto prop = value.getProperty(runtime, "texture");
73
+ result->texture = JSIConverter<std::optional<
74
+ std::shared_ptr<GPUTextureBindingLayout>>>::fromJSI(runtime, prop,
75
+ false);
63
76
  }
64
77
  if (value.hasProperty(runtime, "storageTexture")) {
65
- auto storageTexture = value.getProperty(runtime, "storageTexture");
78
+ auto prop = value.getProperty(runtime, "storageTexture");
79
+ result->storageTexture = JSIConverter<std::optional<
80
+ std::shared_ptr<GPUStorageTextureBindingLayout>>>::fromJSI(runtime,
81
+ prop,
82
+ false);
66
83
  }
67
84
  if (value.hasProperty(runtime, "externalTexture")) {
68
- auto externalTexture = value.getProperty(runtime, "externalTexture");
85
+ auto prop = value.getProperty(runtime, "externalTexture");
86
+ result->externalTexture = JSIConverter<std::optional<
87
+ std::shared_ptr<GPUExternalTextureBindingLayout>>>::fromJSI(runtime,
88
+ prop,
89
+ false);
69
90
  }
70
91
  }
71
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::binding = %f",
72
- result->_instance.binding);
73
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::visibility = %f",
74
- result->_instance.visibility);
75
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::buffer = %f",
76
- result->_instance.buffer);
77
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::sampler = %f",
78
- result->_instance.sampler);
79
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::texture = %f",
80
- result->_instance.texture);
81
- rnwgpu::Logger::logToConsole("GPUBindGroupLayoutEntry::storageTexture = %f",
82
- result->_instance.storageTexture);
83
- rnwgpu::Logger::logToConsole(
84
- "GPUBindGroupLayoutEntry::externalTexture = %f",
85
- result->_instance.externalTexture);
92
+
86
93
  return result;
87
94
  }
88
95
  static jsi::Value
89
96
  toJSI(jsi::Runtime &runtime,
90
97
  std::shared_ptr<rnwgpu::GPUBindGroupLayoutEntry> arg) {
91
- // No conversions here
92
- return jsi::Value::null();
98
+ throw std::runtime_error("Invalid GPUBindGroupLayoutEntry::toJSI()");
93
99
  }
94
100
  };
95
- } // namespace margelo
101
+
102
+ } // 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 GPUBlendComponent {
17
- public:
18
- wgpu::BlendComponent *getInstance() { return &_instance; }
19
-
20
- wgpu::BlendComponent _instance;
17
+ struct GPUBlendComponent {
18
+ std::optional<wgpu::BlendOperation> operation; // GPUBlendOperation
19
+ std::optional<wgpu::BlendFactor> srcFactor; // GPUBlendFactor
20
+ std::optional<wgpu::BlendFactor> dstFactor; // GPUBlendFactor
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::GPUBlendComponent>> {
27
30
  static std::shared_ptr<rnwgpu::GPUBlendComponent>
28
31
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,27 +33,31 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendComponent>> {
30
33
  if (!outOfBounds && arg.isObject()) {
31
34
  auto value = arg.getObject(runtime);
32
35
  if (value.hasProperty(runtime, "operation")) {
33
- auto operation = value.getProperty(runtime, "operation");
36
+ auto prop = value.getProperty(runtime, "operation");
37
+ result->operation =
38
+ JSIConverter<std::optional<wgpu::BlendOperation>>::fromJSI(
39
+ runtime, prop, false);
34
40
  }
35
41
  if (value.hasProperty(runtime, "srcFactor")) {
36
- auto srcFactor = value.getProperty(runtime, "srcFactor");
42
+ auto prop = value.getProperty(runtime, "srcFactor");
43
+ result->srcFactor =
44
+ JSIConverter<std::optional<wgpu::BlendFactor>>::fromJSI(
45
+ runtime, prop, false);
37
46
  }
38
47
  if (value.hasProperty(runtime, "dstFactor")) {
39
- auto dstFactor = value.getProperty(runtime, "dstFactor");
48
+ auto prop = value.getProperty(runtime, "dstFactor");
49
+ result->dstFactor =
50
+ JSIConverter<std::optional<wgpu::BlendFactor>>::fromJSI(
51
+ runtime, prop, false);
40
52
  }
41
53
  }
42
- rnwgpu::Logger::logToConsole("GPUBlendComponent::operation = %f",
43
- result->_instance.operation);
44
- rnwgpu::Logger::logToConsole("GPUBlendComponent::srcFactor = %f",
45
- result->_instance.srcFactor);
46
- rnwgpu::Logger::logToConsole("GPUBlendComponent::dstFactor = %f",
47
- result->_instance.dstFactor);
54
+
48
55
  return result;
49
56
  }
50
57
  static jsi::Value toJSI(jsi::Runtime &runtime,
51
58
  std::shared_ptr<rnwgpu::GPUBlendComponent> arg) {
52
- // No conversions here
53
- return jsi::Value::null();
59
+ throw std::runtime_error("Invalid GPUBlendComponent::toJSI()");
54
60
  }
55
61
  };
56
- } // namespace margelo
62
+
63
+ } // 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 "GPUBlendComponent.h"
11
+ #include "RNFHybridObject.h"
11
12
 
12
13
  namespace jsi = facebook::jsi;
14
+ namespace m = margelo;
13
15
 
14
16
  namespace rnwgpu {
15
17
 
16
- class GPUBlendState {
17
- public:
18
- wgpu::BlendState *getInstance() { return &_instance; }
19
-
20
- wgpu::BlendState _instance;
18
+ struct GPUBlendState {
19
+ std::shared_ptr<GPUBlendComponent> color; // GPUBlendComponent
20
+ std::shared_ptr<GPUBlendComponent> alpha; // GPUBlendComponent
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::GPUBlendState>> {
27
30
  static std::shared_ptr<rnwgpu::GPUBlendState>
28
31
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,36 +33,25 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBlendState>> {
30
33
  if (!outOfBounds && arg.isObject()) {
31
34
  auto value = arg.getObject(runtime);
32
35
  if (value.hasProperty(runtime, "color")) {
33
- auto color = value.getProperty(runtime, "color");
34
-
35
- if (color.isUndefined()) {
36
- throw std::runtime_error("Property GPUBlendState::color is required");
37
- }
38
- } else {
39
- throw std::runtime_error(
40
- "Property GPUBlendState::color is not defined");
36
+ auto prop = value.getProperty(runtime, "color");
37
+ result->color =
38
+ JSIConverter<std::shared_ptr<GPUBlendComponent>>::fromJSI(
39
+ runtime, prop, false);
41
40
  }
42
41
  if (value.hasProperty(runtime, "alpha")) {
43
- auto alpha = value.getProperty(runtime, "alpha");
44
-
45
- if (alpha.isUndefined()) {
46
- throw std::runtime_error("Property GPUBlendState::alpha is required");
47
- }
48
- } else {
49
- throw std::runtime_error(
50
- "Property GPUBlendState::alpha is not defined");
42
+ auto prop = value.getProperty(runtime, "alpha");
43
+ result->alpha =
44
+ JSIConverter<std::shared_ptr<GPUBlendComponent>>::fromJSI(
45
+ runtime, prop, false);
51
46
  }
52
47
  }
53
- rnwgpu::Logger::logToConsole("GPUBlendState::color = %f",
54
- result->_instance.color);
55
- rnwgpu::Logger::logToConsole("GPUBlendState::alpha = %f",
56
- result->_instance.alpha);
48
+
57
49
  return result;
58
50
  }
59
51
  static jsi::Value toJSI(jsi::Runtime &runtime,
60
52
  std::shared_ptr<rnwgpu::GPUBlendState> arg) {
61
- // No conversions here
62
- return jsi::Value::null();
53
+ throw std::runtime_error("Invalid GPUBlendState::toJSI()");
63
54
  }
64
55
  };
65
- } // namespace margelo
56
+
57
+ } // namespace margelo
@@ -1,28 +1,32 @@
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 "GPUBuffer.h"
11
+ #include "RNFHybridObject.h"
11
12
 
12
13
  namespace jsi = facebook::jsi;
14
+ namespace m = margelo;
13
15
 
14
16
  namespace rnwgpu {
15
17
 
16
- class GPUBufferBinding {
17
- public:
18
- wgpu::BufferBinding *getInstance() { return &_instance; }
19
-
20
- wgpu::BufferBinding _instance;
18
+ struct GPUBufferBinding {
19
+ std::shared_ptr<GPUBuffer> buffer; // GPUBuffer
20
+ std::optional<double> offset; // GPUSize64
21
+ std::optional<double> size; // GPUSize64
21
22
  };
23
+
22
24
  } // namespace rnwgpu
23
25
 
24
26
  namespace margelo {
25
27
 
28
+ using namespace rnwgpu; // NOLINT(build/namespaces)
29
+
26
30
  template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBinding>> {
27
31
  static std::shared_ptr<rnwgpu::GPUBufferBinding>
28
32
  fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
@@ -30,43 +34,28 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBufferBinding>> {
30
34
  if (!outOfBounds && arg.isObject()) {
31
35
  auto value = arg.getObject(runtime);
32
36
  if (value.hasProperty(runtime, "buffer")) {
33
- auto buffer = value.getProperty(runtime, "buffer");
34
-
35
- if (buffer.isUndefined()) {
36
- throw std::runtime_error(
37
- "Property GPUBufferBinding::buffer is required");
38
- }
39
- } else {
40
- throw std::runtime_error(
41
- "Property GPUBufferBinding::buffer is not defined");
37
+ auto prop = value.getProperty(runtime, "buffer");
38
+ result->buffer = JSIConverter<std::shared_ptr<GPUBuffer>>::fromJSI(
39
+ runtime, prop, false);
42
40
  }
43
41
  if (value.hasProperty(runtime, "offset")) {
44
- auto offset = value.getProperty(runtime, "offset");
45
-
46
- if (offset.isNumber()) {
47
- result->_instance.offset = offset.getNumber();
48
- }
42
+ auto prop = value.getProperty(runtime, "offset");
43
+ result->offset =
44
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
49
45
  }
50
46
  if (value.hasProperty(runtime, "size")) {
51
- auto size = value.getProperty(runtime, "size");
52
-
53
- if (size.isNumber()) {
54
- result->_instance.size = size.getNumber();
55
- }
47
+ auto prop = value.getProperty(runtime, "size");
48
+ result->size =
49
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
56
50
  }
57
51
  }
58
- rnwgpu::Logger::logToConsole("GPUBufferBinding::buffer = %f",
59
- result->_instance.buffer);
60
- rnwgpu::Logger::logToConsole("GPUBufferBinding::offset = %f",
61
- result->_instance.offset);
62
- rnwgpu::Logger::logToConsole("GPUBufferBinding::size = %f",
63
- result->_instance.size);
52
+
64
53
  return result;
65
54
  }
66
55
  static jsi::Value toJSI(jsi::Runtime &runtime,
67
56
  std::shared_ptr<rnwgpu::GPUBufferBinding> arg) {
68
- // No conversions here
69
- return jsi::Value::null();
57
+ throw std::runtime_error("Invalid GPUBufferBinding::toJSI()");
70
58
  }
71
59
  };
72
- } // namespace margelo
60
+
61
+ } // namespace margelo