@nativescript/canvas 2.0.0-beta.9 → 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 +4 -5
- package/Canvas/index.ios.js +72 -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 +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/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 +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 +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 +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 +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 +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,653 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 01/07/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPURenderPassEncoderImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "GPURenderPipelineImpl.h"
|
|
8
|
+
#include "GPUBufferImpl.h"
|
|
9
|
+
#include "GPURenderBundleImpl.h"
|
|
10
|
+
#include "GPUQuerySetImpl.h"
|
|
11
|
+
#include "GPUBindGroupImpl.h"
|
|
12
|
+
|
|
13
|
+
GPURenderPassEncoderImpl::GPURenderPassEncoderImpl(const CanvasGPURenderPassEncoder *pass) : pass_(
|
|
14
|
+
pass) {}
|
|
15
|
+
|
|
16
|
+
const CanvasGPURenderPassEncoder *GPURenderPassEncoderImpl::GetPass() {
|
|
17
|
+
return this->pass_;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
void GPURenderPassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
22
|
+
v8::Locker locker(isolate);
|
|
23
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
24
|
+
v8::HandleScope handle_scope(isolate);
|
|
25
|
+
|
|
26
|
+
auto ctor = GetCtor(isolate);
|
|
27
|
+
auto context = isolate->GetCurrentContext();
|
|
28
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
29
|
+
|
|
30
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"), func).FromJust();;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
GPURenderPassEncoderImpl *
|
|
34
|
+
GPURenderPassEncoderImpl::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<GPURenderPassEncoderImpl *>(ptr);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *isolate) {
|
|
43
|
+
auto cache = Caches::Get(isolate);
|
|
44
|
+
auto ctor = cache->GPURenderPassEncoderTmpl.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, "GPURenderPassEncoder"));
|
|
52
|
+
|
|
53
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
54
|
+
tmpl->SetInternalFieldCount(2);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
tmpl->Set(
|
|
58
|
+
ConvertToV8String(isolate, "beginOcclusionQuery"),
|
|
59
|
+
v8::FunctionTemplate::New(isolate, &BeginOcclusionQuery));
|
|
60
|
+
|
|
61
|
+
tmpl->Set(
|
|
62
|
+
ConvertToV8String(isolate, "draw"),
|
|
63
|
+
v8::FunctionTemplate::New(isolate, &Draw));
|
|
64
|
+
|
|
65
|
+
tmpl->Set(
|
|
66
|
+
ConvertToV8String(isolate, "drawIndexed"),
|
|
67
|
+
v8::FunctionTemplate::New(isolate, &DrawIndexed));
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
tmpl->Set(
|
|
71
|
+
ConvertToV8String(isolate, "drawIndexedIndirect"),
|
|
72
|
+
v8::FunctionTemplate::New(isolate, &DrawIndexedIndirect));
|
|
73
|
+
|
|
74
|
+
tmpl->Set(
|
|
75
|
+
ConvertToV8String(isolate, "drawIndirect"),
|
|
76
|
+
v8::FunctionTemplate::New(isolate, &DrawIndirect));
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
tmpl->Set(
|
|
80
|
+
ConvertToV8String(isolate, "end"),
|
|
81
|
+
v8::FunctionTemplate::New(isolate, &End));
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
tmpl->Set(
|
|
85
|
+
ConvertToV8String(isolate, "endOcclusionQuery"),
|
|
86
|
+
v8::FunctionTemplate::New(isolate, &EndOcclusionQuery));
|
|
87
|
+
|
|
88
|
+
tmpl->Set(
|
|
89
|
+
ConvertToV8String(isolate, "executeBundles"),
|
|
90
|
+
v8::FunctionTemplate::New(isolate, &ExecuteBundles));
|
|
91
|
+
|
|
92
|
+
tmpl->Set(
|
|
93
|
+
ConvertToV8String(isolate, "insertDebugMarker"),
|
|
94
|
+
v8::FunctionTemplate::New(isolate, &InsertDebugMarker));
|
|
95
|
+
|
|
96
|
+
tmpl->Set(
|
|
97
|
+
ConvertToV8String(isolate, "popDebugGroup"),
|
|
98
|
+
v8::FunctionTemplate::New(isolate, &PopDebugGroup));
|
|
99
|
+
|
|
100
|
+
tmpl->Set(
|
|
101
|
+
ConvertToV8String(isolate, "pushDebugGroup"),
|
|
102
|
+
v8::FunctionTemplate::New(isolate, &PushDebugGroup));
|
|
103
|
+
|
|
104
|
+
tmpl->Set(
|
|
105
|
+
ConvertToV8String(isolate, "setBindGroup"),
|
|
106
|
+
v8::FunctionTemplate::New(isolate, &SetBindGroup));
|
|
107
|
+
|
|
108
|
+
tmpl->Set(
|
|
109
|
+
ConvertToV8String(isolate, "setBlendConstant"),
|
|
110
|
+
v8::FunctionTemplate::New(isolate, &SetBlendConstant));
|
|
111
|
+
|
|
112
|
+
tmpl->Set(
|
|
113
|
+
ConvertToV8String(isolate, "setIndexBuffer"),
|
|
114
|
+
v8::FunctionTemplate::New(isolate, &SetIndexBuffer));
|
|
115
|
+
|
|
116
|
+
tmpl->Set(
|
|
117
|
+
ConvertToV8String(isolate, "setPipeline"),
|
|
118
|
+
v8::FunctionTemplate::New(isolate, &SetPipeline));
|
|
119
|
+
|
|
120
|
+
tmpl->Set(
|
|
121
|
+
ConvertToV8String(isolate, "setScissorRect"),
|
|
122
|
+
v8::FunctionTemplate::New(isolate, &SetScissorRect));
|
|
123
|
+
|
|
124
|
+
tmpl->Set(
|
|
125
|
+
ConvertToV8String(isolate, "setStencilReference"),
|
|
126
|
+
v8::FunctionTemplate::New(isolate, &SetStencilReference));
|
|
127
|
+
|
|
128
|
+
tmpl->Set(
|
|
129
|
+
ConvertToV8String(isolate, "setVertexBuffer"),
|
|
130
|
+
v8::FunctionTemplate::New(isolate, &SetVertexBuffer));
|
|
131
|
+
|
|
132
|
+
tmpl->Set(
|
|
133
|
+
ConvertToV8String(isolate, "setViewport"),
|
|
134
|
+
v8::FunctionTemplate::New(isolate, &SetViewport));
|
|
135
|
+
|
|
136
|
+
cache->GPURenderPassEncoderTmpl =
|
|
137
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
138
|
+
return ctorTmpl;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
void
|
|
143
|
+
GPURenderPassEncoderImpl::BeginOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
144
|
+
auto *ptr = GetPointer(args.This());
|
|
145
|
+
if (ptr == nullptr) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
auto isolate = args.GetIsolate();
|
|
149
|
+
auto context = isolate->GetCurrentContext();
|
|
150
|
+
|
|
151
|
+
auto queryIndexVal = args[0];
|
|
152
|
+
if (queryIndexVal->IsUint32()) {
|
|
153
|
+
auto queryIndex = queryIndexVal->Uint32Value(context).FromJust();
|
|
154
|
+
canvas_native_webgpu_render_pass_encoder_begin_occlusion_query(ptr->GetPass(), queryIndex);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
void GPURenderPassEncoderImpl::Draw(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
160
|
+
auto *ptr = GetPointer(args.This());
|
|
161
|
+
if (ptr == nullptr) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
auto vertexCountVal = args[0];
|
|
166
|
+
auto instanceCountVal = args[1];
|
|
167
|
+
uint32_t instanceCount = 1;
|
|
168
|
+
uint32_t firstVertex = 0;
|
|
169
|
+
uint32_t firstInstance = 0;
|
|
170
|
+
auto firstVertexVal = args[2];
|
|
171
|
+
auto firstInstanceVal = args[3];
|
|
172
|
+
|
|
173
|
+
if (vertexCountVal->IsUint32()) {
|
|
174
|
+
auto vertexCount = vertexCountVal.As<v8::Uint32>()->Value();
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if (instanceCountVal->IsUint32()) {
|
|
178
|
+
instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (firstVertexVal->IsUint32()) {
|
|
182
|
+
firstVertex = firstVertexVal.As<v8::Uint32>()->Value();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (firstInstanceVal->IsUint32()) {
|
|
186
|
+
firstInstance = firstInstanceVal.As<v8::Uint32>()->Value();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
canvas_native_webgpu_render_pass_encoder_draw(ptr->GetPass(), vertexCount, instanceCount,
|
|
190
|
+
firstVertex, firstInstance);
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
196
|
+
auto *ptr = GetPointer(args.This());
|
|
197
|
+
if (ptr == nullptr) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
auto isolate = args.GetIsolate();
|
|
202
|
+
auto context = isolate->GetCurrentContext();
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
uint32_t instanceCount = 1;
|
|
206
|
+
uint32_t firstIndex = 0;
|
|
207
|
+
int32_t baseVertex = 0;
|
|
208
|
+
uint32_t firstInstance = 0;
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
auto indexCountVal = args[0];
|
|
212
|
+
auto firstIndexVal = args[1];
|
|
213
|
+
auto baseVertexVal = args[2];
|
|
214
|
+
auto firstInstanceVal = args[3];
|
|
215
|
+
|
|
216
|
+
if (indexCountVal->IsUint32()) {
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
if (firstIndexVal->IsUint32()) {
|
|
220
|
+
firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (baseVertexVal->IsInt32()) {
|
|
224
|
+
baseVertex = baseVertexVal.As<v8::Int32>()->Value();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (firstInstanceVal->IsUint32()) {
|
|
228
|
+
firstInstance = firstInstanceVal.As<v8::Uint32>()->Value();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
canvas_native_webgpu_render_pass_encoder_draw_indexed(ptr->GetPass(),
|
|
232
|
+
indexCountVal->Uint32Value(
|
|
233
|
+
context).FromJust(),
|
|
234
|
+
instanceCount, firstIndex,
|
|
235
|
+
baseVertex,
|
|
236
|
+
firstInstance);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void
|
|
243
|
+
GPURenderPassEncoderImpl::DrawIndexedIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
244
|
+
auto *ptr = GetPointer(args.This());
|
|
245
|
+
if (ptr == nullptr) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
auto isolate = args.GetIsolate();
|
|
250
|
+
auto context = isolate->GetCurrentContext();
|
|
251
|
+
|
|
252
|
+
auto indirectBufferVal = args[0];
|
|
253
|
+
auto indirectOffsetVal = args[1];
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
auto indirectBufferType = GetNativeType(indirectBufferVal);
|
|
257
|
+
|
|
258
|
+
if (indirectBufferType == NativeType::GPUBuffer) {
|
|
259
|
+
auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
|
|
260
|
+
uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
|
|
261
|
+
canvas_native_webgpu_render_pass_encoder_draw_indexed_indirect(ptr->GetPass(),
|
|
262
|
+
indirectBuffer->GetGPUBuffer(),
|
|
263
|
+
offset);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
void
|
|
270
|
+
GPURenderPassEncoderImpl::DrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
271
|
+
auto *ptr = GetPointer(args.This());
|
|
272
|
+
if (ptr == nullptr) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
auto isolate = args.GetIsolate();
|
|
277
|
+
auto context = isolate->GetCurrentContext();
|
|
278
|
+
|
|
279
|
+
auto indirectBufferVal = args[0];
|
|
280
|
+
auto indirectOffsetVal = args[1];
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
auto indirectBufferType = GetNativeType(indirectBufferVal);
|
|
284
|
+
|
|
285
|
+
if (indirectBufferType == NativeType::GPUBuffer) {
|
|
286
|
+
auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
|
|
287
|
+
uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
|
|
288
|
+
canvas_native_webgpu_render_pass_encoder_draw_indirect(ptr->GetPass(),
|
|
289
|
+
indirectBuffer->GetGPUBuffer(),
|
|
290
|
+
offset);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
void GPURenderPassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
297
|
+
auto *ptr = GetPointer(args.This());
|
|
298
|
+
if (ptr == nullptr) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
canvas_native_webgpu_render_pass_encoder_end(ptr->GetPass());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void GPURenderPassEncoderImpl::EndOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
306
|
+
auto *ptr = GetPointer(args.This());
|
|
307
|
+
if (ptr == nullptr) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
canvas_native_webgpu_render_pass_encoder_end_occlusion_query(ptr->GetPass());
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
void GPURenderPassEncoderImpl::ExecuteBundles(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
315
|
+
auto *ptr = GetPointer(args.This());
|
|
316
|
+
if (ptr == nullptr) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
auto isolate = args.GetIsolate();
|
|
321
|
+
auto context = isolate->GetCurrentContext();
|
|
322
|
+
|
|
323
|
+
auto bundlesVal = args[0];
|
|
324
|
+
if (bundlesVal->IsArray()) {
|
|
325
|
+
auto bundlesArray = bundlesVal.As<v8::Array>();
|
|
326
|
+
auto len = bundlesArray->Length();
|
|
327
|
+
std::vector<const CanvasGPURenderBundle *> bundles;
|
|
328
|
+
for (int i = 0; i < len; i++) {
|
|
329
|
+
v8::Local<v8::Value> bundleVal;
|
|
330
|
+
bundlesArray->Get(context, i).ToLocal(&bundlesVal);
|
|
331
|
+
auto type = GetNativeType(bundleVal);
|
|
332
|
+
if (type == NativeType::GPURenderBundle) {
|
|
333
|
+
auto bundle = GPURenderBundleImpl::GetPointer(bundleVal.As<v8::Object>());
|
|
334
|
+
bundles.emplace_back(bundle->GetBundle());
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (!bundles.empty()) {
|
|
339
|
+
canvas_native_webgpu_render_pass_encoder_execute_bundles(ptr->GetPass(), bundles.data(),
|
|
340
|
+
bundles.size());
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
void
|
|
348
|
+
GPURenderPassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
349
|
+
auto *ptr = GetPointer(args.This());
|
|
350
|
+
if (ptr == nullptr) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
auto isolate = args.GetIsolate();
|
|
355
|
+
|
|
356
|
+
auto markerLabelVal = args[0];
|
|
357
|
+
if (markerLabelVal->IsString()) {
|
|
358
|
+
auto markerLabel = ConvertFromV8String(isolate, markerLabelVal);
|
|
359
|
+
canvas_native_webgpu_render_pass_encoder_insert_debug_marker(ptr->GetPass(),
|
|
360
|
+
markerLabel.c_str());
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
void GPURenderPassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
365
|
+
auto *ptr = GetPointer(args.This());
|
|
366
|
+
if (ptr == nullptr) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
canvas_native_webgpu_render_pass_encoder_pop_debug_group(ptr->GetPass());
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
void GPURenderPassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
374
|
+
auto *ptr = GetPointer(args.This());
|
|
375
|
+
if (ptr == nullptr) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
auto isolate = args.GetIsolate();
|
|
380
|
+
|
|
381
|
+
auto groupLabelVal = args[0];
|
|
382
|
+
if (groupLabelVal->IsString()) {
|
|
383
|
+
auto groupLabel = ConvertFromV8String(isolate, groupLabelVal);
|
|
384
|
+
canvas_native_webgpu_render_pass_encoder_push_debug_group(ptr->GetPass(),
|
|
385
|
+
groupLabel.c_str());
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
390
|
+
auto *ptr = GetPointer(args.This());
|
|
391
|
+
if (ptr == nullptr) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
auto isolate = args.GetIsolate();
|
|
396
|
+
auto context = isolate->GetCurrentContext();
|
|
397
|
+
|
|
398
|
+
auto indexVal = args[0];
|
|
399
|
+
auto bindGroupVal = args[1];
|
|
400
|
+
auto dynamicOffsets = args[2];
|
|
401
|
+
auto dynamicOffsetsStart = args[3];
|
|
402
|
+
auto dynamicOffsetsLength = args[4];
|
|
403
|
+
|
|
404
|
+
auto type = GetNativeType(bindGroupVal);
|
|
405
|
+
|
|
406
|
+
if (type == NativeType::GPUBindGroup) {
|
|
407
|
+
auto index = indexVal->Uint32Value(context).FromJust();
|
|
408
|
+
auto bindgroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
409
|
+
|
|
410
|
+
if (dynamicOffsets->IsUint8Array()) {
|
|
411
|
+
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
412
|
+
auto buffer = buf->Buffer();
|
|
413
|
+
auto store = buffer->GetBackingStore();
|
|
414
|
+
auto offset = buf->ByteOffset();
|
|
415
|
+
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
416
|
+
auto size = buf->Length();
|
|
417
|
+
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
418
|
+
auto offset_length = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
419
|
+
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
420
|
+
bindgroup->GetBindGroup(),
|
|
421
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
422
|
+
size, start, offset_length);
|
|
423
|
+
} else {
|
|
424
|
+
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
425
|
+
bindgroup->GetBindGroup(),
|
|
426
|
+
nullptr, 0, 0, 0);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
432
|
+
auto *ptr = GetPointer(args.This());
|
|
433
|
+
if (ptr == nullptr) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
auto isolate = args.GetIsolate();
|
|
438
|
+
auto context = isolate->GetCurrentContext();
|
|
439
|
+
|
|
440
|
+
auto bufferVal = args[0];
|
|
441
|
+
auto indexFormatVal = args[1];
|
|
442
|
+
int64_t offset = -1;
|
|
443
|
+
int64_t size = -1;
|
|
444
|
+
auto offsetVal = args[2];
|
|
445
|
+
auto sizeVal = args[3];
|
|
446
|
+
|
|
447
|
+
auto type = GetNativeType(bufferVal);
|
|
448
|
+
|
|
449
|
+
if (type == NativeType::GPURenderBundleEncoder) {
|
|
450
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
451
|
+
auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
|
|
452
|
+
if (offsetVal->IsNumber()) {
|
|
453
|
+
offset = (int64_t) offsetVal.As<v8::Number>()->Value();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (sizeVal->IsNumber()) {
|
|
457
|
+
size = (int64_t) sizeVal.As<v8::Number>()->Value();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (indexFormat == "uint16") {
|
|
461
|
+
canvas_native_webgpu_render_pass_encoder_set_index_buffer(ptr->GetPass(),
|
|
462
|
+
buffer->GetGPUBuffer(),
|
|
463
|
+
CanvasIndexFormatUint16,
|
|
464
|
+
offset,
|
|
465
|
+
size);
|
|
466
|
+
} else if (indexFormat == "uint32") {
|
|
467
|
+
canvas_native_webgpu_render_pass_encoder_set_index_buffer(ptr->GetPass(),
|
|
468
|
+
buffer->GetGPUBuffer(),
|
|
469
|
+
CanvasIndexFormatUint32,
|
|
470
|
+
offset,
|
|
471
|
+
size);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
void GPURenderPassEncoderImpl::SetBlendConstant(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
479
|
+
auto *ptr = GetPointer(args.This());
|
|
480
|
+
if (ptr == nullptr) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
auto isolate = args.GetIsolate();
|
|
485
|
+
auto context = isolate->GetCurrentContext();
|
|
486
|
+
|
|
487
|
+
auto colorVal = args[0];
|
|
488
|
+
|
|
489
|
+
if (colorVal->IsObject()) {
|
|
490
|
+
|
|
491
|
+
auto color = CanvasColor{0, 0, 0, 0};
|
|
492
|
+
auto colorObj = colorVal.As<v8::Object>();
|
|
493
|
+
|
|
494
|
+
v8::Local<v8::Value> r;
|
|
495
|
+
v8::Local<v8::Value> g;
|
|
496
|
+
v8::Local<v8::Value> b;
|
|
497
|
+
v8::Local<v8::Value> a;
|
|
498
|
+
|
|
499
|
+
colorObj->Get(context, ConvertToV8String(isolate, "r")).ToLocal(&r);
|
|
500
|
+
colorObj->Get(context, ConvertToV8String(isolate, "g")).ToLocal(&g);
|
|
501
|
+
colorObj->Get(context, ConvertToV8String(isolate, "b")).ToLocal(&b);
|
|
502
|
+
colorObj->Get(context, ConvertToV8String(isolate, "a")).ToLocal(&a);
|
|
503
|
+
|
|
504
|
+
if (!r.IsEmpty() && r->IsNumber()) {
|
|
505
|
+
color.r = r.As<v8::Number>()->Value();
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!g.IsEmpty() && g->IsNumber()) {
|
|
509
|
+
color.g = g.As<v8::Number>()->Value();
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
if (!b.IsEmpty() && b->IsNumber()) {
|
|
514
|
+
color.b = b.As<v8::Number>()->Value();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (!a.IsEmpty() && a->IsNumber()) {
|
|
518
|
+
color.a = a.As<v8::Number>()->Value();
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
canvas_native_webgpu_render_pass_encoder_set_blend_constant(ptr->GetPass(), &color);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
527
|
+
auto *ptr = GetPointer(args.This());
|
|
528
|
+
if (ptr == nullptr) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
auto pipelineVal = args[0];
|
|
533
|
+
if (pipelineVal->IsObject()) {
|
|
534
|
+
auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
|
|
535
|
+
if (pipeline != nullptr) {
|
|
536
|
+
canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
|
|
537
|
+
pipeline->GetGPUPipeline());
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
void GPURenderPassEncoderImpl::SetScissorRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
543
|
+
auto *ptr = GetPointer(args.This());
|
|
544
|
+
if (ptr == nullptr) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
auto x = args[0];
|
|
549
|
+
auto y = args[1];
|
|
550
|
+
auto width = args[2];
|
|
551
|
+
auto height = args[3];
|
|
552
|
+
|
|
553
|
+
auto isolate = args.GetIsolate();
|
|
554
|
+
auto context = isolate->GetCurrentContext();
|
|
555
|
+
|
|
556
|
+
canvas_native_webgpu_render_pass_encoder_set_scissor_rect(ptr->GetPass(),
|
|
557
|
+
x->Uint32Value(context).FromJust(),
|
|
558
|
+
y->Uint32Value(context).FromJust(),
|
|
559
|
+
width->Uint32Value(
|
|
560
|
+
context).FromJust(),
|
|
561
|
+
height->Uint32Value(
|
|
562
|
+
context).FromJust());
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
void
|
|
566
|
+
GPURenderPassEncoderImpl::SetStencilReference(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
567
|
+
auto *ptr = GetPointer(args.This());
|
|
568
|
+
if (ptr == nullptr) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
auto isolate = args.GetIsolate();
|
|
572
|
+
auto context = isolate->GetCurrentContext();
|
|
573
|
+
|
|
574
|
+
auto reference = args[0];
|
|
575
|
+
|
|
576
|
+
if (reference->IsUint32()) {
|
|
577
|
+
canvas_native_webgpu_render_pass_encoder_set_stencil_reference(ptr->GetPass(),
|
|
578
|
+
reference->Uint32Value(
|
|
579
|
+
context).FromJust());
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
587
|
+
auto *ptr = GetPointer(args.This());
|
|
588
|
+
if (ptr == nullptr) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
auto slotVal = args[0];
|
|
593
|
+
auto bufferVal = args[1];
|
|
594
|
+
int64_t offset = -1;
|
|
595
|
+
int64_t size = -1;
|
|
596
|
+
auto offsetVal = args[2];
|
|
597
|
+
auto sizeVal = args[3];
|
|
598
|
+
|
|
599
|
+
if (slotVal->IsUint32() && bufferVal->IsObject()) {
|
|
600
|
+
auto slot = slotVal.As<v8::Uint32>()->Value();
|
|
601
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
602
|
+
if (buffer == nullptr) {
|
|
603
|
+
// todo throw ??
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if (offsetVal->IsNumber()) {
|
|
608
|
+
offset = (int64_t) offsetVal.As<v8::Number>()->Value();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (sizeVal->IsNumber()) {
|
|
612
|
+
size = (int64_t) sizeVal.As<v8::Number>()->Value();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
canvas_native_webgpu_render_pass_encoder_set_vertex_buffer(ptr->GetPass(), slot,
|
|
616
|
+
buffer->GetGPUBuffer(), offset,
|
|
617
|
+
size);
|
|
618
|
+
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
void GPURenderPassEncoderImpl::SetViewport(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
623
|
+
auto *ptr = GetPointer(args.This());
|
|
624
|
+
if (ptr == nullptr) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
auto x = args[0];
|
|
629
|
+
auto y = args[1];
|
|
630
|
+
auto width = args[2];
|
|
631
|
+
auto height = args[3];
|
|
632
|
+
|
|
633
|
+
auto minDepth = args[4];
|
|
634
|
+
auto maxDepth = args[5];
|
|
635
|
+
|
|
636
|
+
auto isolate = args.GetIsolate();
|
|
637
|
+
auto context = isolate->GetCurrentContext();
|
|
638
|
+
|
|
639
|
+
canvas_native_webgpu_render_pass_encoder_set_viewport(ptr->GetPass(),
|
|
640
|
+
(float) x->NumberValue(
|
|
641
|
+
context).FromJust(),
|
|
642
|
+
(float) y->NumberValue(
|
|
643
|
+
context).FromJust(),
|
|
644
|
+
(float) width->NumberValue(
|
|
645
|
+
context).FromJust(),
|
|
646
|
+
(float) height->NumberValue(
|
|
647
|
+
context).FromJust(),
|
|
648
|
+
(float) minDepth->NumberValue(
|
|
649
|
+
context).FromJust(),
|
|
650
|
+
(float) maxDepth->NumberValue(
|
|
651
|
+
context).FromJust());
|
|
652
|
+
|
|
653
|
+
}
|