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,13 +1,12 @@
1
1
  #pragma once
2
2
 
3
- #include <future>
4
- #include <memory>
5
3
  #include <string>
6
4
 
7
5
  #include "Unions.h"
8
- #include <RNFHybridObject.h>
9
6
 
10
- #include "MutableBuffer.h"
7
+ #include "RNFHybridObject.h"
8
+
9
+ #include "AsyncRunner.h"
11
10
 
12
11
  #include "webgpu/webgpu_cpp.h"
13
12
 
@@ -23,11 +22,136 @@ public:
23
22
  public:
24
23
  std::string getBrand() { return _name; }
25
24
 
25
+ double getMaxTextureDimension1D();
26
+ double getMaxTextureDimension2D();
27
+ double getMaxTextureDimension3D();
28
+ double getMaxTextureArrayLayers();
29
+ double getMaxBindGroups();
30
+ double getMaxBindGroupsPlusVertexBuffers();
31
+ double getMaxBindingsPerBindGroup();
32
+ double getMaxDynamicUniformBuffersPerPipelineLayout();
33
+ double getMaxDynamicStorageBuffersPerPipelineLayout();
34
+ double getMaxSampledTexturesPerShaderStage();
35
+ double getMaxSamplersPerShaderStage();
36
+ double getMaxStorageBuffersPerShaderStage();
37
+ double getMaxStorageTexturesPerShaderStage();
38
+ double getMaxUniformBuffersPerShaderStage();
39
+ double getMaxUniformBufferBindingSize();
40
+ double getMaxStorageBufferBindingSize();
41
+ double getMinUniformBufferOffsetAlignment();
42
+ double getMinStorageBufferOffsetAlignment();
43
+ double getMaxVertexBuffers();
44
+ double getMaxBufferSize();
45
+ double getMaxVertexAttributes();
46
+ double getMaxVertexBufferArrayStride();
47
+ double getMaxInterStageShaderComponents();
48
+ double getMaxInterStageShaderVariables();
49
+ double getMaxColorAttachments();
50
+ double getMaxColorAttachmentBytesPerSample();
51
+ double getMaxComputeWorkgroupStorageSize();
52
+ double getMaxComputeInvocationsPerWorkgroup();
53
+ double getMaxComputeWorkgroupSizeX();
54
+ double getMaxComputeWorkgroupSizeY();
55
+ double getMaxComputeWorkgroupSizeZ();
56
+ double getMaxComputeWorkgroupsPerDimension();
57
+
26
58
  void loadHybridMethods() override {
27
59
  registerHybridGetter("__brand", &GPUSupportedLimits::getBrand, this);
60
+
61
+ registerHybridGetter("maxTextureDimension1D",
62
+ &GPUSupportedLimits::getMaxTextureDimension1D, this);
63
+ registerHybridGetter("maxTextureDimension2D",
64
+ &GPUSupportedLimits::getMaxTextureDimension2D, this);
65
+ registerHybridGetter("maxTextureDimension3D",
66
+ &GPUSupportedLimits::getMaxTextureDimension3D, this);
67
+ registerHybridGetter("maxTextureArrayLayers",
68
+ &GPUSupportedLimits::getMaxTextureArrayLayers, this);
69
+ registerHybridGetter("maxBindGroups", &GPUSupportedLimits::getMaxBindGroups,
70
+ this);
71
+ registerHybridGetter("maxBindGroupsPlusVertexBuffers",
72
+ &GPUSupportedLimits::getMaxBindGroupsPlusVertexBuffers,
73
+ this);
74
+ registerHybridGetter("maxBindingsPerBindGroup",
75
+ &GPUSupportedLimits::getMaxBindingsPerBindGroup, this);
76
+ registerHybridGetter(
77
+ "maxDynamicUniformBuffersPerPipelineLayout",
78
+ &GPUSupportedLimits::getMaxDynamicUniformBuffersPerPipelineLayout,
79
+ this);
80
+ registerHybridGetter(
81
+ "maxDynamicStorageBuffersPerPipelineLayout",
82
+ &GPUSupportedLimits::getMaxDynamicStorageBuffersPerPipelineLayout,
83
+ this);
84
+ registerHybridGetter(
85
+ "maxSampledTexturesPerShaderStage",
86
+ &GPUSupportedLimits::getMaxSampledTexturesPerShaderStage, this);
87
+ registerHybridGetter("maxSamplersPerShaderStage",
88
+ &GPUSupportedLimits::getMaxSamplersPerShaderStage,
89
+ this);
90
+ registerHybridGetter(
91
+ "maxStorageBuffersPerShaderStage",
92
+ &GPUSupportedLimits::getMaxStorageBuffersPerShaderStage, this);
93
+ registerHybridGetter(
94
+ "maxStorageTexturesPerShaderStage",
95
+ &GPUSupportedLimits::getMaxStorageTexturesPerShaderStage, this);
96
+ registerHybridGetter(
97
+ "maxUniformBuffersPerShaderStage",
98
+ &GPUSupportedLimits::getMaxUniformBuffersPerShaderStage, this);
99
+ registerHybridGetter("maxUniformBufferBindingSize",
100
+ &GPUSupportedLimits::getMaxUniformBufferBindingSize,
101
+ this);
102
+ registerHybridGetter("maxStorageBufferBindingSize",
103
+ &GPUSupportedLimits::getMaxStorageBufferBindingSize,
104
+ this);
105
+ registerHybridGetter(
106
+ "minUniformBufferOffsetAlignment",
107
+ &GPUSupportedLimits::getMinUniformBufferOffsetAlignment, this);
108
+ registerHybridGetter(
109
+ "minStorageBufferOffsetAlignment",
110
+ &GPUSupportedLimits::getMinStorageBufferOffsetAlignment, this);
111
+ registerHybridGetter("maxVertexBuffers",
112
+ &GPUSupportedLimits::getMaxVertexBuffers, this);
113
+ registerHybridGetter("maxBufferSize", &GPUSupportedLimits::getMaxBufferSize,
114
+ this);
115
+ registerHybridGetter("maxVertexAttributes",
116
+ &GPUSupportedLimits::getMaxVertexAttributes, this);
117
+ registerHybridGetter("maxVertexBufferArrayStride",
118
+ &GPUSupportedLimits::getMaxVertexBufferArrayStride,
119
+ this);
120
+ registerHybridGetter("maxInterStageShaderComponents",
121
+ &GPUSupportedLimits::getMaxInterStageShaderComponents,
122
+ this);
123
+ registerHybridGetter("maxInterStageShaderVariables",
124
+ &GPUSupportedLimits::getMaxInterStageShaderVariables,
125
+ this);
126
+ registerHybridGetter("maxColorAttachments",
127
+ &GPUSupportedLimits::getMaxColorAttachments, this);
128
+ registerHybridGetter(
129
+ "maxColorAttachmentBytesPerSample",
130
+ &GPUSupportedLimits::getMaxColorAttachmentBytesPerSample, this);
131
+ registerHybridGetter("maxComputeWorkgroupStorageSize",
132
+ &GPUSupportedLimits::getMaxComputeWorkgroupStorageSize,
133
+ this);
134
+ registerHybridGetter(
135
+ "maxComputeInvocationsPerWorkgroup",
136
+ &GPUSupportedLimits::getMaxComputeInvocationsPerWorkgroup, this);
137
+ registerHybridGetter("maxComputeWorkgroupSizeX",
138
+ &GPUSupportedLimits::getMaxComputeWorkgroupSizeX,
139
+ this);
140
+ registerHybridGetter("maxComputeWorkgroupSizeY",
141
+ &GPUSupportedLimits::getMaxComputeWorkgroupSizeY,
142
+ this);
143
+ registerHybridGetter("maxComputeWorkgroupSizeZ",
144
+ &GPUSupportedLimits::getMaxComputeWorkgroupSizeZ,
145
+ this);
146
+ registerHybridGetter(
147
+ "maxComputeWorkgroupsPerDimension",
148
+ &GPUSupportedLimits::getMaxComputeWorkgroupsPerDimension, this);
28
149
  }
