@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.
- package/Canvas/common.d.ts +3 -4
- package/Canvas/common.js +35 -125
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +0 -1
- package/Canvas/index.android.js +45 -38
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +11 -3
- package/Canvas/index.ios.js +49 -40
- 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 +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.js +1 -0
- 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.js +77 -33
- 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/index.js +73 -31
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +4 -4
- 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 +3 -2
- 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 +72 -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 +45 -7
- 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 +2 -1
- package/WebGPU/GPURenderPassEncoder.js +5 -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 +221 -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/package.json +20 -0
- package/package.json +1 -3
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
- 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 +9 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +226 -61
- 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 +6871 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +7 -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 +656 -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 +18 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +226 -61
- 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 +6871 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +6871 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +27 -27
- 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 +658 -646
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +696 -684
- package/platforms/ios/src/NSOperationQueueWrapper.h +3 -1
- package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
- package/platforms/ios/src/cpp/AsyncCallback.h +214 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +123 -47
- package/platforms/ios/src/cpp/Helpers.h +2 -164
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +18 -26
- package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +12 -4
- package/platforms/ios/src/cpp/NativeType.h +87 -0
- package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
- package/platforms/ios/src/cpp/PromiseCallback.h +197 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +6 -6
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +18 -13
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
- package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
- package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +142 -73
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +32 -6
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +5 -2
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +27 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +80 -32
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +8 -4
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +29 -2
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +101 -106
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +5 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +26 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1683 -733
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +53 -39
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +27 -1
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +8 -5
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +2 -3
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +88 -36
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +43 -14
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +26 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +40 -14
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +26 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +27 -1
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +5 -2
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +25 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +5 -2
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +6 -4
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +27 -1
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +5 -2
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
- package/utils.d.ts +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include "GPUAdapterImpl.h"
|
|
6
6
|
#include "Caches.h"
|
|
7
|
-
|
|
7
|
+
#include "GPULabel.h"
|
|
8
8
|
GPUAdapterImpl::GPUAdapterImpl(const CanvasGPUAdapter *adapter) : adapter_(adapter) {}
|
|
9
9
|
|
|
10
10
|
const CanvasGPUAdapter *GPUAdapterImpl::GetGPUAdapter() {
|
|
@@ -61,7 +61,6 @@ v8::Local<v8::FunctionTemplate> GPUAdapterImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
61
61
|
GetLimits
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
|
|
65
64
|
tmpl->Set(
|
|
66
65
|
ConvertToV8String(isolate, "requestAdapterInfo"),
|
|
67
66
|
v8::FunctionTemplate::New(isolate, &RequestAdapterInfo));
|
|
@@ -90,19 +89,19 @@ GPUAdapterImpl::GetFeatures(v8::Local<v8::Name> name,
|
|
|
90
89
|
|
|
91
90
|
auto len = canvas_native_string_buffer_get_length(features);
|
|
92
91
|
|
|
93
|
-
auto
|
|
92
|
+
auto set = v8::Set::New(isolate);
|
|
94
93
|
for (int i = 0; i < len; ++i) {
|
|
95
94
|
auto item = canvas_native_string_buffer_get_value_at(features, i);
|
|
96
95
|
if (item != nullptr) {
|
|
97
|
-
auto keyValue =
|
|
98
|
-
|
|
96
|
+
auto keyValue = ConvertToV8String(isolate, (char *) item);
|
|
97
|
+
set->Add(context, keyValue);
|
|
99
98
|
canvas_native_string_destroy(item);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
}
|
|
103
102
|
canvas_native_string_buffer_release(features);
|
|
104
103
|
|
|
105
|
-
info.GetReturnValue().Set(
|
|
104
|
+
info.GetReturnValue().Set(set);
|
|
106
105
|
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
@@ -158,6 +157,27 @@ void GPUAdapterImpl::RequestAdapterInfo(const v8::FunctionCallbackInfo<v8::Value
|
|
|
158
157
|
|
|
159
158
|
}
|
|
160
159
|
|
|
160
|
+
struct RequestData {
|
|
161
|
+
char *error_;
|
|
162
|
+
const CanvasGPUDevice *device_;
|
|
163
|
+
char **required_features_data_;
|
|
164
|
+
size_t required_features_data_size;
|
|
165
|
+
|
|
166
|
+
~RequestData() {
|
|
167
|
+
if (required_features_data_ != nullptr) {
|
|
168
|
+
for (size_t i = 0; i < required_features_data_size; ++i) {
|
|
169
|
+
delete[] required_features_data_[i];
|
|
170
|
+
}
|
|
171
|
+
delete[] required_features_data_;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (error_ != nullptr) {
|
|
175
|
+
canvas_native_string_destroy(error_);
|
|
176
|
+
error_ = nullptr;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
161
181
|
void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
162
182
|
GPUAdapterImpl *ptr = GetPointer(args.This());
|
|
163
183
|
auto isolate = args.GetIsolate();
|
|
@@ -170,9 +190,9 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
170
190
|
return;
|
|
171
191
|
}
|
|
172
192
|
|
|
173
|
-
|
|
193
|
+
auto func = cb.As<v8::Function>();
|
|
174
194
|
|
|
175
|
-
|
|
195
|
+
GPULabel label;
|
|
176
196
|
|
|
177
197
|
std::vector<std::string> required_features_buf;
|
|
178
198
|
|
|
@@ -183,10 +203,9 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
183
203
|
v8::Local<v8::Value> labelValue;
|
|
184
204
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(
|
|
185
205
|
&labelValue);
|
|
206
|
+
|
|
207
|
+
label = GPULabel(isolate, labelValue);
|
|
186
208
|
|
|
187
|
-
if (!labelValue.IsEmpty() && labelValue->IsString()) {
|
|
188
|
-
label = ConvertFromV8String(isolate, labelValue);
|
|
189
|
-
}
|
|
190
209
|
|
|
191
210
|
v8::Local<v8::Value> requiredFeaturesValue;
|
|
192
211
|
|
|
@@ -194,11 +213,9 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
194
213
|
&requiredFeaturesValue);
|
|
195
214
|
|
|
196
215
|
|
|
197
|
-
if (!requiredFeaturesValue.IsEmpty() && requiredFeaturesValue->
|
|
198
|
-
v8::Local<v8::
|
|
199
|
-
v8::Local<v8::Array> requiredFeatures = requiredFeaturesSet->AsArray();
|
|
216
|
+
if (!requiredFeaturesValue.IsEmpty() && requiredFeaturesValue->IsArray()) {
|
|
217
|
+
v8::Local<v8::Array> requiredFeatures = requiredFeaturesValue.As<v8::Array>();
|
|
200
218
|
auto len = requiredFeatures->Length();
|
|
201
|
-
|
|
202
219
|
for (int i = 0; i < len; i++) {
|
|
203
220
|
auto item = requiredFeatures->Get(context, i);
|
|
204
221
|
if (!item.IsEmpty()) {
|
|
@@ -210,7 +227,6 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
229
|
|
|
213
|
-
|
|
214
230
|
v8::Local<v8::Value> limitsValue;
|
|
215
231
|
|
|
216
232
|
options->Get(context, ConvertToV8String(isolate, "requiredLimits")).ToLocal(
|
|
@@ -228,75 +244,128 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
228
244
|
size_t required_features_data_length = required_features_buf.size();
|
|
229
245
|
|
|
230
246
|
if (required_features_data_length > 0) {
|
|
231
|
-
required_features_data = new char *[required_features_data_length
|
|
247
|
+
required_features_data = new char *[required_features_data_length];
|
|
232
248
|
|
|
233
249
|
for (size_t i = 0; i < required_features_data_length; ++i) {
|
|
234
|
-
|
|
250
|
+
required_features_data[i] = new char[required_features_buf[i].size() + 1];
|
|
251
|
+
auto src = required_features_buf[i].c_str();
|
|
252
|
+
std::strcpy(required_features_data[i], src);
|
|
235
253
|
}
|
|
236
254
|
}
|
|
237
255
|
|
|
238
|
-
|
|
239
256
|
auto callback = new AsyncCallback{
|
|
240
257
|
isolate,
|
|
241
|
-
|
|
242
|
-
|
|
258
|
+
func,
|
|
259
|
+
[](bool done, void *data) {
|
|
260
|
+
if (data != nullptr) {
|
|
261
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
262
|
+
auto func = async_data->inner_.get();
|
|
263
|
+
if (func != nullptr && func->isolate_ != nullptr) {
|
|
264
|
+
v8::Isolate *isolate = func->isolate_;
|
|
265
|
+
v8::Locker locker(isolate);
|
|
266
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
267
|
+
v8::HandleScope handle_scope(isolate);
|
|
268
|
+
v8::Local<v8::Function> callback = func->callback_.Get(
|
|
269
|
+
isolate);
|
|
270
|
+
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
271
|
+
v8::Context::Scope context_scope(context);
|
|
272
|
+
|
|
273
|
+
RequestData *requestData = nullptr;
|
|
274
|
+
if (func->data != nullptr) {
|
|
275
|
+
requestData = static_cast<RequestData *>(func->data);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (requestData == nullptr) {
|
|
279
|
+
// Should never happen
|
|
280
|
+
v8::Local<v8::Value> args[1] = {
|
|
281
|
+
v8::Exception::Error(
|
|
282
|
+
ConvertToV8String(isolate, "Internal Error"))};
|
|
283
|
+
|
|
284
|
+
callback->Call(context, context->Global(),
|
|
285
|
+
1,
|
|
286
|
+
args); // ignore JS return value
|
|
287
|
+
delete static_cast<AsyncCallback *>(data);
|
|
288
|
+
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (requestData->error_ != nullptr) {
|
|
293
|
+
v8::Local<v8::Value> args[1] = {
|
|
294
|
+
v8::Exception::Error(
|
|
295
|
+
ConvertToV8String(isolate,
|
|
296
|
+
requestData->error_))};
|
|
297
|
+
|
|
298
|
+
callback->Call(context, context->Global(),
|
|
299
|
+
1,
|
|
300
|
+
args); // ignore JS return value
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
} else {
|
|
304
|
+
|
|
305
|
+
auto impl = new GPUDeviceImpl(requestData->device_);
|
|
306
|
+
auto ret = GPUDeviceImpl::NewInstance(
|
|
307
|
+
isolate, impl);
|
|
308
|
+
|
|
309
|
+
v8::Local<v8::Value> args[2] = {
|
|
310
|
+
v8::Null(isolate), ret};
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
callback->Call(context, context->Global(),
|
|
314
|
+
2,
|
|
315
|
+
args); // ignore JS return value
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (requestData != nullptr) {
|
|
319
|
+
delete requestData;
|
|
320
|
+
requestData = nullptr;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
delete static_cast<AsyncCallback *>(data);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
243
327
|
};
|
|
244
328
|
|
|
245
|
-
|
|
246
|
-
label.empty() ? nullptr : label.c_str(),
|
|
247
|
-
required_features_data, required_features_data_length,
|
|
248
|
-
limits,
|
|
249
|
-
[](char *error, const CanvasGPUDevice *device, void *data) {
|
|
250
|
-
if (data != nullptr) {
|
|
251
|
-
auto func = static_cast<AsyncCallback *>(data);
|
|
252
|
-
if (func->isolate != nullptr) {
|
|
253
|
-
v8::Isolate *isolate = func->isolate;
|
|
254
|
-
v8::Locker locker(isolate);
|
|
255
|
-
v8::Isolate::Scope isolate_scope(isolate);
|
|
256
|
-
v8::HandleScope handle_scope(isolate);
|
|
257
|
-
v8::Local<v8::Function> callback = func->callback.Get(
|
|
258
|
-
isolate);
|
|
259
|
-
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
260
|
-
v8::Context::Scope context_scope(context);
|
|
261
|
-
|
|
262
|
-
if (func->data != nullptr) {
|
|
263
|
-
delete[] static_cast<char **>(func->data);
|
|
264
|
-
func->data = nullptr;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (error != nullptr) {
|
|
268
|
-
v8::Local<v8::Value> args[1] = {
|
|
269
|
-
v8::Exception::Error(
|
|
270
|
-
ConvertToV8String(isolate,
|
|
271
|
-
error))};
|
|
272
|
-
|
|
273
|
-
canvas_native_string_destroy(error);
|
|
274
|
-
|
|
275
|
-
callback->Call(context, context->Global(),
|
|
276
|
-
1,
|
|
277
|
-
args); // ignore JS return value
|
|
278
|
-
delete static_cast<AsyncCallback *>(data);
|
|
279
|
-
} else {
|
|
329
|
+
auto inner = callback->inner_.get();
|
|
280
330
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
callback->Call(context, context->Global(),
|
|
291
|
-
2,
|
|
292
|
-
args); // ignore JS return value
|
|
331
|
+
if (required_features_data != nullptr) {
|
|
332
|
+
inner->data = new RequestData{
|
|
333
|
+
nullptr,
|
|
334
|
+
nullptr,
|
|
335
|
+
required_features_data,
|
|
336
|
+
required_features_data_length
|
|
337
|
+
};
|
|
338
|
+
}
|
|
293
339
|
|
|
294
|
-
|
|
340
|
+
callback->prepare();
|
|
295
341
|
|
|
342
|
+
canvas_native_webgpu_adapter_request_device(ptr->GetGPUAdapter(),
|
|
343
|
+
*label,
|
|
344
|
+
required_features_data,
|
|
345
|
+
required_features_data_length,
|
|
346
|
+
limits,
|
|
347
|
+
[](char *error, const CanvasGPUDevice *device,
|
|
348
|
+
void *data) {
|
|
349
|
+
if (data != nullptr) {
|
|
350
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
351
|
+
auto inner = async_data->inner_.get();
|
|
352
|
+
if (inner != nullptr) {
|
|
353
|
+
if (inner->data == nullptr) {
|
|
354
|
+
inner->data = new RequestData{
|
|
355
|
+
error,
|
|
356
|
+
device
|
|
357
|
+
};
|
|
358
|
+
} else {
|
|
359
|
+
auto request_data = static_cast<RequestData *>(inner->data);
|
|
360
|
+
request_data->error_ = error;
|
|
361
|
+
request_data->device_ = device;
|
|
362
|
+
delete request_data->required_features_data_;
|
|
363
|
+
request_data->required_features_data_ = nullptr;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async_data->execute(true);
|
|
367
|
+
}
|
|
296
368
|
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}, callback);
|
|
300
|
-
|
|
369
|
+
}, callback);
|
|
301
370
|
|
|
302
371
|
}
|
|
@@ -33,7 +33,7 @@ public:
|
|
|
33
33
|
v8::EscapableHandleScope scope(isolate);
|
|
34
34
|
auto object = GPUAdapterImpl::GetCtor(isolate)->GetFunction(
|
|
35
35
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
36
|
-
SetNativeType(
|
|
36
|
+
SetNativeType(adapter, NativeType::GPUAdapter);
|
|
37
37
|
object->SetAlignedPointerInInternalField(0, adapter);
|
|
38
38
|
adapter->BindFinalizer(isolate, object);
|
|
39
39
|
return scope.Escape(object);
|
|
@@ -21,7 +21,7 @@ void GPUAdapterInfoImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *i
|
|
|
21
21
|
auto context = isolate->GetCurrentContext();
|
|
22
22
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
23
23
|
|
|
24
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUAdapterInfo"), func).FromJust()
|
|
24
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUAdapterInfo"), func).FromJust();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
GPUAdapterInfoImpl *GPUAdapterInfoImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -30,7 +30,7 @@ public:
|
|
|
30
30
|
v8::EscapableHandleScope scope(isolate);
|
|
31
31
|
auto object = GPUAdapterInfoImpl::GetCtor(isolate)->GetFunction(
|
|
32
32
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
33
|
-
SetNativeType(
|
|
33
|
+
SetNativeType(info, NativeType::GPUAdapterInfo);
|
|
34
34
|
object->SetAlignedPointerInInternalField(0, info);
|
|
35
35
|
info->BindFinalizer(isolate, object);
|
|
36
36
|
return scope.Escape(object);
|
|
@@ -13,7 +13,7 @@ const CanvasGPUBindGroup *GPUBindGroupImpl::GetBindGroup() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
void GPUBindGroupImpl::Init(v8::Local
|
|
16
|
+
void GPUBindGroupImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
17
17
|
v8::Locker locker(isolate);
|
|
18
18
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
19
19
|
v8::HandleScope handle_scope(isolate);
|
|
@@ -22,10 +22,10 @@ void GPUBindGroupImpl::Init(v8::Local <v8::Object> canvasModule, v8::Isolate *is
|
|
|
22
22
|
auto context = isolate->GetCurrentContext();
|
|
23
23
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
24
24
|
|
|
25
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroup"), func).FromJust()
|
|
25
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroup"), func).FromJust();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local
|
|
28
|
+
GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
29
29
|
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
30
30
|
if (ptr == nullptr) {
|
|
31
31
|
return nullptr;
|
|
@@ -33,21 +33,47 @@ GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local <v8::Object> &obj
|
|
|
33
33
|
return static_cast<GPUBindGroupImpl *>(ptr);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
v8::Local
|
|
36
|
+
v8::Local<v8::FunctionTemplate> GPUBindGroupImpl::GetCtor(v8::Isolate *isolate) {
|
|
37
37
|
auto cache = Caches::Get(isolate);
|
|
38
38
|
auto ctor = cache->GPUBindGroupTmpl.get();
|
|
39
39
|
if (ctor != nullptr) {
|
|
40
40
|
return ctor->Get(isolate);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
v8::Local
|
|
43
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
44
44
|
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
45
45
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUBindGroup"));
|
|
46
46
|
|
|
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->GPUBindGroupTmpl =
|
|
51
|
-
std::make_unique
|
|
56
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate >>(isolate, ctorTmpl);
|
|
52
57
|
return ctorTmpl;
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
void
|
|
62
|
+
GPUBindGroupImpl::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_get_label(ptr->group_);
|
|
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
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
class GPUBindGroupImpl : ObjectWrapperImpl {
|
|
13
13
|
public:
|
|
14
|
-
GPUBindGroupImpl(const CanvasGPUBindGroup *group);
|
|
14
|
+
explicit GPUBindGroupImpl(const CanvasGPUBindGroup *group);
|
|
15
15
|
|
|
16
16
|
~GPUBindGroupImpl() {
|
|
17
17
|
canvas_native_webgpu_bind_group_release(this->GetBindGroup());
|
|
@@ -31,12 +31,15 @@ public:
|
|
|
31
31
|
v8::EscapableHandleScope scope(isolate);
|
|
32
32
|
auto object = GPUBindGroupImpl::GetCtor(isolate)->GetFunction(
|
|
33
33
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
-
SetNativeType(
|
|
34
|
+
SetNativeType(groupLayout, NativeType::GPUBindGroup);
|
|
35
35
|
object->SetAlignedPointerInInternalField(0, groupLayout);
|
|
36
36
|
groupLayout->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 CanvasGPUBindGroup *group_;
|
|
42
45
|
};
|
|
@@ -22,7 +22,7 @@ void GPUBindGroupLayoutImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolat
|
|
|
22
22
|
auto context = isolate->GetCurrentContext();
|
|
23
23
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
24
24
|
|
|
25
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroupLayout"), func).FromJust()
|
|
25
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroupLayout"), func).FromJust();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
GPUBindGroupLayoutImpl *GPUBindGroupLayoutImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -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
|
+
}
|
|
@@ -31,12 +31,15 @@ public:
|
|
|
31
31
|
v8::EscapableHandleScope scope(isolate);
|
|
32
32
|
auto object = GPUBindGroupLayoutImpl::GetCtor(isolate)->GetFunction(
|
|
33
33
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
-
SetNativeType(
|
|
34
|
+
SetNativeType(groupLayout, NativeType::GPUBindGroupLayout);
|
|
35
35
|
object->SetAlignedPointerInInternalField(0, groupLayout);
|
|
36
36
|
groupLayout->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 CanvasGPUBindGroupLayout *groupLayout_;
|
|
42
45
|
};
|
|
@@ -21,7 +21,7 @@ void GPUBufferImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolat
|
|
|
21
21
|
auto context = isolate->GetCurrentContext();
|
|
22
22
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
23
23
|
|
|
24
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBuffer"), func).FromJust()
|
|
24
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBuffer"), func).FromJust();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
GPUBufferImpl *GPUBufferImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -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();
|
|
@@ -154,42 +164,59 @@ void GPUBufferImpl::MapAsync(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
154
164
|
auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked();
|
|
155
165
|
args.GetReturnValue().Set(resolver->GetPromise());
|
|
156
166
|
|
|
157
|
-
v8::Global<v8::Promise::Resolver> promise(isolate, resolver);
|
|
158
167
|
auto callback = new PromiseCallback{
|
|
159
168
|
isolate,
|
|
160
|
-
|
|
169
|
+
resolver,
|
|
170
|
+
[](bool done, void *data){
|
|
171
|
+
auto async_data = static_cast<PromiseCallback *>(data);
|
|
172
|
+
auto func = async_data->inner_.get();
|
|
173
|
+
if (func != nullptr && func->isolate_ != nullptr) {
|
|
174
|
+
v8::Isolate *isolate = func->isolate_;
|
|
175
|
+
v8::Locker locker(isolate);
|
|
176
|
+
v8::Isolate::Scope isolate_scope(
|
|
177
|
+
isolate);
|
|
178
|
+
v8::HandleScope handle_scope(
|
|
179
|
+
isolate);
|
|
180
|
+
v8::Local<v8::Promise::Resolver> callback = func->callback_.Get(
|
|
181
|
+
isolate);
|
|
182
|
+
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
183
|
+
v8::Context::Scope context_scope(
|
|
184
|
+
context);
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if (func->data == nullptr) {
|
|
188
|
+
callback->Resolve(context, v8::Undefined(isolate));
|
|
189
|
+
} else {
|
|
190
|
+
auto errorData = static_cast<MapAsyncData*>(func->data);
|
|
191
|
+
callback->Reject(context,
|
|
192
|
+
v8::Exception::Error(
|
|
193
|
+
ConvertToV8String(
|
|
194
|
+
isolate,
|
|
195
|
+
errorData->error)));
|
|
196
|
+
canvas_native_string_destroy(
|
|
197
|
+
errorData->error);
|
|
198
|
+
delete errorData;
|
|
199
|
+
func->data = nullptr;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
delete static_cast<PromiseCallback *>(data);
|
|
203
|
+
}
|
|
161
204
|
};
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
callback->prepare();
|
|
206
|
+
|
|
207
|
+
|
|
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) {
|
|
164
210
|
if (data != nullptr) {
|
|
165
|
-
auto
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
isolate);
|
|
173
|
-
v8::Local<v8::Promise::Resolver> callback = func->callback.Get(
|
|
174
|
-
isolate);
|
|
175
|
-
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
176
|
-
v8::Context::Scope context_scope(
|
|
177
|
-
context);
|
|
178
|
-
|
|
179
|
-
auto ret = v8::Object::New(
|
|
180
|
-
isolate);
|
|
181
|
-
if (error == nullptr) {
|
|
182
|
-
callback->Resolve(context, ret);
|
|
183
|
-
} else {
|
|
184
|
-
callback->Reject(context,
|
|
185
|
-
v8::Exception::Error(
|
|
186
|
-
ConvertToV8String(
|
|
187
|
-
isolate,
|
|
188
|
-
error)));
|
|
189
|
-
canvas_native_string_destroy(
|
|
190
|
-
error);
|
|
211
|
+
auto async_data = static_cast<PromiseCallback *>(data);
|
|
212
|
+
auto inner = async_data->inner_.get();
|
|
213
|
+
if (inner != nullptr) {
|
|
214
|
+
if(error != nullptr){
|
|
215
|
+
inner->data = new MapAsyncData {
|
|
216
|
+
type, error
|
|
217
|
+
};
|
|
191
218
|
}
|
|
192
|
-
|
|
219
|
+
async_data->execute(true);
|
|
193
220
|
}
|
|
194
221
|
}
|
|
195
222
|
}, callback);
|
|
@@ -227,3 +254,24 @@ void GPUBufferImpl::GetMappedRange(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
227
254
|
args.GetReturnValue().Set(ab);
|
|
228
255
|
}
|
|
229
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
|
+
}
|