@nativescript/canvas 2.0.0-webgpu.2 → 2.0.0-webgpu.21

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 (251) hide show
  1. package/Canvas/common.d.ts +3 -4
  2. package/Canvas/common.js +35 -125
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +0 -1
  5. package/Canvas/index.android.js +45 -38
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +11 -3
  8. package/Canvas/index.ios.js +49 -40
  9. package/Canvas/index.ios.js.map +1 -1
  10. package/Canvas/utils.d.ts +3 -0
  11. package/Canvas/utils.js +85 -0
  12. package/Canvas/utils.js.map +1 -0
  13. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -0
  14. package/Canvas2D/CanvasRenderingContext2D/index.js +1 -0
  15. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  16. package/Dom/Group.d.ts +1 -2
  17. package/Dom/Group.js.map +1 -1
  18. package/Dom/Image.js +0 -1
  19. package/Dom/Image.js.map +1 -1
  20. package/Dom/Paint.d.ts +1 -1
  21. package/Dom/shapes/Path.d.ts +1 -1
  22. package/ImageAsset/index.js +77 -33
  23. package/ImageAsset/index.js.map +1 -1
  24. package/ImageBitmap/index.js +107 -20
  25. package/ImageBitmap/index.js.map +1 -1
  26. package/README.md +2 -4
  27. package/WebGL/WebGLRenderingContext/index.js +73 -31
  28. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  29. package/WebGL2/WebGL2RenderingContext/index.js +4 -4
  30. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  31. package/WebGPU/GPU.js +4 -3
  32. package/WebGPU/GPU.js.map +1 -1
  33. package/WebGPU/GPUAdapter.d.ts +6 -3
  34. package/WebGPU/GPUAdapter.js +31 -0
  35. package/WebGPU/GPUAdapter.js.map +1 -1
  36. package/WebGPU/GPUBindGroup.d.ts +1 -0
  37. package/WebGPU/GPUBindGroup.js +3 -0
  38. package/WebGPU/GPUBindGroup.js.map +1 -1
  39. package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
  40. package/WebGPU/GPUBindGroupLayout.js +3 -0
  41. package/WebGPU/GPUBindGroupLayout.js.map +1 -1
  42. package/WebGPU/GPUBuffer.js +10 -2
  43. package/WebGPU/GPUBuffer.js.map +1 -1
  44. package/WebGPU/GPUCanvasContext.d.ts +3 -2
  45. package/WebGPU/GPUCanvasContext.js +52 -10
  46. package/WebGPU/GPUCanvasContext.js.map +1 -1
  47. package/WebGPU/GPUCommandBuffer.d.ts +1 -0
  48. package/WebGPU/GPUCommandBuffer.js +3 -0
  49. package/WebGPU/GPUCommandBuffer.js.map +1 -1
  50. package/WebGPU/GPUCommandEncoder.d.ts +3 -9
  51. package/WebGPU/GPUCommandEncoder.js +94 -41
  52. package/WebGPU/GPUCommandEncoder.js.map +1 -1
  53. package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
  54. package/WebGPU/GPUComputePassEncoder.js +3 -0
  55. package/WebGPU/GPUComputePassEncoder.js.map +1 -1
  56. package/WebGPU/GPUComputePipeline.d.ts +1 -0
  57. package/WebGPU/GPUComputePipeline.js +3 -0
  58. package/WebGPU/GPUComputePipeline.js.map +1 -1
  59. package/WebGPU/GPUDevice.d.ts +17 -79
  60. package/WebGPU/GPUDevice.js +72 -91
  61. package/WebGPU/GPUDevice.js.map +1 -1
  62. package/WebGPU/GPUExternalTexture.d.ts +1 -0
  63. package/WebGPU/GPUExternalTexture.js +3 -0
  64. package/WebGPU/GPUExternalTexture.js.map +1 -1
  65. package/WebGPU/GPUPipelineLayout.d.ts +1 -0
  66. package/WebGPU/GPUPipelineLayout.js +3 -0
  67. package/WebGPU/GPUPipelineLayout.js.map +1 -1
  68. package/WebGPU/GPUQuerySet.d.ts +1 -0
  69. package/WebGPU/GPUQuerySet.js +3 -0
  70. package/WebGPU/GPUQuerySet.js.map +1 -1
  71. package/WebGPU/GPUQueue.d.ts +1 -0
  72. package/WebGPU/GPUQueue.js +45 -7
  73. package/WebGPU/GPUQueue.js.map +1 -1
  74. package/WebGPU/GPURenderBundle.d.ts +1 -0
  75. package/WebGPU/GPURenderBundle.js +3 -0
  76. package/WebGPU/GPURenderBundle.js.map +1 -1
  77. package/WebGPU/GPURenderBundleEncoder.d.ts +4 -2
  78. package/WebGPU/GPURenderBundleEncoder.js +7 -3
  79. package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
  80. package/WebGPU/GPURenderPassEncoder.d.ts +2 -1
  81. package/WebGPU/GPURenderPassEncoder.js +5 -2
  82. package/WebGPU/GPURenderPassEncoder.js.map +1 -1
  83. package/WebGPU/GPURenderPipeline.d.ts +1 -0
  84. package/WebGPU/GPURenderPipeline.js +3 -0
  85. package/WebGPU/GPURenderPipeline.js.map +1 -1
  86. package/WebGPU/GPUSampler.d.ts +1 -0
  87. package/WebGPU/GPUSampler.js +3 -0
  88. package/WebGPU/GPUSampler.js.map +1 -1
  89. package/WebGPU/GPUShaderModule.d.ts +1 -1
  90. package/WebGPU/GPUShaderModule.js +2 -2
  91. package/WebGPU/GPUShaderModule.js.map +1 -1
  92. package/WebGPU/GPUTexture.d.ts +1 -0
  93. package/WebGPU/GPUTexture.js +3 -0
  94. package/WebGPU/GPUTexture.js.map +1 -1
  95. package/WebGPU/GPUTextureView.d.ts +1 -0
  96. package/WebGPU/GPUTextureView.js +3 -0
  97. package/WebGPU/GPUTextureView.js.map +1 -1
  98. package/WebGPU/Interfaces.d.ts +95 -4
  99. package/WebGPU/Types.d.ts +9 -1
  100. package/WebGPU/Utils.d.ts +6 -0
  101. package/WebGPU/Utils.js +221 -0
  102. package/WebGPU/Utils.js.map +1 -1
  103. package/angular/esm2022/index.mjs +4 -4
  104. package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
  105. package/angular/package.json +20 -0
  106. package/package.json +1 -3
  107. package/platforms/android/canvas-release.aar +0 -0
  108. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  109. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  110. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +9 -0
  111. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  112. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +226 -61
  113. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  114. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  115. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +6871 -5995
  116. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +7 -0
  117. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +7 -0
  118. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  119. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +656 -644
  120. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  121. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +18 -0
  122. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  123. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +226 -61
  124. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  125. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +6871 -5995
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +7 -0
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -0
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +6871 -5995
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +7 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +7 -0
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +27 -27
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +658 -646
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +696 -684
  137. package/platforms/ios/src/NSOperationQueueWrapper.h +3 -1
  138. package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
  139. package/platforms/ios/src/cpp/AsyncCallback.h +214 -0
  140. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +123 -47
  141. package/platforms/ios/src/cpp/Helpers.h +2 -164
  142. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +18 -26
  143. package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
  144. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
  145. package/platforms/ios/src/cpp/ImageBitmapImpl.h +12 -4
  146. package/platforms/ios/src/cpp/NativeType.h +87 -0
  147. package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
  148. package/platforms/ios/src/cpp/PromiseCallback.h +197 -0
  149. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
  150. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
  151. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
  152. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +6 -6
  153. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +18 -13
  154. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
  155. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
  156. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
  157. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
  158. package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
  159. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
  160. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
  161. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
  162. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
  163. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
  164. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
  165. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
  166. package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
  167. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
  168. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
  169. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
  170. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
  171. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
  172. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
  173. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
  174. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
  175. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
  176. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
  177. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
  178. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
  179. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
  180. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
  181. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
  182. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
  183. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
  184. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
  185. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
  186. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
  187. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
  188. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
  189. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
  190. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
  191. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
  192. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
  193. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
  194. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
  195. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
  196. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
  197. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
  198. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
  199. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
  200. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
  201. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +142 -73
  202. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
  203. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
  204. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
  205. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +32 -6
  206. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +5 -2
  207. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +27 -1
  208. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +4 -1
  209. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +80 -32
  210. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +8 -4
  211. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
  212. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
  213. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +29 -2
  214. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +4 -1
  215. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +101 -106
  216. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +5 -1
  217. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
  218. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +4 -1
  219. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +26 -1
  220. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +3 -1
  221. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1683 -733
  222. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +3 -1
  223. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +53 -39
  224. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +2 -2
  225. package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
  226. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +27 -1
  227. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +8 -5
  228. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +2 -3
  229. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +2 -2
  230. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +88 -36
  231. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +4 -1
  232. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +43 -14
  233. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +4 -1
  234. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +26 -1
  235. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +4 -1
  236. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +40 -14
  237. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +4 -1
  238. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +26 -1
  239. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +4 -1
  240. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +27 -1
  241. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +5 -2
  242. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +25 -1
  243. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +5 -2
  244. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
  245. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
  246. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
  247. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +6 -4
  248. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +27 -1
  249. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +5 -2
  250. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
  251. package/utils.d.ts +1 -1
