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
@@ -2,29 +2,44 @@
2
2
 
3
3
  #include <memory>
4
4
  #include <string>
5
+ #include <variant>
6
+ #include <vector>
5
7
 
6
8
  #include "webgpu/webgpu_cpp.h"
7
9
 
8
- #include "Logger.h"
9
10
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
11
+ #include "WGPULogger.h"
12
+
13
+ #include "GPUQuerySet.h"
14
+ #include "GPURenderPassColorAttachment.h"
15
+ #include "GPURenderPassDepthStencilAttachment.h"
16
+ #include "GPURenderPassTimestampWrites.h"
17
+ #include "RNFHybridObject.h"
11
18
 
12
19
  namespace jsi = facebook::jsi;
20
+ namespace m = margelo;
13
21
 
14
22
  namespace rnwgpu {
15
23
 
16
- class GPURenderPassDescriptor {
17
- public:
18
- wgpu::RenderPassDescriptor *getInstance() { return &_instance; }
19
-
20
- wgpu::RenderPassDescriptor _instance;
21
-
22
- std::string label;
24
+ struct GPURenderPassDescriptor {
25
+ std::vector<std::variant<std::nullptr_t,
26
+ std::shared_ptr<GPURenderPassColorAttachment>>>
27
+ colorAttachments; // Iterable<GPURenderPassColorAttachment | null>
28
+ std::optional<std::shared_ptr<GPURenderPassDepthStencilAttachment>>
29
+ depthStencilAttachment; // GPURenderPassDepthStencilAttachment
30
+ std::optional<std::shared_ptr<GPUQuerySet>> occlusionQuerySet; // GPUQuerySet
31
+ std::optional<std::shared_ptr<GPURenderPassTimestampWrites>>
32
+ timestampWrites; // GPURenderPassTimestampWrites
33
+ std::optional<double> maxDrawCount; // GPUSize64
34
+ std::optional<std::string> label; // string
23
35
  };
36
+
24
37
  } // namespace rnwgpu
25
38
 
26
39
  namespace margelo {
27
40
 
41
+ using namespace rnwgpu; // NOLINT(build/namespaces)
42
+
28
43
  template <>
29
44
  struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassDescriptor>> {
30
45
  static std::shared_ptr<rnwgpu::GPURenderPassDescriptor>
@@ -33,68 +48,50 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassDescriptor>> {
33
48
  if (!outOfBounds && arg.isObject()) {
34
49
  auto value = arg.getObject(runtime);
35
50
  if (value.hasProperty(runtime, "colorAttachments")) {
36
- auto colorAttachments = value.getProperty(runtime, "colorAttachments");
37
-
38
- if (colorAttachments.isUndefined()) {
39
- throw std::runtime_error(
40
- "Property GPURenderPassDescriptor::colorAttachments is required");
41
- }
42
- } else {
43
- throw std::runtime_error(
44
- "Property GPURenderPassDescriptor::colorAttachments is not "
45
- "defined");
51
+ auto prop = value.getProperty(runtime, "colorAttachments");
52
+ result->colorAttachments = JSIConverter<std::vector<std::variant<
53
+ std::nullptr_t, std::shared_ptr<GPURenderPassColorAttachment>>>>::
54
+ fromJSI(runtime, prop, false);
46
55
  }
47
56
  if (value.hasProperty(runtime, "depthStencilAttachment")) {
48
- auto depthStencilAttachment =
49
- value.getProperty(runtime, "depthStencilAttachment");
57
+ auto prop = value.getProperty(runtime, "depthStencilAttachment");
58
+ result->depthStencilAttachment =
59
+ JSIConverter<std::optional<std::shared_ptr<
60
+ GPURenderPassDepthStencilAttachment>>>::fromJSI(runtime, prop,
61
+ false);
50
62
  }
51
63
  if (value.hasProperty(runtime, "occlusionQuerySet")) {
52
- auto occlusionQuerySet =
53
- value.getProperty(runtime, "occlusionQuerySet");
64
+ auto prop = value.getProperty(runtime, "occlusionQuerySet");
65
+ result->occlusionQuerySet =
66
+ JSIConverter<std::optional<std::shared_ptr<GPUQuerySet>>>::fromJSI(
67
+ runtime, prop, false);
54
68
  }
55
69
  if (value.hasProperty(runtime, "timestampWrites")) {
56
- auto timestampWrites = value.getProperty(runtime, "timestampWrites");
70
+ auto prop = value.getProperty(runtime, "timestampWrites");
71
+ result->timestampWrites = JSIConverter<std::optional<
72
+ std::shared_ptr<GPURenderPassTimestampWrites>>>::fromJSI(runtime,
73
+ prop,
74
+ false);
57
75
  }
58
76
  if (value.hasProperty(runtime, "maxDrawCount")) {
59
- auto maxDrawCount = value.getProperty(runtime, "maxDrawCount");
60
-
61
- if (maxDrawCount.isNumber()) {
62
- result->_instance.maxDrawCount = maxDrawCount.getNumber();
63
- }
77
+ auto prop = value.getProperty(runtime, "maxDrawCount");
78
+ result->maxDrawCount =
79
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
64
80
  }
65
81
  if (value.hasProperty(runtime, "label")) {
66
- auto label = value.getProperty(runtime, "label");
67
-
68
- if (label.isString()) {
69
- auto str = label.asString(runtime).utf8(runtime);
70
- result->label = str;
71
- result->_instance.label = result->label.c_str();
72
- }
82
+ auto prop = value.getProperty(runtime, "label");
83
+ result->label = JSIConverter<std::optional<std::string>>::fromJSI(
84
+ runtime, prop, false);
73
85
  }
74
86
  }
75
- rnwgpu::Logger::logToConsole(
76
- "GPURenderPassDescriptor::colorAttachments = %f",
77
- result->_instance.colorAttachments);
78
- rnwgpu::Logger::logToConsole(
79
- "GPURenderPassDescriptor::depthStencilAttachment = %f",
80
- result->_instance.depthStencilAttachment);
81
- rnwgpu::Logger::logToConsole(
82
- "GPURenderPassDescriptor::occlusionQuerySet = %f",
83
- result->_instance.occlusionQuerySet);
84
- rnwgpu::Logger::logToConsole(
85
- "GPURenderPassDescriptor::timestampWrites = %f",
86
- result->_instance.timestampWrites);
87
- rnwgpu::Logger::logToConsole("GPURenderPassDescriptor::maxDrawCount = %f",
88
- result->_instance.maxDrawCount);
89
- rnwgpu::Logger::logToConsole("GPURenderPassDescriptor::label = %f",
90
- result->_instance.label);
87
+
91
88
  return result;
92
89
  }
93
90
  static jsi::Value
94
91
  toJSI(jsi::Runtime &runtime,
95
92
  std::shared_ptr<rnwgpu::GPURenderPassDescriptor> arg) {
96
- // No conversions here
97
- return jsi::Value::null();
93
+ throw std::runtime_error("Invalid GPURenderPassDescriptor::toJSI()");
98
94
  }
99
95
  };
100
- } // namespace margelo
96
+
97
+ } // 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 "GPUQuerySet.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 GPURenderPassTimestampWrites {
17
- public:
18
- wgpu::RenderPassTimestampWrites *getInstance() { return &_instance; }
19
-
20
- wgpu::RenderPassTimestampWrites _instance;
18
+ struct GPURenderPassTimestampWrites {
19
+ std::shared_ptr<GPUQuerySet> querySet; // GPUQuerySet
20
+ std::optional<double> beginningOfPassWriteIndex; // GPUSize32
21
+ std::optional<double> endOfPassWriteIndex; // GPUSize32
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 <>
27
31
  struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites>> {
28
32
  static std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites>
@@ -31,50 +35,29 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites>> {
31
35
  if (!outOfBounds && arg.isObject()) {
32
36
  auto value = arg.getObject(runtime);
33
37
  if (value.hasProperty(runtime, "querySet")) {
34
- auto querySet = value.getProperty(runtime, "querySet");
35
-
36
- if (querySet.isUndefined()) {
37
- throw std::runtime_error(
38
- "Property GPURenderPassTimestampWrites::querySet is required");
39
- }
40
- } else {
41
- throw std::runtime_error(
42
- "Property GPURenderPassTimestampWrites::querySet is not defined");
38
+ auto prop = value.getProperty(runtime, "querySet");
39
+ result->querySet = JSIConverter<std::shared_ptr<GPUQuerySet>>::fromJSI(
40
+ runtime, prop, false);
43
41
  }
44
42
  if (value.hasProperty(runtime, "beginningOfPassWriteIndex")) {
45
- auto beginningOfPassWriteIndex =
46
- value.getProperty(runtime, "beginningOfPassWriteIndex");
47
-
48
- if (beginningOfPassWriteIndex.isNumber()) {
49
- result->_instance.beginningOfPassWriteIndex =
50
- static_cast<wgpu::Size32>(beginningOfPassWriteIndex.getNumber());
51
- }
43
+ auto prop = value.getProperty(runtime, "beginningOfPassWriteIndex");
44
+ result->beginningOfPassWriteIndex =
45
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
52
46
  }
53
47
  if (value.hasProperty(runtime, "endOfPassWriteIndex")) {
54
- auto endOfPassWriteIndex =
55
- value.getProperty(runtime, "endOfPassWriteIndex");
56
-
57
- if (endOfPassWriteIndex.isNumber()) {
58
- result->_instance.endOfPassWriteIndex =
59
- static_cast<wgpu::Size32>(endOfPassWriteIndex.getNumber());
60
- }
48
+ auto prop = value.getProperty(runtime, "endOfPassWriteIndex");
49
+ result->endOfPassWriteIndex =
50
+ JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
61
51
  }
62
52
  }
63
- rnwgpu::Logger::logToConsole("GPURenderPassTimestampWrites::querySet = %f",
64
- result->_instance.querySet);
65
- rnwgpu::Logger::logToConsole(
66
- "GPURenderPassTimestampWrites::beginningOfPassWriteIndex = %f",
67
- result->_instance.beginningOfPassWriteIndex);
68
- rnwgpu::Logger::logToConsole(
69
- "GPURenderPassTimestampWrites::endOfPassWriteIndex = %f",
70
- result->_instance.endOfPassWriteIndex);
53
+
71
54
  return result;
72
55
  }
73
56
  static jsi::Value
74
57
  toJSI(jsi::Runtime &runtime,
75
58
  std::shared_ptr<rnwgpu::GPURenderPassTimestampWrites> arg) {
76
- // No conversions here
77
- return jsi::Value::null();
59
+ throw std::runtime_error("Invalid GPURenderPassTimestampWrites::toJSI()");
78
60
  }
79
61
  };
80
- } // namespace margelo
62
+
63
+ } // namespace margelo
@@ -5,26 +5,42 @@
5
5
 
