@nativescript/canvas 2.0.0-webgpu.4 → 2.0.0-webgpu.40
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.
- package/Canvas/common.d.ts +5 -10
- package/Canvas/common.js +61 -144
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +6 -5
- package/Canvas/index.android.js +63 -42
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +13 -3
- package/Canvas/index.ios.d.ts +9 -1
- package/Canvas/index.ios.js +117 -66
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas/utils.d.ts +3 -0
- package/Canvas/utils.js +85 -0
- package/Canvas/utils.js.map +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +3 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +2 -4
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Dom/Group.d.ts +1 -2
- package/Dom/Group.js.map +1 -1
- package/Dom/Image.js +0 -1
- package/Dom/Image.js.map +1 -1
- package/Dom/Paint.d.ts +1 -1
- package/Dom/shapes/Path.d.ts +1 -1
- package/ImageAsset/index.d.ts +4 -2
- package/ImageAsset/index.js +151 -37
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.js +107 -20
- package/ImageBitmap/index.js.map +1 -1
- package/README.md +2 -4
- package/WebGL/WebGLRenderingContext/common.d.ts +1 -1
- package/WebGL/WebGLRenderingContext/index.js +76 -32
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +5 -5
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/GPU.js +4 -3
- package/WebGPU/GPU.js.map +1 -1
- package/WebGPU/GPUAdapter.d.ts +6 -3
- package/WebGPU/GPUAdapter.js +31 -0
- package/WebGPU/GPUAdapter.js.map +1 -1
- package/WebGPU/GPUBindGroup.d.ts +1 -0
- package/WebGPU/GPUBindGroup.js +3 -0
- package/WebGPU/GPUBindGroup.js.map +1 -1
- package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
- package/WebGPU/GPUBindGroupLayout.js +3 -0
- package/WebGPU/GPUBindGroupLayout.js.map +1 -1
- package/WebGPU/GPUBuffer.js +10 -2
- package/WebGPU/GPUBuffer.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +5 -3
- package/WebGPU/GPUCanvasContext.js +52 -10
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandBuffer.d.ts +1 -0
- package/WebGPU/GPUCommandBuffer.js +3 -0
- package/WebGPU/GPUCommandBuffer.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.d.ts +3 -9
- package/WebGPU/GPUCommandEncoder.js +94 -41
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
- package/WebGPU/GPUComputePassEncoder.js +3 -0
- package/WebGPU/GPUComputePassEncoder.js.map +1 -1
- package/WebGPU/GPUComputePipeline.d.ts +1 -0
- package/WebGPU/GPUComputePipeline.js +3 -0
- package/WebGPU/GPUComputePipeline.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +17 -79
- package/WebGPU/GPUDevice.js +75 -91
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUExternalTexture.d.ts +1 -0
- package/WebGPU/GPUExternalTexture.js +3 -0
- package/WebGPU/GPUExternalTexture.js.map +1 -1
- package/WebGPU/GPUPipelineLayout.d.ts +1 -0
- package/WebGPU/GPUPipelineLayout.js +3 -0
- package/WebGPU/GPUPipelineLayout.js.map +1 -1
- package/WebGPU/GPUQuerySet.d.ts +1 -0
- package/WebGPU/GPUQuerySet.js +3 -0
- package/WebGPU/GPUQuerySet.js.map +1 -1
- package/WebGPU/GPUQueue.d.ts +1 -0
- package/WebGPU/GPUQueue.js +65 -14
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderBundle.d.ts +1 -0
- package/WebGPU/GPURenderBundle.js +3 -0
- package/WebGPU/GPURenderBundle.js.map +1 -1
- package/WebGPU/GPURenderBundleEncoder.d.ts +4 -2
- package/WebGPU/GPURenderBundleEncoder.js +7 -3
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.d.ts +5 -1
- package/WebGPU/GPURenderPassEncoder.js +14 -2
- package/WebGPU/GPURenderPassEncoder.js.map +1 -1
- package/WebGPU/GPURenderPipeline.d.ts +1 -0
- package/WebGPU/GPURenderPipeline.js +3 -0
- package/WebGPU/GPURenderPipeline.js.map +1 -1
- package/WebGPU/GPUSampler.d.ts +1 -0
- package/WebGPU/GPUSampler.js +3 -0
- package/WebGPU/GPUSampler.js.map +1 -1
- package/WebGPU/GPUShaderModule.d.ts +1 -1
- package/WebGPU/GPUShaderModule.js +2 -2
- package/WebGPU/GPUShaderModule.js.map +1 -1
- package/WebGPU/GPUTexture.d.ts +1 -0
- package/WebGPU/GPUTexture.js +3 -0
- package/WebGPU/GPUTexture.js.map +1 -1
- package/WebGPU/GPUTextureView.d.ts +1 -0
- package/WebGPU/GPUTextureView.js +3 -0
- package/WebGPU/GPUTextureView.js.map +1 -1
- package/WebGPU/Interfaces.d.ts +95 -4
- package/WebGPU/Types.d.ts +9 -1
- package/WebGPU/Utils.d.ts +6 -0
- package/WebGPU/Utils.js +226 -0
- package/WebGPU/Utils.js.map +1 -1
- package/angular/esm2022/index.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs.map +1 -1
- package/common.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +61 -30
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +144 -176
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +342 -72
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +7997 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +681 -644
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +122 -60
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +144 -176
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +342 -72
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +7997 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +7997 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +40 -29
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +683 -646
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +736 -684
- package/platforms/ios/src/NSOperationQueueWrapper.h +1 -1
- package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
- package/platforms/ios/src/cpp/AsyncCallback.h +16 -8
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +310 -801
- package/platforms/ios/src/cpp/CanvasJSIModule.h +2 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +578 -413
- package/platforms/ios/src/cpp/ImageAssetImpl.h +7 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +10 -3
- package/platforms/ios/src/cpp/PromiseCallback.h +1 -2
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +7 -11
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +3 -3
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +6 -6
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +26 -23
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +31 -5
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +41 -7
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +28 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +75 -79
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +56 -23
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1606 -681
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +2 -1
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -2
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +83 -14
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +66 -34
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +151 -52
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +7 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +24 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
- package/utils.d.ts +1 -1
|
@@ -47,7 +47,33 @@ v8::Local<v8::FunctionTemplate> GPUBindGroupLayoutImpl::GetCtor(v8::Isolate *iso
|
|
|
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->GPUBindGroupLayoutTmpl =
|
|
51
56
|
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
52
57
|
return ctorTmpl;
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
void
|
|
62
|
+
GPUBindGroupLayoutImpl::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_bind_group_layout_get_label(ptr->groupLayout_);
|
|
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
|
+
}
|
|
@@ -75,6 +75,11 @@ v8::Local<v8::FunctionTemplate> GPUBufferImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
75
75
|
ConvertToV8String(isolate, "getMappedRange"),
|
|
76
76
|
v8::FunctionTemplate::New(isolate, &GetMappedRange));
|
|
77
77
|
|
|
78
|
+
tmpl->SetLazyDataProperty(
|
|
79
|
+
ConvertToV8String(isolate, "label"),
|
|
80
|
+
GetLabel
|
|
81
|
+
);
|
|
82
|
+
|
|
78
83
|
|
|
79
84
|
cache->GPUBufferTmpl =
|
|
80
85
|
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
@@ -127,12 +132,17 @@ void GPUBufferImpl::UnMap(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
127
132
|
canvas_native_webgpu_buffer_unmap(ptr->GetGPUBuffer());
|
|
128
133
|
}
|
|
129
134
|
|
|
135
|
+
struct MapAsyncData {
|
|
136
|
+
enum CanvasGPUErrorType type;
|
|
137
|
+
char* error;
|
|
138
|
+
};
|
|
130
139
|
|
|
131
140
|
void GPUBufferImpl::MapAsync(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
132
141
|
GPUBufferImpl *ptr = GetPointer(args.This());
|
|
133
142
|
if (ptr == nullptr) {
|
|
134
143
|
return;
|
|
135
144
|
}
|
|
145
|
+
|
|
136
146
|
auto isolate = args.GetIsolate();
|
|
137
147
|
auto context = isolate->GetCurrentContext();
|
|
138
148
|
auto mode = args[0]->Int32Value(context).ToChecked();
|
|
@@ -177,31 +187,34 @@ void GPUBufferImpl::MapAsync(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
177
187
|
if (func->data == nullptr) {
|
|
178
188
|
callback->Resolve(context, v8::Undefined(isolate));
|
|
179
189
|
} else {
|
|
180
|
-
|
|
190
|
+
auto errorData = static_cast<MapAsyncData*>(func->data);
|
|
181
191
|
callback->Reject(context,
|
|
182
192
|
v8::Exception::Error(
|
|
183
193
|
ConvertToV8String(
|
|
184
194
|
isolate,
|
|
185
|
-
error)));
|
|
195
|
+
errorData->error)));
|
|
186
196
|
canvas_native_string_destroy(
|
|
187
|
-
error);
|
|
197
|
+
errorData->error);
|
|
198
|
+
delete errorData;
|
|
188
199
|
func->data = nullptr;
|
|
189
200
|
}
|
|
190
|
-
delete static_cast<PromiseCallback *>(data);
|
|
191
201
|
}
|
|
202
|
+
delete static_cast<PromiseCallback *>(data);
|
|
192
203
|
}
|
|
193
204
|
};
|
|
194
205
|
callback->prepare();
|
|
195
206
|
|
|
196
207
|
|
|
197
|
-
canvas_native_webgpu_buffer_map_async(ptr->GetGPUBuffer(),
|
|
198
|
-
[](char *error, void *data) {
|
|
208
|
+
canvas_native_webgpu_buffer_map_async(ptr->GetGPUBuffer(), mode == 1 ? GPUMapMode::GPUMapModeRead : GPUMapMode::GPUMapModeWrite, offset, size,
|
|
209
|
+
[](enum CanvasGPUErrorType type, char *error, void *data) {
|
|
199
210
|
if (data != nullptr) {
|
|
200
211
|
auto async_data = static_cast<PromiseCallback *>(data);
|
|
201
212
|
auto inner = async_data->inner_.get();
|
|
202
213
|
if (inner != nullptr) {
|
|
203
214
|
if(error != nullptr){
|
|
204
|
-
inner->data =
|
|
215
|
+
inner->data = new MapAsyncData {
|
|
216
|
+
type, error
|
|
217
|
+
};
|
|
205
218
|
}
|
|
206
219
|
async_data->execute(true);
|
|
207
220
|
}
|
|
@@ -241,3 +254,24 @@ void GPUBufferImpl::GetMappedRange(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
241
254
|
args.GetReturnValue().Set(ab);
|
|
242
255
|
}
|
|
243
256
|
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
void
|
|
260
|
+
GPUBufferImpl::GetLabel(v8::Local<v8::Name> name,
|
|
261
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
262
|
+
auto ptr = GetPointer(info.This());
|
|
263
|
+
if (ptr != nullptr) {
|
|
264
|
+
auto label = canvas_native_webgpu_buffer_get_label(ptr->buffer_);
|
|
265
|
+
if (label == nullptr) {
|
|
266
|
+
info.GetReturnValue().SetEmptyString();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
info.GetReturnValue().Set(
|
|
270
|
+
ConvertToV8String(info.GetIsolate(), label)
|
|
271
|
+
);
|
|
272
|
+
canvas_native_string_destroy(label);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
info.GetReturnValue().SetEmptyString();
|
|
277
|
+
}
|
|
@@ -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);
|
|
@@ -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
|
-
&
|
|
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
|
-
|
|
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
|
|
228
|
-
|
|
229
|
-
|
|
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
|
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
#include "GPUCommandBufferImpl.h"
|
|
6
6
|
#include "Caches.h"
|
|
7
7
|
|
|
8
|
-
GPUCommandBufferImpl::GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer)
|
|
8
|
+
GPUCommandBufferImpl::GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer)
|
|
9
|
+
: commandBuffer_(
|
|
9
10
|
commandBuffer) {}
|
|
10
11
|
|
|
11
12
|
const CanvasGPUCommandBuffer *GPUCommandBufferImpl::GetGPUCommandBuffer() {
|
|
@@ -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
|
+
}
|
|
@@ -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
|
-
|
|
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
|
-
×tampWritesVal);
|
|
151
|
-
|
|
152
171
|
|
|
153
|
-
|
|
172
|
+
auto success = desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
|
|
173
|
+
×tampWritesVal);
|
|
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 (
|
|
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
|
-
|
|
195
|
+
success = timestampWrites->Get(context,
|
|
196
|
+
ConvertToV8String(isolate,
|
|
197
|
+
"beginningOfPassWriteIndex")).ToLocal(
|
|
176
198
|
&beginningOfPassWriteIndexVal);
|
|
177
199
|
|
|
178
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -235,11 +258,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
235
258
|
v8::Local<v8::Value> labelVal;
|
|
236
259
|
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
237
260
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (!labelVal.IsEmpty() && labelVal->IsString()) {
|
|
241
|
-
label = *v8::String::Utf8Value(isolate, labelVal);
|
|
242
|
-
}
|
|
261
|
+
auto label = GPULabel(isolate, labelVal);
|
|
243
262
|
|
|
244
263
|
|
|
245
264
|
v8::Local<v8::Value> colorAttachmentsVal;
|
|
@@ -259,65 +278,46 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
259
278
|
|
|
260
279
|
auto clearValue = ParseColor(isolate, clearValueVal);
|
|
261
280
|
|
|
281
|
+
const CanvasGPUTextureView *view = nullptr;
|
|
282
|
+
|
|
262
283
|
v8::Local<v8::Value> viewVal;
|
|
263
|
-
colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
264
|
-
"view")).ToLocal(&viewVal);
|
|
265
284
|
|
|
266
|
-
|
|
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
|
+
}
|
|
267
293
|
|
|
268
|
-
auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
|
|
269
|
-
view = viewPtr->GetTextureView();
|
|
270
294
|
|
|
271
|
-
const CanvasGPUTextureView *
|
|
295
|
+
const CanvasGPUTextureView *resolveTarget = nullptr;
|
|
272
296
|
|
|
273
|
-
v8::Local<v8::Value>
|
|
297
|
+
v8::Local<v8::Value> resolveTargetVal;
|
|
274
298
|
|
|
275
299
|
colorAttachment->Get(context, ConvertToV8String(isolate, "resolveTarget")).ToLocal(
|
|
276
|
-
&
|
|
300
|
+
&resolveTargetVal);
|
|
277
301
|
|
|
278
|
-
auto resolve_target_type = GetNativeType(
|
|
302
|
+
auto resolve_target_type = GetNativeType(resolveTargetVal);
|
|
279
303
|
|
|
280
304
|
if (resolve_target_type == NativeType::GPUTextureView) {
|
|
281
|
-
auto res = GPUTextureViewImpl::GetPointer(
|
|
282
|
-
|
|
305
|
+
auto res = GPUTextureViewImpl::GetPointer(resolveTargetVal.As<v8::Object>());
|
|
306
|
+
resolveTarget = res->GetTextureView();
|
|
283
307
|
}
|
|
284
308
|
|
|
285
|
-
// default
|
|
286
|
-
CanvasLoadOp load = CanvasLoadOp::CanvasLoadOpClear;
|
|
287
|
-
CanvasStoreOp store = CanvasStoreOp::CanvasStoreOpStore;
|
|
288
309
|
v8::Local<v8::Value> loadVal;
|
|
310
|
+
v8::Local<v8::Value> storeVal;
|
|
311
|
+
colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
312
|
+
"loadOp")).ToLocal(&loadVal);
|
|
289
313
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (loadVal->IsUint32()) {
|
|
293
|
-
load = (CanvasLoadOp) loadVal->Uint32Value(
|
|
294
|
-
context).ToChecked();
|
|
295
|
-
} else if (loadVal->IsString()) {
|
|
296
|
-
auto val = ConvertFromV8String(isolate, loadVal);
|
|
297
|
-
if (val == "clear") {
|
|
298
|
-
load = CanvasLoadOp::CanvasLoadOpClear;
|
|
299
|
-
} else if (val == "load") {
|
|
300
|
-
load = CanvasLoadOp::CanvasLoadOpLoad;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
314
|
+
colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
315
|
+
"storeOp")).ToLocal(&storeVal);
|
|
304
316
|
|
|
305
317
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (storeVal->IsUint32()) {
|
|
310
|
-
store = (CanvasStoreOp) storeVal->Uint32Value(
|
|
311
|
-
context).ToChecked();
|
|
312
|
-
} else if (storeVal->IsString()) {
|
|
313
|
-
auto val = ConvertFromV8String(isolate, storeVal);
|
|
314
|
-
if (val == "discard") {
|
|
315
|
-
store = CanvasStoreOp::CanvasStoreOpDiscard;
|
|
316
|
-
} else if (val == "store") {
|
|
317
|
-
store = CanvasStoreOp::CanvasStoreOpStore;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
318
|
+
CanvasLoadOp load = ParseCanvasLoadOp(isolate, loadVal);
|
|
319
|
+
CanvasStoreOp store = ParseCanvasStoreOp(isolate, storeVal);
|
|
320
|
+
|
|
321
321
|
|
|
322
322
|
CanvasPassChannelColor channel{
|
|
323
323
|
load,
|
|
@@ -328,7 +328,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
328
328
|
|
|
329
329
|
auto attachment = CanvasRenderPassColorAttachment{
|
|
330
330
|
view,
|
|
331
|
-
|
|
331
|
+
resolveTarget,
|
|
332
332
|
channel
|
|
333
333
|
};
|
|
334
334
|
|
|
@@ -577,7 +577,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
577
577
|
|
|
578
578
|
|
|
579
579
|
pass = canvas_native_webgpu_command_encoder_begin_render_pass(
|
|
580
|
-
ptr->GetEncoder(), label, colorAttachments_.data(), colorAttachments_.size(),
|
|
580
|
+
ptr->GetEncoder(), *label, colorAttachments_.data(), colorAttachments_.size(),
|
|
581
581
|
depthStencilAttachment, occlusion_query_set,
|
|
582
582
|
querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
|
|
583
583
|
);
|
|
@@ -1100,19 +1100,15 @@ void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
1100
1100
|
auto context = isolate->GetCurrentContext();
|
|
1101
1101
|
|
|
1102
1102
|
auto descVal = args[0];
|
|
1103
|
-
|
|
1104
|
-
bool didSet = false;
|
|
1103
|
+
GPULabel label;
|
|
1105
1104
|
if (descVal->IsObject()) {
|
|
1106
1105
|
auto desc = descVal.As<v8::Object>();
|
|
1107
1106
|
v8::Local<v8::Value> labelVal;
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
1111
|
-
}
|
|
1107
|
+
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
1108
|
+
label = GPULabel(isolate, labelVal);
|
|
1112
1109
|
}
|
|
1113
1110
|
|
|
1114
|
-
auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(),
|
|
1115
|
-
didSet ? label.c_str() : nullptr);
|
|
1111
|
+
auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(), *label);
|
|
1116
1112
|
|
|
1117
1113
|
if (value != nullptr) {
|
|
1118
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);
|
|
@@ -35,6 +36,9 @@ public:
|
|
|
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);
|
|
@@ -26,7 +26,8 @@ void GPUComputePassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Iso
|
|
|
26
26
|
auto context = isolate->GetCurrentContext();
|
|
27
27
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
28
28
|
|
|
29
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUComputePassEncoder"),
|
|
29
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUComputePassEncoder"),
|
|
30
|
+
func).FromJust();
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
GPUComputePassEncoderImpl *
|
|
@@ -52,6 +53,11 @@ v8::Local<v8::FunctionTemplate> GPUComputePassEncoderImpl::GetCtor(v8::Isolate *
|
|
|
52
53
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
53
54
|
tmpl->SetInternalFieldCount(2);
|
|
54
55
|
|
|
56
|
+
tmpl->SetLazyDataProperty(
|
|
57
|
+
ConvertToV8String(isolate, "label"),
|
|
58
|
+
GetLabel
|
|
59
|
+
);
|
|
60
|
+
|
|
55
61
|
tmpl->Set(
|
|
56
62
|
ConvertToV8String(isolate, "dispatchWorkgroups"),
|
|
57
63
|
v8::FunctionTemplate::New(isolate, &DispatchWorkgroups));
|
|
@@ -86,10 +92,32 @@ v8::Local<v8::FunctionTemplate> GPUComputePassEncoderImpl::GetCtor(v8::Isolate *
|
|
|
86
92
|
|
|
87
93
|
|
|
88
94
|
cache->GPUComputePassEncoderTmpl =
|
|
89
|
-
std::make_unique<v8::Persistent<v8::FunctionTemplate>>
|
|
95
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>
|
|
96
|
+
(isolate, ctorTmpl);
|
|
90
97
|
return ctorTmpl;
|
|
91
98
|
}
|
|
92
99
|
|
|
100
|
+
void
|
|
101
|
+
GPUComputePassEncoderImpl::GetLabel(v8::Local<v8::Name> name,
|
|
102
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
103
|
+
auto ptr = GetPointer(info.This());
|
|
104
|
+
if (ptr != nullptr) {
|
|
105
|
+
auto label = canvas_native_webgpu_compute_pass_encoder_get_label(ptr->computePass_);
|
|
106
|
+
if (label == nullptr) {
|
|
107
|
+
info.GetReturnValue().SetEmptyString();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
info.GetReturnValue().Set(
|
|
111
|
+
ConvertToV8String(info.GetIsolate(), label)
|
|
112
|
+
);
|
|
113
|
+
canvas_native_string_destroy(label);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
info.GetReturnValue().SetEmptyString();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
93
121
|
void
|
|
94
122
|
GPUComputePassEncoderImpl::DispatchWorkgroups(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
95
123
|
auto *ptr = GetPointer(args.This());
|
|
@@ -216,30 +244,35 @@ void GPUComputePassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::
|
|
|
216
244
|
auto dynamicOffsetsStart = args[3];
|
|
217
245
|
auto dynamicOffsetsLength = args[4];
|
|
218
246
|
|
|
247
|
+
const CanvasGPUBindGroup *bindGroup = nullptr;
|
|
248
|
+
|
|
219
249
|
auto type = GetNativeType(bindGroupVal);
|
|
220
250
|
|
|
221
251
|
if (type == NativeType::GPUBindGroup) {
|
|
222
|
-
auto
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
252
|
+
auto group = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
253
|
+
bindGroup = group->GetBindGroup();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
auto index = indexVal->Uint32Value(context).FromJust();
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
if (dynamicOffsets->IsUint8Array()) {
|
|
260
|
+
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
261
|
+
auto buffer = buf->Buffer();
|
|
262
|
+
auto store = buffer->GetBackingStore();
|
|
263
|
+
auto offset = buf->ByteOffset();
|
|
264
|
+
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
265
|
+
auto size = buf->Length();
|
|
266
|
+
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
267
|
+
auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
|
|
268
|
+
canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
|
|
269
|
+
bindGroup,
|
|
270
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
271
|
+
size, start, offset_length);
|
|
272
|
+
} else {
|
|
273
|
+
canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
|
|
274
|
+
bindGroup,
|
|
275
|
+
nullptr, 0, 0, 0);
|
|
243
276
|
}
|
|
244
277
|
}
|
|
245
278
|
|
|
@@ -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
|
static void DispatchWorkgroups(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
40
43
|
|
|
41
44
|
static void DispatchWorkgroupsIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
|