@@ -8,6 +8,7 @@
8
8
  #include "Helpers.h"
9
9
  #include "ObjectWrapperImpl.h"
10
10
 
11
+
11
12
  class GPUBufferImpl : ObjectWrapperImpl {
12
13
  public:
13
14
  explicit GPUBufferImpl(const CanvasGPUBuffer *buffer);
@@ -24,14 +25,14 @@ public:
24
25
 
25
26
  static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
26
27
 
27
- static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUBufferImpl *adapter) {
28
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUBufferImpl *buffer) {
28
29
  auto context = isolate->GetCurrentContext();
29
30
  v8::EscapableHandleScope scope(isolate);
30
31
  auto object = GPUBufferImpl::GetCtor(isolate)->GetFunction(
31
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
32
- SetNativeType(object, NativeType::GPUBuffer);
33
- object->SetAlignedPointerInInternalField(0, adapter);
34
- adapter->BindFinalizer(isolate, object);
33
+ SetNativeType(buffer, NativeType::GPUBuffer);
34
+ object->SetAlignedPointerInInternalField(0, buffer);
35
+ buffer->BindFinalizer(isolate, object);
35
36
  return scope.Escape(object);
36
37
  }
37
38
 
@@ -50,6 +51,9 @@ public:
50
51
 
51
52
  static void GetMappedRange(const v8::FunctionCallbackInfo<v8::Value> &args);
52
53
 
54
+ static void GetLabel(v8::Local<v8::Name> name,
55
+ const v8::PropertyCallbackInfo<v8::Value> &info);
56
+
53
57
 
54
58
  private:
55
59
  const CanvasGPUBuffer *buffer_;
@@ -189,7 +189,7 @@ void GPUCanvasContextImpl::Configure(const v8::FunctionCallbackInfo<v8::Value> &
189
189
 
190
190
  v8::Local<v8::Value> sizeValue;
191
191
  options->Get(context, ConvertToV8String(isolate, "size")).ToLocal(
192
- &usageValue);
192
+ &sizeValue);
193
193
 
194
194
  CanvasExtent3d size = ParseExtent3d(isolate, sizeValue);
195
195
 
@@ -207,7 +207,7 @@ void GPUCanvasContextImpl::UnConfigure(const v8::FunctionCallbackInfo<v8::Value>
207
207
  return;
208
208
  }
209
209
 
210
- // canvas_native_webgpu_context_unconfigure(ptr->GetContext());
210
+ canvas_native_webgpu_context_unconfigure(ptr->GetContext());
211
211
 
212
212
  }
