@nativescript/canvas 2.0.0-webgpu.3 → 2.0.0-webgpu.31

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 (198) hide show
  1. package/Canvas/common.d.ts +4 -9
  2. package/Canvas/common.js +37 -126
  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 +74 -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 +76 -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 +56 -14
  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 +224 -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/package.json +1 -1
  106. package/platforms/android/canvas-release.aar +0 -0
  107. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  108. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  109. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +40 -12
  110. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  111. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +227 -62
  112. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  113. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  114. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +7341 -6577
  115. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +62 -4
  116. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  117. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +62 -4
  118. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
  119. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  120. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +650 -644
  121. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  122. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +80 -24
  123. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +7 -0
  124. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +227 -62
  125. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +7341 -6577
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +62 -4
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +62 -4
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +7341 -6577
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +62 -4
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +62 -4
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +27 -27
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +652 -646
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +704 -684
  141. package/platforms/ios/src/NSOperationQueueWrapper.h +1 -1
  142. package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
  143. package/platforms/ios/src/cpp/AsyncCallback.h +16 -8
  144. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +208 -789
  145. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +18 -28
  146. package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
  147. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
  148. package/platforms/ios/src/cpp/ImageBitmapImpl.h +10 -3
  149. package/platforms/ios/src/cpp/PromiseCallback.h +1 -2
  150. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +1 -1
  151. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +3 -3
  152. package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
  153. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
  154. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +26 -23
  155. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +31 -5
  156. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +4 -1
  157. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +26 -0
  158. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +3 -0
  159. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +41 -7
  160. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -0
  161. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
  162. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +28 -1
  163. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +3 -0
  164. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +75 -79
  165. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +4 -0
  166. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
  167. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +3 -0
  168. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +25 -0
  169. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +2 -0
  170. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1597 -674
  171. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +2 -0
  172. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +2 -1
  173. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
  174. package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
  175. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +26 -0
  176. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +3 -1
  177. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -2
  178. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
  179. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +50 -13
  180. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +3 -0
  181. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +43 -14
  182. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +3 -0
  183. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +25 -0
  184. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +3 -0
  185. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +39 -13
  186. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +3 -0
  187. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +25 -0
  188. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +3 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +26 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +4 -1
  191. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +24 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +3 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
  194. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +2 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +26 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +3 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
  198. package/utils.d.ts +1 -1
@@ -36,6 +36,8 @@ public:
36
36
  return scope.Escape(object);
37
37
  }
38
38
 
39
+ static void GetLabel(v8::Local<v8::Name> name,
40
+ const v8::PropertyCallbackInfo<v8::Value> &info);
39
41
 
40
42
  static void GetFeatures(v8::Local<v8::Name> name,
41
43
  const v8::PropertyCallbackInfo<v8::Value> &info);
