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
@@ -3,16 +3,47 @@
3
3
  #include <future>
4
4
  #include <memory>
5
5
  #include <string>
6
+ #include <unordered_set>
7
+ #include <variant>
6
8
 
7
9
  #include "Unions.h"
8
- #include <RNFHybridObject.h>
9
10
 
10
- #include "MutableBuffer.h"
11
+ #include "RNFHybridObject.h"
12
+
13
+ #include "AsyncRunner.h"
11
14
 
12
15
  #include "webgpu/webgpu_cpp.h"
13
16
 
17
+ #include "GPUBindGroup.h"
18
+ #include "GPUBindGroupDescriptor.h"
19
+ #include "GPUBindGroupLayout.h"
20
+ #include "GPUBindGroupLayoutDescriptor.h"
14
21
  #include "GPUBuffer.h"
15
22
  #include "GPUBufferDescriptor.h"
23
+ #include "GPUCommandEncoder.h"
24
+ #include "GPUCommandEncoderDescriptor.h"
25
+ #include "GPUComputePipeline.h"
26
+ #include "GPUComputePipelineDescriptor.h"
27
+ #include "GPUDeviceLostInfo.h"
28
+ #include "GPUError.h"
29
+ #include "GPUExternalTexture.h"
30
+ #include "GPUExternalTextureDescriptor.h"
31
+ #include "GPUPipelineLayout.h"
32
+ #include "GPUPipelineLayoutDescriptor.h"
33
+ #include "GPUQuerySet.h"
34
+ #include "GPUQuerySetDescriptor.h"
35
+ #include "GPUQueue.h"
36
+ #include "GPURenderBundleEncoder.h"
37
+ #include "GPURenderBundleEncoderDescriptor.h"
38
+ #include "GPURenderPipeline.h"
39
+ #include "GPURenderPipelineDescriptor.h"
40
+ #include "GPUSampler.h"
41
+ #include "GPUSamplerDescriptor.h"
42
+ #include "GPUShaderModule.h"
43
+ #include "GPUShaderModuleDescriptor.h"
44
+ #include "GPUSupportedLimits.h"
45
+ #include "GPUTexture.h"
46
+ #include "GPUTextureDescriptor.h"
16
47
 