213
213
 
@@ -224,9 +224,15 @@ void GPUCanvasContextImpl::GetCurrentTexture(const v8::FunctionCallbackInfo<v8::
224
224
  auto texture = canvas_native_webgpu_context_get_current_texture(ctx);
225
225
 
226
226
  if (texture != nullptr) {
227
- auto textureImpl = new GPUTextureImpl(texture);
228
- auto ret = GPUTextureImpl::NewInstance(isolate, textureImpl);
229
- args.GetReturnValue().Set(ret);
227
+ auto status = canvas_native_webgpu_texture_get_status(texture);
228
+ if(status == SurfaceGetCurrentTextureStatusSuccess){
229
+ auto textureImpl = new GPUTextureImpl(texture);
230
+ auto ret = GPUTextureImpl::NewInstance(isolate, textureImpl);
231
+ args.GetReturnValue().Set(ret);
232
+ }else {
233
+ canvas_native_webgpu_texture_release(texture);
234
+ args.GetReturnValue().SetNull();
235
+ }
230
236
  return;
231
237
  }
232
238
 
@@ -31,7 +31,7 @@ public:
31
31
  v8::EscapableHandleScope scope(isolate);
32
32
  auto object = GPUCanvasContextImpl::GetCtor(isolate)->GetFunction(
33
33
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
- SetNativeType(object, NativeType::GPUCanvasContext);
34
+ SetNativeType(ctx, NativeType::GPUCanvasContext);
35
35
  object->SetAlignedPointerInInternalField(0, ctx);
36
36
  ctx->BindFinalizer(isolate, object);
37
37
  return scope.Escape(object);
@@ -5,7 +5,8 @@
5
5
  #include "GPUCommandBufferImpl.h"
6
6
  #include "Caches.h"
7
7
 
8
- GPUCommandBufferImpl::GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer) : commandBuffer_(
8
+ GPUCommandBufferImpl::GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer)
9
+ : commandBuffer_(
9
10
  commandBuffer) {}
10
11
 
11
12
  const CanvasGPUCommandBuffer *GPUCommandBufferImpl::GetGPUCommandBuffer() {
@@ -22,7 +23,7 @@ void GPUCommandBufferImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate
22
23
  auto context = isolate->GetCurrentContext();
23
24
  auto func = ctor->GetFunction(context).ToLocalChecked();
24
25
 
25
- canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandBuffer"), func).FromJust();;
26
+ canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandBuffer"), func).FromJust();
26
27
  }
27
28
 
28
29
  GPUCommandBufferImpl *GPUCommandBufferImpl::GetPointer(const v8::Local<v8::Object> &object) {
@@ -47,8 +48,34 @@ v8::Local<v8::FunctionTemplate> GPUCommandBufferImpl::GetCtor(v8::Isolate *isola
47
48
  auto tmpl = ctorTmpl->InstanceTemplate();
48
49
  tmpl->SetInternalFieldCount(2);
49
50
 
51
+ tmpl->SetLazyDataProperty(
52
+ ConvertToV8String(isolate, "label"),
53
+ GetLabel
54
+ );
55
+
50
56
 
51
57
  cache->GPUCommandBufferTmpl =
52
58
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
53
59
  return ctorTmpl;
54
60
  }
61
+
62
+
63
+ void
64
+ GPUCommandBufferImpl::GetLabel(v8::Local<v8::Name> name,
65
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
66
+ auto ptr = GetPointer(info.This());
67
+ if (ptr != nullptr) {
68
+ auto label = canvas_native_webgpu_command_buffer_get_label(ptr->commandBuffer_);
69
+ if (label == nullptr) {
70
+ info.GetReturnValue().SetEmptyString();
71
+ return;
72
+ }
73
+ info.GetReturnValue().Set(
74
+ ConvertToV8String(info.GetIsolate(), label)
75
+ );
76
+ canvas_native_string_destroy(label);
77
+ return;
78
+ }
79
+
80
+ info.GetReturnValue().SetEmptyString();
81
+ }
@@ -31,12 +31,15 @@ public:
31
31
  v8::EscapableHandleScope scope(isolate);
32
32
  auto object = GPUCommandBufferImpl::GetCtor(isolate)->GetFunction(
33
33
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
34
- SetNativeType(object, NativeType::GPUCommandBuffer);
34
+ SetNativeType(commandBuffer, NativeType::GPUCommandBuffer);
35
35
  object->SetAlignedPointerInInternalField(0, commandBuffer);
36
36
  commandBuffer->BindFinalizer(isolate, object);
37
37
  return scope.Escape(object);
38
38
  }
39
39
 
40
+ static void GetLabel(v8::Local<v8::Name> name,
41
+ const v8::PropertyCallbackInfo<v8::Value> &info);
42
+
40
43
  private:
41
44
  const CanvasGPUCommandBuffer *commandBuffer_;
42
45
  };
@@ -11,6 +11,7 @@
11
11
  #include "GPURenderPassEncoderImpl.h"
12
12
  #include "GPUCommandBufferImpl.h"
13
13
  #include "GPUTextureImpl.h"
14
+ #include "GPULabel.h"
14
15
 
15
16
  GPUCommandEncoderImpl::GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder) : encoder_(
16
17
  encoder) {}
