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,24 +1,79 @@
1
1
  package com.webgpu;
2
2
 
3
- import androidx.annotation.Nullable;
3
+ import androidx.annotation.NonNull;
4
4
 
5
5
  import android.content.Context;
6
- import android.util.AttributeSet;
6
+ import android.view.Surface;
7
+ import android.view.SurfaceHolder;
8
+ import android.view.SurfaceView;
7
9
 
8
- import android.view.View;
10
+ import com.facebook.proguard.annotations.DoNotStrip;
11
+ import com.facebook.react.uimanager.ThemedReactContext;
9
12
 
10
- public class WebGPUView extends View {
13
+ public class WebGPUView extends SurfaceView implements SurfaceHolder.Callback {
14
+
15
+ private Integer mContextId;
16
+ private WebGPUModule mModule;
11
17
 
12
18
  public WebGPUView(Context context) {
13
19
  super(context);
20
+ getHolder().addCallback(this);
21
+ }
22
+
23
+ public void setContextId(Integer contextId) {
24
+ if (mModule == null) {
25
+ Context context = getContext();
26
+ if (context instanceof ThemedReactContext) {
27
+ mModule = ((ThemedReactContext) context).getReactApplicationContext().getNativeModule(WebGPUModule.class);
28
+ }
29
+ }
30
+ mContextId = contextId;
31
+ }
32
+
33
+ @Override
34
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
35
+ super.onLayout(changed, left, top, right, bottom);
14
36
  }
15
37
 
16
- public WebGPUView(Context context, @Nullable AttributeSet attrs) {
17
- super(context, attrs);
38
+ @Override
39
+ public void surfaceCreated(@NonNull SurfaceHolder holder) {
40
+ float density = getResources().getDisplayMetrics().density;
41
+ float width = getWidth() / density;
42
+ float height = getHeight() / density;
43
+ onSurfaceCreate(holder.getSurface(), mContextId, width, height);
44
+ mModule.onSurfaceCreated(mContextId);
18
45
  }
19
46
 
20
- public WebGPUView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
21
- super(context, attrs, defStyleAttr);
47
+ @Override
48
+ public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
49
+ float density = getResources().getDisplayMetrics().density;
50
+ float scaledWidth = width / density;
51
+ float scaledHeight = height / density;
52
+ onSurfaceChanged(holder.getSurface(), mContextId, scaledWidth, scaledHeight);
22
53
  }
23
54
 
55
+ @Override
56
+ public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
57
+ onSurfaceDestroy(mContextId);
58
+ }
59
+
60
+ @DoNotStrip
61
+ private native void onSurfaceCreate(
62
+ Surface surface,
63
+ int contextId,
64
+ float width,
65
+ float height
66
+ );
67
+
68
+ @DoNotStrip
69
+ private native void onSurfaceChanged(
70
+ Surface surface,
71
+ int contextId,
72
+ float width,
73
+ float height
74
+ );
75
+
76
+
77
+ @DoNotStrip
78
+ private native void onSurfaceDestroy(int contextId);
24
79
  }
@@ -1,8 +1,6 @@
1
1
  package com.webgpu;
2
2
 
3
- import android.graphics.Color;
4
-
5
- import androidx.annotation.Nullable;
3
+ import androidx.annotation.NonNull;
6
4
 
7
5
  import com.facebook.react.module.annotations.ReactModule;
8
6
  import com.facebook.react.uimanager.ThemedReactContext;
