@nativescript/canvas 2.0.0-webgpu.3 → 2.0.0-webgpu.31
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 +4 -9
- package/Canvas/common.js +37 -126
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +0 -1
- package/Canvas/index.android.js +45 -38
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +11 -3
- package/Canvas/index.ios.js +49 -40
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas/utils.d.ts +3 -0
- package/Canvas/utils.js +85 -0
- package/Canvas/utils.js.map +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.js +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Dom/Group.d.ts +1 -2
- package/Dom/Group.js.map +1 -1
- package/Dom/Image.js +0 -1
- package/Dom/Image.js.map +1 -1
- package/Dom/Paint.d.ts +1 -1
- package/Dom/shapes/Path.d.ts +1 -1
- package/ImageAsset/index.js +77 -33
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.js +107 -20
- package/ImageBitmap/index.js.map +1 -1
- package/README.md +2 -4
- package/WebGL/WebGLRenderingContext/index.js +74 -31
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +4 -4
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/GPU.js +4 -3
- package/WebGPU/GPU.js.map +1 -1
- package/WebGPU/GPUAdapter.d.ts +6 -3
- package/WebGPU/GPUAdapter.js +31 -0
- package/WebGPU/GPUAdapter.js.map +1 -1
- package/WebGPU/GPUBindGroup.d.ts +1 -0
- package/WebGPU/GPUBindGroup.js +3 -0
- package/WebGPU/GPUBindGroup.js.map +1 -1
- package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
- package/WebGPU/GPUBindGroupLayout.js +3 -0
- package/WebGPU/GPUBindGroupLayout.js.map +1 -1
- package/WebGPU/GPUBuffer.js +10 -2
- package/WebGPU/GPUBuffer.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +3 -2
- package/WebGPU/GPUCanvasContext.js +52 -10
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandBuffer.d.ts +1 -0
- package/WebGPU/GPUCommandBuffer.js +3 -0
- package/WebGPU/GPUCommandBuffer.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.d.ts +3 -9
- package/WebGPU/GPUCommandEncoder.js +94 -41
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
- package/WebGPU/GPUComputePassEncoder.js +3 -0
- package/WebGPU/GPUComputePassEncoder.js.map +1 -1
- package/WebGPU/GPUComputePipeline.d.ts +1 -0
- package/WebGPU/GPUComputePipeline.js +3 -0
- package/WebGPU/GPUComputePipeline.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +17 -79
- package/WebGPU/GPUDevice.js +76 -91
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUExternalTexture.d.ts +1 -0
- package/WebGPU/GPUExternalTexture.js +3 -0
- package/WebGPU/GPUExternalTexture.js.map +1 -1
- package/WebGPU/GPUPipelineLayout.d.ts +1 -0
- package/WebGPU/GPUPipelineLayout.js +3 -0
- package/WebGPU/GPUPipelineLayout.js.map +1 -1
- package/WebGPU/GPUQuerySet.d.ts +1 -0
- package/WebGPU/GPUQuerySet.js +3 -0
- package/WebGPU/GPUQuerySet.js.map +1 -1
- package/WebGPU/GPUQueue.d.ts +1 -0
- package/WebGPU/GPUQueue.js +56 -14
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderBundle.d.ts +1 -0
- package/WebGPU/GPURenderBundle.js +3 -0
- package/WebGPU/GPURenderBundle.js.map +1 -1
- package/WebGPU/GPURenderBundleEncoder.d.ts +4 -2
- package/WebGPU/GPURenderBundleEncoder.js +7 -3
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.d.ts +2 -1
- package/WebGPU/GPURenderPassEncoder.js +5 -2
- package/WebGPU/GPURenderPassEncoder.js.map +1 -1
- package/WebGPU/GPURenderPipeline.d.ts +1 -0
- package/WebGPU/GPURenderPipeline.js +3 -0
- package/WebGPU/GPURenderPipeline.js.map +1 -1
- package/WebGPU/GPUSampler.d.ts +1 -0
- package/WebGPU/GPUSampler.js +3 -0
- package/WebGPU/GPUSampler.js.map +1 -1
- package/WebGPU/GPUShaderModule.d.ts +1 -1
- package/WebGPU/GPUShaderModule.js +2 -2
- package/WebGPU/GPUShaderModule.js.map +1 -1
- package/WebGPU/GPUTexture.d.ts +1 -0
- package/WebGPU/GPUTexture.js +3 -0
- package/WebGPU/GPUTexture.js.map +1 -1
- package/WebGPU/GPUTextureView.d.ts +1 -0
- package/WebGPU/GPUTextureView.js +3 -0
- package/WebGPU/GPUTextureView.js.map +1 -1
- package/WebGPU/Interfaces.d.ts +95 -4
- package/WebGPU/Types.d.ts +9 -1
- package/WebGPU/Utils.d.ts +6 -0
- package/WebGPU/Utils.js +224 -0
- package/WebGPU/Utils.js.map +1 -1
- package/angular/esm2022/index.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
- package/package.json +1 -1
- 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 +40 -12
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +227 -62
- 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 +7341 -6577
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +62 -4
- 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 +62 -4
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +650 -644
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +80 -24
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +227 -62
- 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 +7341 -6577
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +62 -4
- 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 +62 -4
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +7341 -6577
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +62 -4
- 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 +62 -4
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +27 -27
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +652 -646
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +704 -684
- package/platforms/ios/src/NSOperationQueueWrapper.h +1 -1
- package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
- package/platforms/ios/src/cpp/AsyncCallback.h +16 -8
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +208 -789
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +18 -28
- package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +10 -3
- package/platforms/ios/src/cpp/PromiseCallback.h +1 -2
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +3 -3
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +26 -23
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +31 -5
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +41 -7
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +28 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +75 -79
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -14
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1597 -674
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +2 -1
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -2
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +50 -13
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +43 -14
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +39 -13
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +24 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
- package/utils.d.ts +1 -1
|
@@ -7,6 +7,517 @@
|
|
|
7
7
|
|
|
8
8
|
#include "Common.h"
|
|
9
9
|
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
#include "GPUSamplerImpl.h"
|
|
12
|
+
#include "GPUTextureViewImpl.h"
|
|
13
|
+
#include "GPUBufferImpl.h"
|
|
14
|
+
|
|
15
|
+
inline static CanvasStoreOp
|
|
16
|
+
ParseCanvasStoreOp(v8::Isolate *isolate, const v8::Local<v8::Value> &obj){
|
|
17
|
+
auto ret = CanvasStoreOp::CanvasStoreOpStore;
|
|
18
|
+
if(!obj.IsEmpty()){
|
|
19
|
+
if (obj->IsUint32()) {
|
|
20
|
+
ret = (CanvasStoreOp) obj->Uint32Value(isolate->GetCurrentContext()).ToChecked();
|
|
21
|
+
} else if (obj->IsString()) {
|
|
22
|
+
auto val = ConvertFromV8String(isolate, obj);
|
|
23
|
+
if (val == "discard") {
|
|
24
|
+
ret = CanvasStoreOp::CanvasStoreOpDiscard;
|
|
25
|
+
} else if (val == "store") {
|
|
26
|
+
ret = CanvasStoreOp::CanvasStoreOpStore;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return ret;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
inline static CanvasLoadOp
|
|
34
|
+
ParseCanvasLoadOp(v8::Isolate *isolate, const v8::Local<v8::Value> &obj){
|
|
35
|
+
auto ret = CanvasLoadOp::CanvasLoadOpClear;
|
|
36
|
+
if(!obj.IsEmpty()){
|
|
37
|
+
if (obj->IsUint32()) {
|
|
38
|
+
ret = (CanvasLoadOp) obj->Uint32Value(isolate->GetCurrentContext()).ToChecked();
|
|
39
|
+
} else if (obj->IsString()) {
|
|
40
|
+
auto val = ConvertFromV8String(isolate, obj);
|
|
41
|
+
if (val == "clear") {
|
|
42
|
+
ret = CanvasLoadOp::CanvasLoadOpClear;
|
|
43
|
+
} else if (val == "load") {
|
|
44
|
+
ret = CanvasLoadOp::CanvasLoadOpLoad;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
inline static std::vector<CanvasBindGroupEntry>
|
|
52
|
+
ParseBindGroupEntries(v8::Isolate *isolate, const v8::Local<v8::Value> &obj) {
|
|
53
|
+
std::vector<CanvasBindGroupEntry> entries;
|
|
54
|
+
|
|
55
|
+
if (!obj.IsEmpty() && obj->IsArray()) {
|
|
56
|
+
auto context = isolate->GetCurrentContext();
|
|
57
|
+
auto entriesArray = obj.As<v8::Array>();
|
|
58
|
+
auto len = entriesArray->Length();
|
|
59
|
+
for (int i = 0; i < len; i++) {
|
|
60
|
+
v8::Local<v8::Value> entryVal;
|
|
61
|
+
entriesArray->Get(context, i).ToLocal(&entryVal);
|
|
62
|
+
if (!entryVal.IsEmpty() && entryVal->IsObject()) {
|
|
63
|
+
auto entryObj = entryVal.As<v8::Object>();
|
|
64
|
+
auto binding = entryObj->Get(context, ConvertToV8String(isolate,
|
|
65
|
+
"binding")).ToLocalChecked()->Uint32Value(
|
|
66
|
+
context).FromJust();
|
|
67
|
+
v8::Local<v8::Value> resourceVal;
|
|
68
|
+
entryObj->Get(context, ConvertToV8String(isolate, "resource")).ToLocal(
|
|
69
|
+
&resourceVal);
|
|
70
|
+
|
|
71
|
+
auto resourceType = ObjectWrapperImpl::GetNativeType(resourceVal);
|
|
72
|
+
switch (resourceType) {
|
|
73
|
+
case NativeType::GPUSampler: {
|
|
74
|
+
auto sampler = GPUSamplerImpl::GetPointer(resourceVal.As<v8::Object>());
|
|
75
|
+
if (sampler != nullptr) {
|
|
76
|
+
auto resource = CanvasBindGroupEntryResource{
|
|
77
|
+
CanvasBindGroupEntryResourceSampler,
|
|
78
|
+
};
|
|
79
|
+
resource.sampler = sampler->GetSampler();
|
|
80
|
+
CanvasBindGroupEntry entry{binding, resource};
|
|
81
|
+
entries.push_back(entry);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case NativeType::GPUTextureView: {
|
|
86
|
+
auto textureView = GPUTextureViewImpl::GetPointer(
|
|
87
|
+
resourceVal.As<v8::Object>());
|
|
88
|
+
if (textureView != nullptr) {
|
|
89
|
+
auto resource = CanvasBindGroupEntryResource{
|
|
90
|
+
CanvasBindGroupEntryResourceTextureView,
|
|
91
|
+
};
|
|
92
|
+
resource.texture_view = textureView->GetTextureView();
|
|
93
|
+
CanvasBindGroupEntry entry{binding, resource};
|
|
94
|
+
entries.push_back(entry);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
default: {
|
|
99
|
+
if (!resourceVal.IsEmpty() && resourceVal->IsObject()) {
|
|
100
|
+
auto resourceObj = resourceVal.As<v8::Object>();
|
|
101
|
+
v8::Local<v8::Value> bufferVal;
|
|
102
|
+
resourceObj->Get(context,
|
|
103
|
+
ConvertToV8String(isolate, "buffer")).ToLocal(
|
|
104
|
+
&bufferVal);
|
|
105
|
+
if (ObjectWrapperImpl::GetNativeType(bufferVal) ==
|
|
106
|
+
NativeType::GPUBuffer) {
|
|
107
|
+
auto bufferObj = bufferVal.As<v8::Object>();
|
|
108
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferObj);
|
|
109
|
+
if (buffer != nullptr) {
|
|
110
|
+
auto resource = CanvasBindGroupEntryResource{
|
|
111
|
+
CanvasBindGroupEntryResourceBuffer,
|
|
112
|
+
};
|
|
113
|
+
int64_t offset = -1;
|
|
114
|
+
|
|
115
|
+
v8::Local<v8::Value> offsetVal;
|
|
116
|
+
|
|
117
|
+
resourceObj->Get(context,
|
|
118
|
+
ConvertToV8String(isolate,
|
|
119
|
+
"offset")).ToLocal(
|
|
120
|
+
&offsetVal);
|
|
121
|
+
if (!offsetVal.IsEmpty() && offsetVal->IsNumber()) {
|
|
122
|
+
offset = (int64_t) offsetVal->NumberValue(
|
|
123
|
+
context).ToChecked();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
int64_t size = -1;
|
|
127
|
+
|
|
128
|
+
v8::Local<v8::Value> sizeVal;
|
|
129
|
+
resourceObj->Get(context,
|
|
130
|
+
ConvertToV8String(isolate,
|
|
131
|
+
"size")).ToLocal(
|
|
132
|
+
&sizeVal);
|
|
133
|
+
if (!sizeVal.IsEmpty() && sizeVal->IsNumber()) {
|
|
134
|
+
size = (int64_t) sizeVal->NumberValue(
|
|
135
|
+
context).ToChecked();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
resource.buffer = CanvasBufferBinding{
|
|
139
|
+
buffer->GetGPUBuffer(), offset, size
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
CanvasBindGroupEntry entry{binding, resource};
|
|
143
|
+
entries.push_back(entry);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return entries;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
inline static std::vector<CanvasBindGroupLayoutEntry>
|
|
159
|
+
ParseBindGroupLayoutEntries(v8::Isolate *isolate, const v8::Local<v8::Value> &obj) {
|
|
160
|
+
std::vector<CanvasBindGroupLayoutEntry> entries;
|
|
161
|
+
|
|
162
|
+
if (!obj.IsEmpty() && obj->IsArray()) {
|
|
163
|
+
auto entriesArray = obj.As<v8::Array>();
|
|
164
|
+
auto context = isolate->GetCurrentContext();
|
|
165
|
+
auto len = entriesArray->Length();
|
|
166
|
+
for (int i = 0; i < len; i++) {
|
|
167
|
+
v8::Local<v8::Value> entryVal;
|
|
168
|
+
entriesArray->Get(context, i).ToLocal(&entryVal);
|
|
169
|
+
if (!entryVal.IsEmpty() && entryVal->IsObject()) {
|
|
170
|
+
auto entryObj = entryVal.As<v8::Object>();
|
|
171
|
+
auto binding = entryObj->Get(context, ConvertToV8String(isolate,
|
|
172
|
+
"binding")).ToLocalChecked()->Uint32Value(
|
|
173
|
+
context).FromJust();
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
auto visibility = entryObj->Get(context, ConvertToV8String(isolate,
|
|
177
|
+
"visibility")).ToLocalChecked()->Uint32Value(
|
|
178
|
+
context).FromJust();
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
v8::Local<v8::Value> bufferVal;
|
|
182
|
+
|
|
183
|
+
entryObj->Get(context, ConvertToV8String(isolate, "buffer")).ToLocal(
|
|
184
|
+
&bufferVal);
|
|
185
|
+
|
|
186
|
+
if (!bufferVal.IsEmpty() && bufferVal->IsObject()) {
|
|
187
|
+
auto bufferObj = bufferVal.As<v8::Object>();
|
|
188
|
+
v8::Local<v8::Value> bufferType;
|
|
189
|
+
bufferObj->Get(context, ConvertToV8String(isolate, "type")).ToLocal(
|
|
190
|
+
&bufferType);
|
|
191
|
+
|
|
192
|
+
CanvasBufferBindingType type = CanvasBufferBindingTypeUniform;
|
|
193
|
+
|
|
194
|
+
if (!bufferType.IsEmpty() && bufferType->IsString()) {
|
|
195
|
+
auto typeStr = ConvertFromV8String(isolate, bufferType);
|
|
196
|
+
if (typeStr == "read-only-storage") {
|
|
197
|
+
type = CanvasBufferBindingTypeReadOnlyStorage;
|
|
198
|
+
} else if (typeStr == "storage") {
|
|
199
|
+
type = CanvasBufferBindingTypeStorage;
|
|
200
|
+
} else if (typeStr == "uniform") {
|
|
201
|
+
type = CanvasBufferBindingTypeUniform;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
bool has_dynamic_offset = false;
|
|
206
|
+
|
|
207
|
+
v8::Local<v8::Value> hasDynamicOffsetVal;
|
|
208
|
+
bufferObj->Get(context,
|
|
209
|
+
ConvertToV8String(isolate, "hasDynamicOffset")).ToLocal(
|
|
210
|
+
&hasDynamicOffsetVal);
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
if (!hasDynamicOffsetVal.IsEmpty() && hasDynamicOffsetVal->IsBoolean()) {
|
|
214
|
+
has_dynamic_offset = hasDynamicOffsetVal->BooleanValue(isolate);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
int64_t min_binding_size = -1;
|
|
218
|
+
|
|
219
|
+
v8::Local<v8::Value> minBindingSizeVal;
|
|
220
|
+
bufferObj->Get(context,
|
|
221
|
+
ConvertToV8String(isolate, "minBindingSize")).ToLocal(
|
|
222
|
+
&minBindingSizeVal);
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if (!minBindingSizeVal.IsEmpty() && minBindingSizeVal->IsNumber()) {
|
|
226
|
+
min_binding_size = (int64_t) minBindingSizeVal->NumberValue(
|
|
227
|
+
context).ToChecked();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
CanvasBindingType buffer{
|
|
231
|
+
CanvasBindingTypeBuffer
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
buffer.buffer = CanvasBufferBindingLayout{
|
|
235
|
+
type, has_dynamic_offset, min_binding_size
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
CanvasBindGroupLayoutEntry entry{
|
|
240
|
+
binding,
|
|
241
|
+
visibility,
|
|
242
|
+
buffer
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
entries.push_back(entry);
|
|
246
|
+
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
v8::Local<v8::Value> externalTextureVal;
|
|
251
|
+
|
|
252
|
+
entryObj->Get(context, ConvertToV8String(isolate, "externalTexture")).ToLocal(
|
|
253
|
+
&externalTextureVal);
|
|
254
|
+
|
|
255
|
+
if (!externalTextureVal.IsEmpty() && externalTextureVal->IsObject()) {
|
|
256
|
+
// todo
|
|
257
|
+
// CanvasBindingType buffer{
|
|
258
|
+
// CanvasBindingTypeTexture
|
|
259
|
+
// };
|
|
260
|
+
//
|
|
261
|
+
// buffer.buffer = CanvasBufferBindingLayout{
|
|
262
|
+
// type, has_dynamic_offset, min_binding_size
|
|
263
|
+
// };
|
|
264
|
+
//
|
|
265
|
+
//
|
|
266
|
+
// CanvasBindGroupLayoutEntry entry{
|
|
267
|
+
// binding,
|
|
268
|
+
// visibility,
|
|
269
|
+
// buffer
|
|
270
|
+
// };
|
|
271
|
+
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
v8::Local<v8::Value> samplerVal;
|
|
277
|
+
|
|
278
|
+
entryObj->Get(context, ConvertToV8String(isolate, "sampler")).ToLocal(
|
|
279
|
+
&samplerVal);
|
|
280
|
+
|
|
281
|
+
if (!samplerVal.IsEmpty() && samplerVal->IsObject()) {
|
|
282
|
+
auto samplerObj = samplerVal.As<v8::Object>();
|
|
283
|
+
v8::Local<v8::Value> samplerType;
|
|
284
|
+
samplerObj->Get(context, ConvertToV8String(isolate, "type")).ToLocal(
|
|
285
|
+
&samplerType);
|
|
286
|
+
|
|
287
|
+
CanvasSamplerBindingType type = CanvasSamplerBindingTypeFiltering;
|
|
288
|
+
|
|
289
|
+
if (!samplerType.IsEmpty() && samplerType->IsString()) {
|
|
290
|
+
auto typeStr = ConvertFromV8String(isolate, samplerType);
|
|
291
|
+
if (typeStr == "comparison") {
|
|
292
|
+
type = CanvasSamplerBindingTypeComparison;
|
|
293
|
+
} else if (typeStr == "non-filtering") {
|
|
294
|
+
type = CanvasSamplerBindingTypeNonFiltering;
|
|
295
|
+
} else if (typeStr == "filtering") {
|
|
296
|
+
type = CanvasSamplerBindingTypeFiltering;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
CanvasBindingType sampler{
|
|
301
|
+
CanvasBindingTypeSampler,
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
sampler.sampler = CanvasSamplerBindingLayout{
|
|
305
|
+
type
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
CanvasBindGroupLayoutEntry entry{
|
|
310
|
+
binding,
|
|
311
|
+
visibility,
|
|
312
|
+
sampler
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
entries.push_back(entry);
|
|
316
|
+
|
|
317
|
+
continue;
|
|
318
|
+
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
v8::Local<v8::Value> storageTextureVal;
|
|
323
|
+
|
|
324
|
+
entryObj->Get(context, ConvertToV8String(isolate, "storageTexture")).ToLocal(
|
|
325
|
+
&storageTextureVal);
|
|
326
|
+
|
|
327
|
+
if (!storageTextureVal.IsEmpty() && storageTextureVal->IsObject()) {
|
|
328
|
+
auto storageTextureObj = storageTextureVal.As<v8::Object>();
|
|
329
|
+
|
|
330
|
+
CanvasBindingType storage{
|
|
331
|
+
CanvasBindingTypeStorageTexture
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
CanvasStorageTextureAccess access = CanvasStorageTextureAccessWriteOnly;
|
|
335
|
+
|
|
336
|
+
v8::Local<v8::Value> accessVal;
|
|
337
|
+
|
|
338
|
+
storageTextureObj->Get(context,
|
|
339
|
+
ConvertToV8String(isolate, "access")).ToLocal(
|
|
340
|
+
&accessVal);
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
if (!accessVal.IsEmpty() && accessVal->IsString()) {
|
|
344
|
+
auto accessStr = ConvertFromV8String(isolate, accessVal);
|
|
345
|
+
|
|
346
|
+
if (accessStr == "write-only") {
|
|
347
|
+
access = CanvasStorageTextureAccessWriteOnly;
|
|
348
|
+
} else if (accessStr == "read-only") {
|
|
349
|
+
access = CanvasStorageTextureAccessReadOnly;
|
|
350
|
+
} else if (accessStr == "read-write") {
|
|
351
|
+
access = CanvasStorageTextureAccessReadWrite;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
CanvasTextureViewDimension view_dimension = CanvasTextureViewDimensionD2;
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
v8::Local<v8::Value> viewDimensionVal;
|
|
360
|
+
|
|
361
|
+
storageTextureObj->Get(context,
|
|
362
|
+
ConvertToV8String(isolate, "viewDimension")).ToLocal(
|
|
363
|
+
&viewDimensionVal);
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
if (!viewDimensionVal.IsEmpty() && viewDimensionVal->IsString()) {
|
|
367
|
+
auto viewDimensionStr = ConvertFromV8String(isolate, viewDimensionVal);
|
|
368
|
+
if (viewDimensionStr == "1d") {
|
|
369
|
+
view_dimension = CanvasTextureViewDimensionD1;
|
|
370
|
+
} else if (viewDimensionStr == "2d") {
|
|
371
|
+
view_dimension = CanvasTextureViewDimensionD2;
|
|
372
|
+
} else if (viewDimensionStr == "2d-array") {
|
|
373
|
+
view_dimension = CanvasTextureViewDimensionD2Array;
|
|
374
|
+
} else if (viewDimensionStr == "cube") {
|
|
375
|
+
view_dimension = CanvasTextureViewDimensionCube;
|
|
376
|
+
} else if (viewDimensionStr == "cube-array") {
|
|
377
|
+
view_dimension = CanvasTextureViewDimensionCubeArray;
|
|
378
|
+
} else if (viewDimensionStr == "3d") {
|
|
379
|
+
view_dimension = CanvasTextureViewDimensionD3;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
v8::Local<v8::Value> formatVal;
|
|
385
|
+
|
|
386
|
+
storageTextureObj->Get(context,
|
|
387
|
+
ConvertToV8String(isolate, "format")).ToLocal(
|
|
388
|
+
&formatVal);
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
if (!formatVal.IsEmpty() && formatVal->IsString()) {
|
|
392
|
+
auto formatStr = ConvertFromV8String(isolate, formatVal);
|
|
393
|
+
auto textureFormat = canvas_native_webgpu_enum_string_to_gpu_texture(
|
|
394
|
+
formatStr.c_str());
|
|
395
|
+
if (textureFormat.tag == CanvasOptionalGPUTextureFormatSome) {
|
|
396
|
+
storage.storage_texture = CanvasStorageTextureBindingLayout{
|
|
397
|
+
access,
|
|
398
|
+
textureFormat.some,
|
|
399
|
+
view_dimension
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
CanvasBindGroupLayoutEntry entry{
|
|
403
|
+
binding,
|
|
404
|
+
visibility,
|
|
405
|
+
storage
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
entries.push_back(entry);
|
|
409
|
+
|
|
410
|
+
continue;
|
|
411
|
+
|
|
412
|
+
} else {
|
|
413
|
+
// todo throw ??
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
v8::Local<v8::Value> textureVal;
|
|
423
|
+
|
|
424
|
+
entryObj->Get(context, ConvertToV8String(isolate, "texture")).ToLocal(
|
|
425
|
+
&textureVal);
|
|
426
|
+
|
|
427
|
+
if (!textureVal.IsEmpty() && textureVal->IsObject()) {
|
|
428
|
+
auto textureObj = textureVal.As<v8::Object>();
|
|
429
|
+
bool multisampled = false;
|
|
430
|
+
|
|
431
|
+
v8::Local<v8::Value> multisampledVal;
|
|
432
|
+
|
|
433
|
+
textureObj->Get(context,
|
|
434
|
+
ConvertToV8String(isolate, "multisampled")).ToLocal(
|
|
435
|
+
&multisampledVal);
|
|
436
|
+
|
|
437
|
+
if (!multisampledVal.IsEmpty() && multisampledVal->IsBoolean()) {
|
|
438
|
+
multisampled = multisampledVal->BooleanValue(isolate);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
v8::Local<v8::Value> sampleTypeVal;
|
|
443
|
+
textureObj->Get(context, ConvertToV8String(isolate, "sampleType")).ToLocal(
|
|
444
|
+
&sampleTypeVal);
|
|
445
|
+
|
|
446
|
+
CanvasTextureSampleType type = CanvasTextureSampleTypeFloat;
|
|
447
|
+
|
|
448
|
+
if (!sampleTypeVal.IsEmpty() && sampleTypeVal->IsString()) {
|
|
449
|
+
auto typeStr = ConvertFromV8String(isolate, sampleTypeVal);
|
|
450
|
+
if (typeStr == "depth") {
|
|
451
|
+
type = CanvasTextureSampleTypeDepth;
|
|
452
|
+
} else if (typeStr == "float") {
|
|
453
|
+
type = CanvasTextureSampleTypeFloat;
|
|
454
|
+
} else if (typeStr == "sint") {
|
|
455
|
+
type = CanvasTextureSampleTypeSint;
|
|
456
|
+
} else if (typeStr == "uint") {
|
|
457
|
+
type = CanvasTextureSampleTypeUint;
|
|
458
|
+
} else if (typeStr == "unfilterable-float") {
|
|
459
|
+
type = CanvasTextureSampleTypeUnfilterableFloat;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
CanvasTextureViewDimension view_dimension = CanvasTextureViewDimensionD2;
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
v8::Local<v8::Value> viewDimensionVal;
|
|
468
|
+
|
|
469
|
+
textureObj->Get(context,
|
|
470
|
+
ConvertToV8String(isolate, "viewDimension")).ToLocal(
|
|
471
|
+
&viewDimensionVal);
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
if (!viewDimensionVal.IsEmpty() && viewDimensionVal->IsString()) {
|
|
475
|
+
auto viewDimensionStr = ConvertFromV8String(isolate, viewDimensionVal);
|
|
476
|
+
if (viewDimensionStr == "1d") {
|
|
477
|
+
view_dimension = CanvasTextureViewDimensionD1;
|
|
478
|
+
} else if (viewDimensionStr == "2d") {
|
|
479
|
+
view_dimension = CanvasTextureViewDimensionD2;
|
|
480
|
+
} else if (viewDimensionStr == "2d-array") {
|
|
481
|
+
view_dimension = CanvasTextureViewDimensionD2Array;
|
|
482
|
+
} else if (viewDimensionStr == "cube") {
|
|
483
|
+
view_dimension = CanvasTextureViewDimensionCube;
|
|
484
|
+
} else if (viewDimensionStr == "cube-array") {
|
|
485
|
+
view_dimension = CanvasTextureViewDimensionCubeArray;
|
|
486
|
+
} else if (viewDimensionStr == "3d") {
|
|
487
|
+
view_dimension = CanvasTextureViewDimensionD3;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
CanvasBindingType texture{
|
|
493
|
+
CanvasBindingTypeTexture
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
texture.texture = CanvasTextureBindingLayout{
|
|
497
|
+
type,
|
|
498
|
+
view_dimension,
|
|
499
|
+
multisampled
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
CanvasBindGroupLayoutEntry entry{
|
|
504
|
+
binding,
|
|
505
|
+
visibility,
|
|
506
|
+
texture
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
entries.push_back(entry);
|
|
510
|
+
|
|
511
|
+
continue;
|
|
512
|
+
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return entries;
|
|
520
|
+
}
|
|
10
521
|
|
|
11
522
|
inline static CanvasCompareFunction
|
|
12
523
|
ParseCompareFunction(v8::Isolate *isolate, const v8::Local<v8::Value> &obj,
|
package/utils.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export declare class Utils {
|
|
|
4
4
|
static _CHECKED_FOR_SUPPORT: boolean;
|
|
5
5
|
static toJSArray(array: any): any[];
|
|
6
6
|
static get IS_SUPPORTED_TYPED_ARRAYS_VERSION(): boolean;
|
|
7
|
-
static isTypedArray(value: any):
|
|
7
|
+
static isTypedArray(value: any): value is Uint32Array | Uint8Array | Uint8ClampedArray | Int32Array | Float32Array | Int8Array | Uint16Array | Int16Array;
|
|
8
8
|
}
|
|
9
9
|
export default function lazy<T>(action: () => T): () => T;
|