@@ -53,6 +54,10 @@ v8::Local<v8::FunctionTemplate> GPUCommandEncoderImpl::GetCtor(v8::Isolate *isol
53
54
  auto tmpl = ctorTmpl->InstanceTemplate();
54
55
  tmpl->SetInternalFieldCount(2);
55
56
 
57
+ tmpl->SetLazyDataProperty(
58
+ ConvertToV8String(isolate, "label"),
59
+ GetLabel
60
+ );
56
61
 
57
62
  tmpl->Set(
58
63
  ConvertToV8String(isolate, "beginComputePass"),
@@ -112,6 +117,26 @@ v8::Local<v8::FunctionTemplate> GPUCommandEncoderImpl::GetCtor(v8::Isolate *isol
112
117
  return ctorTmpl;
113
118
  }
114
119
 
120
+ void
121
+ GPUCommandEncoderImpl::GetLabel(v8::Local<v8::Name> name,
122
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
123
+ auto ptr = GetPointer(info.This());
124
+ if (ptr != nullptr) {
125
+ auto label = canvas_native_webgpu_command_encoder_get_label(ptr->encoder_);
126
+ if (label == nullptr) {
127
+ info.GetReturnValue().SetEmptyString();
128
+ return;
129
+ }
130
+ info.GetReturnValue().Set(
131
+ ConvertToV8String(info.GetIsolate(), label)
132
+ );
133
+ canvas_native_string_destroy(label);
134
+ return;
135
+ }
136
+
137
+ info.GetReturnValue().SetEmptyString();
138
+ }
139
+
115
140
 
116
141
  void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args) {
117
142
  auto ptr = GetPointer(args.This());
@@ -133,32 +158,28 @@ void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::
133
158
  v8::Local<v8::Value> labelVal;
134
159
  desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
135
160
 
136
- char *label = nullptr;
137
-
138
- if (!labelVal.IsEmpty() && labelVal->IsString()) {
139
- label = *v8::String::Utf8Value(isolate, labelVal);
140
- }
161
+ auto label = GPULabel(isolate, labelVal);
141
162
 
142
163
  const CanvasGPUQuerySet *querySet = nullptr;
164
+
143
165
  int32_t beginningOfPassWriteIndex = -1;
144
166
 
145
167
  int32_t endOfPassWriteIndex = -1;
146
168
 
147
169
 
148
170
  v8::Local<v8::Value> timestampWritesVal;
149
- desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
150
- &timestampWritesVal);
151
171
 
152
-
153
- if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
172
+ auto success = desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
173
+ &timestampWritesVal);
174
+ if (success && timestampWritesVal->IsObject()) {
154
175
  auto timestampWrites = timestampWritesVal.As<v8::Object>();
155
176
 
156
177
  v8::Local<v8::Value> querySetVal;
157
- timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
178
+ success = timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
158
179
  &querySetVal);
