@nativescript/canvas 2.0.0-beta.8 → 2.0.0-webgpu.0

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 (284) hide show
  1. package/Canvas/common.d.ts +23 -15
  2. package/Canvas/common.js +125 -56
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +5 -7
  5. package/Canvas/index.android.js +61 -133
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +4 -1
  8. package/Canvas/index.ios.d.ts +6 -6
  9. package/Canvas/index.ios.js +75 -85
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -1
  12. package/Canvas2D/CanvasRenderingContext2D/index.js +8 -11
  13. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  14. package/Canvas2D/DOMMatrix/index.d.ts +14 -0
  15. package/Canvas2D/DOMMatrix/index.js +62 -0
  16. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  17. package/Canvas2D/ImageData/index.js +4 -6
  18. package/Canvas2D/ImageData/index.js.map +1 -1
  19. package/ImageAsset/index.d.ts +1 -0
  20. package/ImageAsset/index.js +49 -0
  21. package/ImageAsset/index.js.map +1 -1
  22. package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
  23. package/WebGL/WebGLRenderingContext/index.js +104 -14
  24. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  25. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
  26. package/WebGL2/WebGL2RenderingContext/index.js +2 -3
  27. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  28. package/WebGPU/Constants.d.ts +36 -0
  29. package/WebGPU/Constants.js +42 -0
  30. package/WebGPU/Constants.js.map +1 -0
  31. package/WebGPU/Errors.d.ts +18 -0
  32. package/WebGPU/Errors.js +21 -0
  33. package/WebGPU/Errors.js.map +1 -0
  34. package/WebGPU/GPU.d.ts +13 -0
  35. package/WebGPU/GPU.js +35 -0
  36. package/WebGPU/GPU.js.map +1 -0
  37. package/WebGPU/GPUAdapter.d.ts +23 -0
  38. package/WebGPU/GPUAdapter.js +62 -0
  39. package/WebGPU/GPUAdapter.js.map +1 -0
  40. package/WebGPU/GPUAdapterInfo.d.ts +9 -0
  41. package/WebGPU/GPUAdapterInfo.js +24 -0
  42. package/WebGPU/GPUAdapterInfo.js.map +1 -0
  43. package/WebGPU/GPUBindGroup.d.ts +5 -0
  44. package/WebGPU/GPUBindGroup.js +12 -0
  45. package/WebGPU/GPUBindGroup.js.map +1 -0
  46. package/WebGPU/GPUBindGroupLayout.d.ts +5 -0
  47. package/WebGPU/GPUBindGroupLayout.js +12 -0
  48. package/WebGPU/GPUBindGroupLayout.js.map +1 -0
  49. package/WebGPU/GPUBuffer.d.ts +15 -0
  50. package/WebGPU/GPUBuffer.js +54 -0
  51. package/WebGPU/GPUBuffer.js.map +1 -0
  52. package/WebGPU/GPUCanvasContext.d.ts +33 -0
  53. package/WebGPU/GPUCanvasContext.js +67 -0
  54. package/WebGPU/GPUCanvasContext.js.map +1 -0
  55. package/WebGPU/GPUCommandBuffer.d.ts +5 -0
  56. package/WebGPU/GPUCommandBuffer.js +12 -0
  57. package/WebGPU/GPUCommandBuffer.js.map +1 -0
  58. package/WebGPU/GPUCommandEncoder.d.ts +41 -0
  59. package/WebGPU/GPUCommandEncoder.js +105 -0
  60. package/WebGPU/GPUCommandEncoder.js.map +1 -0
  61. package/WebGPU/GPUComputePassEncoder.d.ts +16 -0
  62. package/WebGPU/GPUComputePassEncoder.js +50 -0
  63. package/WebGPU/GPUComputePassEncoder.js.map +1 -0
  64. package/WebGPU/GPUComputePipeline.d.ts +7 -0
  65. package/WebGPU/GPUComputePipeline.js +16 -0
  66. package/WebGPU/GPUComputePipeline.js.map +1 -0
  67. package/WebGPU/GPUDevice.d.ts +173 -0
  68. package/WebGPU/GPUDevice.js +381 -0
  69. package/WebGPU/GPUDevice.js.map +1 -0
  70. package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
  71. package/WebGPU/GPUDeviceLostInfo.js +10 -0
  72. package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
  73. package/WebGPU/GPUExternalTexture.d.ts +5 -0
  74. package/WebGPU/GPUExternalTexture.js +12 -0
  75. package/WebGPU/GPUExternalTexture.js.map +1 -0
  76. package/WebGPU/GPUPipelineLayout.d.ts +5 -0
  77. package/WebGPU/GPUPipelineLayout.js +12 -0
  78. package/WebGPU/GPUPipelineLayout.js.map +1 -0
  79. package/WebGPU/GPUQuerySet.d.ts +5 -0
  80. package/WebGPU/GPUQuerySet.js +12 -0
  81. package/WebGPU/GPUQuerySet.js.map +1 -0
  82. package/WebGPU/GPUQueue.d.ts +14 -0
  83. package/WebGPU/GPUQueue.js +77 -0
  84. package/WebGPU/GPUQueue.js.map +1 -0
  85. package/WebGPU/GPURenderBundle.d.ts +5 -0
  86. package/WebGPU/GPURenderBundle.js +12 -0
  87. package/WebGPU/GPURenderBundle.js.map +1 -0
  88. package/WebGPU/GPURenderBundleEncoder.d.ts +20 -0
  89. package/WebGPU/GPURenderBundleEncoder.js +61 -0
  90. package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
  91. package/WebGPU/GPURenderPassEncoder.d.ts +29 -0
  92. package/WebGPU/GPURenderPassEncoder.js +94 -0
  93. package/WebGPU/GPURenderPassEncoder.js.map +1 -0
  94. package/WebGPU/GPURenderPipeline.d.ts +7 -0
  95. package/WebGPU/GPURenderPipeline.js +16 -0
  96. package/WebGPU/GPURenderPipeline.js.map +1 -0
  97. package/WebGPU/GPUSampler.d.ts +5 -0
  98. package/WebGPU/GPUSampler.js +12 -0
  99. package/WebGPU/GPUSampler.js.map +1 -0
  100. package/WebGPU/GPUShaderModule.d.ts +6 -0
  101. package/WebGPU/GPUShaderModule.js +15 -0
  102. package/WebGPU/GPUShaderModule.js.map +1 -0
  103. package/WebGPU/GPUTexture.d.ts +16 -0
  104. package/WebGPU/GPUTexture.js +41 -0
  105. package/WebGPU/GPUTexture.js.map +1 -0
  106. package/WebGPU/GPUTextureView.d.ts +5 -0
  107. package/WebGPU/GPUTextureView.js +12 -0
  108. package/WebGPU/GPUTextureView.js.map +1 -0
  109. package/WebGPU/Interfaces.d.ts +155 -0
  110. package/WebGPU/Interfaces.js +2 -0
  111. package/WebGPU/Interfaces.js.map +1 -0
  112. package/WebGPU/Types.d.ts +39 -0
  113. package/WebGPU/Types.js +2 -0
  114. package/WebGPU/Types.js.map +1 -0
  115. package/WebGPU/Utils.d.ts +1 -0
  116. package/WebGPU/Utils.js +75 -0
  117. package/WebGPU/Utils.js.map +1 -0
  118. package/WebGPU/index.d.ts +28 -0
  119. package/WebGPU/index.js +29 -0
  120. package/WebGPU/index.js.map +1 -0
  121. package/index.d.ts +1 -1
  122. package/index.js +22 -1
  123. package/index.js.map +1 -1
  124. package/package.json +1 -4
  125. package/platforms/android/canvas-release.aar +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +23 -23
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1564 -3814
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +27 -34
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +602 -664
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +46 -46
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1564 -3814
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +27 -34
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1564 -3814
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +27 -34
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +604 -663
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -642
  157. package/platforms/ios/build.xcconfig +3 -1
  158. package/platforms/ios/src/cpp/Caches.h +69 -1
  159. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
  160. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
  161. package/platforms/ios/src/cpp/Helpers.h +43 -8
  162. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
  163. package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
  164. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
  165. package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
  166. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
  167. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
  168. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  169. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  170. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
  171. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  172. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
  173. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  174. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  175. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  176. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
  177. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
  178. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
  179. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
  180. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
  181. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
  182. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
  183. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
  184. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
  185. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
  186. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1087 -0
  187. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
  188. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
  191. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2741 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
  194. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
  198. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
  199. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  200. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
  201. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
  202. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
  203. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
  204. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
  205. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
  206. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +653 -0
  207. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
  208. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
  209. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
  210. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
  211. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
  212. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
  213. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
  214. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  215. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  216. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
  217. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
  218. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
  219. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
  220. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +178 -0
  221. package/SVG/Circle.d.ts +0 -11
  222. package/SVG/Circle.js +0 -21
  223. package/SVG/Circle.js.map +0 -1
  224. package/SVG/ClipPath.d.ts +0 -4
  225. package/SVG/ClipPath.js +0 -9
  226. package/SVG/ClipPath.js.map +0 -1
  227. package/SVG/Defs.d.ts +0 -4
  228. package/SVG/Defs.js +0 -9
  229. package/SVG/Defs.js.map +0 -1
  230. package/SVG/Ellipse.d.ts +0 -13
  231. package/SVG/Ellipse.js +0 -26
  232. package/SVG/Ellipse.js.map +0 -1
  233. package/SVG/G.d.ts +0 -7
  234. package/SVG/G.js +0 -9
  235. package/SVG/G.js.map +0 -1
  236. package/SVG/Image.d.ts +0 -11
  237. package/SVG/Image.js +0 -40
  238. package/SVG/Image.js.map +0 -1
  239. package/SVG/Line.d.ts +0 -13
  240. package/SVG/Line.js +0 -26
  241. package/SVG/Line.js.map +0 -1
  242. package/SVG/LinearGradient.d.ts +0 -10
  243. package/SVG/LinearGradient.js +0 -13
  244. package/SVG/LinearGradient.js.map +0 -1
  245. package/SVG/Path.d.ts +0 -7
  246. package/SVG/Path.js +0 -14
  247. package/SVG/Path.js.map +0 -1
  248. package/SVG/Pattern.d.ts +0 -4
  249. package/SVG/Pattern.js +0 -9
  250. package/SVG/Pattern.js.map +0 -1
  251. package/SVG/Polygon.d.ts +0 -7
  252. package/SVG/Polygon.js +0 -14
  253. package/SVG/Polygon.js.map +0 -1
  254. package/SVG/Polyline.d.ts +0 -7
  255. package/SVG/Polyline.js +0 -14
  256. package/SVG/Polyline.js.map +0 -1
  257. package/SVG/Rect.d.ts +0 -8
  258. package/SVG/Rect.js +0 -13
  259. package/SVG/Rect.js.map +0 -1
  260. package/SVG/SVG.d.ts +0 -32
  261. package/SVG/SVG.js +0 -204
  262. package/SVG/SVG.js.map +0 -1
  263. package/SVG/SVGItem.d.ts +0 -5
  264. package/SVG/SVGItem.js +0 -8
  265. package/SVG/SVGItem.js.map +0 -1
  266. package/SVG/Stop.d.ts +0 -5
  267. package/SVG/Stop.js +0 -9
  268. package/SVG/Stop.js.map +0 -1
  269. package/SVG/Symbol.d.ts +0 -4
  270. package/SVG/Symbol.js +0 -9
  271. package/SVG/Symbol.js.map +0 -1
  272. package/SVG/Text.d.ts +0 -14
  273. package/SVG/Text.js +0 -26
  274. package/SVG/Text.js.map +0 -1
  275. package/SVG/Use.d.ts +0 -4
  276. package/SVG/Use.js +0 -9
  277. package/SVG/Use.js.map +0 -1
  278. package/SVG/index.d.ts +0 -18
  279. package/SVG/index.js +0 -19
  280. package/SVG/index.js.map +0 -1
  281. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  282. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  283. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  284. package/platforms/ios/src/cpp/URLImpl.h +0 -121