29
150
 
151
+ inline const wgpu::SupportedLimits get() { return _instance; }
152
+
30
153
  private:
31
154
  wgpu::SupportedLimits _instance;
32
155
  };
156
+
33
157
  } // namespace rnwgpu
@@ -0,0 +1,47 @@
1
+ #include "GPUTexture.h"
2
+
3
+ #include <memory>
4
+
5
+ #include "Convertors.h"
6
+
7
+ namespace rnwgpu {
8
+
9
+ void GPUTexture::destroy() { _instance.Destroy(); }
10
+
11
+ std::shared_ptr<GPUTextureView> GPUTexture::createView(
12
+ std::optional<std::shared_ptr<GPUTextureViewDescriptor>> descriptor) {
13
+ wgpu::TextureViewDescriptor desc;
14
+ Convertor conv;
15
+ if (!conv(desc, descriptor)) {
16
+ throw std::runtime_error("GPUTextureView.createView(): couldn't access "
17
+ "GPUTextureViewDescriptor");
18
+ }
19
+ auto view = _instance.CreateView(&desc);
20
+ return std::make_shared<GPUTextureView>(
21
+ view,
22
+ descriptor.has_value() ? descriptor.value()->label.value_or("") : "");
23
+ }
24
+
25
+ uint32_t GPUTexture::getWidth() { return _instance.GetWidth(); }
26
+
27
+ uint32_t GPUTexture::getHeight() { return _instance.GetHeight(); }
28
+
29
+ uint32_t GPUTexture::getDepthOrArrayLayers() {
30
+ return _instance.GetDepthOrArrayLayers();
31
+ }
32
+
33
+ uint32_t GPUTexture::getMipLevelCount() { return _instance.GetMipLevelCount(); }
34
+
35
+ uint32_t GPUTexture::getSampleCount() { return _instance.GetSampleCount(); }
36
+
37
+ wgpu::TextureDimension GPUTexture::getDimension() {
38
+ return _instance.GetDimension();
39
+ }
40
+
41
+ wgpu::TextureFormat GPUTexture::getFormat() { return _instance.GetFormat(); }
42
+
43
+ double GPUTexture::getUsage() {
44
+ return static_cast<double>(_instance.GetUsage());
45
+ }
46
+
47
+ } // namespace rnwgpu
@@ -1,16 +1,19 @@
1
1
  #pragma once