159
180
 
160
181
 
161
- if (!querySetVal.IsEmpty() && querySetVal->IsObject()) {
182
+ if (success && querySetVal->IsObject()) {
162
183
  auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
163
184
  if (queryPtr != nullptr) {
164
185
  querySet = queryPtr->GetQuerySet();
@@ -171,27 +192,29 @@ void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::
171
192
  v8::Local<v8::Value> endOfPassWriteIndexVal;
172
193
 
173
194
 
174
- timestampWrites->Get(context,
175
- ConvertToV8String(isolate, "beginningOfPassWriteIndex")).ToLocal(
195
+ success = timestampWrites->Get(context,
196
+ ConvertToV8String(isolate,
197
+ "beginningOfPassWriteIndex")).ToLocal(
176
198
  &beginningOfPassWriteIndexVal);
177
199
 
178
- timestampWrites->Get(context,
179
- ConvertToV8String(isolate, "endOfPassWriteIndex")).ToLocal(
180
- &endOfPassWriteIndexVal);
181
-
182
-
183
- if (beginningOfPassWriteIndexVal->IsInt32()) {
200
+ if (success && beginningOfPassWriteIndexVal->IsInt32()) {
184
201
  beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
185
202
  }
186
203
 
187
- if (endOfPassWriteIndexVal->IsInt32()) {
204
+ success = timestampWrites->Get(context,
205
+ ConvertToV8String(isolate,
206
+ "endOfPassWriteIndex")).ToLocal(
207
+ &endOfPassWriteIndexVal);
208
+
209
+
210
+ if (success && endOfPassWriteIndexVal->IsInt32()) {
188
211
  endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
189
212
  }
190
213
  }
191
214
 
192
215
 
193
216
  pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
194
- querySet, label,
217
+ querySet, *label,
195
218
  beginningOfPassWriteIndex,
196
219
  endOfPassWriteIndex);
197
220
 
@@ -232,15 +255,10 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
232
255
  if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
233
256
  auto desc = descVal.As<v8::Object>();
234
257
 
235
-
236
258
  v8::Local<v8::Value> labelVal;
237
259
  desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
238
260
 
239
- char *label = nullptr;
240
-
241
- if (!labelVal.IsEmpty() && labelVal->IsString()) {
242
- label = *v8::String::Utf8Value(isolate, labelVal);
243
- }
261
+ auto label = GPULabel(isolate, labelVal);
244
262
 
245
263
 
246
264
  v8::Local<v8::Value> colorAttachmentsVal;
@@ -260,65 +278,46 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
260
278
 
261
279
  auto clearValue = ParseColor(isolate, clearValueVal);
262
280
 
281
+ const CanvasGPUTextureView *view = nullptr;
282
+
263
283
  v8::Local<v8::Value> viewVal;
264
- colorAttachment->Get(context, ConvertToV8String(isolate,
265
- "view")).ToLocal(&viewVal);
266
284
 
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;
285
+ if (colorAttachment->Get(context, ConvertToV8String(isolate,
286
+ "view")).ToLocal(&viewVal)) {
287
+ auto type = GetNativeType(viewVal);
288
+ if (type == NativeType::GPUTextureView) {
289
+ auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
290
+ view = viewPtr->GetTextureView();
291
+ }
292
+ }
293
+
294
+
295
+ const CanvasGPUTextureView *resolveTarget = nullptr;
273
296
 
274
- v8::Local<v8::Value> resolve_target_val;
297
+ v8::Local<v8::Value> resolveTargetVal;
275
298
 
276
299
  colorAttachment->Get(context, ConvertToV8String(isolate, "resolveTarget")).ToLocal(
277
- &resolve_target_val);
300
+ &resolveTargetVal);
278
301
 
279
- auto resolve_target_type = GetNativeType(resolve_target_val);
302
+ auto resolve_target_type = GetNativeType(resolveTargetVal);
280
303
 
281
304
  if (resolve_target_type == NativeType::GPUTextureView) {
282
- auto res = GPUTextureViewImpl::GetPointer(resolve_target_val.As<v8::Object>());
283
- resolve_target = res->GetTextureView();
305
+ auto res = GPUTextureViewImpl::GetPointer(resolveTargetVal.As<v8::Object>());
306
+ resolveTarget = res->GetTextureView();
284
307
  }
285
308
 
286
- // default
287
- CanvasLoadOp load = CanvasLoadOp::CanvasLoadOpClear;
288
- CanvasStoreOp store = CanvasStoreOp::CanvasStoreOpStore;
289
309
  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
310
  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
- }
311
+ colorAttachment->Get(context, ConvertToV8String(isolate,
312
+ "loadOp")).ToLocal(&loadVal);
313
+
314
+ colorAttachment->Get(context, ConvertToV8String(isolate,
315
+ "storeOp")).ToLocal(&storeVal);
316
+
317
+
318
+ CanvasLoadOp load = ParseCanvasLoadOp(isolate, loadVal);
319
+ CanvasStoreOp store = ParseCanvasStoreOp(isolate, storeVal);
320
+
322
321
 
323
322
  CanvasPassChannelColor channel{
324
323
  load,
@@ -329,7 +328,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
329
328
 
330
329
  auto attachment = CanvasRenderPassColorAttachment{
331
330
  view,
332
- resolve_target,
331
+ resolveTarget,
333
332
  channel
334
333
  };
335
334
 
@@ -381,20 +380,20 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
381
380
  &depthLoadOp);
382
381
 
383
382
  depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
384
- CanvasOptionalLoadOpNone
383
+ CanvasOptionalLoadOpNone
385
384
  };
386
385
 
387
386
  if (!depthLoadOp.IsEmpty() && depthLoadOp->IsString()) {
388
387
  auto value = ConvertFromV8String(isolate, depthLoadOp);
389
388
  if (value == "load") {
390
389
  depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
391
- CanvasOptionalLoadOpSome,
392
- CanvasLoadOpLoad
390
+ CanvasOptionalLoadOpSome,
391
+ CanvasLoadOpLoad
393
392
  };
394
393
  } else if (value == "clear") {
395
394
  depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
396
- CanvasOptionalLoadOpSome,
397
- CanvasLoadOpClear
395
+ CanvasOptionalLoadOpSome,
396
+ CanvasLoadOpClear
398
397
  };
399
398
  }