@@ -0,0 +1,69 @@
1
+ //
2
+ // Created by Osei Fortune on 23/06/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPUCOMMANDENCODERIMPL_H
6
+ #define CANVAS_ANDROID_GPUCOMMANDENCODERIMPL_H
7
+
8
+ #include "Helpers.h"
9
+ #include "ObjectWrapperImpl.h"
10
+ #include "GPUUtils.h"
11
+ class GPUCommandEncoderImpl : ObjectWrapperImpl {
12
+ public:
13
+ explicit GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder);
14
+
15
+ ~GPUCommandEncoderImpl() {
16
+ canvas_native_webgpu_command_encoder_release(this->encoder_);
17
+ }
18
+
19
+ const CanvasGPUCommandEncoder *GetEncoder();
20
+
21
+ static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
22
+
23
+ static GPUCommandEncoderImpl *GetPointer(const v8::Local<v8::Object> &object);
24
+
25
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
26
+
27
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUCommandEncoderImpl *encoder) {
28
+ auto context = isolate->GetCurrentContext();
29
+ v8::EscapableHandleScope scope(isolate);
30
+ auto object = GPUCommandEncoderImpl::GetCtor(isolate)->GetFunction(
31
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
32
+ SetNativeType(object, NativeType::GPUCommandEncoder);
33
+ object->SetAlignedPointerInInternalField(0, encoder);
34
+ encoder->BindFinalizer(isolate, object);
35
+ return scope.Escape(object);
36
+ }
37
+
38
+ static void BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args);
39
+
40
+ static void BeginRenderPass(const v8::FunctionCallbackInfo<v8::Value> &args);
41
+
42
+ static void ClearBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
43
+
44
+ static void CopyBufferToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
45
+
46
+ static void CopyBufferToTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
47
+
48
+ static void CopyTextureToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
49
+
50
+ static void CopyTextureToTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
51
+
52
+ static void Finish(const v8::FunctionCallbackInfo<v8::Value> &args);
53
+
54
+ static void InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args);
55
+
56
+ static void PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
57
+
58
+ static void PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
59
+
60
+ static void ResolveQuerySet(const v8::FunctionCallbackInfo<v8::Value> &args);
61
+
62
+ static void WriteTimestamp(const v8::FunctionCallbackInfo<v8::Value> &args);
63
+
64
+ private:
65
+ const CanvasGPUCommandEncoder *encoder_;
66
+ };
67
+
68
+
69
+ #endif //CANVAS_ANDROID_GPUCOMMANDENCODERIMPL_H
@@ -0,0 +1,260 @@
1
+ //
2
+ // Created by Osei Fortune on 23/06/2024.
3
+ //
4
+
5
+ #include "GPUComputePassEncoderImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPUBindGroupImpl.h"
8
+ #include "GPUComputePipelineImpl.h"
9
+ #include "GPUBufferImpl.h"
10
+
11
+ GPUComputePassEncoderImpl::GPUComputePassEncoderImpl(const CanvasGPUComputePassEncoder *pass)
12
+ : computePass_(
13
+ pass) {}
14
+
15
+ const CanvasGPUComputePassEncoder *GPUComputePassEncoderImpl::GetComputePass() {
16
+ return this->computePass_;
17
+ }
18
+
19
+
20
+ void GPUComputePassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
21
+ v8::Locker locker(isolate);
22
+ v8::Isolate::Scope isolate_scope(isolate);
23
+ v8::HandleScope handle_scope(isolate);
24
+
25
+ auto ctor = GetCtor(isolate);
26
+ auto context = isolate->GetCurrentContext();
27
+ auto func = ctor->GetFunction(context).ToLocalChecked();
28
+
29
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUComputePassEncoder"), func).FromJust();;
30
+ }
31
+
32
+ GPUComputePassEncoderImpl *
33
+ GPUComputePassEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
34
+ auto ptr = object->GetAlignedPointerFromInternalField(0);
35
+ if (ptr == nullptr) {
36
+ return nullptr;
37
+ }
38
+ return static_cast<GPUComputePassEncoderImpl *>(ptr);
39
+ }
40
+
41
+ v8::Local<v8::FunctionTemplate> GPUComputePassEncoderImpl::GetCtor(v8::Isolate *isolate) {
42
+ auto cache = Caches::Get(isolate);
43
+ auto ctor = cache->GPUComputePassEncoderTmpl.get();
44
+ if (ctor != nullptr) {
45
+ return ctor->Get(isolate);
46
+ }
47
+
48
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
49
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
50
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUComputePassEncoder"));
51
+
52
+ auto tmpl = ctorTmpl->InstanceTemplate();
53
+ tmpl->SetInternalFieldCount(2);
54
+
55
+ tmpl->Set(
56
+ ConvertToV8String(isolate, "dispatchWorkgroups"),
57
+ v8::FunctionTemplate::New(isolate, &DispatchWorkgroups));
58
+
59
+ tmpl->Set(
60
+ ConvertToV8String(isolate, "dispatchWorkgroupsIndirect"),
61
+ v8::FunctionTemplate::New(isolate, &DispatchWorkgroupsIndirect));
62
+
63
+ tmpl->Set(
64
+ ConvertToV8String(isolate, "end"),
65
+ v8::FunctionTemplate::New(isolate, &End));
66
+
67
+ tmpl->Set(
68
+ ConvertToV8String(isolate, "insertDebugMarker"),
69
+ v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
70
+
71
+ tmpl->Set(
72
+ ConvertToV8String(isolate, "popDebugGroup"),
73
+ v8::FunctionTemplate::New(isolate, &PopDebugGroup));
74
+
75
+ tmpl->Set(
76
+ ConvertToV8String(isolate, "pushDebugGroup"),
77
+ v8::FunctionTemplate::New(isolate, &PushDebugGroup));
78
+
79
+ tmpl->Set(
80
+ ConvertToV8String(isolate, "setBindGroup"),
81
+ v8::FunctionTemplate::New(isolate, &SetBindGroup));
82
+
83
+ tmpl->Set(
84
+ ConvertToV8String(isolate, "setPipeline"),
85
+ v8::FunctionTemplate::New(isolate, &SetPipeline));
86
+
87
+
88
+ cache->GPUComputePassEncoderTmpl =
89
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
90
+ return ctorTmpl;
91
+ }
92
+
93
+ void
94
+ GPUComputePassEncoderImpl::DispatchWorkgroups(const v8::FunctionCallbackInfo<v8::Value> &args) {
95
+ auto *ptr = GetPointer(args.This());
96
+ if (ptr == nullptr) {
97
+ return;
98
+ }
99
+
100
+ auto isolate = args.GetIsolate();
101
+ auto context = isolate->GetCurrentContext();
102
+
103
+ auto workgroupCountXVal = args[0];
104
+ auto workgroupCountYVal = args[1];
105
+ auto workgroupCountZVal = args[2];
106
+
107
+ uint32_t workgroupCountY = 1;
108
+ uint32_t workgroupCountZ = 1;
109
+
110
+ if (workgroupCountYVal->IsUint32()) {
111
+ workgroupCountY = workgroupCountYVal.As<v8::Uint32>()->Value();
112
+ }
113
+
114
+ if (workgroupCountZVal->IsUint32()) {
115
+ workgroupCountZ = workgroupCountZVal.As<v8::Uint32>()->Value();
116
+ }
117
+
118
+ if (workgroupCountXVal->IsUint32()) {
119
+ canvas_native_webgpu_compute_pass_encoder_dispatch_workgroups(ptr->GetComputePass(),
120
+ workgroupCountXVal->Uint32Value(
121
+ context).FromJust(),
122
+ workgroupCountY,
123
+ workgroupCountZ);
124
+ }
125
+
126
+ }
127
+
128
+ void GPUComputePassEncoderImpl::DispatchWorkgroupsIndirect(
129
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
130
+ auto *ptr = GetPointer(args.This());
131
+ if (ptr == nullptr) {
132
+ return;
133
+ }
134
+ auto isolate = args.GetIsolate();
135
+ auto context = isolate->GetCurrentContext();
136
+
137
+ auto indirectBuffer = args[0];
138
+ auto indirectOffset = args[1];
139
+
140
+ auto type = GetNativeType(indirectBuffer);
141
+
142
+
143
+ if (type == NativeType::GPUBuffer) {
144
+ auto buffer = GPUBufferImpl::GetPointer(indirectBuffer.As<v8::Object>());
145
+ auto offset = (size_t) indirectOffset->NumberValue(context).FromJust();
146
+ canvas_native_webgpu_compute_pass_encoder_dispatch_workgroups_indirect(
147
+ ptr->GetComputePass(), buffer->GetGPUBuffer(), offset);
148
+ }
149
+
150
+ }
151
+
152
+
153
+ void GPUComputePassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
154
+ auto *ptr = GetPointer(args.This());
155
+ if (ptr == nullptr) {
156
+ return;
157
+ }
158
+
159
+ canvas_native_webgpu_compute_pass_encoder_end(ptr->GetComputePass());
160
+ }
161
+
162
+ void
163
+ GPUComputePassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
164
+ auto *ptr = GetPointer(args.This());
165
+ if (ptr == nullptr) {
166
+ return;
167
+ }
168
+
169
+ auto isolate = args.GetIsolate();
170
+
171
+ auto markerLabelVal = args[0];
172
+ if (markerLabelVal->IsString()) {
173
+ auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
174
+ canvas_native_webgpu_compute_pass_encoder_insert_debug_marker(ptr->GetComputePass(),
175
+ markerLabel.c_str());
176
+ }
177
+ }
178
+
179
+ void GPUComputePassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
180
+ auto *ptr = GetPointer(args.This());
181
+ if (ptr == nullptr) {
182
+ return;
183
+ }
184
+
185
+ canvas_native_webgpu_compute_pass_encoder_pop_debug_group(ptr->GetComputePass());
186
+ }
187
+
188
+ void GPUComputePassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
189
+ auto *ptr = GetPointer(args.This());
190
+ if (ptr == nullptr) {
191
+ return;
192
+ }
193
+
194
+ auto isolate = args.GetIsolate();
195
+
196
+ auto groupLabelVal = args[0];
197
+ if (groupLabelVal->IsString()) {
198
+ auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
199
+ canvas_native_webgpu_compute_pass_encoder_push_debug_group(ptr->GetComputePass(),
200
+ groupLabel.c_str());
201
+ }
202
+ }
203
+
204
+ void GPUComputePassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
205
+ auto *ptr = GetPointer(args.This());
206
+ if (ptr == nullptr) {
207
+ return;
208
+ }
209
+
210
+ auto isolate = args.GetIsolate();
211
+ auto context = isolate->GetCurrentContext();
212
+
213
+ auto indexVal = args[0];
214
+ auto bindGroupVal = args[1];
215
+ auto dynamicOffsets = args[2];
216
+ auto dynamicOffsetsStart = args[3];
217
+ auto dynamicOffsetsLength = args[4];
218
+
219
+ auto type = GetNativeType(bindGroupVal);
220
+
221
+ if (type == NativeType::GPUBindGroup) {
222
+ auto index = indexVal->Uint32Value(context).FromJust();
223
+ auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
224
+
225
+ if (dynamicOffsets->IsUint8Array()) {
226
+ auto buf = dynamicOffsets.As<v8::Uint32Array>();
227
+ auto buffer = buf->Buffer();
228
+ auto store = buffer->GetBackingStore();
229
+ auto offset = buf->ByteOffset();
230
+ auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
231
+ auto size = buf->Length();
232
+ auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
233
+ auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
234
+ canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
235
+ bindgroup->GetBindGroup(),
236
+ static_cast<const uint32_t *>(static_cast<void *>(data)),
237
+ size, start, offset_length);
238
+ } else {
239
+ canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
240
+ bindgroup->GetBindGroup(),
241
+ nullptr, 0, 0, 0);
242
+ }
243
+ }
244
+ }
245
+
246
+ void GPUComputePassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args) {
247
+ auto *ptr = GetPointer(args.This());
248
+ if (ptr == nullptr) {
249
+ return;
250
+ }
251
+
252
+ auto pipelineVal = args[0];
253
+ if (pipelineVal->IsObject()) {
254
+ auto pipeline = GPUComputePipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
255
+ if (pipeline != nullptr) {
256
+ canvas_native_webgpu_compute_pass_encoder_set_pipeline(ptr->GetComputePass(),
257
+ pipeline->GetGPUPipeline());
258
+ }
259
+ }
260
+ }
@@ -0,0 +1,62 @@
1
+ //
2
+ // Created by Osei Fortune on 23/06/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPUCOMPUTEPASSENCODERIMPL_H
6
+ #define CANVAS_ANDROID_GPUCOMPUTEPASSENCODERIMPL_H
7
+
8
+ #include "Helpers.h"
9
+ #include "ObjectWrapperImpl.h"
10
+
11
+ class GPUComputePassEncoderImpl : ObjectWrapperImpl {
12
+ public:
13
+ explicit GPUComputePassEncoderImpl(const CanvasGPUComputePassEncoder *computePass);
14
+
15
+ ~GPUComputePassEncoderImpl() {
16
+ canvas_native_webgpu_compute_pass_encoder_release(this->computePass_);
17
+ }
18
+
19
+ const CanvasGPUComputePassEncoder *GetComputePass();
20
+
21
+ static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
22
+
23
+ static GPUComputePassEncoderImpl *GetPointer(const v8::Local<v8::Object> &object);
24
+
25
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
26
+
27
+ static v8::Local<v8::Object>
28
+ NewInstance(v8::Isolate *isolate, GPUComputePassEncoderImpl *pass) {
29
+ auto context = isolate->GetCurrentContext();
30
+ v8::EscapableHandleScope scope(isolate);
31
+ auto object = GPUComputePassEncoderImpl::GetCtor(isolate)->GetFunction(
32
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
33
+ SetNativeType(object, NativeType::GPUComputePass);
34
+ object->SetAlignedPointerInInternalField(0, pass);
35
+ pass->BindFinalizer(isolate, object);
36
+ return scope.Escape(object);
37
+ }
38
+
39
+ static void DispatchWorkgroups(const v8::FunctionCallbackInfo<v8::Value> &args);
40
+
41
+ static void DispatchWorkgroupsIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
42
+
43
+ static void End(const v8::FunctionCallbackInfo<v8::Value> &args);
44
+
45
+ static void InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args);
46
+
47
+ static void PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
48
+
49
+ static void PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
50
+
51
+ static void SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args);
52
+
53
+ static void SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args);
54
+
55
+
56
+
57
+ private:
58
+ const CanvasGPUComputePassEncoder *computePass_;
59
+ };
60
+
61
+
62
+ #endif //CANVAS_ANDROID_GPUCOMPUTEPASSENCODERIMPL_H
@@ -0,0 +1,84 @@
1
+ //
2
+ // Created by Osei Fortune on 17/07/2024.
3
+ //
4
+
5
+ #include "GPUComputePipelineImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPUBindGroupLayoutImpl.h"
8
+
9
+ GPUComputePipelineImpl::GPUComputePipelineImpl(const CanvasGPUComputePipeline *pipeline)
10
+ : pipeline_(
11
+ pipeline) {}
12
+
13
+ const CanvasGPUComputePipeline *GPUComputePipelineImpl::GetGPUPipeline() {
14
+ return this->pipeline_;
15
+ }
16
+
17
+
18
+ void GPUComputePipelineImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
19
+ v8::Locker locker(isolate);
20
+ v8::Isolate::Scope isolate_scope(isolate);
21
+ v8::HandleScope handle_scope(isolate);
22
+
23
+ auto ctor = GetCtor(isolate);
24
+ auto context = isolate->GetCurrentContext();
25
+ auto func = ctor->GetFunction(context).ToLocalChecked();
26
+
27
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUComputePipeline"), func).FromJust();;
28
+ }
29
+
30
+ GPUComputePipelineImpl *GPUComputePipelineImpl::GetPointer(const v8::Local<v8::Object> &object) {
31
+ auto ptr = object->GetAlignedPointerFromInternalField(0);
32
+ if (ptr == nullptr) {
33
+ return nullptr;
34
+ }
35
+ return static_cast<GPUComputePipelineImpl *>(ptr);
36
+ }
37
+
38
+ v8::Local<v8::FunctionTemplate> GPUComputePipelineImpl::GetCtor(v8::Isolate *isolate) {
39
+ auto cache = Caches::Get(isolate);
40
+ auto ctor = cache->GPUComputePipelineTmpl.get();
41
+ if (ctor != nullptr) {
42
+ return ctor->Get(isolate);
43
+ }
44
+
45
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
46
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
47
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUComputePipeline"));
48
+
49
+ auto tmpl = ctorTmpl->InstanceTemplate();
50
+ tmpl->SetInternalFieldCount(2);
51
+
52
+
53
+ tmpl->Set(
54
+ ConvertToV8String(isolate, "getBindGroupLayout"),
55
+ v8::FunctionTemplate::New(isolate, &GetBindGroupLayout));
56
+
57
+ cache->GPUComputePipelineTmpl =
58
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
59
+ return ctorTmpl;
60
+ }
61
+
62
+ void GPUComputePipelineImpl::GetBindGroupLayout(const v8::FunctionCallbackInfo<v8::Value> &args) {
63
+ auto *ptr = GetPointer(args.This());
64
+ if (ptr == nullptr) {
65
+ return;
66
+ }
67
+
68
+ auto isolate = args.GetIsolate();
69
+ auto context = isolate->GetCurrentContext();
70
+ auto index = args[0]->Uint32Value(context).ToChecked();
71
+
72
+
73
+ auto group_layout = canvas_native_webgpu_compute_pipeline_get_bind_group_layout(
74
+ ptr->GetGPUPipeline(), index);
75
+
76
+ if (group_layout != nullptr) {
77
+ auto ret = GPUBindGroupLayoutImpl::NewInstance(isolate,
78
+ new GPUBindGroupLayoutImpl(group_layout));
79
+ args.GetReturnValue().Set(ret);
80
+ return;
81
+ }
82
+
83
+ args.GetReturnValue().SetUndefined();
84
+ }
@@ -0,0 +1,49 @@
1
+ //
2
+ // Created by Osei Fortune on 17/07/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPUCOMPUTEPIPELINEIMPL_H
6
+ #define CANVAS_ANDROID_GPUCOMPUTEPIPELINEIMPL_H
7
+
8
+ #include "Common.h"
9
+ #include "Helpers.h"
10
+ #include "ObjectWrapperImpl.h"
11
+
12
+ class GPUComputePipelineImpl : ObjectWrapperImpl {
13
+ public:
14
+ explicit GPUComputePipelineImpl(const CanvasGPUComputePipeline *pipeline);
15
+
16
+ ~GPUComputePipelineImpl() {
17
+ canvas_native_webgpu_compute_pipeline_release(this->pipeline_);
18
+ }
19
+
20
+ const CanvasGPUComputePipeline *GetGPUPipeline();
21
+
22
+ static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
23
+
24
+ static GPUComputePipelineImpl *GetPointer(const v8::Local<v8::Object> &object);
25
+
26
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
27
+
28
+ static v8::Local<v8::Object>
29
+ NewInstance(v8::Isolate *isolate, GPUComputePipelineImpl *pipeline) {
30
+ auto context = isolate->GetCurrentContext();
31
+ v8::EscapableHandleScope scope(isolate);
32
+ auto object = GPUComputePipelineImpl::GetCtor(isolate)->GetFunction(
33
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
+ SetNativeType(object, NativeType::GPUComputePipeline);
35
+ object->SetAlignedPointerInInternalField(0, pipeline);
36
+ pipeline->BindFinalizer(isolate, object);
37
+ return scope.Escape(object);
38
+ }
39
+
40
+
41
+ static void GetBindGroupLayout(const v8::FunctionCallbackInfo<v8::Value> &args);
42
+
43
+
44
+ private:
45
+ const CanvasGPUComputePipeline *pipeline_;
46
+ };
47
+
48
+
49
+ #endif //CANVAS_ANDROID_GPUCOMPUTEPIPELINEIMPL_H