2
2
 
3
- #include <future>
4
3
  #include <memory>
5
4
  #include <string>
6
5
 
7
6
  #include "Unions.h"
8
- #include <RNFHybridObject.h>
9
7
 
10
- #include "MutableBuffer.h"
8
+ #include "RNFHybridObject.h"
9
+
10
+ #include "AsyncRunner.h"
11
11
 
12
12
  #include "webgpu/webgpu_cpp.h"
13
13
 
14
+ #include "GPUTextureView.h"
15
+ #include "GPUTextureViewDescriptor.h"
16
+
14
17
  namespace rnwgpu {
15
18
 
16
19
  namespace m = margelo;
@@ -23,16 +26,47 @@ public:
23
26
  public:
24
27
  std::string getBrand() { return _name; }
25
28
 
29
+ std::shared_ptr<GPUTextureView> createView(
30
+ std::optional<std::shared_ptr<GPUTextureViewDescriptor>> descriptor);
31
+ void destroy();
32
+
33
+ uint32_t getWidth();
34
+ uint32_t getHeight();
35
+ uint32_t getDepthOrArrayLayers();
36
+ uint32_t getMipLevelCount();
37
+ uint32_t getSampleCount();
38
+ wgpu::TextureDimension getDimension();
39
+ wgpu::TextureFormat getFormat();
40
+ double getUsage();
41
+
26
42
  std::string getLabel() { return _label; }
43
+ void setLabel(const std::string &label) {
44
+ _label = label;
45
+ _instance.SetLabel(_label.c_str());
46
+ }
27
47
 
28
48
  void loadHybridMethods() override {
29
49
  registerHybridGetter("__brand", &GPUTexture::getBrand, this);
30
-
50
+ registerHybridMethod("createView", &GPUTexture::createView, this);
51
+ registerHybridMethod("destroy", &GPUTexture::destroy, this);
52
+ registerHybridGetter("width", &GPUTexture::getWidth, this);
53
+ registerHybridGetter("height", &GPUTexture::getHeight, this);
54
+ registerHybridGetter("depthOrArrayLayers",
55
+ &GPUTexture::getDepthOrArrayLayers, this);
56
+ registerHybridGetter("mipLevelCount", &GPUTexture::getMipLevelCount, this);
57
+ registerHybridGetter("sampleCount", &GPUTexture::getSampleCount, this);
58
+ registerHybridGetter("dimension", &GPUTexture::getDimension, this);
59
+ registerHybridGetter("format", &GPUTexture::getFormat, this);
60
+ registerHybridGetter("usage", &GPUTexture::getUsage, this);
31
61
  registerHybridGetter("label", &GPUTexture::getLabel, this);
62
+ registerHybridSetter("label", &GPUTexture::setLabel, this);
32
63
  }
33
64
 
65
+ inline const wgpu::Texture get() { return _instance; }
66
+
34
67
  private:
35
68
  wgpu::Texture _instance;
36
69
  std::string _label;
37
70
  };