6
6
  #include "webgpu/webgpu_cpp.h"
7
7
 
8
- #include "Logger.h"
9
8
  #include "RNFJSIConverter.h"
10
- #include <RNFHybridObject.h>
9
+ #include "WGPULogger.h"
10
+
11
+ #include "GPUDepthStencilState.h"
12
+ #include "GPUFragmentState.h"
13
+ #include "GPUMultisampleState.h"
14
+ #include "GPUPipelineLayout.h"
15
+ #include "GPUPrimitiveState.h"
16
+ #include "GPUVertexState.h"
17
+ #include "RNFHybridObject.h"
11
18
 
12
19
  namespace jsi = facebook::jsi;
20
+ namespace m = margelo;
13
21
 
14
22
  namespace rnwgpu {
15
23
 
16
- class GPURenderPipelineDescriptor {
17
- public:
18
- wgpu::RenderPipelineDescriptor *getInstance() { return &_instance; }
19
-
20
- wgpu::RenderPipelineDescriptor _instance;
21
-
22
- std::string label;
24
+ struct GPURenderPipelineDescriptor {
25
+ std::shared_ptr<GPUVertexState> vertex; // GPUVertexState
26
+ std::optional<std::shared_ptr<GPUPrimitiveState>>
27
+ primitive; // GPUPrimitiveState
28
+ std::optional<std::shared_ptr<GPUDepthStencilState>>
29
+ depthStencil; // GPUDepthStencilState
30
+ std::optional<std::shared_ptr<GPUMultisampleState>>
31
+ multisample; // GPUMultisampleState
32
+ std::optional<std::shared_ptr<GPUFragmentState>> fragment; // GPUFragmentState
33
+ std::variant<std::nullptr_t, std::shared_ptr<GPUPipelineLayout>>
34
+ layout; // | GPUPipelineLayout | GPUAutoLayoutMode
35
+ std::optional<std::string> label; // string
23
36
  };
37
+
24
38
  } // namespace rnwgpu
25
39
 
26
40
  namespace margelo {
27
41
 
42
+ using namespace rnwgpu; // NOLINT(build/namespaces)
43
+
28
44
  template <>
29
45
  struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor>> {
30
46
  static std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor>
@@ -33,72 +49,60 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor>> {
33
49
  if (!outOfBounds && arg.isObject()) {
34
50
  auto value = arg.getObject(runtime);
35
51
  if (value.hasProperty(runtime, "vertex")) {
36
- auto vertex = value.getProperty(runtime, "vertex");
37
-
38
- if (vertex.isUndefined()) {
39
- throw std::runtime_error(
40
- "Property GPURenderPipelineDescriptor::vertex is required");
41
- }
42
- } else {
43
- throw std::runtime_error(
44
- "Property GPURenderPipelineDescriptor::vertex is not defined");
52
+ auto prop = value.getProperty(runtime, "vertex");
53
+ result->vertex = JSIConverter<std::shared_ptr<GPUVertexState>>::fromJSI(
54
+ runtime, prop, false);
45
55
  }
46
56
  if (value.hasProperty(runtime, "primitive")) {
47
- auto primitive = value.getProperty(runtime, "primitive");
57
+ auto prop = value.getProperty(runtime, "primitive");
58
+ result->primitive = JSIConverter<
59
+ std::optional<std::shared_ptr<GPUPrimitiveState>>>::fromJSI(runtime,
60
+ prop,
61
+ false);
48
62
  }
49
63
  if (value.hasProperty(runtime, "depthStencil")) {
50
- auto depthStencil = value.getProperty(runtime, "depthStencil");
64
+ auto prop = value.getProperty(runtime, "depthStencil");
65
+ result->depthStencil =
66
+ JSIConverter<std::optional<std::shared_ptr<GPUDepthStencilState>>>::
67
+ fromJSI(runtime, prop, false);
51
68
  }
52
69
  if (value.hasProperty(runtime, "multisample")) {
53
- auto multisample = value.getProperty(runtime, "multisample");
70
+ auto prop = value.getProperty(runtime, "multisample");
71
+ result->multisample =
72
+ JSIConverter<std::optional<std::shared_ptr<GPUMultisampleState>>>::
73
+ fromJSI(runtime, prop, false);
54
74
  }
55
75
  if (value.hasProperty(runtime, "fragment")) {
56
- auto fragment = value.getProperty(runtime, "fragment");
76
+ auto prop = value.getProperty(runtime, "fragment");
77
+ result->fragment = JSIConverter<
78
+ std::optional<std::shared_ptr<GPUFragmentState>>>::fromJSI(runtime,
79
+ prop,
80
+ false);
57
81
  }
58
82
  if (value.hasProperty(runtime, "layout")) {
59
- auto layout = value.getProperty(runtime, "layout");
60
-
61
- if (layout.isUndefined()) {
62
- throw std::runtime_error(
63
- "Property GPURenderPipelineDescriptor::layout is required");
83
+ auto prop = value.getProperty(runtime, "layout");
84
+ if (prop.isNull() || prop.isString()) {
85
+ result->layout = nullptr;
86
+ } else {
87
+ result->layout =
88
+ JSIConverter<std::shared_ptr<GPUPipelineLayout>>::fromJSI(
89
+ runtime, prop, false);
64
90
  }
65
- } else {
66
- throw std::runtime_error(
67
- "Property GPURenderPipelineDescriptor::layout is not defined");
68
91
  }
69
92
  if (value.hasProperty(runtime, "label")) {
70
- auto label = value.getProperty(runtime, "label");
71
-
72
- if (label.isString()) {
73
- auto str = label.asString(runtime).utf8(runtime);
74
- result->label = str;
75
- result->_instance.label = result->label.c_str();
76
- }
93
+ auto prop = value.getProperty(runtime, "label");
94
+ result->label = JSIConverter<std::optional<std::string>>::fromJSI(
95
+ runtime, prop, false);
77
96
  }
78
97
  }
79
- rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::vertex = %f",
80
- result->_instance.vertex);
81
- rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::primitive = %f",
82
- result->_instance.primitive);
83
- rnwgpu::Logger::logToConsole(
84
- "GPURenderPipelineDescriptor::depthStencil = %f",
85
- result->_instance.depthStencil);
86
- rnwgpu::Logger::logToConsole(
87
- "GPURenderPipelineDescriptor::multisample = %f",
88
- result->_instance.multisample);
89
- rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::fragment = %f",
90
- result->_instance.fragment);
91
- rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::layout = %f",
92
- result->_instance.layout);
93
- rnwgpu::Logger::logToConsole("GPURenderPipelineDescriptor::label = %f",
94
- result->_instance.label);
98
+
95
99
  return result;
96
100
  }
