@nativescript/canvas 2.0.0-beta.9 → 2.0.0-webgpu.1

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 (288) hide show
  1. package/Canvas/common.d.ts +24 -17
  2. package/Canvas/common.js +133 -66
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +5 -7
  5. package/Canvas/index.android.js +62 -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 +4 -5
  9. package/Canvas/index.ios.js +73 -82
  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 +86 -32
  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 +35 -0
  53. package/WebGPU/GPUCanvasContext.js +76 -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 +110 -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 +356 -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 +17 -0
  104. package/WebGPU/GPUTexture.js +44 -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/common.d.ts +0 -3
  122. package/common.js +1 -5
  123. package/common.js.map +1 -1
  124. package/index.d.ts +1 -1
  125. package/index.js +22 -1
  126. package/index.js.map +1 -1
  127. package/package.json +1 -4
  128. package/platforms/android/canvas-release.aar +0 -0
  129. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +23 -23
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +41 -8
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2318 -103
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1563 -3729
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +27 -34
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +602 -663
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +46 -46
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +41 -8
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2318 -103
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1563 -3729
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +27 -34
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1563 -3729
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +27 -34
  157. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
  158. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  159. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +604 -662
  160. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -641
  161. package/platforms/ios/build.xcconfig +3 -1
  162. package/platforms/ios/src/cpp/Caches.h +69 -1
  163. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
  164. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
  165. package/platforms/ios/src/cpp/Helpers.h +43 -8
  166. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
  167. package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
  168. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
  169. package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
  170. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
  171. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
  172. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  173. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  174. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
  175. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  176. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
  177. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  178. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  179. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  180. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
  181. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
  182. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
  183. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
  184. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
  185. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
  186. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
  187. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
  188. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1222 -0
  191. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
  194. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2750 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
  198. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
  199. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  200. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
  201. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
  202. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
  203. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  204. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
  205. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
  206. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
  207. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
  208. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
  209. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
  210. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +623 -0
  211. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
  212. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
  213. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
  214. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
  215. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
  216. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
  217. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
  218. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  219. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  220. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
  221. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
  222. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
  223. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
  224. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +245 -0
  225. package/SVG/Circle.d.ts +0 -11
  226. package/SVG/Circle.js +0 -21
  227. package/SVG/Circle.js.map +0 -1
  228. package/SVG/ClipPath.d.ts +0 -4
  229. package/SVG/ClipPath.js +0 -9
  230. package/SVG/ClipPath.js.map +0 -1
  231. package/SVG/Defs.d.ts +0 -4
  232. package/SVG/Defs.js +0 -9
  233. package/SVG/Defs.js.map +0 -1
  234. package/SVG/Ellipse.d.ts +0 -13
  235. package/SVG/Ellipse.js +0 -26
  236. package/SVG/Ellipse.js.map +0 -1
  237. package/SVG/G.d.ts +0 -7
  238. package/SVG/G.js +0 -9
  239. package/SVG/G.js.map +0 -1
  240. package/SVG/Image.d.ts +0 -11
  241. package/SVG/Image.js +0 -40
  242. package/SVG/Image.js.map +0 -1
  243. package/SVG/Line.d.ts +0 -13
  244. package/SVG/Line.js +0 -26
  245. package/SVG/Line.js.map +0 -1
  246. package/SVG/LinearGradient.d.ts +0 -10
  247. package/SVG/LinearGradient.js +0 -13
  248. package/SVG/LinearGradient.js.map +0 -1
  249. package/SVG/Path.d.ts +0 -7
  250. package/SVG/Path.js +0 -14
  251. package/SVG/Path.js.map +0 -1
  252. package/SVG/Pattern.d.ts +0 -4
  253. package/SVG/Pattern.js +0 -9
  254. package/SVG/Pattern.js.map +0 -1
  255. package/SVG/Polygon.d.ts +0 -7
  256. package/SVG/Polygon.js +0 -14
  257. package/SVG/Polygon.js.map +0 -1
  258. package/SVG/Polyline.d.ts +0 -7
  259. package/SVG/Polyline.js +0 -14
  260. package/SVG/Polyline.js.map +0 -1
  261. package/SVG/Rect.d.ts +0 -8
  262. package/SVG/Rect.js +0 -13
  263. package/SVG/Rect.js.map +0 -1
  264. package/SVG/SVG.d.ts +0 -32
  265. package/SVG/SVG.js +0 -204
  266. package/SVG/SVG.js.map +0 -1
  267. package/SVG/SVGItem.d.ts +0 -5
  268. package/SVG/SVGItem.js +0 -8
  269. package/SVG/SVGItem.js.map +0 -1
  270. package/SVG/Stop.d.ts +0 -5
  271. package/SVG/Stop.js +0 -9
  272. package/SVG/Stop.js.map +0 -1
  273. package/SVG/Symbol.d.ts +0 -4
  274. package/SVG/Symbol.js +0 -9
  275. package/SVG/Symbol.js.map +0 -1
  276. package/SVG/Text.d.ts +0 -14
  277. package/SVG/Text.js +0 -26
  278. package/SVG/Text.js.map +0 -1
  279. package/SVG/Use.d.ts +0 -4
  280. package/SVG/Use.js +0 -9
  281. package/SVG/Use.js.map +0 -1
  282. package/SVG/index.d.ts +0 -18
  283. package/SVG/index.js +0 -19
  284. package/SVG/index.js.map +0 -1
  285. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  286. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  287. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  288. package/platforms/ios/src/cpp/URLImpl.h +0 -121