71
+
38
72
  } // namespace rnwgpu
@@ -1,13 +1,12 @@
1
1
  #pragma once
2
2
 
3
- #include <future>
4
- #include <memory>
5
3
  #include <string>
6
4
 
7
5
  #include "Unions.h"
8
- #include <RNFHybridObject.h>
9
6
 
10
- #include "MutableBuffer.h"
7
+ #include "RNFHybridObject.h"
8
+
9
+ #include "AsyncRunner.h"
11
10
 
12
11
  #include "webgpu/webgpu_cpp.h"
13
12
 
@@ -24,15 +23,23 @@ public:
24
23
  std::string getBrand() { return _name; }
25
24
 
26
25
  std::string getLabel() { return _label; }
26
+ void setLabel(const std::string &label) {
27
+ _label = label;
28
+ _instance.SetLabel(_label.c_str());
29
+ }
27
30
 
28
31
  void loadHybridMethods() override {
29
32
  registerHybridGetter("__brand", &GPUTextureView::getBrand, this);
30
33
 
31
34
  registerHybridGetter("label", &GPUTextureView::getLabel, this);
35
+ registerHybridSetter("label", &GPUTextureView::setLabel, this);
32
36
  }
33
37
 
38
+ inline const wgpu::TextureView get() { return _instance; }
39
+
34
40
  private:
35
41
  wgpu::TextureView _instance;
36
42
  std::string _label;
37
43
  };
44
+
38
45
  } // namespace rnwgpu