97
101
  static jsi::Value
98
102
  toJSI(jsi::Runtime &runtime,
99
103
  std::shared_ptr<rnwgpu::GPURenderPipelineDescriptor> arg) {
100
- // No conversions here
101
- return jsi::Value::null();
104
+ throw std::runtime_error("Invalid GPURenderPipelineDescriptor::toJSI()");
102
105
  }
103
106
  };
104
- } // namespace margelo
107
+
108
+ } // namespace margelo
@@ -1,28 +1,30 @@
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 GPURequestAdapterOptions {
17
- public:
18
- wgpu::RequestAdapterOptions *getInstance() { return &_instance; }
19
-
20
- wgpu::RequestAdapterOptions _instance;
17
+ struct GPURequestAdapterOptions {
18
+ std::optional<wgpu::PowerPreference> powerPreference; // GPUPowerPreference
19
+ std::optional<bool> forceFallbackAdapter; // boolean
21
20
  };
21
+
22
22
  } // namespace rnwgpu
23
23
 
24
24
  namespace margelo {
25
25
 
26
+ using namespace rnwgpu; // NOLINT(build/namespaces)
27
+
26
28
  template <>
27
29
  struct JSIConverter<std::shared_ptr<rnwgpu::GPURequestAdapterOptions>> {
28
30
  static std::shared_ptr<rnwgpu::GPURequestAdapterOptions>
@@ -31,26 +33,25 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPURequestAdapterOptions>> {
31
33
  if (!outOfBounds && arg.isObject()) {
32
34
  auto value = arg.getObject(runtime);
33
35
  if (value.hasProperty(runtime, "powerPreference")) {
34
- auto powerPreference = value.getProperty(runtime, "powerPreference");
36
+ auto prop = value.getProperty(runtime, "powerPreference");
37
+ result->powerPreference =
38
+ JSIConverter<std::optional<wgpu::PowerPreference>>::fromJSI(
39
+ runtime, prop, false);
35
40
  }
36
41
  if (value.hasProperty(runtime, "forceFallbackAdapter")) {
37
- auto forceFallbackAdapter =
38
- value.getProperty(runtime, "forceFallbackAdapter");
42
+ auto prop = value.getProperty(runtime, "forceFallbackAdapter");
43
+ result->forceFallbackAdapter =
44
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
39
45
  }
40
46
  }
41
- rnwgpu::Logger::logToConsole(
42
- "GPURequestAdapterOptions::powerPreference = %f",
43
- result->_instance.powerPreference);
44
- rnwgpu::Logger::logToConsole(
45
- "GPURequestAdapterOptions::forceFallbackAdapter = %f",
46
- result->_instance.forceFallbackAdapter);
47
+
47
48
  return result;
48
49
  }
49
50
  static jsi::Value
50
51
  toJSI(jsi::Runtime &runtime,
51
52
  std::shared_ptr<rnwgpu::GPURequestAdapterOptions> arg) {
52
- // No conversions here
53
- return jsi::Value::null();
53
+ throw std::runtime_error("Invalid GPURequestAdapterOptions::toJSI()");
54
54
  }
55
55
  };
56
- } // namespace margelo
56
+
57
+ } // namespace margelo
@@ -1,28 +1,29 @@
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 GPUSamplerBindingLayout {
17
- public:
18
- wgpu::SamplerBindingLayout *getInstance() { return &_instance; }
19
-
20
- wgpu::SamplerBindingLayout _instance;
17
+ struct GPUSamplerBindingLayout {
18
+ std::optional<wgpu::SamplerBindingType> type; // GPUSamplerBindingType
21
19
  };
20
+
22
21
  } // namespace rnwgpu