17
48
  namespace rnwgpu {
18
49
 
@@ -20,26 +51,109 @@ namespace m = margelo;
20
51
 
21
52
  class GPUDevice : public m::HybridObject {
22
53
  public:
23
- explicit GPUDevice(wgpu::Device instance, std::string label)
24
- : HybridObject("GPUDevice"), _instance(instance), _label(label) {}
54
+ explicit GPUDevice(wgpu::Device instance, std::shared_ptr<AsyncRunner> async,
55
+ std::string label)
56
+ : HybridObject("GPUDevice"), _instance(instance), _async(async),
57
+ _label(label) {
58
+ m_lostPromise =
59
+ std::make_shared<std::promise<std::shared_ptr<GPUDeviceLostInfo>>>();
60
+ }
25
61
 
26
62
  public:
27
63
  std::string getBrand() { return _name; }
28
64
 
65
+ void destroy();
29
66
  std::shared_ptr<GPUBuffer>
30
67
  createBuffer(std::shared_ptr<GPUBufferDescriptor> descriptor);
68
+ std::shared_ptr<GPUTexture>
69
+ createTexture(std::shared_ptr<GPUTextureDescriptor> descriptor);
70
+ std::shared_ptr<GPUSampler> createSampler(
71
+ std::optional<std::shared_ptr<GPUSamplerDescriptor>> descriptor);
72
+ std::shared_ptr<GPUExternalTexture> importExternalTexture(
73
+ std::shared_ptr<GPUExternalTextureDescriptor> descriptor);
74
+ std::shared_ptr<GPUBindGroupLayout> createBindGroupLayout(
75
+ std::shared_ptr<GPUBindGroupLayoutDescriptor> descriptor);
76
+ std::shared_ptr<GPUPipelineLayout>
77
+ createPipelineLayout(std::shared_ptr<GPUPipelineLayoutDescriptor> descriptor);
78
+ std::shared_ptr<GPUBindGroup>
79
+ createBindGroup(std::shared_ptr<GPUBindGroupDescriptor> descriptor);
80
+ std::shared_ptr<GPUShaderModule>
81
+ createShaderModule(std::shared_ptr<GPUShaderModuleDescriptor> descriptor);
82
+ std::shared_ptr<GPUComputePipeline> createComputePipeline(
83
+ std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
84
+ std::shared_ptr<GPURenderPipeline>
85
+ createRenderPipeline(std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
86
+ std::future<std::shared_ptr<GPUComputePipeline>> createComputePipelineAsync(
87
+ std::shared_ptr<GPUComputePipelineDescriptor> descriptor);
88
+ std::future<std::shared_ptr<GPURenderPipeline>> createRenderPipelineAsync(
89
+ std::shared_ptr<GPURenderPipelineDescriptor> descriptor);
90
+ std::shared_ptr<GPUCommandEncoder> createCommandEncoder(
91
+ std::optional<std::shared_ptr<GPUCommandEncoderDescriptor>> descriptor);
92
+ std::shared_ptr<GPURenderBundleEncoder> createRenderBundleEncoder(
93
+ std::shared_ptr<GPURenderBundleEncoderDescriptor> descriptor);
94
+ std::shared_ptr<GPUQuerySet>
95
+ createQuerySet(std::shared_ptr<GPUQuerySetDescriptor> descriptor);
96
+ void pushErrorScope(wgpu::ErrorFilter filter);
97
+ std::future<std::variant<std::nullptr_t, std::shared_ptr<GPUError>>>
98
+ popErrorScope();
99
+
100
+ std::unordered_set<std::string> getFeatures();
101
+ std::shared_ptr<GPUSupportedLimits> getLimits();
102
+ std::shared_ptr<GPUQueue> getQueue();
103
+ std::future<std::shared_ptr<GPUDeviceLostInfo>> getLost();
31
104
 
32
105
  std::string getLabel() { return _label; }
106
+ void setLabel(const std::string &label) {
107
+ _label = label;
108
+ _instance.SetLabel(_label.c_str());
109
+ }
33
110
 
34
111
  void loadHybridMethods() override {
35
112
  registerHybridGetter("__brand", &GPUDevice::getBrand, this);
113
+ registerHybridMethod("destroy", &GPUDevice::destroy, this);
36
114
  registerHybridMethod("createBuffer", &GPUDevice::createBuffer, this);
37
-
115
+ registerHybridMethod("createTexture", &GPUDevice::createTexture, this);
116
+ registerHybridMethod("createSampler", &GPUDevice::createSampler, this);
117
+ registerHybridMethod("importExternalTexture",
118
+ &GPUDevice::importExternalTexture, this);
119
+ registerHybridMethod("createBindGroupLayout",
120
+ &GPUDevice::createBindGroupLayout, this);
121
+ registerHybridMethod("createPipelineLayout",
122
+ &GPUDevice::createPipelineLayout, this);
123
+ registerHybridMethod("createBindGroup", &GPUDevice::createBindGroup, this);
124
+ registerHybridMethod("createShaderModule", &GPUDevice::createShaderModule,
125
+ this);
126
+ registerHybridMethod("createComputePipeline",
127
+ &GPUDevice::createComputePipeline, this);
128
+ registerHybridMethod("createRenderPipeline",
129
+ &GPUDevice::createRenderPipeline, this);
130
+ registerHybridMethod("createComputePipelineAsync",
131
+ &GPUDevice::createComputePipelineAsync, this);
132
+ registerHybridMethod("createRenderPipelineAsync",
133
+ &GPUDevice::createRenderPipelineAsync, this);
134
+ registerHybridMethod("createCommandEncoder",
135
+ &GPUDevice::createCommandEncoder, this);
136
+ registerHybridMethod("createRenderBundleEncoder",
137
+ &GPUDevice::createRenderBundleEncoder, this);
138
+ registerHybridMethod("createQuerySet", &GPUDevice::createQuerySet, this);
139
+ registerHybridMethod("pushErrorScope", &GPUDevice::pushErrorScope, this);
140
+ registerHybridMethod("popErrorScope", &GPUDevice::popErrorScope, this);
141
+ registerHybridGetter("features", &GPUDevice::getFeatures, this);
142
+ registerHybridGetter("limits", &GPUDevice::getLimits, this);
143
+ registerHybridGetter("queue", &GPUDevice::getQueue, this);
144
+ registerHybridGetter("lost", &GPUDevice::getLost, this);
38
145
  registerHybridGetter("label", &GPUDevice::getLabel, this);
146
+ registerHybridSetter("label", &GPUDevice::setLabel, this);
39
147
  }
40
148
 
149
+ inline const wgpu::Device get() { return _instance; }
150
+
41
151
  private:
42
152
  wgpu::Device _instance;
153
+ std::shared_ptr<AsyncRunner> _async;
43
154
  std::string _label;
155
+ std::shared_ptr<std::promise<std::shared_ptr<GPUDeviceLostInfo>>>
156
+ m_lostPromise;
44
157
  };
158
+
45
159
  } // namespace rnwgpu
@@ -0,0 +1,6 @@
1
+ #include "GPUDeviceLostInfo.h"
2
+
3
+ namespace rnwgpu {
4
+ wgpu::DeviceLostReason getReason();
5
+ std::string getMessage();
6
+ } // 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
 
@@ -17,17 +16,25 @@ namespace m = margelo;
17
16
 
18
17
  class GPUDeviceLostInfo : public m::HybridObject {
19
18
  public:
20
- explicit GPUDeviceLostInfo(wgpu::DeviceLostInfo instance)
21
- : HybridObject("GPUDeviceLostInfo"), _instance(instance) {}
19
+ explicit GPUDeviceLostInfo(wgpu::DeviceLostReason reason, std::string message)
20
+ : HybridObject("GPUDeviceLostInfo"), _reason(reason), _message(message) {}
22
21
 
23
22
  public:
24
23
  std::string getBrand() { return _name; }
25
24
 
25
+ wgpu::DeviceLostReason getReason() { return _reason; }
26
+ std::string getMessage() { return _message; }
27
+
26
28
  void loadHybridMethods() override {
27
29
  registerHybridGetter("__brand", &GPUDeviceLostInfo::getBrand, this);
30
+
31
+ registerHybridGetter("reason", &GPUDeviceLostInfo::getReason, this);
32
+ registerHybridGetter("message", &GPUDeviceLostInfo::getMessage, this);
28
33
  }
29
34
 
30
35
  private:
31
- wgpu::DeviceLostInfo _instance;
36
+ wgpu::DeviceLostReason _reason;
37
+ std::string _message;
32
38
  };
39
+
33
40
  } // namespace rnwgpu
@@ -0,0 +1,42 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include "webgpu/webgpu_cpp.h"
6
+
7
+ #include "RNFEnumMapper.h"
8
+ #include "RNFJSIConverter.h"
9
+
10
+ namespace rnwgpu {
11
+
12
+ class GPUError {
13
+
14
+ public:
15
+ GPUError(wgpu::ErrorType aType, char const *aMessage)
16
+ : type(aType), message(aMessage) {}
17
+
18
+ wgpu::ErrorType type;
19
+ char const *message;
20
+ };
21
+
22
+ } // namespace rnwgpu
23
+
24
+ namespace margelo {
25
+
26
+ using namespace rnwgpu; // NOLINT(build/namespaces)
27
+
28
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUError>> {
29
+ static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
30
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
31
+ throw std::runtime_error("Invalid GPUBindGroupEntry::fromJSI()");
32
+ }
33
+ static jsi::Value toJSI(jsi::Runtime &runtime,
34
+ std::shared_ptr<rnwgpu::GPUError> arg) {
35
+ jsi::Object result(runtime);
36
+ result.setProperty(runtime, "message",
37
+ jsi::String::createFromUtf8(runtime, arg->message));
38
+ return result;
39
+ }
40
+ };
41
+
42
+ } // namespace margelo
@@ -0,0 +1,69 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include "RNFJSIConverter.h"
6
+
7
+ #include "webgpu/webgpu_cpp.h"
8
+
9
+ namespace rnwgpu {
10
+
11
+ struct GPUExtent3D {
12
+ double width;
13
+ double height = 1;
14
+ double depthOrArrayLayers = 1;
15
+ };
16
+
17
+ } // namespace rnwgpu
18
+
19
+ namespace margelo {
20
+
21
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUExtent3D>> {
22
+ static std::shared_ptr<rnwgpu::GPUExtent3D>
23
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
24
+ auto result = std::make_unique<rnwgpu::GPUExtent3D>();
25
+ if (!outOfBounds && arg.isObject()) {
26
+ if (arg.getObject(runtime).isArray(runtime)) {
27
+ auto array = arg.getObject(runtime).asArray(runtime);
28
+ auto size = array.size(runtime);
29
+ if (size == 0) {
30
+ throw std::runtime_error(
31
+ "Expected an array of size >1 for GPUTExtent3D");
32
+ }
33
+ if (size > 0) {
34
+ result->width = array.getValueAtIndex(runtime, 0).asNumber();
35
+ }
36
+ if (size > 1) {
37
+ result->height = array.getValueAtIndex(runtime, 1).asNumber();
38
+ }
39
+ if (size > 2) {
40
+ result->depthOrArrayLayers =
41
+ array.getValueAtIndex(runtime, 2).asNumber();
42
+ }
43
+ } else {
44
+ auto object = arg.getObject(runtime);
45
+ if (object.hasProperty(runtime, "width")) {
46
+ result->width = object.getProperty(runtime, "width").asNumber();
47
+ } else {
48
+ throw std::runtime_error("Property GPUTExtent3D::width is required");
49
+ }
50
+ if (object.hasProperty(runtime, "height")) {
51
+ result->height = object.getProperty(runtime, "height").asNumber();
52
+ }
53
+ if (object.hasProperty(runtime, "depthOrArrayLayers")) {
54
+ result->depthOrArrayLayers =
55
+ object.getProperty(runtime, "depthOrArrayLayers").asNumber();
56
+ }
57
+ }
58
+ } else {
59
+ throw std::runtime_error("Expected an object for GPUTExtent3D");
60
+ }
61
+ return result;
62
+ }
63
+ static jsi::Value toJSI(jsi::Runtime &runtime,
64
+ std::shared_ptr<rnwgpu::GPUExtent3D> arg) {
65
+ // No conversions here
66
+ return jsi::Value::null();
67
+ }
68
+ };
69
+ } // namespace margelo
@@ -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
 