@@ -0,0 +1,1222 @@
1
+ //
2
+ // Created by Osei Fortune on 23/06/2024.
3
+ //
4
+
5
+ #include "GPUCommandEncoderImpl.h"
6
+ #include "Caches.h"
7
+ #include "GPUComputePassEncoderImpl.h"
8
+ #include "GPUQuerySetImpl.h"
9
+ #include "GPUBufferImpl.h"
10
+ #include "GPUTextureViewImpl.h"
11
+ #include "GPURenderPassEncoderImpl.h"
12
+ #include "GPUCommandBufferImpl.h"
13
+ #include "GPUTextureImpl.h"
14
+
15
+ GPUCommandEncoderImpl::GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder) : encoder_(
16
+ encoder) {}
17
+
18
+ const CanvasGPUCommandEncoder *GPUCommandEncoderImpl::GetEncoder() {
19
+ return this->encoder_;
20
+ }
21
+
22
+ void GPUCommandEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
23
+ v8::Locker locker(isolate);
24
+ v8::Isolate::Scope isolate_scope(isolate);
25
+ v8::HandleScope handle_scope(isolate);
26
+
27
+ auto ctor = GetCtor(isolate);
28
+ auto context = isolate->GetCurrentContext();
29
+ auto func = ctor->GetFunction(context).ToLocalChecked();
30
+
31
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandEncoder"), func).FromJust();
32
+ }
33
+
34
+ GPUCommandEncoderImpl *GPUCommandEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
35
+ auto ptr = object->GetAlignedPointerFromInternalField(0);
36
+ if (ptr == nullptr) {
37
+ return nullptr;
38
+ }
39
+ return static_cast<GPUCommandEncoderImpl *>(ptr);
40
+ }
41
+
42
+ v8::Local<v8::FunctionTemplate> GPUCommandEncoderImpl::GetCtor(v8::Isolate *isolate) {
43
+ auto cache = Caches::Get(isolate);
44
+ auto ctor = cache->GPUCommandEncoderTmpl.get();
45
+ if (ctor != nullptr) {
46
+ return ctor->Get(isolate);
47
+ }
48
+
49
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
50
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
51
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCommandEncoder"));
52
+
53
+ auto tmpl = ctorTmpl->InstanceTemplate();
54
+ tmpl->SetInternalFieldCount(2);
55
+
56
+
57
+ tmpl->Set(
58
+ ConvertToV8String(isolate, "beginComputePass"),
59
+ v8::FunctionTemplate::New(isolate, &BeginComputePass));
60
+
61
+ tmpl->Set(
62
+ ConvertToV8String(isolate, "beginRenderPass"),
63
+ v8::FunctionTemplate::New(isolate, &BeginRenderPass));
64
+
65
+ tmpl->Set(
66
+ ConvertToV8String(isolate, "clearBuffer"),
67
+ v8::FunctionTemplate::New(isolate, &ClearBuffer));
68
+
69
+ tmpl->Set(
70
+ ConvertToV8String(isolate, "copyBufferToBuffer"),
71
+ v8::FunctionTemplate::New(isolate, &CopyBufferToBuffer));
72
+
73
+ tmpl->Set(
74
+ ConvertToV8String(isolate, "copyBufferToTexture"),
75
+ v8::FunctionTemplate::New(isolate, &CopyBufferToTexture));
76
+
77
+ tmpl->Set(
78
+ ConvertToV8String(isolate, "copyTextureToBuffer"),
79
+ v8::FunctionTemplate::New(isolate, &CopyTextureToBuffer));
80
+
81
+ tmpl->Set(
82
+ ConvertToV8String(isolate, "copyTextureToTexture"),
83
+ v8::FunctionTemplate::New(isolate, &CopyTextureToTexture));
84
+
85
+ tmpl->Set(
86
+ ConvertToV8String(isolate, "finish"),
87
+ v8::FunctionTemplate::New(isolate, &Finish));
88
+
89
+ tmpl->Set(
90
+ ConvertToV8String(isolate, "insertDebugMarker"),
91
+ v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
92
+
93
+ tmpl->Set(
94
+ ConvertToV8String(isolate, "popDebugGroup"),
95
+ v8::FunctionTemplate::New(isolate, &PopDebugGroup));
96
+
97
+ tmpl->Set(
98
+ ConvertToV8String(isolate, "pushDebugGroup"),
99
+ v8::FunctionTemplate::New(isolate, &PushDebugGroup));
100
+
101
+ tmpl->Set(
102
+ ConvertToV8String(isolate, "resolveQuerySet"),
103
+ v8::FunctionTemplate::New(isolate, &ResolveQuerySet));
104
+
105
+ tmpl->Set(
106
+ ConvertToV8String(isolate, "writeTimestamp"),
107
+ v8::FunctionTemplate::New(isolate, &WriteTimestamp));
108
+
109
+
110
+ cache->GPUCommandEncoderTmpl =
111
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
112
+ return ctorTmpl;
113
+ }
114
+
115
+
116
+ void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args) {
117
+ auto ptr = GetPointer(args.This());
118
+ if (ptr == nullptr) {
119
+ return;
120
+ }
121
+
122
+ auto isolate = args.GetIsolate();
123
+ auto context = isolate->GetCurrentContext();
124
+
125
+ auto descVal = args[0];
126
+
127
+ const CanvasGPUComputePassEncoder *pass;
128
+
129
+ if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
130
+ auto desc = descVal.As<v8::Object>();
131
+
132
+
133
+ v8::Local<v8::Value> labelVal;
134
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
135
+
136
+ char *label = nullptr;
137
+
138
+ if (!labelVal.IsEmpty() && labelVal->IsString()) {
139
+ label = *v8::String::Utf8Value(isolate, labelVal);
140
+ }
141
+
142
+ const CanvasGPUQuerySet *querySet = nullptr;
143
+ int32_t beginningOfPassWriteIndex = -1;
144
+
145
+ int32_t endOfPassWriteIndex = -1;
146
+
147
+
148
+ v8::Local<v8::Value> timestampWritesVal;
149
+ desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
150
+ &timestampWritesVal);
151
+
152
+
153
+ if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
154
+ auto timestampWrites = timestampWritesVal.As<v8::Object>();
155
+
156
+ v8::Local<v8::Value> querySetVal;
157
+ timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
158
+ &querySetVal);
159
+
160
+
161
+ if (!querySetVal.IsEmpty() && querySetVal->IsObject()) {
162
+ auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
163
+ if (queryPtr != nullptr) {
164
+ querySet = queryPtr->GetQuerySet();
165
+ }
166
+ }
167
+
168
+ v8::Local<v8::Value> beginningOfPassWriteIndexVal;
169
+
170
+
171
+ v8::Local<v8::Value> endOfPassWriteIndexVal;
172
+
173
+
174
+ timestampWrites->Get(context,
175
+ ConvertToV8String(isolate, "beginningOfPassWriteIndex")).ToLocal(
176
+ &beginningOfPassWriteIndexVal);
177
+
178
+ timestampWrites->Get(context,
179
+ ConvertToV8String(isolate, "endOfPassWriteIndex")).ToLocal(
180
+ &endOfPassWriteIndexVal);
181
+
182
+
183
+ if (beginningOfPassWriteIndexVal->IsInt32()) {
184
+ beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
185
+ }
186
+
187
+ if (endOfPassWriteIndexVal->IsInt32()) {
188
+ endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
189
+ }
190
+ }
191
+
192
+
193
+ pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
194
+ querySet, label,
195
+ beginningOfPassWriteIndex,
196
+ endOfPassWriteIndex);
197
+
198
+
199
+ } else {
200
+ pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
201
+ nullptr, nullptr, -1,
202
+ -1);
203
+
204
+ }
205
+
206
+
207
+ if (pass != nullptr) {
208
+ auto value = new GPUComputePassEncoderImpl(pass);
209
+ auto ret = GPUComputePassEncoderImpl::NewInstance(isolate, value);
210
+ args.GetReturnValue().Set(ret);
211
+ } else {
212
+ args.GetReturnValue().SetUndefined();
213
+ }
214
+
215
+ }
216
+
217
+ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::Value> &args) {
218
+ auto ptr = GetPointer(args.This());
219
+ if (ptr == nullptr) {
220
+ return;
221
+ }
222
+
223
+ auto isolate = args.GetIsolate();
224
+ auto context = isolate->GetCurrentContext();
225
+
226
+ auto descVal = args[0];
227
+
228
+ const CanvasGPURenderPassEncoder *pass = nullptr;
229
+
230
+ std::vector<CanvasRenderPassColorAttachment> colorAttachments_;
231
+
232
+ if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
233
+ auto desc = descVal.As<v8::Object>();
234
+
235
+
236
+ v8::Local<v8::Value> labelVal;
237
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
238
+
239
+ char *label = nullptr;
240
+
241
+ if (!labelVal.IsEmpty() && labelVal->IsString()) {
242
+ label = *v8::String::Utf8Value(isolate, labelVal);
243
+ }
244
+
245
+
246
+ v8::Local<v8::Value> colorAttachmentsVal;
247
+ desc->Get(context, ConvertToV8String(isolate, "colorAttachments")).ToLocal(
248
+ &colorAttachmentsVal);
249
+
250
+ auto colorAttachments = colorAttachmentsVal.As<v8::Array>();
251
+ auto colorAttachmentsLength = colorAttachments->Length();
252
+
253
+ for (int i = 0; i < colorAttachmentsLength; i++) {
254
+ auto colorAttachment = colorAttachments->Get(context,
255
+ i).ToLocalChecked().As<v8::Object>();
256
+
257
+ v8::Local<v8::Value> clearValueVal;
258
+ colorAttachment->Get(context, ConvertToV8String(isolate, "clearValue")).ToLocal(
259
+ &clearValueVal);
260
+
261
+ auto clearValue = ParseColor(isolate, clearValueVal);
262
+
263
+ v8::Local<v8::Value> viewVal;
264
+ colorAttachment->Get(context, ConvertToV8String(isolate,
265
+ "view")).ToLocal(&viewVal);
266
+
267
+ const CanvasGPUTextureView *view = nullptr;
268
+
269
+ auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
270
+ view = viewPtr->GetTextureView();
271
+
272
+ const CanvasGPUTextureView *resolve_target = nullptr;
273
+
274
+ v8::Local<v8::Value> resolve_target_val;
275
+
276
+ colorAttachment->Get(context, ConvertToV8String(isolate, "resolveTarget")).ToLocal(
277
+ &resolve_target_val);
278
+
279
+ auto resolve_target_type = GetNativeType(resolve_target_val);
280
+
281
+ if (resolve_target_type == NativeType::GPUTextureView) {
282
+ auto res = GPUTextureViewImpl::GetPointer(resolve_target_val.As<v8::Object>());
283
+ resolve_target = res->GetTextureView();
284
+ }
285
+
286
+ // default
287
+ CanvasLoadOp load = CanvasLoadOp::CanvasLoadOpClear;
288
+ CanvasStoreOp store = CanvasStoreOp::CanvasStoreOpStore;
289
+ v8::Local<v8::Value> loadVal;
290
+
291
+ if(colorAttachment->Get(context, ConvertToV8String(isolate,
292
+ "loadOp")).ToLocal(&loadVal)){
293
+ if (loadVal->IsUint32()) {
294
+ load = (CanvasLoadOp) loadVal->Uint32Value(
295
+ context).ToChecked();
296
+ } else if (loadVal->IsString()) {
297
+ auto val = ConvertFromV8String(isolate, loadVal);
298
+ if (val == "clear") {
299
+ load = CanvasLoadOp::CanvasLoadOpClear;
300
+ } else if (val == "load") {
301
+ load = CanvasLoadOp::CanvasLoadOpLoad;
302
+ }
303
+ }
304
+ }
305
+
306
+
307
+ v8::Local<v8::Value> storeVal;
308
+ if(colorAttachment->Get(context, ConvertToV8String(isolate,
309
+ "storeOp")).ToLocal(&storeVal)){
310
+ if (storeVal->IsUint32()) {
311
+ store = (CanvasStoreOp) storeVal->Uint32Value(
312
+ context).ToChecked();
313
+ } else if (storeVal->IsString()) {
314
+ auto val = ConvertFromV8String(isolate, storeVal);
315
+ if (val == "discard") {
316
+ store = CanvasStoreOp::CanvasStoreOpDiscard;
317
+ } else if (val == "store") {
318
+ store = CanvasStoreOp::CanvasStoreOpStore;
319
+ }
320
+ }
321
+ }
322
+
323
+ CanvasPassChannelColor channel{
324
+ load,
325
+ store,
326
+ clearValue,
327
+ false
328
+ };
329
+
330
+ auto attachment = CanvasRenderPassColorAttachment{
331
+ view,
332
+ resolve_target,
333
+ channel
334
+ };
335
+
336
+ colorAttachments_.push_back(attachment);
337
+
338
+ }
339
+
340
+
341
+ // todo add when supported
342
+ v8::Local<v8::Value> maxDrawCountVal;
343
+ desc->Get(context, ConvertToV8String(isolate, "maxDrawCount")).ToLocal(&maxDrawCountVal);
344
+
345
+
346
+ CanvasRenderPassDepthStencilAttachment *depthStencilAttachment = nullptr;
347
+ v8::Local<v8::Value> depthStencilAttachmentVal;
348
+
349
+ desc->Get(context, ConvertToV8String(isolate, "depthStencilAttachment")).ToLocal(
350
+ &depthStencilAttachmentVal);
351
+
352
+
353
+ if (!depthStencilAttachmentVal.IsEmpty() && depthStencilAttachmentVal->IsObject()) {
354
+ auto depthStencilAttachmentObj = depthStencilAttachmentVal.As<v8::Object>();
355
+ depthStencilAttachment = new CanvasRenderPassDepthStencilAttachment{};
356
+
357
+
358
+ v8::Local<v8::Value> viewVal;
359
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
360
+ "view")).ToLocal(&viewVal);
361
+
362
+ auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
363
+ depthStencilAttachment->view = viewPtr->GetTextureView();
364
+
365
+
366
+ v8::Local<v8::Value> depthClearValue;
367
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
368
+ "depthClearValue")).ToLocal(
369
+ &depthClearValue);
370
+
371
+ depthStencilAttachment->depth_clear_value = 0;
372
+
373
+ if (!depthClearValue.IsEmpty() && depthClearValue->IsNumber()) {
374
+ depthStencilAttachment->depth_clear_value = (float) depthClearValue->NumberValue(
375
+ context).FromJust();
376
+ }
377
+
378
+ v8::Local<v8::Value> depthLoadOp;
379
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
380
+ "depthLoadOp")).ToLocal(
381
+ &depthLoadOp);
382
+
383
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
384
+ CanvasOptionalLoadOpNone
385
+ };
386
+
387
+ if (!depthLoadOp.IsEmpty() && depthLoadOp->IsString()) {
388
+ auto value = ConvertFromV8String(isolate, depthLoadOp);
389
+ if (value == "load") {
390
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
391
+ CanvasOptionalLoadOpSome,
392
+ CanvasLoadOpLoad
393
+ };
394
+ } else if (value == "clear") {
395
+ depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
396
+ CanvasOptionalLoadOpSome,
397
+ CanvasLoadOpClear
398
+ };
399
+ }
400
+ }
401
+
402
+
403
+ v8::Local<v8::Value> depthStoreOp;
404
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
405
+ "depthStoreOp")).ToLocal(
406
+ &depthStoreOp);
407
+
408
+ depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
409
+ CanvasOptionalStoreOpNone
410
+ };
411
+
412
+ if (!depthStoreOp.IsEmpty() && depthStoreOp->IsString()) {
413
+ auto value = ConvertFromV8String(isolate, depthStoreOp);
414
+ if (value == "store") {
415
+ depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
416
+ CanvasOptionalStoreOpSome,
417
+ CanvasStoreOpStore
418
+ };
419
+ } else if (value == "discard") {
420
+ depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
421
+ CanvasOptionalStoreOpSome,
422
+ CanvasStoreOpDiscard
423
+ };
424
+ }
425
+ }
426
+
427
+
428
+ v8::Local<v8::Value> depthReadOnly;
429
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
430
+ "depthReadOnly")).ToLocal(
431
+ &depthReadOnly);
432
+
433
+ depthStencilAttachment->depth_read_only = false;
434
+ if (!depthReadOnly.IsEmpty() && depthReadOnly->IsBoolean()) {
435
+ depthStencilAttachment->depth_read_only = depthReadOnly->BooleanValue(isolate);
436
+ }
437
+
438
+
439
+ v8::Local<v8::Value> stencilClearValue;
440
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
441
+ "stencilClearValue")).ToLocal(
442
+ &stencilClearValue);
443
+
444
+ depthStencilAttachment->stencil_clear_value = 0;
445
+
446
+ if (!stencilClearValue.IsEmpty() && stencilClearValue->IsUint32()) {
447
+ depthStencilAttachment->stencil_clear_value = stencilClearValue->Uint32Value(
448
+ context).FromJust();
449
+ }
450
+
451
+
452
+ v8::Local<v8::Value> stencilLoadOp;
453
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
454
+ "stencilLoadOp")).ToLocal(
455
+ &stencilLoadOp);
456
+
457
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
458
+ CanvasOptionalLoadOpNone
459
+ };
460
+
461
+ if (!stencilLoadOp.IsEmpty() && stencilLoadOp->IsString()) {
462
+ auto value = ConvertFromV8String(isolate, stencilLoadOp);
463
+ if (value == "load") {
464
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
465
+ CanvasOptionalLoadOpSome,
466
+ CanvasLoadOpLoad
467
+ };
468
+ } else if (value == "clear") {
469
+ depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
470
+ CanvasOptionalLoadOpSome,
471
+ CanvasLoadOpClear
472
+ };
473
+ }
474
+ }
475
+
476
+
477
+ v8::Local<v8::Value> stencilStoreOp;
478
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
479
+ "stencilStoreOp")).ToLocal(
480
+ &stencilStoreOp);
481
+
482
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
483
+ CanvasOptionalStoreOpNone
484
+ };
485
+
486
+ if (!stencilStoreOp.IsEmpty() && stencilStoreOp->IsString()) {
487
+ auto value = ConvertFromV8String(isolate, stencilStoreOp);
488
+ if (value == "store") {
489
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
490
+ CanvasOptionalStoreOpSome,
491
+ CanvasStoreOpStore
492
+ };
493
+ } else if (value == "discard") {
494
+ depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
495
+ CanvasOptionalStoreOpSome,
496
+ CanvasStoreOpDiscard
497
+ };
498
+ }
499
+ }
500
+
501
+
502
+ v8::Local<v8::Value> stencilReadOnly;
503
+ depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
504
+ "stencilReadOnly")).ToLocal(
505
+ &stencilReadOnly);
506
+
507
+ depthStencilAttachment->stencil_read_only = false;
508
+ if (!stencilReadOnly.IsEmpty() && stencilReadOnly->IsBoolean()) {
509
+ depthStencilAttachment->stencil_read_only = stencilReadOnly->BooleanValue(isolate);
510
+ }
511
+
512
+ }
513
+
514
+ const CanvasGPUQuerySet *occlusion_query_set = nullptr;
515
+ v8::Local<v8::Value> occlusionQuerySetVal;
516
+
517
+
518
+ desc->Get(context, ConvertToV8String(isolate, "occlusionQuerySet")).ToLocal(
519
+ &occlusionQuerySetVal);
520
+
521
+
522
+ if (GetNativeType(occlusionQuerySetVal) == NativeType::GPUQuerySet) {
523
+ auto occlusionQuerySet = GPUQuerySetImpl::GetPointer(
524
+ occlusionQuerySetVal.As<v8::Object>());
525
+ occlusion_query_set = occlusionQuerySet->GetQuerySet();
526
+ }
527
+
528
+
529
+ v8::Local<v8::Value> timestampWritesVal;
530
+ desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
531
+ &timestampWritesVal);
532
+
533
+
534
+ const CanvasGPUQuerySet *querySet = nullptr;
535
+ int32_t beginningOfPassWriteIndex = -1;
536
+ int32_t endOfPassWriteIndex = -1;
537
+
538
+ if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
539
+ auto timestampWrites = timestampWritesVal.As<v8::Object>();
540
+ v8::Local<v8::Value> querySetVal;
541
+ timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
542
+ &querySetVal);
543
+
544
+
545
+ if (GetNativeType(querySetVal) == NativeType::GPUQuerySet) {
546
+ auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
547
+ if (queryPtr != nullptr) {
548
+ querySet = queryPtr->GetQuerySet();
549
+ }
550
+ }
551
+
552
+ v8::Local<v8::Value> beginningOfPassWriteIndexVal;
553
+
554
+ v8::Local<v8::Value> endOfPassWriteIndexVal;
555
+
556
+
557
+ auto beginningOfPassWriteIndexValSuccess = timestampWrites->Get(context,
558
+ ConvertToV8String(
559
+ isolate,
560
+ "beginningOfPassWriteIndex")).ToLocal(
561
+ &beginningOfPassWriteIndexVal);
562
+
563
+ auto endOfPassWriteIndexValSuccess = timestampWrites->Get(context,
564
+ ConvertToV8String(isolate,
565
+ "endOfPassWriteIndex")).ToLocal(
566
+ &endOfPassWriteIndexVal);
567
+
568
+
569
+ if (beginningOfPassWriteIndexValSuccess && beginningOfPassWriteIndexVal->IsInt32()) {
570
+ beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
571
+ }
572
+
573
+ if (endOfPassWriteIndexValSuccess && endOfPassWriteIndexVal->IsInt32()) {
574
+ endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
575
+ }
576
+
577
+ }
578
+
579
+
580
+ pass = canvas_native_webgpu_command_encoder_begin_render_pass(
581
+ ptr->GetEncoder(), label, colorAttachments_.data(), colorAttachments_.size(),
582
+ depthStencilAttachment, occlusion_query_set,
583
+ querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
584
+ );
585
+
586
+ if (depthStencilAttachment != nullptr) {
587
+ delete depthStencilAttachment;
588
+ }
589
+
590
+
591
+ }
592
+
593
+
594
+ if (pass != nullptr) {
595
+ auto value = new GPURenderPassEncoderImpl(pass);
596
+ auto ret = GPURenderPassEncoderImpl::NewInstance(isolate, value);
597
+ args.GetReturnValue().Set(ret);
598
+ } else {
599
+ args.GetReturnValue().SetUndefined();
600
+ }
601
+
602
+ }
603
+
604
+ void GPUCommandEncoderImpl::ClearBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
605
+ auto ptr = GetPointer(args.This());
606
+ if (ptr == nullptr) {
607
+ return;
608
+ }
609
+
610
+ auto bufferVal = args[0];
611
+ const CanvasGPUBuffer *buffer = nullptr;
612
+
613
+ if (bufferVal->IsObject()) {
614
+ auto bufferPtr = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
615
+ if (bufferPtr != nullptr) {
616
+ buffer = bufferPtr->GetGPUBuffer();
617
+ }
618
+ }
619
+
620
+ if (buffer == nullptr) {
621
+ return;
622
+ }
623
+
624
+ int64_t offset = -1;
625
+ auto offsetVal = args[1];
626
+
627
+ if (offsetVal->IsNumber()) {
628
+ offset = (int64_t) offsetVal.As<v8::Number>()->Value();
629
+ }
630
+
631
+ int64_t size = -1;
632
+ auto sizeVal = args[2];
633
+
634
+ if (sizeVal->IsNumber()) {
635
+ size = (int64_t) sizeVal.As<v8::Number>()->Value();
636
+ }
637
+
638
+ canvas_native_webgpu_command_encoder_clear_buffer(ptr->GetEncoder(), buffer, offset, size);
639
+
640
+ }
641
+
642
+ void GPUCommandEncoderImpl::CopyBufferToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
643
+ auto ptr = GetPointer(args.This());
644
+ if (ptr == nullptr) {
645
+ return;
646
+ }
647
+ auto isolate = args.GetIsolate();
648
+ auto context = isolate->GetCurrentContext();
649
+
650
+ auto source = args[0];
651
+ auto sourceType = GetNativeType(source);
652
+ auto sourceOffset = args[1];
653
+ auto destination = args[2];
654
+ auto destinationType = GetNativeType(destination);
655
+ auto destinationOffset = args[3];
656
+ auto size = args[4];
657
+
658
+ if (sourceType == NativeType::GPUBuffer && destinationType == NativeType::GPUBuffer) {
659
+ auto src = GPUBufferImpl::GetPointer(source.As<v8::Object>());
660
+ auto dst = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
661
+ canvas_native_webgpu_command_encoder_copy_buffer_to_buffer(ptr->GetEncoder(),
662
+ src->GetGPUBuffer(),
663
+ (int64_t) sourceOffset->NumberValue(
664
+ context).FromJust(),
665
+ dst->GetGPUBuffer(),
666
+ (int64_t) destinationOffset->NumberValue(
667
+ context).FromJust(),
668
+ (uint64_t) size->NumberValue(
669
+ context).FromJust()
670
+ );
671
+ }
672
+
673
+ }
674
+
675
+ void GPUCommandEncoderImpl::CopyBufferToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
676
+ auto ptr = GetPointer(args.This());
677
+ if (ptr == nullptr) {
678
+ return;
679
+ }
680
+
681
+
682
+ auto isolate = args.GetIsolate();
683
+ auto context = isolate->GetCurrentContext();
684
+
685
+ auto source = args[0];
686
+ auto destination = args[1];
687
+ auto copySize = args[2];
688
+
689
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
690
+ const CanvasGPUBuffer *buffer = nullptr;
691
+ auto src = source.As<v8::Object>();
692
+ v8::Local<v8::Value> bufferVal;
693
+ src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
694
+ if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
695
+ buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
696
+ }
697
+ uint64_t offset = 0;
698
+ int32_t rowsPerImage = -1;
699
+
700
+ v8::Local<v8::Value> rowsPerImageVal;
701
+
702
+ src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
703
+
704
+ if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
705
+ rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
706
+ }
707
+
708
+
709
+ v8::Local<v8::Value> offsetVal;
710
+
711
+ src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
712
+
713
+ if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
714
+ offset = (int64_t) offsetVal->NumberValue(context).FromJust();
715
+ }
716
+
717
+ v8::Local<v8::Value> bytesPerRowVal;
718
+
719
+ src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
720
+
721
+ CanvasImageCopyBuffer copy{
722
+ buffer,
723
+ offset,
724
+ bytesPerRowVal->Int32Value(context).FromJust(),
725
+ rowsPerImage
726
+ };
727
+
728
+
729
+ uint32_t mipLevel = 0;
730
+ CanvasOrigin3d origin{0, 0, 0};
731
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
732
+
733
+ const CanvasGPUTexture *texture = nullptr;
734
+ auto dst = destination.As<v8::Object>();
735
+
736
+
737
+ v8::Local<v8::Value> textureVal;
738
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
739
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
740
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
741
+ }
742
+
743
+
744
+ v8::Local<v8::Value> mipLevelVal;
745
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
746
+
747
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
748
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
749
+ }
750
+
751
+ v8::Local<v8::Value> originVal;
752
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
753
+
754
+
755
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
756
+ auto originObj = originVal.As<v8::Object>();
757
+
758
+
759
+ v8::Local<v8::Value> xVal;
760
+ v8::Local<v8::Value> yVal;
761
+ v8::Local<v8::Value> zVal;
762
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
763
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
764
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
765
+
766
+ if (xVal->IsUint32()) {
767
+ origin.x = xVal->Uint32Value(context).FromJust();
768
+ }
769
+ if (yVal->IsUint32()) {
770
+ origin.y = yVal->Uint32Value(context).FromJust();
771
+ }
772
+ if (zVal->IsUint32()) {
773
+ origin.z = zVal->Uint32Value(context).FromJust();
774
+ }
775
+
776
+ }
777
+
778
+
779
+ v8::Local<v8::Value> aspectVal;
780
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
781
+
782
+
783
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
784
+
785
+ if (aspectStr == "stencil-only") {
786
+ aspect = CanvasTextureAspectStencilOnly;
787
+ } else if (aspectStr == "depth-only") {
788
+ aspect = CanvasTextureAspectDepthOnly;
789
+ }
790
+
791
+ CanvasImageCopyTexture ct{
792
+ texture, mipLevel, origin, aspect
793
+ };
794
+
795
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
796
+ canvas_native_webgpu_command_encoder_copy_buffer_to_texture(
797
+ ptr->GetEncoder(),
798
+ &copy,
799
+ &ct,
800
+ &cz
801
+ );
802
+ }
803
+
804
+
805
+ }
806
+
807
+ void GPUCommandEncoderImpl::CopyTextureToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
808
+ auto ptr = GetPointer(args.This());
809
+ if (ptr == nullptr) {
810
+ return;
811
+ }
812
+
813
+
814
+ auto isolate = args.GetIsolate();
815
+ auto context = isolate->GetCurrentContext();
816
+
817
+ // copying texture to buffer swapped the real source and dst
818
+ auto source = args[1];
819
+ auto destination = args[0];
820
+ auto copySize = args[2];
821
+
822
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
823
+ const CanvasGPUBuffer *buffer = nullptr;
824
+ auto src = source.As<v8::Object>();
825
+
826
+ v8::Local<v8::Value> bufferVal;
827
+ src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
828
+ if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
829
+ buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
830
+ }
831
+ uint64_t offset = 0;
832
+ int32_t rowsPerImage = -1;
833
+
834
+ v8::Local<v8::Value> rowsPerImageVal;
835
+
836
+ src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
837
+
838
+ if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
839
+ rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
840
+ }
841
+
842
+
843
+ v8::Local<v8::Value> offsetVal;
844
+
845
+ src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
846
+
847
+ if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
848
+ offset = (int64_t) offsetVal->NumberValue(context).FromJust();
849
+ }
850
+
851
+ v8::Local<v8::Value> bytesPerRowVal;
852
+
853
+ src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
854
+
855
+ CanvasImageCopyBuffer copy{
856
+ buffer,
857
+ offset,
858
+ bytesPerRowVal->Int32Value(context).FromJust(),
859
+ rowsPerImage
860
+ };
861
+
862
+
863
+ uint32_t mipLevel = 0;
864
+ CanvasOrigin3d origin{0, 0, 0};
865
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
866
+
867
+ const CanvasGPUTexture *texture = nullptr;
868
+ auto dst = destination.As<v8::Object>();
869
+
870
+
871
+ v8::Local<v8::Value> textureVal;
872
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
873
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
874
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
875
+ }
876
+
877
+
878
+ v8::Local<v8::Value> mipLevelVal;
879
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
880
+
881
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
882
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
883
+ }
884
+
885
+ v8::Local<v8::Value> originVal;
886
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
887
+
888
+
889
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
890
+ auto originObj = originVal.As<v8::Object>();
891
+
892
+
893
+ v8::Local<v8::Value> xVal;
894
+ v8::Local<v8::Value> yVal;
895
+ v8::Local<v8::Value> zVal;
896
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
897
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
898
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
899
+
900
+ if (xVal->IsUint32()) {
901
+ origin.x = xVal->Uint32Value(context).FromJust();
902
+ }
903
+ if (yVal->IsUint32()) {
904
+ origin.y = yVal->Uint32Value(context).FromJust();
905
+ }
906
+ if (zVal->IsUint32()) {
907
+ origin.z = zVal->Uint32Value(context).FromJust();
908
+ }
909
+
910
+ }
911
+
912
+
913
+ v8::Local<v8::Value> aspectVal;
914
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
915
+
916
+
917
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
918
+
919
+ if (aspectStr == "stencil-only") {
920
+ aspect = CanvasTextureAspectStencilOnly;
921
+ } else if (aspectStr == "depth-only") {
922
+ aspect = CanvasTextureAspectDepthOnly;
923
+ }
924
+
925
+ CanvasImageCopyTexture ct{
926
+ texture, mipLevel, origin, aspect
927
+ };
928
+
929
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
930
+ canvas_native_webgpu_command_encoder_copy_texture_to_buffer(
931
+ ptr->GetEncoder(),
932
+ &ct,
933
+ &copy,
934
+ &cz
935
+ );
936
+ }
937
+
938
+
939
+ }
940
+
941
+ void GPUCommandEncoderImpl::CopyTextureToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
942
+ auto ptr = GetPointer(args.This());
943
+ if (ptr == nullptr) {
944
+ return;
945
+ }
946
+
947
+ auto isolate = args.GetIsolate();
948
+ auto context = isolate->GetCurrentContext();
949
+
950
+ // copying texture to buffer swapped the real source and dst
951
+ auto source = args[0];
952
+ auto destination = args[1];
953
+ auto copySize = args[2];
954
+
955
+ if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
956
+ auto src = source.As<v8::Object>();
957
+
958
+ uint32_t mipLevelA = 0;
959
+ CanvasOrigin3d originA{0, 0, 0};
960
+ CanvasTextureAspect aspectA = CanvasTextureAspectAll;
961
+
962
+ const CanvasGPUTexture *textureA = nullptr;
963
+
964
+ v8::Local<v8::Value> srcTextureVal;
965
+ src->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&srcTextureVal);
966
+ if (GetNativeType(srcTextureVal) == NativeType::GPUTexture) {
967
+ textureA = GPUTextureImpl::GetPointer(srcTextureVal.As<v8::Object>())->GetTexture();
968
+ }
969
+
970
+ v8::Local<v8::Value> mipLevelAVal;
971
+ src->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelAVal);
972
+
973
+ if (!mipLevelAVal.IsEmpty() && mipLevelAVal->IsUint32()) {
974
+ mipLevelA = mipLevelAVal->Uint32Value(context).FromJust();
975
+ }
976
+
977
+ v8::Local<v8::Value> originAVal;
978
+ src->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originAVal);
979
+
980
+
981
+ if (!originAVal.IsEmpty() && originAVal->IsObject()) {
982
+ auto originObj = originAVal.As<v8::Object>();
983
+
984
+ v8::Local<v8::Value> xVal;
985
+ v8::Local<v8::Value> yVal;
986
+ v8::Local<v8::Value> zVal;
987
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
988
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
989
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
990
+
991
+ if (xVal->IsUint32()) {
992
+ originA.x = xVal->Uint32Value(context).FromJust();
993
+ }
994
+ if (yVal->IsUint32()) {
995
+ originA.y = yVal->Uint32Value(context).FromJust();
996
+ }
997
+ if (zVal->IsUint32()) {
998
+ originA.z = zVal->Uint32Value(context).FromJust();
999
+ }
1000
+
1001
+ }
1002
+
1003
+ v8::Local<v8::Value> aspectAVal;
1004
+ src->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectAVal);
1005
+
1006
+ auto aspectAStr = ConvertFromV8String(isolate, aspectAVal);
1007
+
1008
+ if (aspectAStr == "stencil-only") {
1009
+ aspectA = CanvasTextureAspectStencilOnly;
1010
+ } else if (aspectAStr == "depth-only") {
1011
+ aspectA = CanvasTextureAspectDepthOnly;
1012
+ }
1013
+ CanvasImageCopyTexture copy{
1014
+ textureA, mipLevelA, originA, aspectA
1015
+ };
1016
+
1017
+ uint32_t mipLevel = 0;
1018
+ CanvasOrigin3d origin{0, 0, 0};
1019
+ CanvasTextureAspect aspect = CanvasTextureAspectAll;
1020
+
1021
+ const CanvasGPUTexture *texture = nullptr;
1022
+ auto dst = destination.As<v8::Object>();
1023
+
1024
+
1025
+ v8::Local<v8::Value> textureVal;
1026
+ dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
1027
+ if (GetNativeType(textureVal) == NativeType::GPUTexture) {
1028
+ texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
1029
+ }
1030
+
1031
+
1032
+ v8::Local<v8::Value> mipLevelVal;
1033
+ dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
1034
+
1035
+ if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
1036
+ mipLevel = mipLevelVal->Uint32Value(context).FromJust();
1037
+ }
1038
+
1039
+ v8::Local<v8::Value> originVal;
1040
+ dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
1041
+
1042
+ if (!originVal.IsEmpty() && originVal->IsObject()) {
1043
+ auto originObj = originVal.As<v8::Object>();
1044
+
1045
+ v8::Local<v8::Value> xVal;
1046
+ v8::Local<v8::Value> yVal;
1047
+ v8::Local<v8::Value> zVal;
1048
+ originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
1049
+ originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
1050
+ originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
1051
+
1052
+ if (xVal->IsUint32()) {
1053
+ origin.x = xVal->Uint32Value(context).FromJust();
1054
+ }
1055
+ if (yVal->IsUint32()) {
1056
+ origin.y = yVal->Uint32Value(context).FromJust();
1057
+ }
1058
+ if (zVal->IsUint32()) {
1059
+ origin.z = zVal->Uint32Value(context).FromJust();
1060
+ }
1061
+
1062
+ }
1063
+
1064
+
1065
+ v8::Local<v8::Value> aspectVal;
1066
+ dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
1067
+
1068
+ auto aspectStr = ConvertFromV8String(isolate, aspectVal);
1069
+
1070
+ if (aspectStr == "stencil-only") {
1071
+ aspect = CanvasTextureAspectStencilOnly;
1072
+ } else if (aspectStr == "depth-only") {
1073
+ aspect = CanvasTextureAspectDepthOnly;
1074
+ }
1075
+
1076
+ CanvasImageCopyTexture ct{
1077
+ texture, mipLevel, origin, aspect
1078
+ };
1079
+
1080
+ CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
1081
+
1082
+ canvas_native_webgpu_command_encoder_copy_texture_to_texture(
1083
+ ptr->GetEncoder(),
1084
+ &copy,
1085
+ &ct,
1086
+ &cz
1087
+ );
1088
+ }
1089
+
1090
+
1091
+ }
1092
+
1093
+ void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &args) {
1094
+ auto ptr = GetPointer(args.This());
1095
+ if (ptr == nullptr) {
1096
+ return;
1097
+ }
1098
+
1099
+ auto isolate = args.GetIsolate();
1100
+ auto context = isolate->GetCurrentContext();
1101
+
1102
+
1103
+ auto descVal = args[0];
1104
+ std::string label;
1105
+ bool didSet = false;
1106
+ if (descVal->IsObject()) {
1107
+ auto desc = descVal.As<v8::Object>();
1108
+ v8::Local<v8::Value> labelVal;
1109
+ didSet = desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
1110
+ if (didSet && labelVal->IsString()) {
1111
+ label = ConvertFromV8String(isolate, labelVal);
1112
+ }
1113
+ }
1114
+
1115
+ auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(),
1116
+ didSet ? label.c_str() : nullptr);
1117
+
1118
+ if (value != nullptr) {
1119
+ auto ret = GPUCommandBufferImpl::NewInstance(isolate, new GPUCommandBufferImpl(value));
1120
+ args.GetReturnValue().Set(ret);
1121
+ return;
1122
+ }
1123
+
1124
+ args.GetReturnValue().SetUndefined();
1125
+ }
1126
+
1127
+ void
1128
+ GPUCommandEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
1129
+ auto *ptr = GetPointer(args.This());
1130
+ if (ptr == nullptr) {
1131
+ return;
1132
+ }
1133
+
1134
+ auto isolate = args.GetIsolate();
1135
+
1136
+ auto markerLabelVal = args[0];
1137
+ if (markerLabelVal->IsString()) {
1138
+ auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
1139
+ canvas_native_webgpu_command_encoder_insert_debug_marker(ptr->GetEncoder(),
1140
+ markerLabel.c_str());
1141
+ }
1142
+ }
1143
+
1144
+ void GPUCommandEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
1145
+ auto *ptr = GetPointer(args.This());
1146
+ if (ptr == nullptr) {
1147
+ return;
1148
+ }
1149
+
1150
+ canvas_native_webgpu_command_encoder_pop_debug_group(ptr->GetEncoder());
1151
+ }
1152
+
1153
+ void GPUCommandEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
1154
+ auto *ptr = GetPointer(args.This());
1155
+ if (ptr == nullptr) {
1156
+ return;
1157
+ }
1158
+
1159
+ auto isolate = args.GetIsolate();
1160
+
1161
+ auto groupLabelVal = args[0];
1162
+ if (groupLabelVal->IsString()) {
1163
+ auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
1164
+ canvas_native_webgpu_command_encoder_push_debug_group(ptr->GetEncoder(),
1165
+ groupLabel.c_str());
1166
+ }
1167
+ }
1168
+
1169
+ void GPUCommandEncoderImpl::ResolveQuerySet(const v8::FunctionCallbackInfo<v8::Value> &args) {
1170
+ auto *ptr = GetPointer(args.This());
1171
+ if (ptr == nullptr) {
1172
+ return;
1173
+ }
1174
+
1175
+ auto isolate = args.GetIsolate();
1176
+ auto context = isolate->GetCurrentContext();
1177
+
1178
+ auto querySet = args[0];
1179
+ auto queryType = GetNativeType(querySet);
1180
+ auto firstQuery = args[1];
1181
+ auto queryCount = args[2];
1182
+ auto destination = args[3];
1183
+ auto destinationType = GetNativeType(destination);
1184
+ auto destinationOffset = args[4];
1185
+
1186
+
1187
+ if (queryType == NativeType::GPUQuerySet && destinationType == NativeType::GPUBuffer) {
1188
+ auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
1189
+ auto dest = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
1190
+ canvas_native_webgpu_command_encoder_resolve_query_set(ptr->GetEncoder(), qs->GetQuerySet(),
1191
+ firstQuery->Uint32Value(
1192
+ context).FromJust(),
1193
+ queryCount->Uint32Value(
1194
+ context).FromJust(),
1195
+ dest->GetGPUBuffer(),
1196
+ (uint64_t) destinationOffset->NumberValue(
1197
+ context).FromJust());
1198
+ }
1199
+ }
1200
+
1201
+ void GPUCommandEncoderImpl::WriteTimestamp(const v8::FunctionCallbackInfo<v8::Value> &args) {
1202
+ auto *ptr = GetPointer(args.This());
1203
+ if (ptr == nullptr) {
1204
+ return;
1205
+ }
1206
+
1207
+ auto isolate = args.GetIsolate();
1208
+ auto context = isolate->GetCurrentContext();
1209
+
1210
+ auto querySet = args[0];
1211
+ auto queryType = GetNativeType(querySet);
1212
+ auto queryIndex = args[1];
1213
+
1214
+ if (queryType == NativeType::GPUQuerySet) {
1215
+ auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
1216
+ canvas_native_webgpu_command_encoder_write_timestamp(ptr->GetEncoder(), qs->GetQuerySet(),
1217
+ queryIndex->Uint32Value(
1218
+ context).FromJust());
1219
+ }
1220
+
1221
+
1222
+ }