@nativescript/canvas 2.0.0-beta.8 → 2.0.0-webgpu.0
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 +23 -15
- package/Canvas/common.js +125 -56
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +5 -7
- package/Canvas/index.android.js +61 -133
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +4 -1
- package/Canvas/index.ios.d.ts +6 -6
- package/Canvas/index.ios.js +75 -85
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +8 -11
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.d.ts +14 -0
- package/Canvas2D/DOMMatrix/index.js +62 -0
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/index.js +4 -6
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/ImageAsset/index.d.ts +1 -0
- package/ImageAsset/index.js +49 -0
- package/ImageAsset/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
- package/WebGL/WebGLRenderingContext/index.js +104 -14
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
- package/WebGL2/WebGL2RenderingContext/index.js +2 -3
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/Constants.d.ts +36 -0
- package/WebGPU/Constants.js +42 -0
- package/WebGPU/Constants.js.map +1 -0
- package/WebGPU/Errors.d.ts +18 -0
- package/WebGPU/Errors.js +21 -0
- package/WebGPU/Errors.js.map +1 -0
- package/WebGPU/GPU.d.ts +13 -0
- package/WebGPU/GPU.js +35 -0
- package/WebGPU/GPU.js.map +1 -0
- package/WebGPU/GPUAdapter.d.ts +23 -0
- package/WebGPU/GPUAdapter.js +62 -0
- package/WebGPU/GPUAdapter.js.map +1 -0
- package/WebGPU/GPUAdapterInfo.d.ts +9 -0
- package/WebGPU/GPUAdapterInfo.js +24 -0
- package/WebGPU/GPUAdapterInfo.js.map +1 -0
- package/WebGPU/GPUBindGroup.d.ts +5 -0
- package/WebGPU/GPUBindGroup.js +12 -0
- package/WebGPU/GPUBindGroup.js.map +1 -0
- package/WebGPU/GPUBindGroupLayout.d.ts +5 -0
- package/WebGPU/GPUBindGroupLayout.js +12 -0
- package/WebGPU/GPUBindGroupLayout.js.map +1 -0
- package/WebGPU/GPUBuffer.d.ts +15 -0
- package/WebGPU/GPUBuffer.js +54 -0
- package/WebGPU/GPUBuffer.js.map +1 -0
- package/WebGPU/GPUCanvasContext.d.ts +33 -0
- package/WebGPU/GPUCanvasContext.js +67 -0
- package/WebGPU/GPUCanvasContext.js.map +1 -0
- package/WebGPU/GPUCommandBuffer.d.ts +5 -0
- package/WebGPU/GPUCommandBuffer.js +12 -0
- package/WebGPU/GPUCommandBuffer.js.map +1 -0
- package/WebGPU/GPUCommandEncoder.d.ts +41 -0
- package/WebGPU/GPUCommandEncoder.js +105 -0
- package/WebGPU/GPUCommandEncoder.js.map +1 -0
- package/WebGPU/GPUComputePassEncoder.d.ts +16 -0
- package/WebGPU/GPUComputePassEncoder.js +50 -0
- package/WebGPU/GPUComputePassEncoder.js.map +1 -0
- package/WebGPU/GPUComputePipeline.d.ts +7 -0
- package/WebGPU/GPUComputePipeline.js +16 -0
- package/WebGPU/GPUComputePipeline.js.map +1 -0
- package/WebGPU/GPUDevice.d.ts +173 -0
- package/WebGPU/GPUDevice.js +381 -0
- package/WebGPU/GPUDevice.js.map +1 -0
- package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
- package/WebGPU/GPUDeviceLostInfo.js +10 -0
- package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
- package/WebGPU/GPUExternalTexture.d.ts +5 -0
- package/WebGPU/GPUExternalTexture.js +12 -0
- package/WebGPU/GPUExternalTexture.js.map +1 -0
- package/WebGPU/GPUPipelineLayout.d.ts +5 -0
- package/WebGPU/GPUPipelineLayout.js +12 -0
- package/WebGPU/GPUPipelineLayout.js.map +1 -0
- package/WebGPU/GPUQuerySet.d.ts +5 -0
- package/WebGPU/GPUQuerySet.js +12 -0
- package/WebGPU/GPUQuerySet.js.map +1 -0
- package/WebGPU/GPUQueue.d.ts +14 -0
- package/WebGPU/GPUQueue.js +77 -0
- package/WebGPU/GPUQueue.js.map +1 -0
- package/WebGPU/GPURenderBundle.d.ts +5 -0
- package/WebGPU/GPURenderBundle.js +12 -0
- package/WebGPU/GPURenderBundle.js.map +1 -0
- package/WebGPU/GPURenderBundleEncoder.d.ts +20 -0
- package/WebGPU/GPURenderBundleEncoder.js +61 -0
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
- package/WebGPU/GPURenderPassEncoder.d.ts +29 -0
- package/WebGPU/GPURenderPassEncoder.js +94 -0
- package/WebGPU/GPURenderPassEncoder.js.map +1 -0
- package/WebGPU/GPURenderPipeline.d.ts +7 -0
- package/WebGPU/GPURenderPipeline.js +16 -0
- package/WebGPU/GPURenderPipeline.js.map +1 -0
- package/WebGPU/GPUSampler.d.ts +5 -0
- package/WebGPU/GPUSampler.js +12 -0
- package/WebGPU/GPUSampler.js.map +1 -0
- package/WebGPU/GPUShaderModule.d.ts +6 -0
- package/WebGPU/GPUShaderModule.js +15 -0
- package/WebGPU/GPUShaderModule.js.map +1 -0
- package/WebGPU/GPUTexture.d.ts +16 -0
- package/WebGPU/GPUTexture.js +41 -0
- package/WebGPU/GPUTexture.js.map +1 -0
- package/WebGPU/GPUTextureView.d.ts +5 -0
- package/WebGPU/GPUTextureView.js +12 -0
- package/WebGPU/GPUTextureView.js.map +1 -0
- package/WebGPU/Interfaces.d.ts +155 -0
- package/WebGPU/Interfaces.js +2 -0
- package/WebGPU/Interfaces.js.map +1 -0
- package/WebGPU/Types.d.ts +39 -0
- package/WebGPU/Types.js +2 -0
- package/WebGPU/Types.js.map +1 -0
- package/WebGPU/Utils.d.ts +1 -0
- package/WebGPU/Utils.js +75 -0
- package/WebGPU/Utils.js.map +1 -0
- package/WebGPU/index.d.ts +28 -0
- package/WebGPU/index.js +29 -0
- package/WebGPU/index.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +22 -1
- package/index.js.map +1 -1
- package/package.json +1 -4
- 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 +23 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +47 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2280 -103
- 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 +1564 -3814
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
- 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 +27 -34
- 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 +602 -664
- 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 +46 -46
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +47 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2280 -103
- 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 +1564 -3814
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
- 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 +27 -34
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1564 -3814
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
- 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 +27 -34
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
- 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 +604 -663
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -642
- package/platforms/ios/build.xcconfig +3 -1
- package/platforms/ios/src/cpp/Caches.h +69 -1
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
- package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
- package/platforms/ios/src/cpp/Helpers.h +43 -8
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
- package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1087 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2741 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +653 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +178 -0
- package/SVG/Circle.d.ts +0 -11
- package/SVG/Circle.js +0 -21
- package/SVG/Circle.js.map +0 -1
- package/SVG/ClipPath.d.ts +0 -4
- package/SVG/ClipPath.js +0 -9
- package/SVG/ClipPath.js.map +0 -1
- package/SVG/Defs.d.ts +0 -4
- package/SVG/Defs.js +0 -9
- package/SVG/Defs.js.map +0 -1
- package/SVG/Ellipse.d.ts +0 -13
- package/SVG/Ellipse.js +0 -26
- package/SVG/Ellipse.js.map +0 -1
- package/SVG/G.d.ts +0 -7
- package/SVG/G.js +0 -9
- package/SVG/G.js.map +0 -1
- package/SVG/Image.d.ts +0 -11
- package/SVG/Image.js +0 -40
- package/SVG/Image.js.map +0 -1
- package/SVG/Line.d.ts +0 -13
- package/SVG/Line.js +0 -26
- package/SVG/Line.js.map +0 -1
- package/SVG/LinearGradient.d.ts +0 -10
- package/SVG/LinearGradient.js +0 -13
- package/SVG/LinearGradient.js.map +0 -1
- package/SVG/Path.d.ts +0 -7
- package/SVG/Path.js +0 -14
- package/SVG/Path.js.map +0 -1
- package/SVG/Pattern.d.ts +0 -4
- package/SVG/Pattern.js +0 -9
- package/SVG/Pattern.js.map +0 -1
- package/SVG/Polygon.d.ts +0 -7
- package/SVG/Polygon.js +0 -14
- package/SVG/Polygon.js.map +0 -1
- package/SVG/Polyline.d.ts +0 -7
- package/SVG/Polyline.js +0 -14
- package/SVG/Polyline.js.map +0 -1
- package/SVG/Rect.d.ts +0 -8
- package/SVG/Rect.js +0 -13
- package/SVG/Rect.js.map +0 -1
- package/SVG/SVG.d.ts +0 -32
- package/SVG/SVG.js +0 -204
- package/SVG/SVG.js.map +0 -1
- package/SVG/SVGItem.d.ts +0 -5
- package/SVG/SVGItem.js +0 -8
- package/SVG/SVGItem.js.map +0 -1
- package/SVG/Stop.d.ts +0 -5
- package/SVG/Stop.js +0 -9
- package/SVG/Stop.js.map +0 -1
- package/SVG/Symbol.d.ts +0 -4
- package/SVG/Symbol.js +0 -9
- package/SVG/Symbol.js.map +0 -1
- package/SVG/Text.d.ts +0 -14
- package/SVG/Text.js +0 -26
- package/SVG/Text.js.map +0 -1
- package/SVG/Use.d.ts +0 -4
- package/SVG/Use.js +0 -9
- package/SVG/Use.js.map +0 -1
- package/SVG/index.d.ts +0 -18
- package/SVG/index.js +0 -19
- package/SVG/index.js.map +0 -1
- package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
- package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
- package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
- package/platforms/ios/src/cpp/URLImpl.h +0 -121
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 18/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUQueueImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "GPUBufferImpl.h"
|
|
8
|
+
#include "GPUCommandBufferImpl.h"
|
|
9
|
+
#include "JSICallback.h"
|
|
10
|
+
#include "GPUTextureImpl.h"
|
|
11
|
+
#include "ImageAssetImpl.h"
|
|
12
|
+
#include "ImageBitmapImpl.h"
|
|
13
|
+
#include "ImageDataImpl.h"
|
|
14
|
+
#include "CanvasRenderingContext2DImpl.h"
|
|
15
|
+
#include "WebGLRenderingContextBase.h"
|
|
16
|
+
|
|
17
|
+
GPUQueueImpl::GPUQueueImpl(const CanvasGPUQueue *queue) : queue_(queue) {}
|
|
18
|
+
|
|
19
|
+
const CanvasGPUQueue *GPUQueueImpl::GetGPUQueue() {
|
|
20
|
+
return this->queue_;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
void GPUQueueImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
25
|
+
v8::Locker locker(isolate);
|
|
26
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
27
|
+
v8::HandleScope handle_scope(isolate);
|
|
28
|
+
|
|
29
|
+
auto ctor = GetCtor(isolate);
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
32
|
+
|
|
33
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUQueue"), func).FromJust();;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
GPUQueueImpl *GPUQueueImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
37
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
38
|
+
if (ptr == nullptr) {
|
|
39
|
+
return nullptr;
|
|
40
|
+
}
|
|
41
|
+
return static_cast<GPUQueueImpl *>(ptr);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
v8::Local<v8::FunctionTemplate> GPUQueueImpl::GetCtor(v8::Isolate *isolate) {
|
|
45
|
+
auto cache = Caches::Get(isolate);
|
|
46
|
+
auto ctor = cache->GPUQueueTmpl.get();
|
|
47
|
+
if (ctor != nullptr) {
|
|
48
|
+
return ctor->Get(isolate);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
52
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
53
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUQueue"));
|
|
54
|
+
|
|
55
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
56
|
+
tmpl->SetInternalFieldCount(2);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
tmpl->Set(
|
|
60
|
+
ConvertToV8String(isolate, "copyExternalImageToTexture"),
|
|
61
|
+
v8::FunctionTemplate::New(isolate, &CopyExternalImageToTexture));
|
|
62
|
+
|
|
63
|
+
tmpl->Set(
|
|
64
|
+
ConvertToV8String(isolate, "submit"),
|
|
65
|
+
v8::FunctionTemplate::New(isolate, &Submit));
|
|
66
|
+
|
|
67
|
+
tmpl->Set(
|
|
68
|
+
ConvertToV8String(isolate, "onSubmittedWorkDone"),
|
|
69
|
+
v8::FunctionTemplate::New(isolate, &SubmitWorkDone));
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
tmpl->Set(
|
|
73
|
+
ConvertToV8String(isolate, "writeBuffer"),
|
|
74
|
+
v8::FunctionTemplate::New(isolate, &WriteBuffer));
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
tmpl->Set(
|
|
78
|
+
ConvertToV8String(isolate, "writeTexture"),
|
|
79
|
+
v8::FunctionTemplate::New(isolate, &WriteTexture));
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
cache->GPUQueueTmpl =
|
|
83
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
84
|
+
return ctorTmpl;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
88
|
+
auto *ptr = GetPointer(args.This());
|
|
89
|
+
if (ptr == nullptr) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
auto isolate = args.GetIsolate();
|
|
94
|
+
auto context = isolate->GetCurrentContext();
|
|
95
|
+
|
|
96
|
+
auto sourceVal = args[0];
|
|
97
|
+
auto destinationVal = args[1];
|
|
98
|
+
auto sizeVal = args[2];
|
|
99
|
+
|
|
100
|
+
if (sourceVal->IsObject() && destinationVal->IsObject() &&
|
|
101
|
+
sizeVal->IsObject()) {
|
|
102
|
+
|
|
103
|
+
auto sourceObj = sourceVal.As<v8::Object>();
|
|
104
|
+
|
|
105
|
+
v8::Local<v8::Value> sourceSourceValue;
|
|
106
|
+
sourceObj->Get(context, ConvertToV8String(isolate, "source")).ToLocal(&sourceSourceValue);
|
|
107
|
+
|
|
108
|
+
auto sourceType = GetNativeType(sourceSourceValue);
|
|
109
|
+
|
|
110
|
+
U8Buffer *buffer = nullptr;
|
|
111
|
+
uint32_t width = 0;
|
|
112
|
+
uint32_t height = 0;
|
|
113
|
+
if (sourceType == NativeType::ImageBitmap) {
|
|
114
|
+
auto imageAsset = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
115
|
+
buffer = canvas_native_image_asset_get_data(imageAsset->GetImageAsset());
|
|
116
|
+
width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
|
|
117
|
+
height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
|
|
118
|
+
} else if (sourceType == NativeType::ImageAsset) {
|
|
119
|
+
auto imageAsset = ImageAssetImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
120
|
+
buffer = canvas_native_image_asset_get_data(imageAsset->GetImageAsset());
|
|
121
|
+
width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
|
|
122
|
+
height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
|
|
123
|
+
} else if (sourceType == NativeType::ImageData) {
|
|
124
|
+
auto imageData = ImageDataImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
125
|
+
buffer = canvas_native_image_data_get_data(imageData->GetImageData());
|
|
126
|
+
width = canvas_native_image_data_get_width(imageData->GetImageData());
|
|
127
|
+
height = canvas_native_image_data_get_height(imageData->GetImageData());
|
|
128
|
+
} else if (sourceType == NativeType::CanvasRenderingContext2D) {
|
|
129
|
+
auto c2d = CanvasRenderingContext2DImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
130
|
+
} else if (sourceType == NativeType::WebGLRenderingContextBase) {
|
|
131
|
+
auto webgl = WebGLRenderingContextBase::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (buffer == nullptr) {
|
|
135
|
+
// todo error ??
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
CanvasOrigin2d sourceOrigin{0, 0};
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
v8::Local<v8::Value> sourceOriginVal;
|
|
143
|
+
if (sourceObj->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(
|
|
144
|
+
&sourceOriginVal) &&
|
|
145
|
+
sourceOriginVal->IsObject()) {
|
|
146
|
+
auto sourceOriginObj = sourceOriginVal.As<v8::Object>();
|
|
147
|
+
|
|
148
|
+
v8::Local<v8::Value> xVal;
|
|
149
|
+
if (sourceOriginObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal) &&
|
|
150
|
+
xVal->IsUint32()) {
|
|
151
|
+
sourceOrigin.x = xVal->Uint32Value(context).FromJust();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
v8::Local<v8::Value> yVal;
|
|
155
|
+
if (sourceOriginObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal) &&
|
|
156
|
+
yVal->IsUint32()) {
|
|
157
|
+
sourceOrigin.y = yVal->Uint32Value(context).FromJust();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
bool flipY = false;
|
|
163
|
+
|
|
164
|
+
v8::Local<v8::Value> flipYVal;
|
|
165
|
+
if (sourceObj->Get(context, ConvertToV8String(isolate, "flipY")).ToLocal(&flipYVal) &&
|
|
166
|
+
flipYVal->IsBoolean()) {
|
|
167
|
+
flipY = flipYVal->BooleanValue(isolate);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
auto destinationObj = destinationVal.As<v8::Object>();
|
|
171
|
+
|
|
172
|
+
auto textureVal = destinationObj->Get(context, ConvertToV8String(isolate,
|
|
173
|
+
"texture")).ToLocalChecked();
|
|
174
|
+
auto texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
|
|
175
|
+
|
|
176
|
+
uint32_t mipLevel = 0;
|
|
177
|
+
CanvasOrigin3d origin{0, 0, 0};
|
|
178
|
+
CanvasTextureAspect aspect = CanvasTextureAspectAll;
|
|
179
|
+
|
|
180
|
+
v8::Local<v8::Value> mipLevelVal;
|
|
181
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(
|
|
182
|
+
&mipLevelVal) &&
|
|
183
|
+
mipLevelVal->IsUint32()) {
|
|
184
|
+
mipLevel = mipLevelVal->Uint32Value(context).FromJust();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
v8::Local<v8::Value> originVal;
|
|
189
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(
|
|
190
|
+
&originVal) &&
|
|
191
|
+
originVal->IsObject()) {
|
|
192
|
+
auto originObj = originVal.As<v8::Object>();
|
|
193
|
+
|
|
194
|
+
v8::Local<v8::Value> xVal;
|
|
195
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal) &&
|
|
196
|
+
xVal->IsUint32()) {
|
|
197
|
+
origin.x = xVal->Uint32Value(context).FromJust();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
v8::Local<v8::Value> yVal;
|
|
201
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal) &&
|
|
202
|
+
yVal->IsUint32()) {
|
|
203
|
+
origin.y = yVal->Uint32Value(context).FromJust();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
v8::Local<v8::Value> zVal;
|
|
207
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal) &&
|
|
208
|
+
zVal->IsUint32()) {
|
|
209
|
+
origin.z = zVal->Uint32Value(context).FromJust();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
v8::Local<v8::Value> aspectVal;
|
|
216
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(
|
|
217
|
+
&aspectVal)) {
|
|
218
|
+
if (aspectVal->IsString()) {
|
|
219
|
+
auto aspectStr = ConvertFromV8String(isolate, aspectVal);
|
|
220
|
+
if (aspectStr == "depth-only") {
|
|
221
|
+
aspect = CanvasTextureAspectDepthOnly;
|
|
222
|
+
} else if (aspectStr == "stencil-only") {
|
|
223
|
+
aspect = CanvasTextureAspectStencilOnly;
|
|
224
|
+
} else if (aspectStr == "all") {
|
|
225
|
+
aspect = CanvasTextureAspectAll;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
CanvasImageCopyTexture destination{
|
|
231
|
+
texture,
|
|
232
|
+
mipLevel,
|
|
233
|
+
origin,
|
|
234
|
+
aspect
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
|
|
239
|
+
|
|
240
|
+
auto data = canvas_native_u8_buffer_get_bytes(buffer);
|
|
241
|
+
auto size = canvas_native_u8_buffer_get_length(buffer);
|
|
242
|
+
|
|
243
|
+
if (data == nullptr || size == 0) {
|
|
244
|
+
// todo error
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
CanvasImageCopyExternalImage source{
|
|
249
|
+
data,
|
|
250
|
+
size,
|
|
251
|
+
sourceOrigin,
|
|
252
|
+
flipY,
|
|
253
|
+
width,
|
|
254
|
+
height,
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
canvas_native_webgpu_queue_copy_external_image_to_texture(ptr->GetGPUQueue(), &source,
|
|
259
|
+
&destination,
|
|
260
|
+
&extent3D);
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
void GPUQueueImpl::Submit(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
266
|
+
auto *ptr = GetPointer(args.This());
|
|
267
|
+
if (ptr == nullptr) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
auto isolate = args.GetIsolate();
|
|
272
|
+
auto context = isolate->GetCurrentContext();
|
|
273
|
+
|
|
274
|
+
std::vector<const CanvasGPUCommandBuffer *> commandBuffers;
|
|
275
|
+
auto commandBuffersVal = args[0];
|
|
276
|
+
|
|
277
|
+
if (commandBuffersVal->IsArray()) {
|
|
278
|
+
auto commandBuffersArray = commandBuffersVal.As<v8::Array>();
|
|
279
|
+
auto len = commandBuffersArray->Length();
|
|
280
|
+
|
|
281
|
+
for (int i = 0; i < len; i++) {
|
|
282
|
+
v8::Local<v8::Value> item;
|
|
283
|
+
commandBuffersArray->Get(context, i).ToLocal(&item);
|
|
284
|
+
auto type = GetNativeType(item);
|
|
285
|
+
if (type == NativeType::GPUCommandBuffer) {
|
|
286
|
+
auto buffer = GPUCommandBufferImpl::GetPointer(item.As<v8::Object>());
|
|
287
|
+
if (buffer != nullptr) {
|
|
288
|
+
commandBuffers.push_back(buffer->GetGPUCommandBuffer());
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
canvas_native_webgpu_queue_submit(ptr->GetGPUQueue(), commandBuffers.data(),
|
|
295
|
+
commandBuffers.size());
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
void GPUQueueImpl::SubmitWorkDone(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
303
|
+
auto *ptr = GetPointer(args.This());
|
|
304
|
+
if (ptr == nullptr) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
auto isolate = args.GetIsolate();
|
|
309
|
+
|
|
310
|
+
auto cb = args[0];
|
|
311
|
+
auto callback = new JSICallback(isolate, cb.As<v8::Function>());
|
|
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);
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
callback->Call(context,
|
|
331
|
+
context->Global(),
|
|
332
|
+
0, nullptr);
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
delete static_cast<JSICallback *>(data);
|
|
336
|
+
},
|
|
337
|
+
callback);
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
void GPUQueueImpl::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
343
|
+
auto *ptr = GetPointer(args.This());
|
|
344
|
+
if (ptr == nullptr) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
auto isolate = args.GetIsolate();
|
|
349
|
+
auto context = isolate->GetCurrentContext();
|
|
350
|
+
|
|
351
|
+
auto bufferValue = args[0];
|
|
352
|
+
|
|
353
|
+
if (bufferValue->IsObject()) {
|
|
354
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferValue.As<v8::Object>());
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
auto bufferOffset = (uint64_t) args[1].As<v8::Number>()->Value();
|
|
358
|
+
|
|
359
|
+
auto dataValue = args[2].As<v8::TypedArray>();
|
|
360
|
+
|
|
361
|
+
auto offset = dataValue->ByteOffset();
|
|
362
|
+
|
|
363
|
+
auto store = dataValue->Buffer()->GetBackingStore();
|
|
364
|
+
|
|
365
|
+
auto data = static_cast<uint8_t *>(store->Data()) + offset;
|
|
366
|
+
|
|
367
|
+
auto data_size = store->ByteLength();
|
|
368
|
+
|
|
369
|
+
auto dataOffset = (uint64_t) args[3].As<v8::Number>()->Value();
|
|
370
|
+
|
|
371
|
+
int64_t size = -1;
|
|
372
|
+
auto sizeValue = args[4];
|
|
373
|
+
|
|
374
|
+
if (sizeValue->IsNumber()) {
|
|
375
|
+
size = (int64_t) sizeValue->ToNumber(context).ToLocalChecked()->Value();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
if (buffer != nullptr) {
|
|
380
|
+
canvas_native_webgpu_queue_write_buffer(ptr->GetGPUQueue(), buffer->GetGPUBuffer(),
|
|
381
|
+
bufferOffset, data, data_size, dataOffset,
|
|
382
|
+
size);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
void GPUQueueImpl::WriteTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
390
|
+
auto *ptr = GetPointer(args.This());
|
|
391
|
+
if (ptr == nullptr) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
auto isolate = args.GetIsolate();
|
|
396
|
+
auto context = isolate->GetCurrentContext();
|
|
397
|
+
|
|
398
|
+
bool flipY = false;
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
auto destinationVal = args[0];
|
|
402
|
+
auto dataVal = args[1];
|
|
403
|
+
auto dataLayoutVal = args[2];
|
|
404
|
+
auto sizeVal = args[3];
|
|
405
|
+
|
|
406
|
+
if (destinationVal->IsObject() && dataVal->IsObject() && dataLayoutVal->IsObject() &&
|
|
407
|
+
sizeVal->IsObject()) {
|
|
408
|
+
auto destinationObj = destinationVal.As<v8::Object>();
|
|
409
|
+
|
|
410
|
+
auto textureVal = destinationObj->Get(context, ConvertToV8String(isolate,
|
|
411
|
+
"texture")).ToLocalChecked();
|
|
412
|
+
auto texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
|
|
413
|
+
|
|
414
|
+
uint32_t mipLevel = 0;
|
|
415
|
+
CanvasOrigin3d origin{0, 0, 0};
|
|
416
|
+
CanvasTextureAspect aspect = CanvasTextureAspectAll;
|
|
417
|
+
|
|
418
|
+
v8::Local<v8::Value> mipLevelVal;
|
|
419
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(
|
|
420
|
+
&mipLevelVal) &&
|
|
421
|
+
mipLevelVal->IsUint32()) {
|
|
422
|
+
mipLevel = mipLevelVal->Uint32Value(context).FromJust();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
v8::Local<v8::Value> originVal;
|
|
427
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(
|
|
428
|
+
&originVal) &&
|
|
429
|
+
originVal->IsObject()) {
|
|
430
|
+
auto originObj = originVal.As<v8::Object>();
|
|
431
|
+
|
|
432
|
+
v8::Local<v8::Value> xVal;
|
|
433
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal) &&
|
|
434
|
+
xVal->IsUint32()) {
|
|
435
|
+
origin.x = xVal->Uint32Value(context).FromJust();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
v8::Local<v8::Value> yVal;
|
|
439
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal) &&
|
|
440
|
+
yVal->IsUint32()) {
|
|
441
|
+
origin.y = yVal->Uint32Value(context).FromJust();
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
v8::Local<v8::Value> zVal;
|
|
445
|
+
if (originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal) &&
|
|
446
|
+
zVal->IsUint32()) {
|
|
447
|
+
origin.z = zVal->Uint32Value(context).FromJust();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
v8::Local<v8::Value> aspectVal;
|
|
454
|
+
if (destinationObj->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(
|
|
455
|
+
&aspectVal)) {
|
|
456
|
+
if (aspectVal->IsString()) {
|
|
457
|
+
auto aspectStr = ConvertFromV8String(isolate, aspectVal);
|
|
458
|
+
if (aspectStr == "depth-only") {
|
|
459
|
+
aspect = CanvasTextureAspectDepthOnly;
|
|
460
|
+
} else if (aspectStr == "stencil-only") {
|
|
461
|
+
aspect = CanvasTextureAspectStencilOnly;
|
|
462
|
+
} else if (aspectStr == "all") {
|
|
463
|
+
aspect = CanvasTextureAspectAll;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
CanvasImageCopyTexture destination{
|
|
469
|
+
texture,
|
|
470
|
+
mipLevel,
|
|
471
|
+
origin,
|
|
472
|
+
aspect
|
|
473
|
+
};
|
|
474
|
+
auto array = dataVal.As<v8::TypedArray>();
|
|
475
|
+
auto ab = array->Buffer();
|
|
476
|
+
auto offset = array->ByteOffset();
|
|
477
|
+
auto store = ab->GetBackingStore();
|
|
478
|
+
auto data = static_cast<const uint8_t *>(store->Data()) + offset;
|
|
479
|
+
auto size = array->ByteLength();
|
|
480
|
+
|
|
481
|
+
auto dataLayoutObj = dataLayoutVal.As<v8::Object>();
|
|
482
|
+
|
|
483
|
+
CanvasImageDataLayout layout{
|
|
484
|
+
0, -1, -1
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
v8::Local<v8::Value> offsetVal;
|
|
488
|
+
if (dataLayoutObj->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal) &&
|
|
489
|
+
offsetVal->IsNumber()) {
|
|
490
|
+
layout.offset = (uint64_t) offsetVal->NumberValue(context).FromJust();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
v8::Local<v8::Value> bytesPerRowVal;
|
|
495
|
+
if (dataLayoutObj->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(
|
|
496
|
+
&bytesPerRowVal) &&
|
|
497
|
+
bytesPerRowVal->IsInt32()) {
|
|
498
|
+
layout.bytes_per_row = bytesPerRowVal->Int32Value(context).FromJust();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
v8::Local<v8::Value> rowsPerImageVal;
|
|
503
|
+
if (dataLayoutObj->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(
|
|
504
|
+
&rowsPerImageVal) &&
|
|
505
|
+
rowsPerImageVal->IsInt32()) {
|
|
506
|
+
layout.rows_per_image = rowsPerImageVal->Int32Value(context).FromJust();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
|
|
511
|
+
|
|
512
|
+
canvas_native_webgpu_queue_write_texture(ptr->GetGPUQueue(), &destination, &layout,
|
|
513
|
+
&extent3D, data, size);
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 18/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUQUEUEIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUQUEUEIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
#include "GPUUtils.h"
|
|
12
|
+
|
|
13
|
+
class GPUQueueImpl : ObjectWrapperImpl {
|
|
14
|
+
public:
|
|
15
|
+
explicit GPUQueueImpl(const CanvasGPUQueue *queue);
|
|
16
|
+
|
|
17
|
+
~GPUQueueImpl() {
|
|
18
|
+
canvas_native_webgpu_queue_release(this->GetGPUQueue());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const CanvasGPUQueue *GetGPUQueue();
|
|
22
|
+
|
|
23
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
24
|
+
|
|
25
|
+
static GPUQueueImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
26
|
+
|
|
27
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
28
|
+
|
|
29
|
+
static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUQueueImpl *queue) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUQueueImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(object, NativeType::GPUQueue);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, queue);
|
|
36
|
+
queue->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
41
|
+
|
|
42
|
+
static void Submit(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
43
|
+
|
|
44
|
+
static void SubmitWorkDone(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
45
|
+
|
|
46
|
+
static void WriteBuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
47
|
+
|
|
48
|
+
static void WriteTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
const CanvasGPUQueue *queue_;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
#endif //CANVAS_ANDROID_GPUQUEUEIMPL_H
|