@nativescript/canvas 2.0.0-beta.9 → 2.0.0-webgpu.1
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 +24 -17
- package/Canvas/common.js +133 -66
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +5 -7
- package/Canvas/index.android.js +62 -133
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +4 -1
- package/Canvas/index.ios.d.ts +4 -5
- package/Canvas/index.ios.js +73 -82
- 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 +86 -32
- 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 +35 -0
- package/WebGPU/GPUCanvasContext.js +76 -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 +110 -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 +356 -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 +17 -0
- package/WebGPU/GPUTexture.js +44 -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/common.d.ts +0 -3
- package/common.js +1 -5
- package/common.js.map +1 -1
- 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/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 +23 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +41 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2318 -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 +1563 -3729
- 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 -663
- 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 +41 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2318 -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 +1563 -3729
- 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 +1563 -3729
- 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 -662
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -641
- 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 +1222 -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 +2750 -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 +623 -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 +245 -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,302 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUAdapterImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
|
|
8
|
+
GPUAdapterImpl::GPUAdapterImpl(const CanvasGPUAdapter *adapter) : adapter_(adapter) {}
|
|
9
|
+
|
|
10
|
+
const CanvasGPUAdapter *GPUAdapterImpl::GetGPUAdapter() {
|
|
11
|
+
return this->adapter_;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
void GPUAdapterImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
16
|
+
v8::Locker locker(isolate);
|
|
17
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
18
|
+
v8::HandleScope handle_scope(isolate);
|
|
19
|
+
|
|
20
|
+
auto ctor = GetCtor(isolate);
|
|
21
|
+
auto context = isolate->GetCurrentContext();
|
|
22
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
23
|
+
|
|
24
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUAdapter"), func).FromJust();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
GPUAdapterImpl *GPUAdapterImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
28
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
29
|
+
if (ptr == nullptr) {
|
|
30
|
+
return nullptr;
|
|
31
|
+
}
|
|
32
|
+
return static_cast<GPUAdapterImpl *>(ptr);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
v8::Local<v8::FunctionTemplate> GPUAdapterImpl::GetCtor(v8::Isolate *isolate) {
|
|
36
|
+
auto cache = Caches::Get(isolate);
|
|
37
|
+
auto ctor = cache->GPUAdapterTmpl.get();
|
|
38
|
+
if (ctor != nullptr) {
|
|
39
|
+
return ctor->Get(isolate);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
43
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
44
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUAdapter"));
|
|
45
|
+
|
|
46
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
47
|
+
tmpl->SetInternalFieldCount(2);
|
|
48
|
+
|
|
49
|
+
tmpl->SetLazyDataProperty(
|
|
50
|
+
ConvertToV8String(isolate, "features"),
|
|
51
|
+
GetFeatures
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
tmpl->SetLazyDataProperty(
|
|
55
|
+
ConvertToV8String(isolate, "isFallbackAdapter"),
|
|
56
|
+
GetIsFallbackAdapter
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
tmpl->SetLazyDataProperty(
|
|
60
|
+
ConvertToV8String(isolate, "limits"),
|
|
61
|
+
GetLimits
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
tmpl->Set(
|
|
66
|
+
ConvertToV8String(isolate, "requestAdapterInfo"),
|
|
67
|
+
v8::FunctionTemplate::New(isolate, &RequestAdapterInfo));
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
tmpl->Set(
|
|
71
|
+
ConvertToV8String(isolate, "requestDevice"),
|
|
72
|
+
v8::FunctionTemplate::New(isolate, &RequestDevice));
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
cache->GPUAdapterTmpl =
|
|
76
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
77
|
+
return ctorTmpl;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
void
|
|
82
|
+
GPUAdapterImpl::GetFeatures(v8::Local<v8::Name> name,
|
|
83
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
84
|
+
auto ptr = GetPointer(info.This());
|
|
85
|
+
auto isolate = info.GetIsolate();
|
|
86
|
+
if (ptr != nullptr) {
|
|
87
|
+
auto context = isolate->GetCurrentContext();
|
|
88
|
+
|
|
89
|
+
auto features = canvas_native_webgpu_adapter_get_features(ptr->GetGPUAdapter());
|
|
90
|
+
|
|
91
|
+
auto len = canvas_native_string_buffer_get_length(features);
|
|
92
|
+
|
|
93
|
+
auto map = v8::Map::New(isolate);
|
|
94
|
+
for (int i = 0; i < len; ++i) {
|
|
95
|
+
auto item = canvas_native_string_buffer_get_value_at(features, i);
|
|
96
|
+
if (item != nullptr) {
|
|
97
|
+
auto keyValue = ConvertToV8OneByteString(isolate, (char *) item);
|
|
98
|
+
map->Set(context, keyValue, keyValue);
|
|
99
|
+
canvas_native_string_destroy(item);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
canvas_native_string_buffer_destroy(features);
|
|
104
|
+
|
|
105
|
+
info.GetReturnValue().Set(map);
|
|
106
|
+
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
info.GetReturnValue().Set(v8::Map::New(info.GetIsolate()));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void
|
|
114
|
+
GPUAdapterImpl::GetIsFallbackAdapter(v8::Local<v8::Name> name,
|
|
115
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
116
|
+
auto ptr = GetPointer(info.This());
|
|
117
|
+
if (ptr != nullptr) {
|
|
118
|
+
info.GetReturnValue().Set(
|
|
119
|
+
canvas_native_webgpu_adapter_is_fallback_adapter(ptr->GetGPUAdapter())
|
|
120
|
+
);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
info.GetReturnValue().Set(false);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
void
|
|
127
|
+
GPUAdapterImpl::GetLimits(v8::Local<v8::Name> name,
|
|
128
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
129
|
+
auto ptr = GetPointer(info.This());
|
|
130
|
+
if (ptr != nullptr) {
|
|
131
|
+
auto limits = canvas_native_webgpu_adapter_get_limits(ptr->GetGPUAdapter());
|
|
132
|
+
auto ret = GPUSupportedLimitsImpl::NewInstance(info.GetIsolate(),
|
|
133
|
+
new GPUSupportedLimitsImpl(limits));
|
|
134
|
+
info.GetReturnValue().Set(ret);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
info.GetReturnValue().SetUndefined();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
void GPUAdapterImpl::RequestAdapterInfo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
142
|
+
GPUAdapterImpl *ptr = GetPointer(args.This());
|
|
143
|
+
if (ptr == nullptr) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
auto isolate = args.GetIsolate();
|
|
148
|
+
|
|
149
|
+
auto info = canvas_native_webgpu_adapter_request_adapter_info(ptr->GetGPUAdapter());
|
|
150
|
+
|
|
151
|
+
if (info != nullptr) {
|
|
152
|
+
auto value = new GPUAdapterInfoImpl(info);
|
|
153
|
+
auto ret = GPUAdapterInfoImpl::NewInstance(isolate, value);
|
|
154
|
+
args.GetReturnValue().Set(ret);
|
|
155
|
+
} else {
|
|
156
|
+
args.GetReturnValue().SetUndefined();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
162
|
+
GPUAdapterImpl *ptr = GetPointer(args.This());
|
|
163
|
+
auto isolate = args.GetIsolate();
|
|
164
|
+
auto context = isolate->GetCurrentContext();
|
|
165
|
+
auto optionsValue = args[0];
|
|
166
|
+
auto cb = args[1];
|
|
167
|
+
if (ptr == nullptr) {
|
|
168
|
+
// todo error
|
|
169
|
+
cb.As<v8::Function>()->Call(context, context->Global(), 0, nullptr);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
v8::Global<v8::Function> func(isolate, cb.As<v8::Function>());
|
|
174
|
+
|
|
175
|
+
std::string label;
|
|
176
|
+
|
|
177
|
+
std::vector<std::string> required_features_buf;
|
|
178
|
+
|
|
179
|
+
CanvasGPUSupportedLimits *limits = nullptr;
|
|
180
|
+
|
|
181
|
+
if (!optionsValue.IsEmpty() && optionsValue->IsObject()) {
|
|
182
|
+
auto options = optionsValue.As<v8::Object>();
|
|
183
|
+
v8::Local<v8::Value> labelValue;
|
|
184
|
+
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(
|
|
185
|
+
&labelValue);
|
|
186
|
+
|
|
187
|
+
if (!labelValue.IsEmpty() && labelValue->IsString()) {
|
|
188
|
+
label = ConvertFromV8String(isolate, labelValue);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
v8::Local<v8::Value> requiredFeaturesValue;
|
|
192
|
+
|
|
193
|
+
options->Get(context, ConvertToV8String(isolate, "requiredFeatures")).ToLocal(
|
|
194
|
+
&requiredFeaturesValue);
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
if (!requiredFeaturesValue.IsEmpty() && requiredFeaturesValue->IsSet()) {
|
|
198
|
+
v8::Local<v8::Set> requiredFeaturesSet = requiredFeaturesValue.As<v8::Set>();
|
|
199
|
+
v8::Local<v8::Array> requiredFeatures = requiredFeaturesSet->AsArray();
|
|
200
|
+
auto len = requiredFeatures->Length();
|
|
201
|
+
|
|
202
|
+
for (int i = 0; i < len; i++) {
|
|
203
|
+
auto item = requiredFeatures->Get(context, i);
|
|
204
|
+
if (!item.IsEmpty()) {
|
|
205
|
+
auto value = item.ToLocalChecked();
|
|
206
|
+
if (value->IsString()) {
|
|
207
|
+
required_features_buf.push_back(ConvertFromV8String(isolate, value));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
v8::Local<v8::Value> limitsValue;
|
|
215
|
+
|
|
216
|
+
options->Get(context, ConvertToV8String(isolate, "requiredLimits")).ToLocal(
|
|
217
|
+
&limitsValue);
|
|
218
|
+
|
|
219
|
+
if (!limitsValue.IsEmpty() && limitsValue->IsObject()) {
|
|
220
|
+
auto limits_ptr = GPUSupportedLimitsImpl::GetPointer(limitsValue.As<v8::Object>());
|
|
221
|
+
if (limits_ptr != nullptr) {
|
|
222
|
+
limits = limits_ptr->GetLimits();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
char **required_features_data = nullptr;
|
|
228
|
+
size_t required_features_data_length = required_features_buf.size();
|
|
229
|
+
|
|
230
|
+
if (required_features_data_length > 0) {
|
|
231
|
+
required_features_data = new char *[required_features_data_length + 1];
|
|
232
|
+
|
|
233
|
+
for (size_t i = 0; i < required_features_data_length; ++i) {
|
|
234
|
+
std::strcpy(required_features_data[i], required_features_buf[i].c_str());
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
auto callback = new AsyncCallback{
|
|
240
|
+
isolate,
|
|
241
|
+
std::move(func),
|
|
242
|
+
static_cast<void *>(required_features_data)
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
canvas_native_webgpu_adapter_request_device(ptr->GetGPUAdapter(),
|
|
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 {
|
|
280
|
+
|
|
281
|
+
auto impl = new GPUDeviceImpl(device);
|
|
282
|
+
auto ret = GPUDeviceImpl::NewInstance(
|
|
283
|
+
isolate, impl);
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
v8::Local<v8::Value> args[2] = {
|
|
287
|
+
v8::Null(isolate), ret};
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
callback->Call(context, context->Global(),
|
|
291
|
+
2,
|
|
292
|
+
args); // ignore JS return value
|
|
293
|
+
|
|
294
|
+
delete static_cast<AsyncCallback *>(data);
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, callback);
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUADAPTERIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUADAPTERIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
#include "GPUSupportedLimitsImpl.h"
|
|
12
|
+
#include "GPUDeviceImpl.h"
|
|
13
|
+
#include "GPUAdapterInfoImpl.h"
|
|
14
|
+
|
|
15
|
+
class GPUAdapterImpl : ObjectWrapperImpl {
|
|
16
|
+
public:
|
|
17
|
+
explicit GPUAdapterImpl(const CanvasGPUAdapter *adapter);
|
|
18
|
+
|
|
19
|
+
~GPUAdapterImpl() {
|
|
20
|
+
canvas_native_webgpu_adapter_release(this->GetGPUAdapter());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CanvasGPUAdapter *GetGPUAdapter();
|
|
24
|
+
|
|
25
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
26
|
+
|
|
27
|
+
static GPUAdapterImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
28
|
+
|
|
29
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
30
|
+
|
|
31
|
+
static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUAdapterImpl *adapter) {
|
|
32
|
+
auto context = isolate->GetCurrentContext();
|
|
33
|
+
v8::EscapableHandleScope scope(isolate);
|
|
34
|
+
auto object = GPUAdapterImpl::GetCtor(isolate)->GetFunction(
|
|
35
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
36
|
+
SetNativeType(object, NativeType::GPUAdapter);
|
|
37
|
+
object->SetAlignedPointerInInternalField(0, adapter);
|
|
38
|
+
adapter->BindFinalizer(isolate, object);
|
|
39
|
+
return scope.Escape(object);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static void GetFeatures(v8::Local<v8::Name> name,
|
|
43
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
static void GetIsFallbackAdapter(v8::Local<v8::Name> name,
|
|
47
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
48
|
+
|
|
49
|
+
static void GetLimits(v8::Local<v8::Name> name,
|
|
50
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
static void RequestAdapterInfo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
54
|
+
|
|
55
|
+
static void RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
const CanvasGPUAdapter *adapter_;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
#endif //CANVAS_ANDROID_GPUADAPTERIMPL_H
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUAdapterInfoImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
|
|
8
|
+
GPUAdapterInfoImpl::GPUAdapterInfoImpl(const CanvasGPUAdapterInfo *info) : info_(info) {}
|
|
9
|
+
|
|
10
|
+
const CanvasGPUAdapterInfo *GPUAdapterInfoImpl::GetInfo() {
|
|
11
|
+
return this->info_;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
void GPUAdapterInfoImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
16
|
+
v8::Locker locker(isolate);
|
|
17
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
18
|
+
v8::HandleScope handle_scope(isolate);
|
|
19
|
+
|
|
20
|
+
auto ctor = GetCtor(isolate);
|
|
21
|
+
auto context = isolate->GetCurrentContext();
|
|
22
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
23
|
+
|
|
24
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUAdapterInfo"), func).FromJust();;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
GPUAdapterInfoImpl *GPUAdapterInfoImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
28
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
29
|
+
if (ptr == nullptr) {
|
|
30
|
+
return nullptr;
|
|
31
|
+
}
|
|
32
|
+
return static_cast<GPUAdapterInfoImpl *>(ptr);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
v8::Local<v8::FunctionTemplate> GPUAdapterInfoImpl::GetCtor(v8::Isolate *isolate) {
|
|
36
|
+
auto cache = Caches::Get(isolate);
|
|
37
|
+
auto ctor = cache->GPUAdapterInfoTmpl.get();
|
|
38
|
+
if (ctor != nullptr) {
|
|
39
|
+
return ctor->Get(isolate);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
43
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
44
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUAdapterInfo"));
|
|
45
|
+
|
|
46
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
47
|
+
tmpl->SetInternalFieldCount(2);
|
|
48
|
+
|
|
49
|
+
tmpl->SetLazyDataProperty(
|
|
50
|
+
ConvertToV8String(isolate, "architecture"),
|
|
51
|
+
GetArchitecture
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
tmpl->SetLazyDataProperty(
|
|
55
|
+
ConvertToV8String(isolate, "description"),
|
|
56
|
+
GetDescription
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
tmpl->SetLazyDataProperty(
|
|
60
|
+
ConvertToV8String(isolate, "device"),
|
|
61
|
+
GetDevice
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
tmpl->SetLazyDataProperty(
|
|
65
|
+
ConvertToV8String(isolate, "vendor"),
|
|
66
|
+
GetVendor
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
cache->GPUAdapterInfoTmpl =
|
|
71
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
72
|
+
return ctorTmpl;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
void
|
|
77
|
+
GPUAdapterInfoImpl::GetArchitecture(v8::Local<v8::Name> name,
|
|
78
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
79
|
+
auto ptr = GetPointer(info.This());
|
|
80
|
+
|
|
81
|
+
if (ptr == nullptr) {
|
|
82
|
+
info.GetReturnValue().SetEmptyString();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
auto architecture = canvas_native_webgpu_adapter_info_architecture(ptr->GetInfo());
|
|
87
|
+
|
|
88
|
+
if (architecture == nullptr) {
|
|
89
|
+
info.GetReturnValue().SetEmptyString();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
auto ret = ConvertToV8String(info.GetIsolate(), architecture);
|
|
94
|
+
|
|
95
|
+
canvas_native_string_destroy(architecture);
|
|
96
|
+
|
|
97
|
+
info.GetReturnValue().Set(ret);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
void
|
|
102
|
+
GPUAdapterInfoImpl::GetDescription(v8::Local<v8::Name> name,
|
|
103
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
104
|
+
auto ptr = GetPointer(info.This());
|
|
105
|
+
|
|
106
|
+
if (ptr == nullptr) {
|
|
107
|
+
info.GetReturnValue().SetEmptyString();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
auto description = canvas_native_webgpu_adapter_info_description(ptr->GetInfo());
|
|
112
|
+
|
|
113
|
+
if (description == nullptr) {
|
|
114
|
+
info.GetReturnValue().SetEmptyString();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
auto ret = ConvertToV8String(info.GetIsolate(), description);
|
|
119
|
+
|
|
120
|
+
canvas_native_string_destroy(description);
|
|
121
|
+
|
|
122
|
+
info.GetReturnValue().Set(ret);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
void
|
|
127
|
+
GPUAdapterInfoImpl::GetDevice(v8::Local<v8::Name> name,
|
|
128
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
129
|
+
auto ptr = GetPointer(info.This());
|
|
130
|
+
|
|
131
|
+
if (ptr == nullptr) {
|
|
132
|
+
info.GetReturnValue().SetEmptyString();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
auto device = canvas_native_webgpu_adapter_info_device(ptr->GetInfo());
|
|
137
|
+
|
|
138
|
+
if (device == nullptr) {
|
|
139
|
+
info.GetReturnValue().SetEmptyString();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
auto ret = ConvertToV8String(info.GetIsolate(), device);
|
|
144
|
+
|
|
145
|
+
canvas_native_string_destroy(device);
|
|
146
|
+
|
|
147
|
+
info.GetReturnValue().Set(ret);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
void
|
|
152
|
+
GPUAdapterInfoImpl::GetVendor(v8::Local<v8::Name> name,
|
|
153
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
154
|
+
auto ptr = GetPointer(info.This());
|
|
155
|
+
|
|
156
|
+
if (ptr == nullptr) {
|
|
157
|
+
info.GetReturnValue().SetEmptyString();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
auto vendor = canvas_native_webgpu_adapter_info_vendor(ptr->GetInfo());
|
|
162
|
+
|
|
163
|
+
if (vendor == nullptr) {
|
|
164
|
+
info.GetReturnValue().SetEmptyString();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
auto ret = ConvertToV8String(info.GetIsolate(), vendor);
|
|
169
|
+
|
|
170
|
+
canvas_native_string_destroy(vendor);
|
|
171
|
+
|
|
172
|
+
info.GetReturnValue().Set(ret);
|
|
173
|
+
}
|
|
174
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUADAPTERINFOIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUADAPTERINFOIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
|
|
12
|
+
class GPUAdapterInfoImpl : ObjectWrapperImpl {
|
|
13
|
+
public:
|
|
14
|
+
explicit GPUAdapterInfoImpl(const CanvasGPUAdapterInfo *info);
|
|
15
|
+
|
|
16
|
+
~GPUAdapterInfoImpl() {
|
|
17
|
+
canvas_native_webgpu_adapter_info_release(this->GetInfo());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CanvasGPUAdapterInfo *GetInfo();
|
|
21
|
+
|
|
22
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
23
|
+
|
|
24
|
+
static GPUAdapterInfoImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
25
|
+
|
|
26
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
27
|
+
|
|
28
|
+
static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUAdapterInfoImpl *info) {
|
|
29
|
+
auto context = isolate->GetCurrentContext();
|
|
30
|
+
v8::EscapableHandleScope scope(isolate);
|
|
31
|
+
auto object = GPUAdapterInfoImpl::GetCtor(isolate)->GetFunction(
|
|
32
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
33
|
+
SetNativeType(object, NativeType::GPUAdapterInfo);
|
|
34
|
+
object->SetAlignedPointerInInternalField(0, info);
|
|
35
|
+
info->BindFinalizer(isolate, object);
|
|
36
|
+
return scope.Escape(object);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static void GetArchitecture(v8::Local<v8::Name> name,
|
|
40
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
static void GetDescription(v8::Local<v8::Name> name,
|
|
44
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
45
|
+
|
|
46
|
+
static void GetDevice(v8::Local<v8::Name> name,
|
|
47
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
48
|
+
|
|
49
|
+
static void GetVendor(v8::Local<v8::Name> name,
|
|
50
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
private:
|
|
54
|
+
const CanvasGPUAdapterInfo *info_;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
#endif //CANVAS_ANDROID_GPUADAPTERINFOIMPL_H
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/07/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUBindGroupImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
|
|
8
|
+
GPUBindGroupImpl::GPUBindGroupImpl(const CanvasGPUBindGroup *groupLayout)
|
|
9
|
+
: group_(groupLayout) {}
|
|
10
|
+
|
|
11
|
+
const CanvasGPUBindGroup *GPUBindGroupImpl::GetBindGroup() {
|
|
12
|
+
return this->group_;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
void GPUBindGroupImpl::Init(v8::Local <v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
17
|
+
v8::Locker locker(isolate);
|
|
18
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
19
|
+
v8::HandleScope handle_scope(isolate);
|
|
20
|
+
|
|
21
|
+
auto ctor = GetCtor(isolate);
|
|
22
|
+
auto context = isolate->GetCurrentContext();
|
|
23
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
24
|
+
|
|
25
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroup"), func).FromJust();;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local <v8::Object> &object) {
|
|
29
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
30
|
+
if (ptr == nullptr) {
|
|
31
|
+
return nullptr;
|
|
32
|
+
}
|
|
33
|
+
return static_cast<GPUBindGroupImpl *>(ptr);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
v8::Local <v8::FunctionTemplate> GPUBindGroupImpl::GetCtor(v8::Isolate *isolate) {
|
|
37
|
+
auto cache = Caches::Get(isolate);
|
|
38
|
+
auto ctor = cache->GPUBindGroupTmpl.get();
|
|
39
|
+
if (ctor != nullptr) {
|
|
40
|
+
return ctor->Get(isolate);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
v8::Local <v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
44
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
45
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUBindGroup"));
|
|
46
|
+
|
|
47
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
48
|
+
tmpl->SetInternalFieldCount(2);
|
|
49
|
+
|
|
50
|
+
cache->GPUBindGroupTmpl =
|
|
51
|
+
std::make_unique < v8::Persistent < v8::FunctionTemplate >> (isolate, ctorTmpl);
|
|
52
|
+
return ctorTmpl;
|
|
53
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 17/07/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUBINDGROUPIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUBINDGROUPIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
|
|
12
|
+
class GPUBindGroupImpl : ObjectWrapperImpl {
|
|
13
|
+
public:
|
|
14
|
+
GPUBindGroupImpl(const CanvasGPUBindGroup *group);
|
|
15
|
+
|
|
16
|
+
~GPUBindGroupImpl() {
|
|
17
|
+
canvas_native_webgpu_bind_group_release(this->GetBindGroup());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CanvasGPUBindGroup *GetBindGroup();
|
|
21
|
+
|
|
22
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
23
|
+
|
|
24
|
+
static GPUBindGroupImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
25
|
+
|
|
26
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
27
|
+
|
|
28
|
+
static v8::Local<v8::Object>
|
|
29
|
+
NewInstance(v8::Isolate *isolate, GPUBindGroupImpl *groupLayout) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUBindGroupImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(object, NativeType::GPUBindGroup);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, groupLayout);
|
|
36
|
+
groupLayout->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private:
|
|
41
|
+
const CanvasGPUBindGroup *group_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
#endif //CANVAS_ANDROID_GPUBINDGROUPIMPL_H
|