@@ -0,0 +1,34 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include "webgpu/webgpu_cpp.h"
6
+
7
+ #include "PlatformContext.h"
8
+ #include "RNFHybridObject.h"
9
+
10
+ namespace rnwgpu {
11
+
12
+ class ImageBitmap : public margelo::HybridObject {
13
+ public:
14
+ explicit ImageBitmap(ImageData &imageData)
15
+ : HybridObject("ImageBitmap"), _imageData(imageData) {}
16
+
17
+ size_t getWidth() { return _imageData.width; }
18
+
19
+ size_t getHeight() { return _imageData.height; }
20
+
21
+ void *getData() { return _imageData.data.data(); }
22
+
23
+ size_t getSize() { return _imageData.data.size(); }
24
+
25
+ void loadHybridMethods() override {
26
+ registerHybridGetter("width", &ImageBitmap::getWidth, this);
27
+ registerHybridGetter("height", &ImageBitmap::getHeight, this);
28
+ }
29
+
30
+ private:
31
+ ImageData _imageData;
32
+ };
33
+
34
+ } // namespace rnwgpu
@@ -0,0 +1,100 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ #include "GPU.h"
7
+ #include "GPUCanvasContext.h"
8
+ #include "ImageBitmap.h"
9
+ #include "PlatformContext.h"
10
+
11
+ namespace rnwgpu {
12
+
13
+ namespace m = margelo;
14
+
15
+ struct Blob {
16
+ std::string blobId;
17
+ double size;
18
+ double offset;
19
+ std::string type;
20
+ std::string name;
21
+ };
22
+
23
+ class RNWebGPU : public m::HybridObject {
24
+ public:
25
+ explicit RNWebGPU(std::shared_ptr<GPU> gpu,
26
+ std::shared_ptr<PlatformContext> platformContext)
27
+ : HybridObject("RNWebGPU"), _gpu(gpu), _platformContext(platformContext) {
28
+ }
29
+
30
+ std::shared_ptr<GPU> getGPU() { return _gpu; }
31
+
32
+ std::shared_ptr<GPUCanvasContext>
33
+ MakeWebGPUCanvasContext(std::shared_ptr<Canvas> canvas) {
34
+ auto nativeSurface = canvas->getSurface();
35
+ auto width = canvas->getWidth();
36
+ auto height = canvas->getHeight();
37
+ auto surface = _platformContext->makeSurface(
38
+ _gpu->get(), reinterpret_cast<void *>(nativeSurface), width, height);
39
+ if (surface == nullptr) {
40
+ throw std::runtime_error("null surface");
41
+ }
42
+ auto ctx = std::make_shared<GPUCanvasContext>(surface, canvas);
43
+ return ctx;
44
+ }
45
+
46
+ std::shared_ptr<ImageBitmap> createImageBitmap(std::shared_ptr<Blob> blob) {
47
+ auto imageData = _platformContext->createImageBitmap(
48
+ blob->blobId, blob->offset, blob->size);
49
+ auto imageBitmap = std::make_shared<ImageBitmap>(imageData);
50
+ return imageBitmap;
51
+ }
52
+
53
+ void loadHybridMethods() override {
54
+ registerHybridGetter("gpu", &RNWebGPU::getGPU, this);
55
+ registerHybridMethod("createImageBitmap", &RNWebGPU::createImageBitmap,
56
+ this);
57
+ registerHybridMethod("MakeWebGPUCanvasContext",
58
+ &RNWebGPU::MakeWebGPUCanvasContext, this);
59
+ }
60
+
61
+ private:
62
+ std::shared_ptr<GPU> _gpu;
63
+ std::shared_ptr<PlatformContext> _platformContext;
64
+ };
65
+
66
+ } // namespace rnwgpu
67
+
68
+ namespace margelo {
69
+
70
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::Blob>> {
71
+ static std::shared_ptr<rnwgpu::Blob>
72
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
73
+ if (!outOfBounds && arg.isObject()) {
74
+ auto result = std::make_unique<rnwgpu::Blob>();
75
+ auto val = arg.asObject(runtime);
76
+ if (val.hasProperty(runtime, "_data")) {
77
+ auto value = val.getPropertyAsObject(runtime, "_data");
78
+ result->blobId = JSIConverter<std::string>::fromJSI(
79
+ runtime, value.getProperty(runtime, "blobId"), false);
80
+ // result->type = JSIConverter<std::string>::fromJSI(
81
+ // runtime, value.getProperty(runtime, "type"), false);
82
+ // result->name = JSIConverter<std::string>::fromJSI(
83
+ // runtime, value.getProperty(runtime, "name"), false);
84
+ result->size = JSIConverter<double>::fromJSI(
85
+ runtime, value.getProperty(runtime, "size"), false);
86
+ result->offset = JSIConverter<double>::fromJSI(
87
+ runtime, value.getProperty(runtime, "offset"), false);
88
+ }
89
+ return result;
90
+ } else {
91
+ throw std::runtime_error("Invalid Blob::fromJSI()");
92
+ }
93
+ }
94
+ static jsi::Value toJSI(jsi::Runtime &runtime,
95
+ std::shared_ptr<rnwgpu::Blob> arg) {
96
+ throw std::runtime_error("Invalid Blob::toJSI()");
97
+ }
98
+ };
99
+
100
+ } // namespace margelo
@@ -0,0 +1,59 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <string>
5
+ #include <utility>
6
+
7
+ #include "Unions.h"
8
+
9
+ #include "webgpu/webgpu_cpp.h"
10
+
11
+ #include "RNFHybridObject.h"
12
+
13
+ #include "AsyncRunner.h"
14
+
15
+ #include "GPUCanvasContext.h"
16
+
17
+ #ifdef __APPLE__
18
+ #include "WebGPUModule.h"
19
+ #endif
20
+
21
+ namespace rnwgpu {
22
+
23
+ namespace m = margelo;
24
+
25
+ class WebGPUCanvasContextFactory : public m::HybridObject {
26
+ public:
27
+ GPUCanvasContextFactory() : HybridObject("GPUCanvasContextFactory") {}
28
+
29
+ public:
30
+ std::shared_ptr<GPUCanvasContext> Make(uint64_t surface, int width,
31
+ int height) {
32
+ #ifdef __APPLE__
33
+ wgpu::SurfaceDescriptorFromMetalLayer metalSurfaceDesc;
34
+ metalSurfaceDesc.layer = reinterpret_cast<void *>(surface);
35
+
36
+ wgpu::SurfaceDescriptor surfaceDescriptor;
37
+ surfaceDescriptor.nextInChain = &metalSurfaceDesc;
38
+
39
+ auto surfaceGpu = std::make_unique<wgpu::Surface>(
40
+ WebGPUModule::getManager()->getGPU()->get().CreateSurface(
41
+ &surfaceDescriptor));
42
+ const float scaleFactor = 1;
43
+ const float scaledWidth = width * scaleFactor;
44
+ const float scaledHeight = height * scaleFactor;
45
+
46
+ rnwgpu::SurfaceData surfaceData{scaledWidth, scaledHeight,
47
+ std::move(surfaceGpu)};
48
+ #elif __ANDROID__
49
+ throw std::runtime_error("Not implemented");
50
+ #endif
51
+ return std::make_shared<rnwgpu::GPUCanvasContext>(surfaceData);
52
+ }
53
+
54
+ void loadHybridMethods() override {
55
+ registerHybridGetter("Make", &GPUCanvasContextFactory::Make, this);
56
+ }
57
+ };
58
+
59
+ } // namespace rnwgpu
@@ -2,29 +2,35 @@
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 "GPUBindGroupEntry.h"
13
+ #include "GPUBindGroupLayout.h"
14
+ #include "RNFHybridObject.h"
11
15
 
