@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,1087 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 23/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUCommandEncoderImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "GPUComputePassEncoderImpl.h"
|
|
8
|
+
#include "GPUQuerySetImpl.h"
|
|
9
|
+
#include "GPUBufferImpl.h"
|
|
10
|
+
#include "GPUTextureViewImpl.h"
|
|
11
|
+
#include "GPURenderPassEncoderImpl.h"
|
|
12
|
+
#include "GPUCommandBufferImpl.h"
|
|
13
|
+
#include "GPUTextureImpl.h"
|
|
14
|
+
|
|
15
|
+
GPUCommandEncoderImpl::GPUCommandEncoderImpl(const CanvasGPUCommandEncoder *encoder) : encoder_(
|
|
16
|
+
encoder) {}
|
|
17
|
+
|
|
18
|
+
const CanvasGPUCommandEncoder *GPUCommandEncoderImpl::GetEncoder() {
|
|
19
|
+
return this->encoder_;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void GPUCommandEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
23
|
+
v8::Locker locker(isolate);
|
|
24
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
25
|
+
v8::HandleScope handle_scope(isolate);
|
|
26
|
+
|
|
27
|
+
auto ctor = GetCtor(isolate);
|
|
28
|
+
auto context = isolate->GetCurrentContext();
|
|
29
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
30
|
+
|
|
31
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandEncoder"), func).FromJust();;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
GPUCommandEncoderImpl *GPUCommandEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
35
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
36
|
+
if (ptr == nullptr) {
|
|
37
|
+
return nullptr;
|
|
38
|
+
}
|
|
39
|
+
return static_cast<GPUCommandEncoderImpl *>(ptr);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
v8::Local<v8::FunctionTemplate> GPUCommandEncoderImpl::GetCtor(v8::Isolate *isolate) {
|
|
43
|
+
auto cache = Caches::Get(isolate);
|
|
44
|
+
auto ctor = cache->GPUCommandEncoderTmpl.get();
|
|
45
|
+
if (ctor != nullptr) {
|
|
46
|
+
return ctor->Get(isolate);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
50
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
51
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCommandEncoder"));
|
|
52
|
+
|
|
53
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
54
|
+
tmpl->SetInternalFieldCount(2);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
tmpl->Set(
|
|
58
|
+
ConvertToV8String(isolate, "beginComputePass"),
|
|
59
|
+
v8::FunctionTemplate::New(isolate, &BeginComputePass));
|
|
60
|
+
|
|
61
|
+
tmpl->Set(
|
|
62
|
+
ConvertToV8String(isolate, "beginRenderPass"),
|
|
63
|
+
v8::FunctionTemplate::New(isolate, &BeginRenderPass));
|
|
64
|
+
|
|
65
|
+
tmpl->Set(
|
|
66
|
+
ConvertToV8String(isolate, "clearBuffer"),
|
|
67
|
+
v8::FunctionTemplate::New(isolate, &ClearBuffer));
|
|
68
|
+
|
|
69
|
+
tmpl->Set(
|
|
70
|
+
ConvertToV8String(isolate, "copyBufferToBuffer"),
|
|
71
|
+
v8::FunctionTemplate::New(isolate, &CopyBufferToBuffer));
|
|
72
|
+
|
|
73
|
+
tmpl->Set(
|
|
74
|
+
ConvertToV8String(isolate, "copyBufferToTexture"),
|
|
75
|
+
v8::FunctionTemplate::New(isolate, &CopyBufferToTexture));
|
|
76
|
+
|
|
77
|
+
tmpl->Set(
|
|
78
|
+
ConvertToV8String(isolate, "copyTextureToBuffer"),
|
|
79
|
+
v8::FunctionTemplate::New(isolate, &CopyTextureToBuffer));
|
|
80
|
+
|
|
81
|
+
tmpl->Set(
|
|
82
|
+
ConvertToV8String(isolate, "copyTextureToTexture"),
|
|
83
|
+
v8::FunctionTemplate::New(isolate, &CopyTextureToTexture));
|
|
84
|
+
|
|
85
|
+
tmpl->Set(
|
|
86
|
+
ConvertToV8String(isolate, "finish"),
|
|
87
|
+
v8::FunctionTemplate::New(isolate, &Finish));
|
|
88
|
+
|
|
89
|
+
tmpl->Set(
|
|
90
|
+
ConvertToV8String(isolate, "insertDebugMarker"),
|
|
91
|
+
v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
|
|
92
|
+
|
|
93
|
+
tmpl->Set(
|
|
94
|
+
ConvertToV8String(isolate, "popDebugGroup"),
|
|
95
|
+
v8::FunctionTemplate::New(isolate, &PopDebugGroup));
|
|
96
|
+
|
|
97
|
+
tmpl->Set(
|
|
98
|
+
ConvertToV8String(isolate, "pushDebugGroup"),
|
|
99
|
+
v8::FunctionTemplate::New(isolate, &PushDebugGroup));
|
|
100
|
+
|
|
101
|
+
tmpl->Set(
|
|
102
|
+
ConvertToV8String(isolate, "resolveQuerySet"),
|
|
103
|
+
v8::FunctionTemplate::New(isolate, &ResolveQuerySet));
|
|
104
|
+
|
|
105
|
+
tmpl->Set(
|
|
106
|
+
ConvertToV8String(isolate, "writeTimestamp"),
|
|
107
|
+
v8::FunctionTemplate::New(isolate, &WriteTimestamp));
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
cache->GPUCommandEncoderTmpl =
|
|
111
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
112
|
+
return ctorTmpl;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
void GPUCommandEncoderImpl::BeginComputePass(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
117
|
+
auto ptr = GetPointer(args.This());
|
|
118
|
+
if (ptr == nullptr) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
auto isolate = args.GetIsolate();
|
|
123
|
+
auto context = isolate->GetCurrentContext();
|
|
124
|
+
|
|
125
|
+
auto descVal = args[0];
|
|
126
|
+
|
|
127
|
+
const CanvasGPUComputePassEncoder *pass;
|
|
128
|
+
|
|
129
|
+
if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
|
|
130
|
+
auto desc = descVal.As<v8::Object>();
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
v8::Local<v8::Value> labelVal;
|
|
134
|
+
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
135
|
+
|
|
136
|
+
char *label = nullptr;
|
|
137
|
+
|
|
138
|
+
if (!labelVal.IsEmpty() && labelVal->IsString()) {
|
|
139
|
+
label = *v8::String::Utf8Value(isolate, labelVal);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const CanvasGPUQuerySet *querySet = nullptr;
|
|
143
|
+
int32_t beginningOfPassWriteIndex = -1;
|
|
144
|
+
|
|
145
|
+
int32_t endOfPassWriteIndex = -1;
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
v8::Local<v8::Value> timestampWritesVal;
|
|
149
|
+
desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
|
|
150
|
+
×tampWritesVal);
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
|
|
154
|
+
auto timestampWrites = timestampWritesVal.As<v8::Object>();
|
|
155
|
+
|
|
156
|
+
v8::Local<v8::Value> querySetVal;
|
|
157
|
+
timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
|
|
158
|
+
&querySetVal);
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if (!querySetVal.IsEmpty() && querySetVal->IsObject()) {
|
|
162
|
+
auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
|
|
163
|
+
if (queryPtr != nullptr) {
|
|
164
|
+
querySet = queryPtr->GetQuerySet();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
v8::Local<v8::Value> beginningOfPassWriteIndexVal;
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
v8::Local<v8::Value> endOfPassWriteIndexVal;
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
timestampWrites->Get(context,
|
|
175
|
+
ConvertToV8String(isolate, "beginningOfPassWriteIndex")).ToLocal(
|
|
176
|
+
&beginningOfPassWriteIndexVal);
|
|
177
|
+
|
|
178
|
+
timestampWrites->Get(context,
|
|
179
|
+
ConvertToV8String(isolate, "endOfPassWriteIndex")).ToLocal(
|
|
180
|
+
&endOfPassWriteIndexVal);
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
if (beginningOfPassWriteIndexVal->IsInt32()) {
|
|
184
|
+
beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (endOfPassWriteIndexVal->IsInt32()) {
|
|
188
|
+
endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
|
|
194
|
+
querySet, label,
|
|
195
|
+
beginningOfPassWriteIndex,
|
|
196
|
+
endOfPassWriteIndex);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
} else {
|
|
200
|
+
pass = canvas_native_webgpu_command_encoder_begin_compute_pass(ptr->GetEncoder(),
|
|
201
|
+
nullptr, nullptr, -1,
|
|
202
|
+
-1);
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if (pass != nullptr) {
|
|
208
|
+
auto value = new GPUComputePassEncoderImpl(pass);
|
|
209
|
+
auto ret = GPUComputePassEncoderImpl::NewInstance(isolate, value);
|
|
210
|
+
args.GetReturnValue().Set(ret);
|
|
211
|
+
} else {
|
|
212
|
+
args.GetReturnValue().SetUndefined();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
218
|
+
auto ptr = GetPointer(args.This());
|
|
219
|
+
if (ptr == nullptr) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
auto isolate = args.GetIsolate();
|
|
224
|
+
auto context = isolate->GetCurrentContext();
|
|
225
|
+
|
|
226
|
+
auto descVal = args[0];
|
|
227
|
+
|
|
228
|
+
const CanvasGPURenderPassEncoder *pass = nullptr;
|
|
229
|
+
|
|
230
|
+
std::vector<CanvasRenderPassColorAttachment> colorAttachments_;
|
|
231
|
+
|
|
232
|
+
if (!descVal->IsNullOrUndefined() && descVal->IsObject()) {
|
|
233
|
+
auto desc = descVal.As<v8::Object>();
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
v8::Local<v8::Value> labelVal;
|
|
237
|
+
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
238
|
+
|
|
239
|
+
char *label = nullptr;
|
|
240
|
+
|
|
241
|
+
if (!labelVal.IsEmpty() && labelVal->IsString()) {
|
|
242
|
+
label = *v8::String::Utf8Value(isolate, labelVal);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
v8::Local<v8::Value> colorAttachmentsVal;
|
|
247
|
+
desc->Get(context, ConvertToV8String(isolate, "colorAttachments")).ToLocal(
|
|
248
|
+
&colorAttachmentsVal);
|
|
249
|
+
|
|
250
|
+
auto colorAttachments = colorAttachmentsVal.As<v8::Array>();
|
|
251
|
+
auto colorAttachmentsLength = colorAttachments->Length();
|
|
252
|
+
|
|
253
|
+
for (int i = 0; i < colorAttachmentsLength; i++) {
|
|
254
|
+
auto colorAttachment = colorAttachments->Get(context,
|
|
255
|
+
i).ToLocalChecked().As<v8::Object>();
|
|
256
|
+
|
|
257
|
+
v8::Local<v8::Value> clearValueVal;
|
|
258
|
+
colorAttachment->Get(context, ConvertToV8String(isolate, "clearValue")).ToLocal(
|
|
259
|
+
&clearValueVal);
|
|
260
|
+
auto clearValue = CanvasColor{0, 0, 0, 0};
|
|
261
|
+
if (!clearValueVal.IsEmpty() && clearValueVal->IsObject()) {
|
|
262
|
+
auto clearValueObj = clearValueVal.As<v8::Object>();
|
|
263
|
+
|
|
264
|
+
v8::Local<v8::Value> r;
|
|
265
|
+
v8::Local<v8::Value> g;
|
|
266
|
+
v8::Local<v8::Value> b;
|
|
267
|
+
v8::Local<v8::Value> a;
|
|
268
|
+
|
|
269
|
+
clearValueObj->Get(context, ConvertToV8String(isolate, "r")).ToLocal(&r);
|
|
270
|
+
clearValueObj->Get(context, ConvertToV8String(isolate, "g")).ToLocal(&g);
|
|
271
|
+
clearValueObj->Get(context, ConvertToV8String(isolate, "b")).ToLocal(&b);
|
|
272
|
+
clearValueObj->Get(context, ConvertToV8String(isolate, "a")).ToLocal(&a);
|
|
273
|
+
|
|
274
|
+
if (!r.IsEmpty() && r->IsNumber()) {
|
|
275
|
+
clearValue.r = r.As<v8::Number>()->Value();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (!g.IsEmpty() && g->IsNumber()) {
|
|
279
|
+
clearValue.g = g.As<v8::Number>()->Value();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
if (!b.IsEmpty() && b->IsNumber()) {
|
|
284
|
+
clearValue.b = b.As<v8::Number>()->Value();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (!a.IsEmpty() && a->IsNumber()) {
|
|
288
|
+
clearValue.a = a.As<v8::Number>()->Value();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
auto viewVal = colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
294
|
+
"view")).ToLocalChecked();
|
|
295
|
+
|
|
296
|
+
auto view = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
const CanvasGPUTextureView *resolve_target = nullptr;
|
|
300
|
+
|
|
301
|
+
v8::Local<v8::Value> resolve_target_val;
|
|
302
|
+
|
|
303
|
+
colorAttachment->Get(context, ConvertToV8String(isolate, "resolveTarget")).ToLocal(
|
|
304
|
+
&resolve_target_val);
|
|
305
|
+
|
|
306
|
+
auto resolve_target_type = GetNativeType(resolve_target_val);
|
|
307
|
+
|
|
308
|
+
if (resolve_target_type == NativeType::GPUTextureView) {
|
|
309
|
+
auto res = GPUTextureViewImpl::GetPointer(resolve_target_val.As<v8::Object>());
|
|
310
|
+
resolve_target = res->GetTextureView();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// default
|
|
314
|
+
CanvasLoadOp load = CanvasLoadOp::CanvasLoadOpClear;
|
|
315
|
+
CanvasStoreOp store = CanvasStoreOp::CanvasStoreOpStore;
|
|
316
|
+
auto loadVal = colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
317
|
+
"loadOp")).ToLocalChecked();
|
|
318
|
+
|
|
319
|
+
if (loadVal->IsUint32()) {
|
|
320
|
+
load = (CanvasLoadOp) loadVal->Uint32Value(
|
|
321
|
+
context).ToChecked();
|
|
322
|
+
} else if (loadVal->IsString()) {
|
|
323
|
+
auto val = ConvertFromV8String(isolate, loadVal);
|
|
324
|
+
if (val == "clear") {
|
|
325
|
+
load = CanvasLoadOp::CanvasLoadOpClear;
|
|
326
|
+
} else if (val == "load") {
|
|
327
|
+
load = CanvasLoadOp::CanvasLoadOpLoad;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
auto storeVal = colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
333
|
+
"storeOp")).ToLocalChecked();
|
|
334
|
+
|
|
335
|
+
if (!storeVal.IsEmpty() && storeVal->IsUint32()) {
|
|
336
|
+
store = (CanvasStoreOp) storeVal->Uint32Value(
|
|
337
|
+
context).ToChecked();
|
|
338
|
+
} else if (storeVal->IsString()) {
|
|
339
|
+
auto val = ConvertFromV8String(isolate, storeVal);
|
|
340
|
+
if (val == "discard") {
|
|
341
|
+
store = CanvasStoreOp::CanvasStoreOpDiscard;
|
|
342
|
+
} else if (val == "store") {
|
|
343
|
+
store = CanvasStoreOp::CanvasStoreOpStore;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
CanvasPassChannelColor channel{
|
|
348
|
+
load,
|
|
349
|
+
store,
|
|
350
|
+
clearValue,
|
|
351
|
+
false
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
auto attachment = CanvasRenderPassColorAttachment{
|
|
355
|
+
view->GetTextureView(),
|
|
356
|
+
resolve_target,
|
|
357
|
+
channel
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
colorAttachments_.push_back(attachment);
|
|
361
|
+
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
v8::Local<v8::Value> maxDrawCountVal;
|
|
366
|
+
|
|
367
|
+
desc->Get(context, ConvertToV8String(isolate, "maxDrawCount")).ToLocal(&maxDrawCountVal);
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
CanvasRenderPassDepthStencilAttachment *depthStencilAttachment = nullptr;
|
|
371
|
+
v8::Local<v8::Value> depthStencilAttachmentVal;
|
|
372
|
+
|
|
373
|
+
desc->Get(context, ConvertToV8String(isolate, "depthStencilAttachment")).ToLocal(
|
|
374
|
+
&depthStencilAttachmentVal);
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
if (!depthStencilAttachmentVal.IsEmpty() && depthStencilAttachmentVal->IsObject()) {
|
|
378
|
+
auto depthStencilAttachmentObj = depthStencilAttachmentVal.As<v8::Object>();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
const CanvasGPUQuerySet *occlusion_query_set = nullptr;
|
|
383
|
+
v8::Local<v8::Value> occlusionQuerySetVal;
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
desc->Get(context, ConvertToV8String(isolate, "occlusionQuerySet")).ToLocal(
|
|
387
|
+
&occlusionQuerySetVal);
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
if (!occlusionQuerySetVal.IsEmpty() && occlusionQuerySetVal->IsObject()) {
|
|
391
|
+
auto occlusionQuerySet = GPUQuerySetImpl::GetPointer(
|
|
392
|
+
occlusionQuerySetVal.As<v8::Object>());
|
|
393
|
+
occlusion_query_set = occlusionQuerySet->GetQuerySet();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
v8::Local<v8::Value> timestampWritesVal;
|
|
398
|
+
desc->Get(context, ConvertToV8String(isolate, "timestampWrites")).ToLocal(
|
|
399
|
+
×tampWritesVal);
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
const CanvasGPUQuerySet *querySet = nullptr;
|
|
403
|
+
int32_t beginningOfPassWriteIndex = -1;
|
|
404
|
+
int32_t endOfPassWriteIndex = -1;
|
|
405
|
+
|
|
406
|
+
if (!timestampWritesVal.IsEmpty() && timestampWritesVal->IsObject()) {
|
|
407
|
+
auto timestampWrites = timestampWritesVal.As<v8::Object>();
|
|
408
|
+
v8::Local<v8::Value> querySetVal;
|
|
409
|
+
timestampWrites->Get(context, ConvertToV8String(isolate, "querySet")).ToLocal(
|
|
410
|
+
&querySetVal);
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
if (!querySetVal.IsEmpty() && querySetVal->IsObject()) {
|
|
414
|
+
auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
|
|
415
|
+
if (queryPtr != nullptr) {
|
|
416
|
+
querySet = queryPtr->GetQuerySet();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
v8::Local<v8::Value> beginningOfPassWriteIndexVal;
|
|
421
|
+
|
|
422
|
+
v8::Local<v8::Value> endOfPassWriteIndexVal;
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
auto beginningOfPassWriteIndexValSuccess = timestampWrites->Get(context,
|
|
426
|
+
ConvertToV8String(
|
|
427
|
+
isolate,
|
|
428
|
+
"beginningOfPassWriteIndex")).ToLocal(
|
|
429
|
+
&beginningOfPassWriteIndexVal);
|
|
430
|
+
|
|
431
|
+
auto endOfPassWriteIndexValSuccess = timestampWrites->Get(context,
|
|
432
|
+
ConvertToV8String(isolate,
|
|
433
|
+
"endOfPassWriteIndex")).ToLocal(
|
|
434
|
+
&endOfPassWriteIndexVal);
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
if (beginningOfPassWriteIndexValSuccess && beginningOfPassWriteIndexVal->IsInt32()) {
|
|
438
|
+
beginningOfPassWriteIndex = beginningOfPassWriteIndexVal.As<v8::Int32>()->Value();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (endOfPassWriteIndexValSuccess && endOfPassWriteIndexVal->IsInt32()) {
|
|
442
|
+
endOfPassWriteIndex = endOfPassWriteIndexVal.As<v8::Int32>()->Value();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
pass = canvas_native_webgpu_command_encoder_begin_render_pass(
|
|
449
|
+
ptr->GetEncoder(), label, colorAttachments_.data(), colorAttachments_.size(),
|
|
450
|
+
depthStencilAttachment, occlusion_query_set,
|
|
451
|
+
querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
if (pass != nullptr) {
|
|
459
|
+
auto value = new GPURenderPassEncoderImpl(pass);
|
|
460
|
+
auto ret = GPURenderPassEncoderImpl::NewInstance(isolate, value);
|
|
461
|
+
args.GetReturnValue().Set(ret);
|
|
462
|
+
} else {
|
|
463
|
+
args.GetReturnValue().SetUndefined();
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
void GPUCommandEncoderImpl::ClearBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
469
|
+
auto ptr = GetPointer(args.This());
|
|
470
|
+
if (ptr == nullptr) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
auto bufferVal = args[0];
|
|
475
|
+
const CanvasGPUBuffer *buffer = nullptr;
|
|
476
|
+
|
|
477
|
+
if (bufferVal->IsObject()) {
|
|
478
|
+
auto bufferPtr = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
479
|
+
if (bufferPtr != nullptr) {
|
|
480
|
+
buffer = bufferPtr->GetGPUBuffer();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (buffer == nullptr) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
int64_t offset = -1;
|
|
489
|
+
auto offsetVal = args[1];
|
|
490
|
+
|
|
491
|
+
if (offsetVal->IsNumber()) {
|
|
492
|
+
offset = (int64_t) offsetVal.As<v8::Number>()->Value();
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
int64_t size = -1;
|
|
496
|
+
auto sizeVal = args[2];
|
|
497
|
+
|
|
498
|
+
if (sizeVal->IsNumber()) {
|
|
499
|
+
size = (int64_t) sizeVal.As<v8::Number>()->Value();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
canvas_native_webgpu_command_encoder_clear_buffer(ptr->GetEncoder(), buffer, offset, size);
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
void GPUCommandEncoderImpl::CopyBufferToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
507
|
+
auto ptr = GetPointer(args.This());
|
|
508
|
+
if (ptr == nullptr) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
auto isolate = args.GetIsolate();
|
|
512
|
+
auto context = isolate->GetCurrentContext();
|
|
513
|
+
|
|
514
|
+
auto source = args[0];
|
|
515
|
+
auto sourceType = GetNativeType(source);
|
|
516
|
+
auto sourceOffset = args[1];
|
|
517
|
+
auto destination = args[2];
|
|
518
|
+
auto destinationType = GetNativeType(destination);
|
|
519
|
+
auto destinationOffset = args[3];
|
|
520
|
+
auto size = args[4];
|
|
521
|
+
|
|
522
|
+
if (sourceType == NativeType::GPUBuffer && destinationType == NativeType::GPUBuffer) {
|
|
523
|
+
auto src = GPUBufferImpl::GetPointer(source.As<v8::Object>());
|
|
524
|
+
auto dst = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
|
|
525
|
+
canvas_native_webgpu_command_encoder_copy_buffer_to_buffer(ptr->GetEncoder(),
|
|
526
|
+
src->GetGPUBuffer(),
|
|
527
|
+
(int64_t) sourceOffset->NumberValue(
|
|
528
|
+
context).FromJust(),
|
|
529
|
+
dst->GetGPUBuffer(),
|
|
530
|
+
(int64_t) destinationOffset->NumberValue(
|
|
531
|
+
context).FromJust(),
|
|
532
|
+
(uint64_t) size->NumberValue(
|
|
533
|
+
context).FromJust()
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
void GPUCommandEncoderImpl::CopyBufferToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
540
|
+
auto ptr = GetPointer(args.This());
|
|
541
|
+
if (ptr == nullptr) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
auto isolate = args.GetIsolate();
|
|
547
|
+
auto context = isolate->GetCurrentContext();
|
|
548
|
+
|
|
549
|
+
auto source = args[0];
|
|
550
|
+
auto destination = args[1];
|
|
551
|
+
auto copySize = args[2];
|
|
552
|
+
|
|
553
|
+
if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
|
|
554
|
+
const CanvasGPUBuffer *buffer = nullptr;
|
|
555
|
+
auto src = source.As<v8::Object>();
|
|
556
|
+
v8::Local<v8::Value> bufferVal;
|
|
557
|
+
src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
|
|
558
|
+
if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
|
|
559
|
+
buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
|
|
560
|
+
}
|
|
561
|
+
uint64_t offset = 0;
|
|
562
|
+
int32_t rowsPerImage = -1;
|
|
563
|
+
|
|
564
|
+
v8::Local<v8::Value> rowsPerImageVal;
|
|
565
|
+
|
|
566
|
+
src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
|
|
567
|
+
|
|
568
|
+
if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
|
|
569
|
+
rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
v8::Local<v8::Value> offsetVal;
|
|
574
|
+
|
|
575
|
+
src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
|
|
576
|
+
|
|
577
|
+
if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
|
|
578
|
+
offset = (int64_t) offsetVal->NumberValue(context).FromJust();
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
v8::Local<v8::Value> bytesPerRowVal;
|
|
582
|
+
|
|
583
|
+
src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
|
|
584
|
+
|
|
585
|
+
CanvasImageCopyBuffer copy{
|
|
586
|
+
buffer,
|
|
587
|
+
offset,
|
|
588
|
+
bytesPerRowVal->Int32Value(context).FromJust(),
|
|
589
|
+
rowsPerImage
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
uint32_t mipLevel = 0;
|
|
594
|
+
CanvasOrigin3d origin{0, 0, 0};
|
|
595
|
+
CanvasTextureAspect aspect = CanvasTextureAspectAll;
|
|
596
|
+
|
|
597
|
+
const CanvasGPUTexture *texture = nullptr;
|
|
598
|
+
auto dst = destination.As<v8::Object>();
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
v8::Local<v8::Value> textureVal;
|
|
602
|
+
dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
|
|
603
|
+
if (GetNativeType(textureVal) == NativeType::GPUTexture) {
|
|
604
|
+
texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
v8::Local<v8::Value> mipLevelVal;
|
|
609
|
+
dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
|
|
610
|
+
|
|
611
|
+
if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
|
|
612
|
+
mipLevel = mipLevelVal->Uint32Value(context).FromJust();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
v8::Local<v8::Value> originVal;
|
|
616
|
+
dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
if (!originVal.IsEmpty() && originVal->IsObject()) {
|
|
620
|
+
auto originObj = originVal.As<v8::Object>();
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
v8::Local<v8::Value> xVal;
|
|
624
|
+
v8::Local<v8::Value> yVal;
|
|
625
|
+
v8::Local<v8::Value> zVal;
|
|
626
|
+
originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
|
|
627
|
+
originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
|
|
628
|
+
originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
|
|
629
|
+
|
|
630
|
+
if (xVal->IsUint32()) {
|
|
631
|
+
origin.x = xVal->Uint32Value(context).FromJust();
|
|
632
|
+
}
|
|
633
|
+
if (yVal->IsUint32()) {
|
|
634
|
+
origin.y = yVal->Uint32Value(context).FromJust();
|
|
635
|
+
}
|
|
636
|
+
if (zVal->IsUint32()) {
|
|
637
|
+
origin.z = zVal->Uint32Value(context).FromJust();
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
v8::Local<v8::Value> aspectVal;
|
|
644
|
+
dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
auto aspectStr = ConvertFromV8String(isolate, aspectVal);
|
|
648
|
+
|
|
649
|
+
if (aspectStr == "stencil-only") {
|
|
650
|
+
aspect = CanvasTextureAspectStencilOnly;
|
|
651
|
+
} else if (aspectStr == "depth-only") {
|
|
652
|
+
aspect = CanvasTextureAspectDepthOnly;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
CanvasImageCopyTexture ct{
|
|
656
|
+
texture, mipLevel, origin, aspect
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
|
|
660
|
+
canvas_native_webgpu_command_encoder_copy_buffer_to_texture(
|
|
661
|
+
ptr->GetEncoder(),
|
|
662
|
+
©,
|
|
663
|
+
&ct,
|
|
664
|
+
&cz
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
void GPUCommandEncoderImpl::CopyTextureToBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
672
|
+
auto ptr = GetPointer(args.This());
|
|
673
|
+
if (ptr == nullptr) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
auto isolate = args.GetIsolate();
|
|
679
|
+
auto context = isolate->GetCurrentContext();
|
|
680
|
+
|
|
681
|
+
// copying texture to buffer swapped the real source and dst
|
|
682
|
+
auto source = args[1];
|
|
683
|
+
auto destination = args[0];
|
|
684
|
+
auto copySize = args[2];
|
|
685
|
+
|
|
686
|
+
if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
|
|
687
|
+
const CanvasGPUBuffer *buffer = nullptr;
|
|
688
|
+
auto src = source.As<v8::Object>();
|
|
689
|
+
|
|
690
|
+
v8::Local<v8::Value> bufferVal;
|
|
691
|
+
src->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(&bufferVal);
|
|
692
|
+
if (GetNativeType(bufferVal) == NativeType::GPUBuffer) {
|
|
693
|
+
buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>())->GetGPUBuffer();
|
|
694
|
+
}
|
|
695
|
+
uint64_t offset = 0;
|
|
696
|
+
int32_t rowsPerImage = -1;
|
|
697
|
+
|
|
698
|
+
v8::Local<v8::Value> rowsPerImageVal;
|
|
699
|
+
|
|
700
|
+
src->Get(context, ConvertToV8String(isolate, "rowsPerImage")).ToLocal(&rowsPerImageVal);
|
|
701
|
+
|
|
702
|
+
if (!rowsPerImageVal.IsEmpty() && rowsPerImageVal->IsInt32()) {
|
|
703
|
+
rowsPerImage = rowsPerImageVal->Int32Value(context).FromJust();
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
v8::Local<v8::Value> offsetVal;
|
|
708
|
+
|
|
709
|
+
src->Get(context, ConvertToV8String(isolate, "offset")).ToLocal(&offsetVal);
|
|
710
|
+
|
|
711
|
+
if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
|
|
712
|
+
offset = (int64_t) offsetVal->NumberValue(context).FromJust();
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
v8::Local<v8::Value> bytesPerRowVal;
|
|
716
|
+
|
|
717
|
+
src->Get(context, ConvertToV8String(isolate, "bytesPerRow")).ToLocal(&bytesPerRowVal);
|
|
718
|
+
|
|
719
|
+
CanvasImageCopyBuffer copy{
|
|
720
|
+
buffer,
|
|
721
|
+
offset,
|
|
722
|
+
bytesPerRowVal->Int32Value(context).FromJust(),
|
|
723
|
+
rowsPerImage
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
uint32_t mipLevel = 0;
|
|
728
|
+
CanvasOrigin3d origin{0, 0, 0};
|
|
729
|
+
CanvasTextureAspect aspect = CanvasTextureAspectAll;
|
|
730
|
+
|
|
731
|
+
const CanvasGPUTexture *texture = nullptr;
|
|
732
|
+
auto dst = destination.As<v8::Object>();
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
v8::Local<v8::Value> textureVal;
|
|
736
|
+
dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
|
|
737
|
+
if (GetNativeType(textureVal) == NativeType::GPUTexture) {
|
|
738
|
+
texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
v8::Local<v8::Value> mipLevelVal;
|
|
743
|
+
dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
|
|
744
|
+
|
|
745
|
+
if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
|
|
746
|
+
mipLevel = mipLevelVal->Uint32Value(context).FromJust();
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
v8::Local<v8::Value> originVal;
|
|
750
|
+
dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
if (!originVal.IsEmpty() && originVal->IsObject()) {
|
|
754
|
+
auto originObj = originVal.As<v8::Object>();
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
v8::Local<v8::Value> xVal;
|
|
758
|
+
v8::Local<v8::Value> yVal;
|
|
759
|
+
v8::Local<v8::Value> zVal;
|
|
760
|
+
originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
|
|
761
|
+
originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
|
|
762
|
+
originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
|
|
763
|
+
|
|
764
|
+
if (xVal->IsUint32()) {
|
|
765
|
+
origin.x = xVal->Uint32Value(context).FromJust();
|
|
766
|
+
}
|
|
767
|
+
if (yVal->IsUint32()) {
|
|
768
|
+
origin.y = yVal->Uint32Value(context).FromJust();
|
|
769
|
+
}
|
|
770
|
+
if (zVal->IsUint32()) {
|
|
771
|
+
origin.z = zVal->Uint32Value(context).FromJust();
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
v8::Local<v8::Value> aspectVal;
|
|
778
|
+
dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
auto aspectStr = ConvertFromV8String(isolate, aspectVal);
|
|
782
|
+
|
|
783
|
+
if (aspectStr == "stencil-only") {
|
|
784
|
+
aspect = CanvasTextureAspectStencilOnly;
|
|
785
|
+
} else if (aspectStr == "depth-only") {
|
|
786
|
+
aspect = CanvasTextureAspectDepthOnly;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
CanvasImageCopyTexture ct{
|
|
790
|
+
texture, mipLevel, origin, aspect
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
|
|
794
|
+
canvas_native_webgpu_command_encoder_copy_texture_to_buffer(
|
|
795
|
+
ptr->GetEncoder(),
|
|
796
|
+
&ct,
|
|
797
|
+
©,
|
|
798
|
+
&cz
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
void GPUCommandEncoderImpl::CopyTextureToTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
806
|
+
auto ptr = GetPointer(args.This());
|
|
807
|
+
if (ptr == nullptr) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
auto isolate = args.GetIsolate();
|
|
812
|
+
auto context = isolate->GetCurrentContext();
|
|
813
|
+
|
|
814
|
+
// copying texture to buffer swapped the real source and dst
|
|
815
|
+
auto source = args[0];
|
|
816
|
+
auto destination = args[1];
|
|
817
|
+
auto copySize = args[2];
|
|
818
|
+
|
|
819
|
+
if (source->IsObject() && destination->IsObject() && copySize->IsObject()) {
|
|
820
|
+
auto src = source.As<v8::Object>();
|
|
821
|
+
|
|
822
|
+
uint32_t mipLevelA = 0;
|
|
823
|
+
CanvasOrigin3d originA{0, 0, 0};
|
|
824
|
+
CanvasTextureAspect aspectA = CanvasTextureAspectAll;
|
|
825
|
+
|
|
826
|
+
const CanvasGPUTexture *textureA = nullptr;
|
|
827
|
+
|
|
828
|
+
v8::Local<v8::Value> srcTextureVal;
|
|
829
|
+
src->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&srcTextureVal);
|
|
830
|
+
if (GetNativeType(srcTextureVal) == NativeType::GPUTexture) {
|
|
831
|
+
textureA = GPUTextureImpl::GetPointer(srcTextureVal.As<v8::Object>())->GetTexture();
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
v8::Local<v8::Value> mipLevelAVal;
|
|
835
|
+
src->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelAVal);
|
|
836
|
+
|
|
837
|
+
if (!mipLevelAVal.IsEmpty() && mipLevelAVal->IsUint32()) {
|
|
838
|
+
mipLevelA = mipLevelAVal->Uint32Value(context).FromJust();
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
v8::Local<v8::Value> originAVal;
|
|
842
|
+
src->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originAVal);
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
if (!originAVal.IsEmpty() && originAVal->IsObject()) {
|
|
846
|
+
auto originObj = originAVal.As<v8::Object>();
|
|
847
|
+
|
|
848
|
+
v8::Local<v8::Value> xVal;
|
|
849
|
+
v8::Local<v8::Value> yVal;
|
|
850
|
+
v8::Local<v8::Value> zVal;
|
|
851
|
+
originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
|
|
852
|
+
originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
|
|
853
|
+
originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
|
|
854
|
+
|
|
855
|
+
if (xVal->IsUint32()) {
|
|
856
|
+
originA.x = xVal->Uint32Value(context).FromJust();
|
|
857
|
+
}
|
|
858
|
+
if (yVal->IsUint32()) {
|
|
859
|
+
originA.y = yVal->Uint32Value(context).FromJust();
|
|
860
|
+
}
|
|
861
|
+
if (zVal->IsUint32()) {
|
|
862
|
+
originA.z = zVal->Uint32Value(context).FromJust();
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
v8::Local<v8::Value> aspectAVal;
|
|
868
|
+
src->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectAVal);
|
|
869
|
+
|
|
870
|
+
auto aspectAStr = ConvertFromV8String(isolate, aspectAVal);
|
|
871
|
+
|
|
872
|
+
if (aspectAStr == "stencil-only") {
|
|
873
|
+
aspectA = CanvasTextureAspectStencilOnly;
|
|
874
|
+
} else if (aspectAStr == "depth-only") {
|
|
875
|
+
aspectA = CanvasTextureAspectDepthOnly;
|
|
876
|
+
}
|
|
877
|
+
CanvasImageCopyTexture copy{
|
|
878
|
+
textureA, mipLevelA, originA, aspectA
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
uint32_t mipLevel = 0;
|
|
882
|
+
CanvasOrigin3d origin{0, 0, 0};
|
|
883
|
+
CanvasTextureAspect aspect = CanvasTextureAspectAll;
|
|
884
|
+
|
|
885
|
+
const CanvasGPUTexture *texture = nullptr;
|
|
886
|
+
auto dst = destination.As<v8::Object>();
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
v8::Local<v8::Value> textureVal;
|
|
890
|
+
dst->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(&textureVal);
|
|
891
|
+
if (GetNativeType(textureVal) == NativeType::GPUTexture) {
|
|
892
|
+
texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>())->GetTexture();
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
v8::Local<v8::Value> mipLevelVal;
|
|
897
|
+
dst->Get(context, ConvertToV8String(isolate, "mipLevel")).ToLocal(&mipLevelVal);
|
|
898
|
+
|
|
899
|
+
if (!mipLevelVal.IsEmpty() && mipLevelVal->IsUint32()) {
|
|
900
|
+
mipLevel = mipLevelVal->Uint32Value(context).FromJust();
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
v8::Local<v8::Value> originVal;
|
|
904
|
+
dst->Get(context, ConvertToV8String(isolate, "origin")).ToLocal(&originVal);
|
|
905
|
+
|
|
906
|
+
if (!originVal.IsEmpty() && originVal->IsObject()) {
|
|
907
|
+
auto originObj = originVal.As<v8::Object>();
|
|
908
|
+
|
|
909
|
+
v8::Local<v8::Value> xVal;
|
|
910
|
+
v8::Local<v8::Value> yVal;
|
|
911
|
+
v8::Local<v8::Value> zVal;
|
|
912
|
+
originObj->Get(context, ConvertToV8String(isolate, "x")).ToLocal(&xVal);
|
|
913
|
+
originObj->Get(context, ConvertToV8String(isolate, "y")).ToLocal(&yVal);
|
|
914
|
+
originObj->Get(context, ConvertToV8String(isolate, "z")).ToLocal(&zVal);
|
|
915
|
+
|
|
916
|
+
if (xVal->IsUint32()) {
|
|
917
|
+
origin.x = xVal->Uint32Value(context).FromJust();
|
|
918
|
+
}
|
|
919
|
+
if (yVal->IsUint32()) {
|
|
920
|
+
origin.y = yVal->Uint32Value(context).FromJust();
|
|
921
|
+
}
|
|
922
|
+
if (zVal->IsUint32()) {
|
|
923
|
+
origin.z = zVal->Uint32Value(context).FromJust();
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
v8::Local<v8::Value> aspectVal;
|
|
930
|
+
dst->Get(context, ConvertToV8String(isolate, "aspect")).ToLocal(&aspectVal);
|
|
931
|
+
|
|
932
|
+
auto aspectStr = ConvertFromV8String(isolate, aspectVal);
|
|
933
|
+
|
|
934
|
+
if (aspectStr == "stencil-only") {
|
|
935
|
+
aspect = CanvasTextureAspectStencilOnly;
|
|
936
|
+
} else if (aspectStr == "depth-only") {
|
|
937
|
+
aspect = CanvasTextureAspectDepthOnly;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
CanvasImageCopyTexture ct{
|
|
941
|
+
texture, mipLevel, origin, aspect
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
CanvasExtent3d cz = ParseExtent3d(isolate, copySize);
|
|
945
|
+
|
|
946
|
+
canvas_native_webgpu_command_encoder_copy_texture_to_texture(
|
|
947
|
+
ptr->GetEncoder(),
|
|
948
|
+
©,
|
|
949
|
+
&ct,
|
|
950
|
+
&cz
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
958
|
+
auto ptr = GetPointer(args.This());
|
|
959
|
+
if (ptr == nullptr) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
auto isolate = args.GetIsolate();
|
|
964
|
+
auto context = isolate->GetCurrentContext();
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
auto descVal = args[0];
|
|
968
|
+
std::string label;
|
|
969
|
+
bool didSet = false;
|
|
970
|
+
if (descVal->IsObject()) {
|
|
971
|
+
auto desc = descVal.As<v8::Object>();
|
|
972
|
+
v8::Local<v8::Value> labelVal;
|
|
973
|
+
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
974
|
+
if (!labelVal.IsEmpty() && labelVal->IsString()) {
|
|
975
|
+
label = ConvertFromV8String(isolate, labelVal);
|
|
976
|
+
didSet = true;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
auto value = canvas_native_webgpu_command_encoder_finish(ptr->GetEncoder(),
|
|
981
|
+
didSet ? label.c_str() : nullptr);
|
|
982
|
+
|
|
983
|
+
if (value != nullptr) {
|
|
984
|
+
auto ret = GPUCommandBufferImpl::NewInstance(isolate, new GPUCommandBufferImpl(value));
|
|
985
|
+
args.GetReturnValue().Set(ret);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
args.GetReturnValue().SetUndefined();
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
void
|
|
993
|
+
GPUCommandEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
994
|
+
auto *ptr = GetPointer(args.This());
|
|
995
|
+
if (ptr == nullptr) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
auto isolate = args.GetIsolate();
|
|
1000
|
+
|
|
1001
|
+
auto markerLabelVal = args[0];
|
|
1002
|
+
if (markerLabelVal->IsString()) {
|
|
1003
|
+
auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
|
|
1004
|
+
canvas_native_webgpu_command_encoder_insert_debug_marker(ptr->GetEncoder(),
|
|
1005
|
+
markerLabel.c_str());
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
void GPUCommandEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1010
|
+
auto *ptr = GetPointer(args.This());
|
|
1011
|
+
if (ptr == nullptr) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
canvas_native_webgpu_command_encoder_pop_debug_group(ptr->GetEncoder());
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
void GPUCommandEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1019
|
+
auto *ptr = GetPointer(args.This());
|
|
1020
|
+
if (ptr == nullptr) {
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
auto isolate = args.GetIsolate();
|
|
1025
|
+
|
|
1026
|
+
auto groupLabelVal = args[0];
|
|
1027
|
+
if (groupLabelVal->IsString()) {
|
|
1028
|
+
auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
|
|
1029
|
+
canvas_native_webgpu_command_encoder_push_debug_group(ptr->GetEncoder(),
|
|
1030
|
+
groupLabel.c_str());
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
void GPUCommandEncoderImpl::ResolveQuerySet(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1035
|
+
auto *ptr = GetPointer(args.This());
|
|
1036
|
+
if (ptr == nullptr) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
auto isolate = args.GetIsolate();
|
|
1041
|
+
auto context = isolate->GetCurrentContext();
|
|
1042
|
+
|
|
1043
|
+
auto querySet = args[0];
|
|
1044
|
+
auto queryType = GetNativeType(querySet);
|
|
1045
|
+
auto firstQuery = args[1];
|
|
1046
|
+
auto queryCount = args[2];
|
|
1047
|
+
auto destination = args[3];
|
|
1048
|
+
auto destinationType = GetNativeType(destination);
|
|
1049
|
+
auto destinationOffset = args[4];
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
if (queryType == NativeType::GPUQuerySet && destinationType == NativeType::GPUBuffer) {
|
|
1053
|
+
auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
|
|
1054
|
+
auto dest = GPUBufferImpl::GetPointer(destination.As<v8::Object>());
|
|
1055
|
+
canvas_native_webgpu_command_encoder_resolve_query_set(ptr->GetEncoder(), qs->GetQuerySet(),
|
|
1056
|
+
firstQuery->Uint32Value(
|
|
1057
|
+
context).FromJust(),
|
|
1058
|
+
queryCount->Uint32Value(
|
|
1059
|
+
context).FromJust(),
|
|
1060
|
+
dest->GetGPUBuffer(),
|
|
1061
|
+
(uint64_t) destinationOffset->NumberValue(
|
|
1062
|
+
context).FromJust());
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
void GPUCommandEncoderImpl::WriteTimestamp(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1067
|
+
auto *ptr = GetPointer(args.This());
|
|
1068
|
+
if (ptr == nullptr) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
auto isolate = args.GetIsolate();
|
|
1073
|
+
auto context = isolate->GetCurrentContext();
|
|
1074
|
+
|
|
1075
|
+
auto querySet = args[0];
|
|
1076
|
+
auto queryType = GetNativeType(querySet);
|
|
1077
|
+
auto queryIndex = args[1];
|
|
1078
|
+
|
|
1079
|
+
if (queryType == NativeType::GPUQuerySet) {
|
|
1080
|
+
auto qs = GPUQuerySetImpl::GetPointer(querySet.As<v8::Object>());
|
|
1081
|
+
canvas_native_webgpu_command_encoder_write_timestamp(ptr->GetEncoder(), qs->GetQuerySet(),
|
|
1082
|
+
queryIndex->Uint32Value(
|
|
1083
|
+
context).FromJust());
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
}
|