@nativescript/canvas 2.0.0-webgpu.2 → 2.0.0-webgpu.20
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 +94 -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/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 +224 -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 +224 -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 +32 -6
- 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
|
@@ -30,12 +30,14 @@ public:
|
|
|
30
30
|
v8::EscapableHandleScope scope(isolate);
|
|
31
31
|
auto object = GPUDeviceImpl::GetCtor(isolate)->GetFunction(
|
|
32
32
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
33
|
-
SetNativeType(
|
|
33
|
+
SetNativeType(device, NativeType::GPUDevice);
|
|
34
34
|
object->SetAlignedPointerInInternalField(0, device);
|
|
35
35
|
device->BindFinalizer(isolate, object);
|
|
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);
|
|
@@ -20,7 +20,7 @@ void GPUImpl::Init(const v8::Local<v8::Object> &canvasModule, v8::Isolate *isola
|
|
|
20
20
|
auto context = isolate->GetCurrentContext();
|
|
21
21
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
22
22
|
|
|
23
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPU"), func).FromJust()
|
|
23
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPU"), func).FromJust();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
|
@@ -69,7 +69,7 @@ void GPUImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
69
69
|
|
|
70
70
|
ret->SetAlignedPointerInInternalField(0, object);
|
|
71
71
|
|
|
72
|
-
SetNativeType(
|
|
72
|
+
SetNativeType(object, NativeType::GPUInstance);
|
|
73
73
|
|
|
74
74
|
object->BindFinalizer(isolate, ret);
|
|
75
75
|
|
|
@@ -122,49 +122,63 @@ void GPUImpl::RequestAdapter(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
auto callback = new AsyncCallback{
|
|
127
127
|
isolate,
|
|
128
|
-
|
|
128
|
+
args[1].As<v8::Function>(),
|
|
129
|
+
[](bool done, void *data) {
|
|
130
|
+
if (data != nullptr) {
|
|
131
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
132
|
+
auto func = async_data->inner_.get();
|
|
133
|
+
if (func != nullptr && func->isolate_ != nullptr) {
|
|
134
|
+
v8::Isolate *isolate = func->isolate_;
|
|
135
|
+
v8::Locker locker(isolate);
|
|
136
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
137
|
+
v8::HandleScope handle_scope(isolate);
|
|
138
|
+
v8::Local<v8::Function> callback = func->callback_.Get(
|
|
139
|
+
isolate);
|
|
140
|
+
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
141
|
+
v8::Context::Scope context_scope(context);
|
|
142
|
+
|
|
143
|
+
if (func->data != nullptr) {
|
|
144
|
+
auto impl = new GPUAdapterImpl(
|
|
145
|
+
static_cast<const CanvasGPUAdapter *>(func->data));
|
|
146
|
+
auto ret = GPUAdapterImpl::NewInstance(
|
|
147
|
+
isolate, impl);
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
v8::Local<v8::Value> args[2] = {
|
|
151
|
+
v8::Null(isolate), ret};
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
callback->Call(context, context->Global(),
|
|
155
|
+
2,
|
|
156
|
+
args); // ignore JS return value
|
|
157
|
+
|
|
158
|
+
delete static_cast<AsyncCallback *>(data);
|
|
159
|
+
|
|
160
|
+
} else {
|
|
161
|
+
v8::Local<v8::Value> args[1] = {
|
|
162
|
+
v8::Null(isolate)};
|
|
163
|
+
|
|
164
|
+
callback->Call(context, context->Global(),
|
|
165
|
+
1,
|
|
166
|
+
args); // ignore JS return value
|
|
167
|
+
delete static_cast<AsyncCallback *>(data);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
129
172
|
};
|
|
173
|
+
callback->prepare();
|
|
130
174
|
canvas_native_webgpu_request_adapter(ptr->GetGPUInstance(), &opts,
|
|
131
175
|
[](const CanvasGPUAdapter *adapter, void *data) {
|
|
132
176
|
if (data != nullptr) {
|
|
133
|
-
auto
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
v8::HandleScope handle_scope(isolate);
|
|
139
|
-
v8::Local<v8::Function> callback = func->callback.Get(
|
|
140
|
-
isolate);
|
|
141
|
-
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
142
|
-
v8::Context::Scope context_scope(context);
|
|
143
|
-
|
|
144
|
-
if (adapter != nullptr) {
|
|
145
|
-
auto impl = new GPUAdapterImpl(adapter);
|
|
146
|
-
auto ret = GPUAdapterImpl::NewInstance(
|
|
147
|
-
isolate, impl);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
v8::Local<v8::Value> args[2] = {
|
|
151
|
-
v8::Null(isolate), ret};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
callback->Call(context, context->Global(),
|
|
155
|
-
2,
|
|
156
|
-
args); // ignore JS return value
|
|
157
|
-
|
|
158
|
-
delete static_cast<AsyncCallback *>(data);
|
|
159
|
-
} else {
|
|
160
|
-
v8::Local<v8::Value> args[1] = {
|
|
161
|
-
v8::Null(isolate)};
|
|
162
|
-
|
|
163
|
-
callback->Call(context, context->Global(),
|
|
164
|
-
1,
|
|
165
|
-
args); // ignore JS return value
|
|
166
|
-
delete static_cast<AsyncCallback *>(data);
|
|
167
|
-
}
|
|
177
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
178
|
+
auto inner = async_data->inner_.get();
|
|
179
|
+
if (inner != nullptr) {
|
|
180
|
+
inner->data = (void *) adapter;
|
|
181
|
+
async_data->execute(true);
|
|
168
182
|
}
|
|
169
183
|
}
|
|
170
184
|
}, callback);
|
|
@@ -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) {
|
|
@@ -37,7 +37,7 @@ public:
|
|
|
37
37
|
v8::EscapableHandleScope scope(isolate);
|
|
38
38
|
auto object = GPUImpl::GetCtor(isolate)->GetFunction(
|
|
39
39
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
40
|
-
SetNativeType(
|
|
40
|
+
SetNativeType(instance, NativeType::GPUInstance);
|
|
41
41
|
object->SetAlignedPointerInInternalField(0, instance);
|
|
42
42
|
instance->BindFinalizer(isolate, object);
|
|
43
43
|
return scope.Escape(object);
|
|
@@ -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
|
|
@@ -22,7 +22,7 @@ void GPUPipelineLayoutImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate
|
|
|
22
22
|
auto context = isolate->GetCurrentContext();
|
|
23
23
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
24
24
|
|
|
25
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUPipelineLayout"), func).FromJust()
|
|
25
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUPipelineLayout"), func).FromJust();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
GPUPipelineLayoutImpl *GPUPipelineLayoutImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -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());
|
|
@@ -26,17 +26,20 @@ public:
|
|
|
26
26
|
|
|
27
27
|
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
28
28
|
|
|
29
|
-
static v8::Local<v8::Object>
|
|
29
|
+
static v8::Local<v8::Object>
|
|
30
|
+
NewInstance(v8::Isolate *isolate, GPUPipelineLayoutImpl *pipeline) {
|
|
30
31
|
auto context = isolate->GetCurrentContext();
|
|
31
32
|
v8::EscapableHandleScope scope(isolate);
|
|
32
33
|
auto object = GPUPipelineLayoutImpl::GetCtor(isolate)->GetFunction(
|
|
33
34
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
-
SetNativeType(
|
|
35
|
-
object->SetAlignedPointerInInternalField(0,
|
|
36
|
-
|
|
35
|
+
SetNativeType(pipeline, NativeType::GPUPipelineLayout);
|
|
36
|
+
object->SetAlignedPointerInInternalField(0, pipeline);
|
|
37
|
+
pipeline->BindFinalizer(isolate, object);
|
|
37
38
|
return scope.Escape(object);
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
static void GetLabel(v8::Local<v8::Name> name,
|
|
42
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
40
43
|
|
|
41
44
|
private:
|
|
42
45
|
const CanvasGPUPipelineLayout *pipeline_;
|
|
@@ -21,7 +21,7 @@ void GPUQuerySetImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isol
|
|
|
21
21
|
auto context = isolate->GetCurrentContext();
|
|
22
22
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
23
23
|
|
|
24
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUQuerySet"), func).FromJust()
|
|
24
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUQuerySet"), func).FromJust();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
GPUQuerySetImpl *GPUQuerySetImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -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
|
-
|
|
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());
|
|
@@ -29,7 +29,7 @@ public:
|
|
|
29
29
|
v8::EscapableHandleScope scope(isolate);
|
|
30
30
|
auto object = GPUQuerySetImpl::GetCtor(isolate)->GetFunction(
|
|
31
31
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
32
|
-
SetNativeType(
|
|
32
|
+
SetNativeType(querySet, NativeType::GPUQuerySet);
|
|
33
33
|
object->SetAlignedPointerInInternalField(0, querySet);
|
|
34
34
|
querySet->BindFinalizer(isolate, object);
|
|
35
35
|
return scope.Escape(object);
|
|
@@ -30,7 +30,7 @@ void GPUQueueImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate
|
|
|
30
30
|
auto context = isolate->GetCurrentContext();
|
|
31
31
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
32
32
|
|
|
33
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUQueue"), func).FromJust()
|
|
33
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUQueue"), func).FromJust();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
GPUQueueImpl *GPUQueueImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -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
|
|
115
|
-
|
|
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
|
|
120
|
-
|
|
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;
|
|
@@ -306,33 +346,48 @@ void GPUQueueImpl::SubmitWorkDone(const v8::FunctionCallbackInfo<v8::Value> &arg
|
|
|
306
346
|
}
|
|
307
347
|
|
|
308
348
|
auto isolate = args.GetIsolate();
|
|
349
|
+
auto cb = args[0].As<v8::Function>();
|
|
350
|
+
auto callback = new AsyncCallback(isolate, cb, [](bool done, void *data) {
|
|
351
|
+
if (data != nullptr) {
|
|
352
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
353
|
+
auto func = async_data->inner_.get();
|
|
354
|
+
if (func != nullptr && func->isolate_ != nullptr) {
|
|
355
|
+
v8::Isolate *isolate = func->isolate_;
|
|
356
|
+
v8::Locker locker(isolate);
|
|
357
|
+
v8::Isolate::Scope isolate_scope(
|
|
358
|
+
isolate);
|
|
359
|
+
v8::HandleScope handle_scope(
|
|
360
|
+
isolate);
|
|
361
|
+
v8::Local<v8::Function> callback = func->callback_.Get(
|
|
362
|
+
isolate);
|
|
363
|
+
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
364
|
+
v8::Context::Scope context_scope(
|
|
365
|
+
context);
|
|
366
|
+
|
|
367
|
+
if (func->data != nullptr) {
|
|
368
|
+
// todo handle error
|
|
369
|
+
canvas_native_string_destroy(static_cast<char *>(func->data));
|
|
370
|
+
func->data = nullptr;
|
|
371
|
+
}
|
|
309
372
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
canvas_native_webgpu_queue_on_submitted_work_done(ptr->GetGPUQueue(),
|
|
314
|
-
[](char *error, void *data) {
|
|
315
|
-
auto cb = static_cast<JSICallback *>(data);
|
|
316
|
-
|
|
317
|
-
v8::Isolate *isolate = cb->isolate_;
|
|
318
|
-
v8::Locker locker(isolate);
|
|
319
|
-
v8::Isolate::Scope isolate_scope(
|
|
320
|
-
isolate);
|
|
321
|
-
v8::HandleScope handle_scope(
|
|
322
|
-
isolate);
|
|
323
|
-
v8::Local<v8::Function> callback = cb->callback_->Get(
|
|
324
|
-
isolate);
|
|
325
|
-
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
326
|
-
v8::Context::Scope context_scope(
|
|
327
|
-
context);
|
|
373
|
+
callback->Call(context,
|
|
374
|
+
context->Global(),
|
|
375
|
+
0, nullptr);
|
|
328
376
|
|
|
377
|
+
delete static_cast<AsyncCallback *>(data);
|
|
378
|
+
}
|
|
329
379
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
0, nullptr);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
333
382
|
|
|
383
|
+
callback->prepare();
|
|
334
384
|
|
|
335
|
-
|
|
385
|
+
canvas_native_webgpu_queue_on_submitted_work_done(ptr->GetGPUQueue(),
|
|
386
|
+
[](char *error, void *data) {
|
|
387
|
+
if (data != nullptr) {
|
|
388
|
+
auto async_data = static_cast<AsyncCallback *>(data);
|
|
389
|
+
async_data->execute(true);
|
|
390
|
+
}
|
|
336
391
|
},
|
|
337
392
|
callback);
|
|
338
393
|
|
|
@@ -353,7 +408,6 @@ void GPUQueueImpl::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
353
408
|
if (bufferValue->IsObject()) {
|
|
354
409
|
auto buffer = GPUBufferImpl::GetPointer(bufferValue.As<v8::Object>());
|
|
355
410
|
|
|
356
|
-
|
|
357
411
|
auto bufferOffset = (uint64_t) args[1].As<v8::Number>()->Value();
|
|
358
412
|
|
|
359
413
|
auto dataValue = args[2].As<v8::TypedArray>();
|
|
@@ -364,7 +418,7 @@ void GPUQueueImpl::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
364
418
|
|
|
365
419
|
auto data = static_cast<uint8_t *>(store->Data()) + offset;
|
|
366
420
|
|
|
367
|
-
auto data_size = store->ByteLength();
|
|
421
|
+
auto data_size = store->ByteLength() - offset;
|
|
368
422
|
|
|
369
423
|
auto dataOffset = (uint64_t) args[3].As<v8::Number>()->Value();
|
|
370
424
|
|
|
@@ -395,8 +449,6 @@ void GPUQueueImpl::WriteTexture(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
395
449
|
auto isolate = args.GetIsolate();
|
|
396
450
|
auto context = isolate->GetCurrentContext();
|
|
397
451
|
|
|
398
|
-
bool flipY = false;
|
|
399
|
-
|
|
400
452
|
|
|
401
453
|
auto destinationVal = args[0];
|
|
402
454
|
auto dataVal = args[1];
|
|
@@ -31,12 +31,15 @@ public:
|
|
|
31
31
|
v8::EscapableHandleScope scope(isolate);
|
|
32
32
|
auto object = GPUQueueImpl::GetCtor(isolate)->GetFunction(
|
|
33
33
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
-
SetNativeType(
|
|
34
|
+
SetNativeType(queue, NativeType::GPUQueue);
|
|
35
35
|
object->SetAlignedPointerInInternalField(0, queue);
|
|
36
36
|
queue->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
|
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
|
|
167
|
-
auto
|
|
168
|
-
auto
|
|
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
|
-
|
|
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
|
-
|
|
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->
|
|
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::
|
|
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
|
|
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
|
-
|
|
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();
|