@@ -13,6 +11,7 @@ public class WebGPUViewManager extends WebGPUViewManagerSpec<WebGPUView> {
13
11
 
14
12
  public static final String NAME = "WebGPUView";
15
13
 
14
+ @NonNull
16
15
  @Override
17
16
  public String getName() {
18
17
  return NAME;
@@ -24,8 +23,8 @@ public class WebGPUViewManager extends WebGPUViewManagerSpec<WebGPUView> {
24
23
  }
25
24
 
26
25
  @Override
27
- @ReactProp(name = "color")
28
- public void setColor(WebGPUView view, @Nullable String color) {
29
- view.setBackgroundColor(Color.parseColor(color));
26
+ @ReactProp(name = "contextId")
27
+ public void setContextId(WebGPUView view, int value) {
28
+ view.setContextId(value);
30
29
  }
31
30
  }
@@ -6,14 +6,14 @@ import androidx.annotation.Nullable;
6
6
 
7
7
  import com.facebook.react.uimanager.SimpleViewManager;
8
8
  import com.facebook.react.uimanager.ViewManagerDelegate;
9
- import com.facebook.react.viewmanagers.WgpuViewManagerDelegate;
10
- import com.facebook.react.viewmanagers.WgpuViewManagerInterface;
9
+ import com.facebook.react.viewmanagers.WebGPUViewManagerDelegate;
10
+ import com.facebook.react.viewmanagers.WebGPUViewManagerInterface;
11
11
 
12
- public abstract class WgpuViewManagerSpec<T extends View> extends SimpleViewManager<T> implements WgpuViewManagerInterface<T> {
12
+ public abstract class WebGPUViewManagerSpec<T extends View> extends SimpleViewManager<T> implements WebGPUViewManagerInterface<T> {
13
13
  private final ViewManagerDelegate<T> mDelegate;
14
14
 
15
- public WgpuViewManagerSpec() {
16
- mDelegate = new WgpuViewManagerDelegate(this);
15
+ public WebGPUViewManagerSpec() {
16
+ mDelegate = new WebGPUViewManagerDelegate(this);
17
17
  }
18
18
 
19
19
  @Nullable
@@ -0,0 +1,23 @@
1
+ package com.webgpu;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
+
9
+ class NativeWebGPUModuleSpec extends ReactContextBaseJavaModule {
10
+
11
+ public static final String NAME = "WebGPUModule";
12
+
13
+ public NativeWebGPUModuleSpec(@Nullable ReactApplicationContext reactContext) {
14
+ super(reactContext);
15
+ }
16
+
17
+ @NonNull
18
+ @Override
19
+ public String getName() {
20
+ return NAME;
21
+ }
22
+
23
+ }
@@ -7,5 +7,5 @@ import androidx.annotation.Nullable;
7
7
  import com.facebook.react.uimanager.SimpleViewManager;
8
8
 
9
9
  public abstract class WebGPUViewManagerSpec<T extends View> extends SimpleViewManager<T> {
10
- public abstract void setColor(T view, @Nullable String value);
10
+ public abstract void setContextId(T view, int contextId);
11
11
  }
@@ -11,7 +11,7 @@
11
11
  #include <android/log.h>
12
12
  #endif
13
13
 
14
- #ifdef TARGET_OS_IPHONE
14
+ #ifdef __APPLE__
15
15
  #include <syslog.h>
16
16
  #endif
17
17
 
@@ -27,10 +27,10 @@ public:
27
27
  */
28
28
  static void logToConsole(std::string message) {
29
29
  #if defined(ANDROID) || defined(__ANDROID__)
30
- __android_log_write(ANDROID_LOG_INFO, "RNSkia", message.c_str());
30
+ __android_log_write(ANDROID_LOG_INFO, "WebGPU", message.c_str());
31
31
  #endif
32
32
 
33
- #ifdef TARGET_OS_IPHONE
33
+ #ifdef __APPLE__
34
34
  syslog(LOG_ERR, "%s\n", message.c_str());
35
35
  #endif
36
36
  }
@@ -47,10 +47,10 @@ public:
47
47
  static char buffer[512];
48
48
  vsnprintf(buffer, sizeof(buffer), fmt, args);
49
49
  #if defined(ANDROID) || defined(__ANDROID__)
50
- __android_log_write(ANDROID_LOG_INFO, "RNSkia", buffer);
50
+ __android_log_write(ANDROID_LOG_INFO, "WebGPU", buffer);
51
51
  #endif
52
- #ifdef TARGET_OS_IPHONE
53
- syslog(LOG_ERR, "RNSKIA: %s\n", buffer);
52
+ #ifdef __APPLE__
53
+ syslog(LOG_ERR, "WebGPU: %s\n", buffer);
54
54
  #endif
55
55
  va_end(args);
56
56
  }
@@ -69,6 +69,13 @@ public:
69
69
  warn.call(runtime, jsi::String::createFromUtf8(runtime, message));
70
70
  }
71
71
 
72
+ static void errorToJavascriptConsole(jsi::Runtime &runtime,
73
+ const std::string &message) {
74
+ auto console = Logger::getJavascriptConsole(runtime).asObject(runtime);
75
+ auto warn = console.getPropertyAsFunction(runtime, "error");
76
+ warn.call(runtime, jsi::String::createFromUtf8(runtime, message));
77
+ }
78
+
72
79
  private:
73
80
  static jsi::Value getJavascriptConsole(jsi::Runtime &runtime) {
74
81
  auto console = runtime.global().getProperty(runtime, "console");
package/cpp/dawn/webgpu.h CHANGED
@@ -124,6 +124,7 @@ typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE;
124
124
  typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE;
125
125
 
126
126
  // Structure forward declarations
127
+ struct WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER;
127
128
  struct WGPUAdapterInfo;
128
129
  struct WGPUAdapterProperties;
129
130
  struct WGPUAdapterPropertiesD3D;
@@ -482,6 +483,8 @@ typedef enum WGPUFeatureName {
482
483
  WGPUFeatureName_RG11B10UfloatRenderable = 0x00000009,
483
484
  WGPUFeatureName_BGRA8UnormStorage = 0x0000000A,
484
485
  WGPUFeatureName_Float32Filterable = 0x0000000B,
486
+ WGPUFeatureName_Subgroups = 0x0000000C,
487
+ WGPUFeatureName_SubgroupsF16 = 0x0000000D,
485
488
  WGPUFeatureName_DawnInternalUsages = 0x00050000,
486
489
  WGPUFeatureName_DawnMultiPlanarFormats = 0x00050001,
487
490
  WGPUFeatureName_DawnNative = 0x00050002,
@@ -1223,6 +1226,12 @@ typedef struct WGPUUncapturedErrorCallbackInfo2 {
1223
1226
  /*.userdata2=*/nullptr WGPU_COMMA \
1224
1227
  })
1225
1228
 
1229
+ typedef struct WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER {
1230
+ } WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER WGPU_STRUCTURE_ATTRIBUTE;
1231
+
1232
+ #define WGPU_INTERNAL__HAVE_EMDAWNWEBGPU_HEADER_INIT WGPU_MAKE_INIT_STRUCT(WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER, { \
1233
+ })
1234
+
1226
1235
  typedef struct WGPUAdapterInfo {
1227
1236
  WGPUChainedStructOut * nextInChain;
1228
1237
  char const * vendor;
@@ -25,7 +25,7 @@
25
25
  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
26
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  #ifdef __EMSCRIPTEN__
28
- #error "Do not include this header. Emscripten already provides headers needed for WebGPU."
28
+ #error "This header is for native Dawn. Use Dawn's or Emscripten's Emscripten bindings instead."
29
29
  #endif
30
30
  #ifndef WEBGPU_CPP_H_
31
31
  #define WEBGPU_CPP_H_
@@ -303,6 +303,8 @@ enum class FeatureName : uint32_t {
303
303
  RG11B10UfloatRenderable = WGPUFeatureName_RG11B10UfloatRenderable,
304
304
  BGRA8UnormStorage = WGPUFeatureName_BGRA8UnormStorage,
305
305
  Float32Filterable = WGPUFeatureName_Float32Filterable,
306
+ Subgroups = WGPUFeatureName_Subgroups,
307
+ SubgroupsF16 = WGPUFeatureName_SubgroupsF16,
306
308
  DawnInternalUsages = WGPUFeatureName_DawnInternalUsages,
307
309
  DawnMultiPlanarFormats = WGPUFeatureName_DawnMultiPlanarFormats,
308
310
  DawnNative = WGPUFeatureName_DawnNative,
@@ -1080,6 +1082,7 @@ class SwapChain;
1080
1082
  class Texture;
1081
1083
  class TextureView;
1082
1084
 
1085
+ struct INTERNAL__HAVE_EMDAWNWEBGPU_HEADER;
1083
1086
  struct AdapterInfo;
1084
1087
  struct AdapterProperties;
1085
1088
  struct AdapterPropertiesD3D;
@@ -1867,6 +1870,11 @@ static_assert(offsetof(ChainedStruct, sType) == offsetof(WGPUChainedStruct, sTyp
1867
1870
  "offsetof mismatch for ChainedStruct::sType");
1868
1871
 
1869
1872
 
1873
+ struct INTERNAL__HAVE_EMDAWNWEBGPU_HEADER {
1874
+ inline operator const WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER&() const noexcept;
1875
+
1876
+ };
1877
+
1870
1878
  struct AdapterInfo {
1871
1879
  inline AdapterInfo();
1872
1880
  inline ~AdapterInfo();
@@ -1888,6 +1896,7 @@ struct AdapterInfo {
1888
1896
  Bool const compatibilityMode = false;
1889
1897
 
1890
1898
  private:
1899
+ inline void FreeMembers();
1891
1900
  static inline void Reset(AdapterInfo& value);
1892
1901
  };
1893
1902
 
@@ -1912,6 +1921,7 @@ struct AdapterProperties {
1912
1921
  Bool const compatibilityMode = false;
1913
1922
 
1914
1923
  private:
1924
+ inline void FreeMembers();
1915
1925
  static inline void Reset(AdapterProperties& value);
1916
1926
  };
1917
1927
 
@@ -2678,6 +2688,7 @@ struct SharedBufferMemoryEndAccessState {
2678
2688
  uint64_t const * const signaledValues = {};
2679
2689
 
2680
2690
  private:
2691
+ inline void FreeMembers();
2681
2692
  static inline void Reset(SharedBufferMemoryEndAccessState& value);
2682
2693
  };
2683
2694
 
@@ -2927,6 +2938,7 @@ struct SharedTextureMemoryEndAccessState {
2927
2938
  uint64_t const * const signaledValues = {};
2928
2939
 
2929
2940
  private:
2941
+ inline void FreeMembers();
2930
2942
  static inline void Reset(SharedTextureMemoryEndAccessState& value);
2931
2943
  };
2932
2944
 
@@ -3046,6 +3058,7 @@ struct SurfaceCapabilities {
3046
3058
  CompositeAlphaMode const * const alphaModes = {};
3047
3059
 
3048
3060
  private:
3061
+ inline void FreeMembers();
3049
3062
  static inline void Reset(SurfaceCapabilities& value);
3050
3063
  };
3051
3064
 
@@ -3312,6 +3325,7 @@ struct AdapterPropertiesMemoryHeaps : ChainedStructOut {
3312
3325
  MemoryHeapInfo const * const heapInfo = {};
3313
3326
 
3314
3327
  private:
3328
+ inline void FreeMembers();
3315
3329
  static inline void Reset(AdapterPropertiesMemoryHeaps& value);
3316
3330
  };
3317
3331
 
@@ -3394,6 +3408,7 @@ struct DrmFormatCapabilities : ChainedStructOut {
3394
3408
  DrmFormatProperties const * const properties = {};
3395
3409
 
3396
3410
  private:
3411
+ inline void FreeMembers();
3397
3412
  static inline void Reset(DrmFormatCapabilities& value);
3398
3413
  };
3399
3414
 
@@ -3726,13 +3741,19 @@ struct DeviceDescriptor : protected detail::DeviceDescriptor {
3726
3741
  #pragma GCC diagnostic ignored "-Winvalid-offsetof"
3727
3742
  #endif
3728
3743
 
3744
+ // INTERNAL__HAVE_EMDAWNWEBGPU_HEADER implementation
3745
+
3746
+ INTERNAL__HAVE_EMDAWNWEBGPU_HEADER::operator const WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER&() const noexcept {
3747
+ return *reinterpret_cast<const WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER*>(this);
3748
+ }
3749
+
3750
+ static_assert(sizeof(INTERNAL__HAVE_EMDAWNWEBGPU_HEADER) == sizeof(WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER), "sizeof mismatch for INTERNAL__HAVE_EMDAWNWEBGPU_HEADER");
3751
+ static_assert(alignof(INTERNAL__HAVE_EMDAWNWEBGPU_HEADER) == alignof(WGPUINTERNAL__HAVE_EMDAWNWEBGPU_HEADER), "alignof mismatch for INTERNAL__HAVE_EMDAWNWEBGPU_HEADER");
3752
+
3729
3753
  // AdapterInfo implementation
3730
3754
  AdapterInfo::AdapterInfo() = default;
3731
3755
  AdapterInfo::~AdapterInfo() {
3732
- if (this->vendor != nullptr || this->architecture != nullptr || this->device != nullptr || this->description != nullptr) {
3733
- wgpuAdapterInfoFreeMembers(
3734
- *reinterpret_cast<WGPUAdapterInfo*>(this));
3735
- }
3756
+ FreeMembers();
3736
3757
  }
3737
3758
 
3738
3759
  AdapterInfo::AdapterInfo(AdapterInfo&& rhs)
@@ -3752,7 +3773,7 @@ AdapterInfo& AdapterInfo::operator=(AdapterInfo&& rhs) {
3752
3773
  if (&rhs == this) {
3753
3774
  return *this;
3754
3775
  }
3755
- this->~AdapterInfo();
3776
+ FreeMembers();
3756
3777
  ::wgpu::detail::AsNonConstReference(this->vendor) = std::move(rhs.vendor);
3757
3778
  ::wgpu::detail::AsNonConstReference(this->architecture) = std::move(rhs.architecture);
3758
3779
  ::wgpu::detail::AsNonConstReference(this->device) = std::move(rhs.device);
@@ -3766,7 +3787,14 @@ AdapterInfo& AdapterInfo::operator=(AdapterInfo&& rhs) {
3766
3787
  return *this;
3767
3788
  }
3768
3789
 
3769
- // static
3790
+ void AdapterInfo::FreeMembers() {
3791
+ if (this->vendor != nullptr || this->architecture != nullptr || this->device != nullptr || this->description != nullptr) {
3792
+ wgpuAdapterInfoFreeMembers(
3793
+ *reinterpret_cast<WGPUAdapterInfo*>(this));
3794
+ }
3795
+ }
3796
+
3797
+ // static
3770
3798
  void AdapterInfo::Reset(AdapterInfo& value) {
3771
3799
  AdapterInfo defaultValue{};
3772
3800
  ::wgpu::detail::AsNonConstReference(value.vendor) = defaultValue.vendor;
@@ -3810,10 +3838,7 @@ static_assert(offsetof(AdapterInfo, compatibilityMode) == offsetof(WGPUAdapterIn
3810
3838
  // AdapterProperties implementation
3811
3839
  AdapterProperties::AdapterProperties() = default;
3812
3840
  AdapterProperties::~AdapterProperties() {
3813
- if (this->vendorName != nullptr || this->architecture != nullptr || this->name != nullptr || this->driverDescription != nullptr) {
3814
- wgpuAdapterPropertiesFreeMembers(
3815
- *reinterpret_cast<WGPUAdapterProperties*>(this));
3816
- }
3841
+ FreeMembers();
3817
3842
  }
3818
3843
 
3819
3844
  AdapterProperties::AdapterProperties(AdapterProperties&& rhs)
@@ -3833,7 +3858,7 @@ AdapterProperties& AdapterProperties::operator=(AdapterProperties&& rhs) {
3833
3858
  if (&rhs == this) {
3834
3859
  return *this;
3835
3860
  }
3836
- this->~AdapterProperties();
3861
+ FreeMembers();
3837
3862
  ::wgpu::detail::AsNonConstReference(this->vendorID) = std::move(rhs.vendorID);
3838
3863
  ::wgpu::detail::AsNonConstReference(this->vendorName) = std::move(rhs.vendorName);
3839
3864
  ::wgpu::detail::AsNonConstReference(this->architecture) = std::move(rhs.architecture);
@@ -3847,7 +3872,14 @@ AdapterProperties& AdapterProperties::operator=(AdapterProperties&& rhs) {
3847
3872
  return *this;
3848
3873
  }
3849
3874
 
3850
- // static
3875
+ void AdapterProperties::FreeMembers() {
3876
+ if (this->vendorName != nullptr || this->architecture != nullptr || this->name != nullptr || this->driverDescription != nullptr) {
3877
+ wgpuAdapterPropertiesFreeMembers(
3878
+ *reinterpret_cast<WGPUAdapterProperties*>(this));
3879
+ }
3880
+ }
3881
+
3882
+ // static
3851
3883
  void AdapterProperties::Reset(AdapterProperties& value) {
3852
3884
  AdapterProperties defaultValue{};
3853
3885
  ::wgpu::detail::AsNonConstReference(value.vendorID) = defaultValue.vendorID;
@@ -5259,10 +5291,7 @@ static_assert(offsetof(SharedBufferMemoryDescriptor, label) == offsetof(WGPUShar
5259
5291
  // SharedBufferMemoryEndAccessState implementation
5260
5292
  SharedBufferMemoryEndAccessState::SharedBufferMemoryEndAccessState() = default;
5261
5293
  SharedBufferMemoryEndAccessState::~SharedBufferMemoryEndAccessState() {
5262
- if (this->fences != nullptr || this->signaledValues != nullptr) {
5263
- wgpuSharedBufferMemoryEndAccessStateFreeMembers(
5264
- *reinterpret_cast<WGPUSharedBufferMemoryEndAccessState*>(this));
5265
- }
5294
+ FreeMembers();
5266
5295
  }
5267
5296
 
5268
5297
  SharedBufferMemoryEndAccessState::SharedBufferMemoryEndAccessState(SharedBufferMemoryEndAccessState&& rhs)
@@ -5277,7 +5306,7 @@ SharedBufferMemoryEndAccessState& SharedBufferMemoryEndAccessState::operator=(Sh
5277
5306
  if (&rhs == this) {
5278
5307
  return *this;
5279
5308
  }
5280
- this->~SharedBufferMemoryEndAccessState();
5309
+ FreeMembers();
5281
5310
  ::wgpu::detail::AsNonConstReference(this->initialized) = std::move(rhs.initialized);
5282
5311
  ::wgpu::detail::AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount);
5283
5312
  ::wgpu::detail::AsNonConstReference(this->fences) = std::move(rhs.fences);
@@ -5286,7 +5315,14 @@ SharedBufferMemoryEndAccessState& SharedBufferMemoryEndAccessState::operator=(Sh
5286
5315
  return *this;
5287
5316
  }
5288
5317
 
5289
- // static
5318
+ void SharedBufferMemoryEndAccessState::FreeMembers() {
5319
+ if (this->fences != nullptr || this->signaledValues != nullptr) {
5320
+ wgpuSharedBufferMemoryEndAccessStateFreeMembers(
5321
+ *reinterpret_cast<WGPUSharedBufferMemoryEndAccessState*>(this));
5322
+ }
5323
+ }
5324
+
5325
+ // static
5290
5326
  void SharedBufferMemoryEndAccessState::Reset(SharedBufferMemoryEndAccessState& value) {
5291
5327
  SharedBufferMemoryEndAccessState defaultValue{};
5292
5328
  ::wgpu::detail::AsNonConstReference(value.initialized) = defaultValue.initialized;
@@ -5713,10 +5749,7 @@ static_assert(offsetof(SharedTextureMemoryDmaBufPlane, stride) == offsetof(WGPUS
5713
5749
  // SharedTextureMemoryEndAccessState implementation
5714
5750
  SharedTextureMemoryEndAccessState::SharedTextureMemoryEndAccessState() = default;
5715
5751
  SharedTextureMemoryEndAccessState::~SharedTextureMemoryEndAccessState() {
5716
- if (this->fences != nullptr || this->signaledValues != nullptr) {
5717
- wgpuSharedTextureMemoryEndAccessStateFreeMembers(
5718
- *reinterpret_cast<WGPUSharedTextureMemoryEndAccessState*>(this));
5719
- }
5752
+ FreeMembers();
5720
5753
  }
5721
5754
 
5722
5755
  SharedTextureMemoryEndAccessState::SharedTextureMemoryEndAccessState(SharedTextureMemoryEndAccessState&& rhs)
@@ -5731,7 +5764,7 @@ SharedTextureMemoryEndAccessState& SharedTextureMemoryEndAccessState::operator=(
5731
5764
  if (&rhs == this) {
5732
5765
  return *this;
5733
5766
  }
5734
- this->~SharedTextureMemoryEndAccessState();
5767
+ FreeMembers();
5735
5768
  ::wgpu::detail::AsNonConstReference(this->initialized) = std::move(rhs.initialized);
5736
5769
  ::wgpu::detail::AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount);
5737
5770
  ::wgpu::detail::AsNonConstReference(this->fences) = std::move(rhs.fences);
@@ -5740,7 +5773,14 @@ SharedTextureMemoryEndAccessState& SharedTextureMemoryEndAccessState::operator=(
5740
5773
  return *this;
5741
5774
  }
5742
5775
 
5743
- // static
5776
+ void SharedTextureMemoryEndAccessState::FreeMembers() {
5777
+ if (this->fences != nullptr || this->signaledValues != nullptr) {
5778
+ wgpuSharedTextureMemoryEndAccessStateFreeMembers(
5779
+ *reinterpret_cast<WGPUSharedTextureMemoryEndAccessState*>(this));
5780
+ }
5781
+ }
5782
+
5783
+ // static
5744
5784
  void SharedTextureMemoryEndAccessState::Reset(SharedTextureMemoryEndAccessState& value) {
5745
5785
  SharedTextureMemoryEndAccessState defaultValue{};
5746
5786
  ::wgpu::detail::AsNonConstReference(value.initialized) = defaultValue.initialized;
@@ -5951,10 +5991,7 @@ static_assert(offsetof(StorageTextureBindingLayout, viewDimension) == offsetof(W
5951
5991
  // SurfaceCapabilities implementation
5952
5992
  SurfaceCapabilities::SurfaceCapabilities() = default;
5953
5993
  SurfaceCapabilities::~SurfaceCapabilities() {
5954
- if (this->formats != nullptr || this->presentModes != nullptr || this->alphaModes != nullptr) {
5955
- wgpuSurfaceCapabilitiesFreeMembers(
5956
- *reinterpret_cast<WGPUSurfaceCapabilities*>(this));
5957
- }
5994
+ FreeMembers();
5958
5995
  }
5959
5996
 
5960
5997
  SurfaceCapabilities::SurfaceCapabilities(SurfaceCapabilities&& rhs)
@@ -5972,7 +6009,7 @@ SurfaceCapabilities& SurfaceCapabilities::operator=(SurfaceCapabilities&& rhs) {
5972
6009
  if (&rhs == this) {
5973
6010
  return *this;
5974
6011
  }
5975
- this->~SurfaceCapabilities();
6012
+ FreeMembers();
5976
6013
  ::wgpu::detail::AsNonConstReference(this->usages) = std::move(rhs.usages);
5977
6014
  ::wgpu::detail::AsNonConstReference(this->formatCount) = std::move(rhs.formatCount);
5978
6015
  ::wgpu::detail::AsNonConstReference(this->formats) = std::move(rhs.formats);
@@ -5984,7 +6021,14 @@ SurfaceCapabilities& SurfaceCapabilities::operator=(SurfaceCapabilities&& rhs) {
5984
6021
  return *this;
5985
6022
  }
5986
6023
 
5987
- // static
6024
+ void SurfaceCapabilities::FreeMembers() {
6025
+ if (this->formats != nullptr || this->presentModes != nullptr || this->alphaModes != nullptr) {
6026
+ wgpuSurfaceCapabilitiesFreeMembers(
6027
+ *reinterpret_cast<WGPUSurfaceCapabilities*>(this));
6028
+ }
6029
+ }
6030
+
6031
+ // static
5988
6032
  void SurfaceCapabilities::Reset(SurfaceCapabilities& value) {
5989
6033
  SurfaceCapabilities defaultValue{};
5990
6034
  ::wgpu::detail::AsNonConstReference(value.usages) = defaultValue.usages;
@@ -6494,10 +6538,7 @@ AdapterPropertiesMemoryHeaps::AdapterPropertiesMemoryHeaps(AdapterPropertiesMemo
6494
6538
  heapCount(std::move(init.heapCount)),
6495
6539
  heapInfo(std::move(init.heapInfo)){}
6496
6540
  AdapterPropertiesMemoryHeaps::~AdapterPropertiesMemoryHeaps() {
6497
- if (this->heapInfo != nullptr) {
6498
- wgpuAdapterPropertiesMemoryHeapsFreeMembers(
6499
- *reinterpret_cast<WGPUAdapterPropertiesMemoryHeaps*>(this));
6500
- }
6541
+ FreeMembers();
6501
6542
  }
6502
6543
 
6503
6544
  AdapterPropertiesMemoryHeaps::AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps&& rhs)
@@ -6510,14 +6551,21 @@ AdapterPropertiesMemoryHeaps& AdapterPropertiesMemoryHeaps::operator=(AdapterPro
6510
6551
  if (&rhs == this) {
6511
6552
  return *this;
6512
6553
  }
6513
- this->~AdapterPropertiesMemoryHeaps();
6554
+ FreeMembers();
6514
6555
  ::wgpu::detail::AsNonConstReference(this->heapCount) = std::move(rhs.heapCount);
6515
6556
  ::wgpu::detail::AsNonConstReference(this->heapInfo) = std::move(rhs.heapInfo);
6516
6557
  Reset(rhs);
6517
6558
  return *this;
6518
6559
  }
6519
6560
 
6520
- // static
6561
+ void AdapterPropertiesMemoryHeaps::FreeMembers() {
6562
+ if (this->heapInfo != nullptr) {
6563
+ wgpuAdapterPropertiesMemoryHeapsFreeMembers(
6564
+ *reinterpret_cast<WGPUAdapterPropertiesMemoryHeaps*>(this));
6565
+ }
6566
+ }
6567
+
6568
+ // static
6521
6569
  void AdapterPropertiesMemoryHeaps::Reset(AdapterPropertiesMemoryHeaps& value) {
6522
6570
  AdapterPropertiesMemoryHeaps defaultValue{};
6523
6571
  ::wgpu::detail::AsNonConstReference(value.heapCount) = defaultValue.heapCount;
@@ -6664,10 +6712,7 @@ DrmFormatCapabilities::DrmFormatCapabilities(DrmFormatCapabilities::Init&& init)
6664
6712
  propertiesCount(std::move(init.propertiesCount)),
6665
6713
  properties(std::move(init.properties)){}
6666
6714
  DrmFormatCapabilities::~DrmFormatCapabilities() {
6667
- if (this->properties != nullptr) {
6668
- wgpuDrmFormatCapabilitiesFreeMembers(
6669
- *reinterpret_cast<WGPUDrmFormatCapabilities*>(this));
6670
- }
6715
+ FreeMembers();
6671
6716
  }
6672
6717
 
6673
6718
  DrmFormatCapabilities::DrmFormatCapabilities(DrmFormatCapabilities&& rhs)
@@ -6680,14 +6725,21 @@ DrmFormatCapabilities& DrmFormatCapabilities::operator=(DrmFormatCapabilities&&
6680
6725
  if (&rhs == this) {
6681
6726
  return *this;
6682
6727
  }
6683
- this->~DrmFormatCapabilities();
6728
+ FreeMembers();
6684
6729
  ::wgpu::detail::AsNonConstReference(this->propertiesCount) = std::move(rhs.propertiesCount);
6685
6730
  ::wgpu::detail::AsNonConstReference(this->properties) = std::move(rhs.properties);
6686
6731
  Reset(rhs);
6687
6732
  return *this;
6688
6733
  }
6689
6734
 
6690
- // static
6735
+ void DrmFormatCapabilities::FreeMembers() {
6736
+ if (this->properties != nullptr) {
6737
+ wgpuDrmFormatCapabilitiesFreeMembers(
6738
+ *reinterpret_cast<WGPUDrmFormatCapabilities*>(this));
6739
+ }
6740
+ }
6741
+
6742
+ // static
6691
6743
  void DrmFormatCapabilities::Reset(DrmFormatCapabilities& value) {
6692
6744
  DrmFormatCapabilities defaultValue{};
6693
6745
  ::wgpu::detail::AsNonConstReference(value.propertiesCount) = defaultValue.propertiesCount;
@@ -610,6 +610,12 @@ namespace wgpu {
610
610
  case FeatureName::Float32Filterable:
611
611
  o << "FeatureName::Float32Filterable";
612
612
  break;
613
+ case FeatureName::Subgroups:
614
+ o << "FeatureName::Subgroups";
615
+ break;
616
+ case FeatureName::SubgroupsF16:
617
+ o << "FeatureName::SubgroupsF16";
618
+ break;
613
619
  case FeatureName::DawnInternalUsages:
614
620
  o << "FeatureName::DawnInternalUsages";
615
621
  break;