400
399
  }
@@ -406,20 +405,20 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
406
405
  &depthStoreOp);
407
406
 
408
407
  depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
409
- CanvasOptionalStoreOpNone
408
+ CanvasOptionalStoreOpNone
410
409
  };
411
410
 
412
411
  if (!depthStoreOp.IsEmpty() && depthStoreOp->IsString()) {
413
412
  auto value = ConvertFromV8String(isolate, depthStoreOp);
414
413
  if (value == "store") {
415
414
  depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
416
- CanvasOptionalStoreOpSome,
417
- CanvasStoreOpStore
415
+ CanvasOptionalStoreOpSome,
416
+ CanvasStoreOpStore
418
417
  };
419
418
  } else if (value == "discard") {
420
419
  depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
421
- CanvasOptionalStoreOpSome,
422
- CanvasStoreOpDiscard
420
+ CanvasOptionalStoreOpSome,
421
+ CanvasStoreOpDiscard
423
422
  };
424
423
  }
425
424
  }
@@ -455,20 +454,20 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
455
454
  &stencilLoadOp);
456
455
 
457
456
  depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
458
- CanvasOptionalLoadOpNone
457
+ CanvasOptionalLoadOpNone
459
458
  };
460
459
 
461
460
  if (!stencilLoadOp.IsEmpty() && stencilLoadOp->IsString()) {
462
461
  auto value = ConvertFromV8String(isolate, stencilLoadOp);
463
462
  if (value == "load") {
464
463
  depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
465
- CanvasOptionalLoadOpSome,
466
- CanvasLoadOpLoad
464
+ CanvasOptionalLoadOpSome,
465
+ CanvasLoadOpLoad
467
466
  };
468
467
  } else if (value == "clear") {
469
468
  depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
470
- CanvasOptionalLoadOpSome,
471
- CanvasLoadOpClear
469
+ CanvasOptionalLoadOpSome,
470
+ CanvasLoadOpClear
472
471
  };