12
16
  namespace jsi = facebook::jsi;
17
+ namespace m = margelo;
13
18
 
14
19
  namespace rnwgpu {
15
20
 
16
- class GPUBindGroupDescriptor {
17
- public:
18
- wgpu::BindGroupDescriptor *getInstance() { return &_instance; }
19
-
20
- wgpu::BindGroupDescriptor _instance;
21
-
22
- std::string label;
21
+ struct GPUBindGroupDescriptor {
22
+ std::shared_ptr<GPUBindGroupLayout> layout; // GPUBindGroupLayout
23
+ std::vector<std::shared_ptr<GPUBindGroupEntry>>
24
+ entries; // Iterable<GPUBindGroupEntry>
25
+ std::optional<std::string> label; // string
23
26
  };
27
+
24
28
  } // namespace rnwgpu
25
29
 
26
30
  namespace margelo {
27
31
 
32
+ using namespace rnwgpu; // NOLINT(build/namespaces)
33
+
28
34
  template <>
29
35
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
30
36
  static std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>
@@ -33,49 +39,31 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupDescriptor>> {
33
39
  if (!outOfBounds && arg.isObject()) {
34
40
  auto value = arg.getObject(runtime);
35
41
  if (value.hasProperty(runtime, "layout")) {
36
- auto layout = value.getProperty(runtime, "layout");
37
-
38
- if (layout.isUndefined()) {
39
- throw std::runtime_error(
40
- "Property GPUBindGroupDescriptor::layout is required");
41
- }
42
- } else {
43
- throw std::runtime_error(
44
- "Property GPUBindGroupDescriptor::layout is not defined");
42
+ auto prop = value.getProperty(runtime, "layout");
43
+ result->layout =
44
+ JSIConverter<std::shared_ptr<GPUBindGroupLayout>>::fromJSI(
45
+ runtime, prop, false);
45
46
  }
46
47
  if (value.hasProperty(runtime, "entries")) {
47
- auto entries = value.getProperty(runtime, "entries");
48
-
49
- if (entries.isUndefined()) {
50
- throw std::runtime_error(
51
- "Property GPUBindGroupDescriptor::entries is required");
52
- }
53
- } else {
54
- throw std::runtime_error(
55
- "Property GPUBindGroupDescriptor::entries is not defined");
48
+ auto prop = value.getProperty(runtime, "entries");
49
+ result->entries = JSIConverter<
50
+ std::vector<std::shared_ptr<GPUBindGroupEntry>>>::fromJSI(runtime,
51
+ prop,
52
+ false);
56
53
  }
57
54
  if (value.hasProperty(runtime, "label")) {
58
- auto label = value.getProperty(runtime, "label");
59
-
60
- if (label.isString()) {
61
- auto str = label.asString(runtime).utf8(runtime);
62
- result->label = str;
63
- result->_instance.label = result->label.c_str();
64
- }
55
+ auto prop = value.getProperty(runtime, "label");
56
+ result->label = JSIConverter<std::optional<std::string>>::fromJSI(
57
+ runtime, prop, false);
65
58
  }
66
59
  }
67
- rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::layout = %f",
68
- result->_instance.layout);
69
- rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::entries = %f",
70
- result->_instance.entries);
71
- rnwgpu::Logger::logToConsole("GPUBindGroupDescriptor::label = %f",
72
- result->_instance.label);
60
+
73
61
  return result;
74
62
  }
75
63
  static jsi::Value toJSI(jsi::Runtime &runtime,
76
64
  std::shared_ptr<rnwgpu::GPUBindGroupDescriptor> arg) {
77
- // No conversions here
78
- return jsi::Value::null();
65
+ throw std::runtime_error("Invalid GPUBindGroupDescriptor::toJSI()");
79
66
  }
80
67
  };
81
- } // namespace margelo
68
+
69
+ } // namespace margelo