23
22
 
24
23
  namespace margelo {
25
24
 
25
+ using namespace rnwgpu; // NOLINT(build/namespaces)
26
+
26
27
  template <>
27
28
  struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerBindingLayout>> {
28
29
  static std::shared_ptr<rnwgpu::GPUSamplerBindingLayout>
@@ -31,18 +32,20 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUSamplerBindingLayout>> {
31
32
  if (!outOfBounds && arg.isObject()) {
32
33
  auto value = arg.getObject(runtime);
33
34
  if (value.hasProperty(runtime, "type")) {
34
- auto type = value.getProperty(runtime, "type");
35
+ auto prop = value.getProperty(runtime, "type");
36
+ result->type =
37
+ JSIConverter<std::optional<wgpu::SamplerBindingType>>::fromJSI(
38
+ runtime, prop, false);
35
39
  }
36
40
  }
37
- rnwgpu::Logger::logToConsole("GPUSamplerBindingLayout::type = %f",
38
- result->_instance.type);
41
+
39
42
  return result;
40
43
  }
41
44
  static jsi::Value
42
45
  toJSI(jsi::Runtime &runtime,
43
46
  std::shared_ptr<rnwgpu::GPUSamplerBindingLayout> arg) {
44
- // No conversions here
45
- return jsi::Value::null();
47
+ throw std::runtime_error("Invalid GPUSamplerBindingLayout::toJSI()");
46
48
  }
47
49
  };
48
- } // namespace margelo
50
+
51
+ } // namespace margelo