473
472
  }
474
473
  }
@@ -480,20 +479,20 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
480
479
  &stencilStoreOp);
481
480
 
482
481
  depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
483
- CanvasOptionalStoreOpNone
482
+ CanvasOptionalStoreOpNone
484
483
  };
485
484
 
486
485
  if (!stencilStoreOp.IsEmpty() && stencilStoreOp->IsString()) {
487
486
  auto value = ConvertFromV8String(isolate, stencilStoreOp);
488
487
  if (value == "store") {
489
488
  depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
490
- CanvasOptionalStoreOpSome,
491
- CanvasStoreOpStore
489
+ CanvasOptionalStoreOpSome,
490
+ CanvasStoreOpStore
492
491
  };
493
492
  } else if (value == "discard") {
494
493
  depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
495
- CanvasOptionalStoreOpSome,
496
- CanvasStoreOpDiscard
494
+ CanvasOptionalStoreOpSome,
495
+ CanvasStoreOpDiscard
497
496
  };
498
497
  }
499
498
  }
@@ -518,7 +517,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
518
517
  desc->Get(context, ConvertToV8String(isolate, "occlusionQuerySet")).ToLocal(
519
518
  &occlusionQuerySetVal);
520
519
 
521
-
520
+
522
521
  if (GetNativeType(occlusionQuerySetVal) == NativeType::GPUQuerySet) {
523
522
  auto occlusionQuerySet = GPUQuerySetImpl::GetPointer(
524
523
  occlusionQuerySetVal.As<v8::Object>());
@@ -578,13 +577,14 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
578
577
 
579
578
 
580
579
  pass = canvas_native_webgpu_command_encoder_begin_render_pass(
581
- ptr->GetEncoder(), label, colorAttachments_.data(), colorAttachments_.size(),
580
+ ptr->GetEncoder(), *label, colorAttachments_.data(), colorAttachments_.size(),
582
581
  depthStencilAttachment, occlusion_query_set,
583
582
  querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
584
583
  );
585
584
 
586
585
  if (depthStencilAttachment != nullptr) {
587
586
  delete depthStencilAttachment;
587
+ depthStencilAttachment = nullptr;
588
588
  }
589
589
 
590
590
 
@@ -1099,21 +1099,16 @@ void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &ar
1099
1099
  auto isolate = args.GetIsolate();
1100
1100
  auto context = isolate->GetCurrentContext();
1101
1101
 
1102
-
1103
1102
  auto descVal = args[0];
1104
- std::string label;
1105
- bool didSet = false;
1103
+ GPULabel label;
1106
1104
  if (descVal->IsObject()) {
1107
1105
  auto desc = descVal.As<v8::Object>();
1108
1106
  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
- }
1107
+ desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
1108
+ label = GPULabel(isolate, labelVal);
1113
1109
  }