@@ -154,8 +154,9 @@ void GPUImpl::RequestAdapter(const v8::FunctionCallbackInfo<v8::Value> &args) {
154
154
  callback->Call(context, context->Global(),
155
155
  2,
156
156
  args); // ignore JS return value
157
-
157
+
158
158
  delete static_cast<AsyncCallback *>(data);
159
+
159
160
  } else {
160
161
  v8::Local<v8::Value> args[1] = {
161
162
  v8::Null(isolate)};
@@ -12,7 +12,7 @@
12
12
 
13
13
  class GPUImpl : ObjectWrapperImpl {
14
14
  public:
15
- GPUImpl(const CanvasWebGPUInstance *instance);
15
+ explicit GPUImpl(const CanvasWebGPUInstance *instance);
16
16
 
17
17
  ~GPUImpl() {
18
18
  if (this->instance_ != nullptr) {
@@ -0,0 +1,33 @@
1
+ //
2
+ // Created by Osei Fortune on 19/08/2024.
3
+ //
4
+
5
+ #ifndef CANVAS_ANDROID_GPULABEL_H
6
+ #define CANVAS_ANDROID_GPULABEL_H
7
+
8
+ #include "Common.h"
9
+ #include "Helpers.h"
10
+
11
+ class GPULabel {
12
+ public:
13
+ GPULabel(){}
14
+ GPULabel(v8::Isolate *isolate, const v8::Local<v8::Value> &label) {
15
+ if (label->IsString() || label->IsStringObject()) {
16
+ label_ = ConvertFromV8String(isolate, label);
17
+ hasLabel_ = true;
18
+ }
19
+ }
20
+
21
+ const char *operator*() {
22
+ if (hasLabel_) {
23
+ return label_.c_str();
24
+ }
25
+ return nullptr;
26
+ }
27
+
28
+ private:
29
+ std::string label_;
30
+ bool hasLabel_ = false;
31
+ };
32
+
33
+ #endif //CANVAS_ANDROID_GPULABEL_H
@@ -47,8 +47,34 @@ v8::Local<v8::FunctionTemplate> GPUPipelineLayoutImpl::GetCtor(v8::Isolate *isol
47
47
  auto tmpl = ctorTmpl->InstanceTemplate();
48
48
  tmpl->SetInternalFieldCount(2);
49
49
 
50
+ tmpl->SetLazyDataProperty(
51
+ ConvertToV8String(isolate, "label"),
52
+ GetLabel
53
+ );
54
+
50
55
  cache->GPUPipelineLayoutTmpl =
51
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
52
57
  return ctorTmpl;
53
58
  }
54
59
 
60
+
61
+ void
62
+ GPUPipelineLayoutImpl::GetLabel(v8::Local<v8::Name> name,
63
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
64
+ auto ptr = GetPointer(info.This());
65
+ if (ptr != nullptr) {
66
+ auto label = canvas_native_webgpu_pipeline_layout_get_label(ptr->pipeline_);
67
+ if (label == nullptr) {
68
+ info.GetReturnValue().SetEmptyString();
69
+ return;
70
+ }
71
+ info.GetReturnValue().Set(
72
+ ConvertToV8String(info.GetIsolate(), label)
73
+ );
74
+ canvas_native_string_destroy(label);
75
+ return;
76
+ }
77
+
78
+ info.GetReturnValue().SetEmptyString();
79
+ }
80
+
@@ -12,7 +12,7 @@
12
12
 
13
13
  class GPUPipelineLayoutImpl : ObjectWrapperImpl {
14
14
  public:
15
- GPUPipelineLayoutImpl(const CanvasGPUPipelineLayout *pipeline);
15
+ explicit GPUPipelineLayoutImpl(const CanvasGPUPipelineLayout *pipeline);
16
16
 
17
17
  ~GPUPipelineLayoutImpl() {
18
18
  canvas_native_webgpu_pipeline_layout_release(this->GetPipeline());
@@ -38,6 +38,8 @@ public:
38
38
  return scope.Escape(object);
39
39
  }
40
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
41
43
 
42
44
  private:
43
45
  const CanvasGPUPipelineLayout *pipeline_;
@@ -78,7 +78,6 @@ void
78
78
  GPUQuerySetImpl::GetCount(v8::Local<v8::Name> name,
79
79
  const v8::PropertyCallbackInfo<v8::Value> &info) {
80
80
  auto ptr = GetPointer(info.This());
81
- auto isolate = info.GetIsolate();
82
81
  if (ptr != nullptr) {
83
82
  info.GetReturnValue().Set(canvas_native_webgpu_query_set_get_count(ptr->GetQuerySet()));
84
83
  return;
@@ -132,6 +131,6 @@ void GPUQuerySetImpl::Destroy(const v8::FunctionCallbackInfo<v8::Value> &args) {
132
131
  if (ptr == nullptr) {
133
132
  return;
134
133
  }
135
- // todo
134
+ canvas_native_webgpu_query_set_destroy(ptr->querySet_);
136
135
 
137
136
  }
@@ -10,7 +10,7 @@
10
10
 
11
11
  class GPUQuerySetImpl : ObjectWrapperImpl {
12
12
  public:
13
- GPUQuerySetImpl(const CanvasGPUQuerySet *querySet);
13
+ explicit GPUQuerySetImpl(const CanvasGPUQuerySet *querySet);
14
14
 
15
15
  ~GPUQuerySetImpl() {
16
16
  canvas_native_webgpu_query_set_release(this->GetQuerySet());
@@ -55,6 +55,10 @@ v8::Local<v8::FunctionTemplate> GPUQueueImpl::GetCtor(v8::Isolate *isolate) {
55
55
  auto tmpl = ctorTmpl->InstanceTemplate();
56
56
  tmpl->SetInternalFieldCount(2);
57
57
 
58
+ tmpl->SetLazyDataProperty(
59
+ ConvertToV8String(isolate, "label"),
60
+ GetLabel
61
+ );
58
62
 
59
63
  tmpl->Set(
60
64
  ConvertToV8String(isolate, "copyExternalImageToTexture"),
@@ -84,6 +88,28 @@ v8::Local<v8::FunctionTemplate> GPUQueueImpl::GetCtor(v8::Isolate *isolate) {
84
88
  return ctorTmpl;
85
89
  }
86
90
 
91
+
92
+ void
93
+ GPUQueueImpl::GetLabel(v8::Local<v8::Name> name,
94
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
95
+ auto ptr = GetPointer(info.This());
96
+ if (ptr != nullptr) {
97
+ auto label = canvas_native_webgpu_queue_get_label(ptr->queue_);
98
+ if (label == nullptr) {
99
+ info.GetReturnValue().SetEmptyString();
100
+ return;
101
+ }
102
+ info.GetReturnValue().Set(
103
+ ConvertToV8String(info.GetIsolate(), label)
104
+ );
105
+ canvas_native_string_destroy(label);
106
+ return;
107
+ }
108
+
109
+ info.GetReturnValue().SetEmptyString();
110
+ }
111
+
112
+
87
113
  void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
88
114
  auto *ptr = GetPointer(args.This());
89
115
  if (ptr == nullptr) {
@@ -110,16 +136,13 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
110
136
  U8Buffer *buffer = nullptr;
111
137
  uint32_t width = 0;
112
138
  uint32_t height = 0;
139
+ const ImageAsset* imageAsset = nullptr;
113
140
  if (sourceType == NativeType::ImageBitmap) {
114
- auto imageAsset = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
115
- buffer = canvas_native_image_asset_get_data(imageAsset->GetImageAsset());
116
- width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
117
- height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
141
+ auto bitmap = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
142
+ imageAsset = bitmap->GetImageAsset();
118
143
  } else if (sourceType == NativeType::ImageAsset) {
119
- auto imageAsset = ImageAssetImpl::GetPointer(sourceSourceValue.As<v8::Object>());
120
- buffer = canvas_native_image_asset_get_data(imageAsset->GetImageAsset());
121
- width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
122
- height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
144
+ auto asset = ImageAssetImpl::GetPointer(sourceSourceValue.As<v8::Object>());
145
+ imageAsset = asset->GetImageAsset();
123
146
  } else if (sourceType == NativeType::ImageData) {
124
147
  auto imageData = ImageDataImpl::GetPointer(sourceSourceValue.As<v8::Object>());
125
148
  buffer = canvas_native_image_data_get_data(imageData->GetImageData());
@@ -131,7 +154,7 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
131
154
  auto webgl = WebGLRenderingContextBase::GetPointer(sourceSourceValue.As<v8::Object>());
132
155
  }
133
156
 
134
- if (buffer == nullptr) {
157
+ if (buffer == nullptr && imageAsset == nullptr) {
135
158
  // todo error ??
136
159
  return;
137
160
  }
@@ -237,9 +260,26 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
237
260
 
238
261
  CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
239
262
 
263
+ if (imageAsset != nullptr){
264
+ CanvasImageCopyImageAsset source{
265
+ imageAsset,
266
+ sourceOrigin,
267
+ flipY,
268
+ };
269
+
270
+
271
+ canvas_native_webgpu_queue_copy_image_asset_to_texture(ptr->GetGPUQueue(), &source,
272
+ &destination,
273
+ &extent3D);
274
+ return;
275
+ }
276
+
277
+
240
278
  auto data = canvas_native_u8_buffer_get_bytes(buffer);
241
279
  auto size = canvas_native_u8_buffer_get_length(buffer);
242
280
 
281
+
282
+
243
283
  if (data == nullptr || size == 0) {
244
284
  // todo error
245
285
  return;
@@ -368,7 +408,6 @@ void GPUQueueImpl::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args)
368
408
  if (bufferValue->IsObject()) {
369
409
  auto buffer = GPUBufferImpl::GetPointer(bufferValue.As<v8::Object>());
370
410
 
371
-
372
411
  auto bufferOffset = (uint64_t) args[1].As<v8::Number>()->Value();
373
412
 
374
413
  auto dataValue = args[2].As<v8::TypedArray>();
@@ -379,7 +418,7 @@ void GPUQueueImpl::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args)
379
418
 
380
419
  auto data = static_cast<uint8_t *>(store->Data()) + offset;
381
420
 
382
- auto data_size = store->ByteLength();
421
+ auto data_size = store->ByteLength() - offset;
383
422
 
384
423
  auto dataOffset = (uint64_t) args[3].As<v8::Number>()->Value();
385
424
 
@@ -410,8 +449,6 @@ void GPUQueueImpl::WriteTexture(const v8::FunctionCallbackInfo<v8::Value> &args)
410
449
  auto isolate = args.GetIsolate();
411
450
  auto context = isolate->GetCurrentContext();
412
451
 
413
- bool flipY = false;
414
-
415
452
 
416
453
  auto destinationVal = args[0];
417
454
  auto dataVal = args[1];
@@ -37,6 +37,9 @@ public:
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
  static void CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
41
44
 
42
45
  static void Submit(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -8,6 +8,7 @@
8
8
  #include "GPUBufferImpl.h"
9
9
  #include "GPURenderBundleImpl.h"
10
10
  #include "GPUBindGroupImpl.h"
11
+ #include "GPULabel.h"
11
12
 
12
13
  GPURenderBundleEncoderImpl::GPURenderBundleEncoderImpl(const CanvasGPURenderBundleEncoder *encoder)
13
14
  : encoder_(
@@ -54,6 +55,11 @@ v8::Local<v8::FunctionTemplate> GPURenderBundleEncoderImpl::GetCtor(v8::Isolate
54
55
  auto tmpl = ctorTmpl->InstanceTemplate();
55
56
  tmpl->SetInternalFieldCount(2);
56
57
 
58
+ tmpl->SetLazyDataProperty(
59
+ ConvertToV8String(isolate, "label"),
60
+ GetLabel
61
+ );
62
+
57
63
  tmpl->Set(
58
64
  ConvertToV8String(isolate, "draw"),
59
65
  v8::FunctionTemplate::New(isolate, &Draw));
@@ -109,6 +115,28 @@ v8::Local<v8::FunctionTemplate> GPURenderBundleEncoderImpl::GetCtor(v8::Isolate
109
115
  return ctorTmpl;
110
116
  }
111
117
 
118
+
119
+ void
120
+ GPURenderBundleEncoderImpl::GetLabel(v8::Local<v8::Name> name,
121
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
122
+ auto ptr = GetPointer(info.This());
123
+ if (ptr != nullptr) {
124
+ auto label = canvas_native_webgpu_render_bundle_encoder_get_label(ptr->encoder_);
125
+ if (label == nullptr) {
126
+ info.GetReturnValue().SetEmptyString();
127
+ return;
128
+ }
129
+ info.GetReturnValue().Set(
130
+ ConvertToV8String(info.GetIsolate(), label)
131
+ );
132
+ canvas_native_string_destroy(label);
133
+ return;
134
+ }
135
+
136
+ info.GetReturnValue().SetEmptyString();
137
+ }
138
+
139
+
112
140
  void GPURenderBundleEncoderImpl::Draw(const v8::FunctionCallbackInfo<v8::Value> &args) {
113
141
  auto *ptr = GetPointer(args.This());
114
142
  if (ptr == nullptr) {
@@ -163,12 +191,16 @@ void GPURenderBundleEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::
163
191
 
164
192
 
165
193
  auto indexCountVal = args[0];
166
- auto firstIndexVal = args[1];
167
- auto baseVertexVal = args[2];
168
- auto firstInstanceVal = args[3];
194
+ auto instanceCountVal = args[1];
195
+ auto firstIndexVal = args[2];
196
+ auto baseVertexVal = args[3];
197
+ auto firstInstanceVal = args[4];
169
198
 
170
199
  if (indexCountVal->IsUint32()) {
171
200
 
201
+ if (instanceCountVal->IsUint32()) {
202
+ instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
203
+ }
172
204
 
173
205
  if (firstIndexVal->IsUint32()) {
174
206
  firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
@@ -256,7 +288,7 @@ void GPURenderBundleEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value
256
288
  auto isolate = args.GetIsolate();
257
289
  auto context = isolate->GetCurrentContext();
258
290
 
259
- char *label = nullptr;
291
+ GPULabel label;
260
292
  v8::Local<v8::Value> labelVal;
261
293
 
262
294
  auto optionsVal = args[0];
@@ -265,13 +297,11 @@ void GPURenderBundleEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value
265
297
  auto options = optionsVal.As<v8::Object>();
266
298
  options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
267
299
 
268
- if (!labelVal.IsEmpty() && labelVal->IsString()) {
269
- label = *v8::String::Utf8Value(isolate, labelVal);
270
- }
300
+ label = GPULabel(isolate, labelVal);
271
301
  }
272
302
 
273
303
 
274
- auto bundle = canvas_native_webgpu_render_bundle_encoder_finish(ptr->GetEncoder(), label);
304
+ auto bundle = canvas_native_webgpu_render_bundle_encoder_finish(ptr->GetEncoder(), *label);
275
305
 
276
306
  if (bundle != nullptr) {
277
307
  auto ret = GPURenderBundleImpl::NewInstance(isolate, new GPURenderBundleImpl(bundle));
@@ -345,7 +375,7 @@ void GPURenderBundleEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8:
345
375
  auto index = indexVal->Uint32Value(context).FromJust();
346
376
  auto bindGroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
347
377
 
348
- if (dynamicOffsets->IsUint8Array()) {
378
+ if (dynamicOffsets->IsUint32Array()) {
349
379
  auto buf = dynamicOffsets.As<v8::Uint32Array>();
350
380
  auto buffer = buf->Buffer();
351
381
  auto store = buffer->GetBackingStore();
@@ -374,7 +404,6 @@ void GPURenderBundleEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v
374
404
  }
375
405
 
376
406
  auto isolate = args.GetIsolate();
377
- auto context = isolate->GetCurrentContext();
378
407
 
379
408
  auto bufferVal = args[0];
380
409
  auto indexFormatVal = args[1];
@@ -385,7 +414,7 @@ void GPURenderBundleEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v
385
414
 
386
415
  auto type = GetNativeType(bufferVal);
387
416
 
388
- if (type == NativeType::GPURenderBundleEncoder) {
417
+ if (type == NativeType::GPUBuffer) {
389
418
  auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
390
419
  auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
391
420
  if (offsetVal->IsNumber()) {
@@ -421,7 +450,7 @@ void GPURenderBundleEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::
421
450
  }
422
451
 
423
452
  auto pipelineVal = args[0];
424
- if (pipelineVal->IsObject()) {
453
+ if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
425
454
  auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
426
455
  if (pipeline != nullptr) {
427
456
  canvas_native_webgpu_render_bundle_encoder_set_pipeline(ptr->GetEncoder(),
@@ -445,11 +474,11 @@ void GPURenderBundleEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<
445
474
 
446
475
  if (slotVal->IsUint32() && bufferVal->IsObject()) {
447
476
  auto slot = slotVal.As<v8::Uint32>()->Value();
448
- auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
449
- if (buffer == nullptr) {
477
+ if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
450
478
  // todo throw ??
451
479
  return;
452
480
  }
481
+ auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
453
482
 
454
483
  if (offsetVal->IsNumber()) {
455
484
  offset = (int64_t) offsetVal.As<v8::Number>()->Value();
@@ -38,6 +38,9 @@ public:
38
38
  return scope.Escape(object);
39
39
  }
40
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
43
+
41
44
  static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
42
45
 
43
46
  static void DrawIndexed(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -47,7 +47,32 @@ v8::Local<v8::FunctionTemplate> GPURenderBundleImpl::GetCtor(v8::Isolate *isolat
47
47
  auto tmpl = ctorTmpl->InstanceTemplate();
48
48
  tmpl->SetInternalFieldCount(2);
49
49
 
50
+ tmpl->SetLazyDataProperty(
51
+ ConvertToV8String(isolate, "label"),
52
+ GetLabel
53
+ );
54
+
50
55
  cache->GPURenderBundleTmpl =
51
56
  std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
52
57
  return ctorTmpl;
53
58
  }
59
+
60
+ void
61
+ GPURenderBundleImpl::GetLabel(v8::Local<v8::Name> name,
62
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
63
+ auto ptr = GetPointer(info.This());
64
+ if (ptr != nullptr) {
65
+ auto label = canvas_native_webgpu_render_bundle_get_label(ptr->bundle_);
66
+ if (label == nullptr) {
67
+ info.GetReturnValue().SetEmptyString();
68
+ return;
69
+ }
70
+ info.GetReturnValue().Set(
71
+ ConvertToV8String(info.GetIsolate(), label)
72
+ );
73
+ canvas_native_string_destroy(label);
74
+ return;
75
+ }
76
+
77
+ info.GetReturnValue().SetEmptyString();
78
+ }
@@ -36,6 +36,9 @@ public:
36
36
  return scope.Escape(object);
37
37
  }
38
38
 
39
+ static void GetLabel(v8::Local<v8::Name> name,
40
+ const v8::PropertyCallbackInfo<v8::Value> &info);
41
+
39
42
 
40
43
  private:
41
44
  const CanvasGPURenderBundle *bundle_;
@@ -54,6 +54,11 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
54
54
  auto tmpl = ctorTmpl->InstanceTemplate();
55
55
  tmpl->SetInternalFieldCount(2);
56
56
 
57
+ tmpl->SetLazyDataProperty(
58
+ ConvertToV8String(isolate, "label"),
59
+ GetLabel
60
+ );
61
+
57
62
  tmpl->Set(
58
63
  ConvertToV8String(isolate, "beginOcclusionQuery"),
59
64
  v8::FunctionTemplate::New(isolate, &BeginOcclusionQuery));
@@ -136,6 +141,27 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
136
141
  }
137
142
 
138
143
 
144
+ void
145
+ GPURenderPassEncoderImpl::GetLabel(v8::Local<v8::Name> name,
146
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
147
+ auto ptr = GetPointer(info.This());
148
+ if (ptr != nullptr) {
149
+ auto label = canvas_native_webgpu_render_pass_encoder_get_label(ptr->pass_);
150
+ if (label == nullptr) {
151
+ info.GetReturnValue().SetEmptyString();
152
+ return;
153
+ }
154
+ info.GetReturnValue().Set(
155
+ ConvertToV8String(info.GetIsolate(), label)
156
+ );
157
+ canvas_native_string_destroy(label);
158
+ return;
159
+ }
160
+
161
+ info.GetReturnValue().SetEmptyString();
162
+ }
163
+
164
+
139
165
  void
140
166
  GPURenderPassEncoderImpl::BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
141
167
  auto *ptr = GetPointer(args.This());
@@ -229,7 +255,7 @@ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Va
229
255
  }
230
256
 
231
257
  auto indexCount = indexCountVal->Uint32Value(
232
- context).FromJust();
258
+ context).FromJust();
233
259
  canvas_native_webgpu_render_pass_encoder_draw_indexed(ptr->GetPass(),
234
260
  indexCount,
235
261
  instanceCount, firstIndex,
@@ -328,7 +354,7 @@ void GPURenderPassEncoderImpl::ExecuteBundles(const v8::FunctionCallbackInfo<v8:
328
354
  std::vector<const CanvasGPURenderBundle *> bundles;
329
355
  for (int i = 0; i < len; i++) {
330
356
  v8::Local<v8::Value> bundleVal;
331
- bundlesArray->Get(context, i).ToLocal(&bundlesVal);
357
+ bundlesArray->Get(context, i).ToLocal(&bundleVal);
332
358
  auto type = GetNativeType(bundleVal);
333
359
  if (type == NativeType::GPURenderBundle) {
334
360
  auto bundle = GPURenderBundleImpl::GetPointer(bundleVal.As<v8::Object>());
@@ -408,7 +434,7 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
408
434
  auto index = indexVal->Uint32Value(context).FromJust();
409
435
  auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
410
436
 
411
- if (dynamicOffsets->IsUint8Array()) {
437
+ if (dynamicOffsets->IsUint32Array()) {
412
438
  auto buf = dynamicOffsets.As<v8::Uint32Array>();
413
439
  auto buffer = buf->Buffer();
414
440
  auto store = buffer->GetBackingStore();
@@ -446,7 +472,7 @@ void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8:
446
472
 
447
473
  auto type = GetNativeType(bufferVal);
448
474
 
449
- if (type == NativeType::GPURenderBundleEncoder) {
475
+ if (type == NativeType::GPUBuffer) {
450
476
  auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
451
477
  auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
452
478
  if (offsetVal->IsNumber()) {
@@ -502,7 +528,7 @@ void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Va
502
528
  }
503
529
 
504
530
  auto pipelineVal = args[0];
505
- if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
531
+ if (GetNativeType(pipelineVal) == NativeType::GPURenderPipeline) {
506
532
  auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
507
533
  canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
508
534
  pipeline->GetGPUPipeline());
@@ -565,13 +591,13 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
565
591
  int64_t size = -1;
566
592
  auto offsetVal = args[2];
567
593
  auto sizeVal = args[3];
568
-
569
- if (slotVal->IsUint32() && bufferVal->IsObject()) {
570
- auto slot = slotVal.As<v8::Uint32>()->Value();
571
- if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
572
- // todo throw ??
573
- return;
574
- }
594
+ auto type = GetNativeType(bufferVal);
595
+ auto isolate = args.GetIsolate();
596
+ if (type == NativeType::GPUBuffer) {
597
+ auto context = isolate->GetCurrentContext();
598
+ auto slot = slotVal->ToUint32(context).ToLocalChecked();
599
+
600
+
575
601
 
576
602
  auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
577
603
 
@@ -583,7 +609,7 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
583
609
  size = (int64_t) sizeVal.As<v8::Number>()->Value();
584
610
  }
585
611
 
586
- canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot,
612
+ canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot->Value(),
587
613
  buffer->GetGPUBuffer(), offset,
588
614
  size);
589
615
 
@@ -38,6 +38,9 @@ public:
38
38
  return scope.Escape(object);
39
39
  }
40
40
 
41
+ static void GetLabel(v8::Local<v8::Name> name,
42
+ const v8::PropertyCallbackInfo<v8::Value> &info);
43
+
41
44
  static void BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
42
45
 
43
46
  static void Draw(const v8::FunctionCallbackInfo<v8::Value> &args);
@@ -48,6 +48,10 @@ v8::Local<v8::FunctionTemplate> GPURenderPipelineImpl::GetCtor(v8::Isolate *isol
48
48
  auto tmpl = ctorTmpl->InstanceTemplate();
49
49
  tmpl->SetInternalFieldCount(2);
50
50
 
51
+ tmpl->SetLazyDataProperty(
52
+ ConvertToV8String(isolate, "label"),
53
+ GetLabel
54
+ );
51
55
 
52
56
  tmpl->Set(
53
57
  ConvertToV8String(isolate, "getBindGroupLayout"),
@@ -82,3 +86,24 @@ void GPURenderPipelineImpl::GetBindGroupLayout(const v8::FunctionCallbackInfo<v8
82
86
  args.GetReturnValue().SetUndefined();
83
87
  }
84
88
 
89
+
90
+ void
91
+ GPURenderPipelineImpl::GetLabel(v8::Local<v8::Name> name,
92
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
93
+ auto ptr = GetPointer(info.This());
94
+ if (ptr != nullptr) {
95
+ auto label = canvas_native_webgpu_render_pipeline_get_label(ptr->pipeline_);
96
+ if (label == nullptr) {
97
+ info.GetReturnValue().SetEmptyString();
98
+ return;
99
+ }
100
+ info.GetReturnValue().Set(
101
+ ConvertToV8String(info.GetIsolate(), label)
102
+ );
103
+ canvas_native_string_destroy(label);
104
+ return;
105
+ }
106
+
107
+ info.GetReturnValue().SetEmptyString();
108
+ }
109
+
@@ -37,6 +37,9 @@ public:
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
 
41
44
  static void GetBindGroupLayout(const v8::FunctionCallbackInfo <v8::Value> &args);
42
45