@@ -25,15 +24,23 @@ public:
25
24
  std::string getBrand() { return _name; }
26
25
 
27
26
  std::string getLabel() { return _label; }
27
+ void setLabel(const std::string &label) {
28
+ _label = label;
29
+ _instance.SetLabel(_label.c_str());
30
+ }
28
31
 
29
32
  void loadHybridMethods() override {
30
33
  registerHybridGetter("__brand", &GPUExternalTexture::getBrand, this);
31
34
 
32
35
  registerHybridGetter("label", &GPUExternalTexture::getLabel, this);
36
+ registerHybridSetter("label", &GPUExternalTexture::setLabel, this);
33
37
  }
34
38
 
39
+ inline const wgpu::ExternalTexture get() { return _instance; }
40
+
35
41
  private:
36
42
  wgpu::ExternalTexture _instance;
37
43
  std::string _label;
38
44
  };
45
+
39
46
  } // namespace rnwgpu
@@ -0,0 +1,221 @@
1
+ #pragma once
2
+
3
+ #include <string>
4
+
5
+ #include "webgpu/webgpu_cpp.h"
6
+
7
+ #include "WGPULogger.h"
8
+
9
+ namespace rnwgpu {
10
+
11
+ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
12
+ std::string *outUnion) {
13
+ switch (inEnum) {
14
+ case wgpu::FeatureName::DepthClipControl:
15
+ *outUnion = "depth-clip-control";
16
+ break;
17
+ case wgpu::FeatureName::Depth32FloatStencil8:
18
+ *outUnion = "depth32float-stencil8";
19
+ break;
20
+ case wgpu::FeatureName::TimestampQuery:
21
+ *outUnion = "timestamp-query";
22
+ break;
23
+ case wgpu::FeatureName::TextureCompressionBC:
24
+ *outUnion = "texture-compression-bc";
25
+ break;
26
+ case wgpu::FeatureName::TextureCompressionETC2:
27
+ *outUnion = "texture-compression-etc2";
28
+ break;
29
+ case wgpu::FeatureName::TextureCompressionASTC:
30
+ *outUnion = "texture-compression-astc";
31
+ break;
32
+ case wgpu::FeatureName::IndirectFirstInstance:
33
+ *outUnion = "indirect-first-instance";
34
+ break;
35
+ case wgpu::FeatureName::ShaderF16:
36
+ *outUnion = "shader-f16";
37
+ break;
38
+ case wgpu::FeatureName::RG11B10UfloatRenderable:
39
+ *outUnion = "rg11b10ufloat-renderable";
40
+ break;
41
+ case wgpu::FeatureName::BGRA8UnormStorage:
42
+ *outUnion = "bgra8unorm-storage";
43
+ break;
44
+ case wgpu::FeatureName::Float32Filterable:
45
+ *outUnion = "float32-filterable";
46
+ break;
47
+ case wgpu::FeatureName::Subgroups:
48
+ *outUnion = "subgroups";
49
+ break;
50
+ case wgpu::FeatureName::SubgroupsF16:
51
+ *outUnion = "subgroups-f16";
52
+ break;
53
+ case wgpu::FeatureName::DawnInternalUsages:
54
+ *outUnion = "dawn-internal-usages";
55
+ break;
56
+ case wgpu::FeatureName::DawnMultiPlanarFormats:
57
+ *outUnion = "dawn-multi-planar-formats";
58
+ break;
59
+ case wgpu::FeatureName::DawnNative:
60
+ *outUnion = "dawn-native";
61
+ break;
62
+ case wgpu::FeatureName::ChromiumExperimentalTimestampQueryInsidePasses:
63
+ *outUnion = "chromium-experimental-timestamp-query-inside-passes";
64
+ break;
65
+ case wgpu::FeatureName::ImplicitDeviceSynchronization:
66
+ *outUnion = "implicit-device-synchronization";
67
+ break;
68
+ case wgpu::FeatureName::SurfaceCapabilities:
69
+ *outUnion = "surface-capabilities";
70
+ break;
71
+ case wgpu::FeatureName::TransientAttachments:
72
+ *outUnion = "transient-attachments";
73
+ break;
74
+ case wgpu::FeatureName::MSAARenderToSingleSampled:
75
+ *outUnion = "msaa-render-to-single-sampled";
76
+ break;
77
+ case wgpu::FeatureName::DualSourceBlending:
78
+ *outUnion = "dual-source-blending";
79
+ break;
80
+ case wgpu::FeatureName::D3D11MultithreadProtected:
81
+ *outUnion = "d3d11-multithread-protected";
82
+ break;
83
+ case wgpu::FeatureName::ANGLETextureSharing:
84
+ *outUnion = "angle-texture-sharing";
85
+ break;
86
+ case wgpu::FeatureName::ChromiumExperimentalSubgroups:
87
+ *outUnion = "chromium-experimental-subgroups";
88
+ break;
89
+ case wgpu::FeatureName::ChromiumExperimentalSubgroupUniformControlFlow:
90
+ *outUnion = "chromium-experimental-subgroup-uniform-control-flow";
91
+ break;
92
+ case wgpu::FeatureName::PixelLocalStorageCoherent:
93
+ *outUnion = "pixel-local-storage-coherent";
94
+ break;
95
+ case wgpu::FeatureName::PixelLocalStorageNonCoherent:
96
+ *outUnion = "pixel-local-storage-non-coherent";
97
+ break;
98
+ case wgpu::FeatureName::Unorm16TextureFormats:
99
+ *outUnion = "unorm16-texture-formats";
100
+ break;
101
+ case wgpu::FeatureName::Snorm16TextureFormats:
102
+ *outUnion = "snorm16-texture-formats";
103
+ break;
104
+ case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
105
+ *outUnion = "multi-planar-format-extended-usages";
106
+ break;
107
+ case wgpu::FeatureName::MultiPlanarFormatP010:
108
+ *outUnion = "multi-planar-format-p010";
109
+ break;
110
+ case wgpu::FeatureName::HostMappedPointer:
111
+ *outUnion = "host-mapped-pointer";
112
+ break;
113
+ case wgpu::FeatureName::MultiPlanarRenderTargets:
114
+ *outUnion = "multi-planar-render-targets";
115
+ break;
116
+ case wgpu::FeatureName::MultiPlanarFormatNv12a:
117
+ *outUnion = "multi-planar-format-nv12a";
118
+ break;
119
+ case wgpu::FeatureName::FramebufferFetch:
120
+ *outUnion = "framebuffer-fetch";
121
+ break;
122
+ case wgpu::FeatureName::BufferMapExtendedUsages:
123
+ *outUnion = "buffer-map-extended-usages";
124
+ break;
125
+ case wgpu::FeatureName::AdapterPropertiesMemoryHeaps:
126
+ *outUnion = "adapter-properties-memory-heaps";
127
+ break;
128
+ case wgpu::FeatureName::AdapterPropertiesD3D:
129
+ *outUnion = "adapter-properties-d3d";
130
+ break;
131
+ case wgpu::FeatureName::AdapterPropertiesVk:
132
+ *outUnion = "adapter-properties-vk";
133
+ break;
134
+ case wgpu::FeatureName::R8UnormStorage:
135
+ *outUnion = "r8unorm-storage";
136
+ break;
137
+ case wgpu::FeatureName::FormatCapabilities:
138
+ *outUnion = "format-capabilities";
139
+ break;
140
+ case wgpu::FeatureName::DrmFormatCapabilities:
141
+ *outUnion = "drm-format-capabilities";
142
+ break;
143
+ case wgpu::FeatureName::Norm16TextureFormats:
144
+ *outUnion = "norm16-texture-formats";
145
+ break;
146
+ case wgpu::FeatureName::MultiPlanarFormatNv16:
147
+ *outUnion = "multi-planar-format-nv16";
148
+ break;
149
+ case wgpu::FeatureName::MultiPlanarFormatNv24:
150
+ *outUnion = "multi-planar-format-nv24";
151
+ break;
152
+ case wgpu::FeatureName::MultiPlanarFormatP210:
153
+ *outUnion = "multi-planar-format-p210";
154
+ break;
155
+ case wgpu::FeatureName::MultiPlanarFormatP410:
156
+ *outUnion = "multi-planar-format-p410";
157
+ break;
158
+ case wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation:
159
+ *outUnion = "shared-texture-memory-vk-dedicated-allocation";
160
+ break;
161
+ case wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer:
162
+ *outUnion = "shared-texture-memory-ahardware-buffer";
163
+ break;
164
+ case wgpu::FeatureName::SharedTextureMemoryDmaBuf:
165
+ *outUnion = "shared-texture-memory-dma-buf";
166
+ break;
167
+ case wgpu::FeatureName::SharedTextureMemoryOpaqueFD:
168
+ *outUnion = "shared-texture-memory-opaque-fd";
169
+ break;
170
+ case wgpu::FeatureName::SharedTextureMemoryZirconHandle:
171
+ *outUnion = "shared-texture-memory-zircon-handle";
172
+ break;
173
+ case wgpu::FeatureName::SharedTextureMemoryDXGISharedHandle:
174
+ *outUnion = "shared-texture-memory-dxgi-shared-handle";
175
+ break;
176
+ case wgpu::FeatureName::SharedTextureMemoryD3D11Texture2D:
177
+ *outUnion = "shared-texture-memory-d3d11-texture2d";
178
+ break;
179
+ case wgpu::FeatureName::SharedTextureMemoryIOSurface:
180
+ *outUnion = "shared-texture-memory-iosurface";
181
+ break;
182
+ case wgpu::FeatureName::SharedTextureMemoryEGLImage:
183
+ *outUnion = "shared-texture-memory-egl-image";
184
+ break;
185
+ case wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD:
186
+ *outUnion = "shared-fence-vk-semaphore-opaque-fd";
187
+ break;
188
+ case wgpu::FeatureName::SharedFenceVkSemaphoreSyncFD:
189
+ *outUnion = "shared-fence-vk-semaphore-sync-fd";
190
+ break;
191
+ case wgpu::FeatureName::SharedFenceVkSemaphoreZirconHandle:
192
+ *outUnion = "shared-fence-vk-semaphore-zircon-handle";
193
+ break;
194
+ case wgpu::FeatureName::SharedFenceDXGISharedHandle:
195
+ *outUnion = "shared-fence-dxgi-shared-handle";
196
+ break;
197
+ case wgpu::FeatureName::SharedFenceMTLSharedEvent:
198
+ *outUnion = "shared-fence-mtl-shared-event";
199
+ break;
200
+ case wgpu::FeatureName::SharedBufferMemoryD3D12Resource:
201
+ *outUnion = "shared-buffer-memory-d3d12-resource";
202
+ break;
203
+ case wgpu::FeatureName::StaticSamplers:
204
+ *outUnion = "static-samplers";
205
+ break;
206
+ case wgpu::FeatureName::YCbCrVulkanSamplers:
207
+ *outUnion = "ycbcr-vulkan-samplers";
208
+ break;
209
+ case wgpu::FeatureName::ShaderModuleCompilationOptions:
210
+ *outUnion = "shader-module-compilation-options";
211
+ break;
212
+ case wgpu::FeatureName::DawnLoadResolveTexture:
213
+ *outUnion = "dawn-load-resolve-texture";
214
+ break;
215
+ default:
216
+ Logger::logToConsole("Unknown feature name %d", inEnum);
217
+ *outUnion = "";
218
+ }
219
+ }
220
+
221
+ } // namespace rnwgpu
@@ -0,0 +1,59 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+
5
+ #include "RNFJSIConverter.h"
6
+
7
+ #include "webgpu/webgpu_cpp.h"
8
+
9
+ namespace rnwgpu {
10
+
11
+ struct GPUOrigin2D {
12
+ double x = 0;
13
+ double y = 0;
14
+ };
15
+
16
+ } // namespace rnwgpu
17
+
18
+ namespace margelo {
19
+
20
+ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUOrigin2D>> {
21
+ static std::shared_ptr<rnwgpu::GPUOrigin2D>
22
+ fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
23
+ auto result = std::make_unique<rnwgpu::GPUOrigin2D>();
24
+ if (!outOfBounds && arg.isObject()) {
25
+ if (arg.getObject(runtime).isArray(runtime)) {
26
+ auto array = arg.getObject(runtime).asArray(runtime);
27
+ auto size = array.size(runtime);
28
+ if (size == 0) {
29
+ throw std::runtime_error(
30
+ "Expected an array of size >1 for GPUTExtent2D");
31
+ }
32
+ if (size > 0) {
33
+ result->x = array.getValueAtIndex(runtime, 0).asNumber();
34
+ }
35
+ if (size > 1) {
36
+ result->y = array.getValueAtIndex(runtime, 1).asNumber();
37
+ }
38
+ } else {
39
+ auto object = arg.getObject(runtime);
40
+ if (object.hasProperty(runtime, "x")) {
41
+ result->x = object.getProperty(runtime, "x").asNumber();
42
+ }
43
+ if (object.hasProperty(runtime, "y")) {
44
+ result->y = object.getProperty(runtime, "y").asNumber();
45
+ }
46
+ }
47
+ } else {
48
+ throw std::runtime_error("Expected an object for GPUOrigin3D");
49
+ }
50
+ return result;
51
+ }
52
+ static jsi::Value toJSI(jsi::Runtime &runtime,
53
+ std::shared_ptr<rnwgpu::GPUOrigin2D> arg) {
54
+ // No conversions here
55
+ return jsi::Value::null();
56
+ }
57
+ };
58
+
59
+ } // namespace margelo