1114
1110
 
1115
- auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(),
1116
- didSet ? label.c_str() : nullptr);
1111
+ auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(), *label);
1117
1112
 
1118
1113
  if (value != nullptr) {
1119
1114
  auto ret = GPUCommandBufferImpl::NewInstance(isolate, new GPUCommandBufferImpl(value));
@@ -8,6 +8,7 @@
8
8
  #include "Helpers.h"
9
9
  #include "ObjectWrapperImpl.h"
10
10
  #include "GPUUtils.h"
11
+
11
12
  class GPUCommandEncoderImpl : ObjectWrapperImpl {
12
13
  public:
13
14
  explicit GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder);
@@ -29,12 +30,15 @@ public:
29
30
  v8::EscapableHandleScope scope(isolate);
30
31
  auto object = GPUCommandEncoderImpl::GetCtor(isolate)->GetFunction(
31
32
  context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
32
- SetNativeType(object, NativeType::GPUCommandEncoder);
33
+ SetNativeType(encoder, NativeType::GPUCommandEncoder);
33
34
  object->SetAlignedPointerInInternalField(0, encoder);
34
35
  encoder->BindFinalizer(isolate, object);
35
36
  return scope.Escape(object);
36
37
  }
37
38
 
39
+ static void GetLabel(v8::Local<v8::Name> name,
40
+ const v8::PropertyCallbackInfo<v8::Value> &info);
41
+
38
42
  static void BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args);
39
43
 
40
44
  static void BeginRenderPass(const v8::FunctionCallbackInfo<v8::Value> &args);