@nativescript/canvas 2.0.0-webgpu.34 → 2.0.0-webgpu.36
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 +1 -1
- package/Canvas/common.js +24 -18
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.d.ts +7 -1
- package/Canvas/index.ios.js +57 -17
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +2 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +1 -4
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/ImageAsset/index.d.ts +4 -2
- package/ImageAsset/index.js +76 -6
- package/ImageAsset/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.d.ts +1 -1
- package/WebGL/WebGLRenderingContext/index.js +5 -4
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +2 -1
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUQueue.js +9 -0
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.d.ts +3 -0
- package/WebGPU/GPURenderPassEncoder.js +9 -0
- package/WebGPU/GPURenderPassEncoder.js.map +1 -1
- package/angular/esm2022/index.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs.map +1 -1
- package/common.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- 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 +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +85 -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 +109 -18
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +4 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +4 -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 +681 -675
- 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 +2 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +85 -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 +109 -18
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +4 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +109 -18
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +4 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +4 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +24 -24
- 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 +683 -677
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +736 -730
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +140 -12
- package/platforms/ios/src/cpp/CanvasJSIModule.h +2 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +572 -397
- package/platforms/ios/src/cpp/ImageAssetImpl.h +4 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +42 -37
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +40 -8
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +26 -23
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +93 -23
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +4 -0
- package/utils.d.ts +1 -1
|
@@ -61,6 +61,10 @@ public:
|
|
|
61
61
|
|
|
62
62
|
static void FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
63
63
|
|
|
64
|
+
static void FromEncodedBytesSync(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
65
|
+
|
|
66
|
+
static void FromEncodedBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
67
|
+
|
|
64
68
|
/* static void SaveSync(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
65
69
|
|
|
66
70
|
static void SaveCb(const v8::FunctionCallbackInfo<v8::Value> &args);*/
|
|
@@ -141,8 +141,8 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase() {
|
|
|
141
141
|
if (_raf != nullptr) {
|
|
142
142
|
canvas_native_raf_stop(
|
|
143
143
|
_raf->GetRaf());
|
|
144
|
+
canvas_native_raf_release(_raf->GetRaf());
|
|
144
145
|
}
|
|
145
|
-
canvas_native_raf_release(_raf->GetRaf());
|
|
146
146
|
this->raf_ = nullptr;
|
|
147
147
|
canvas_native_webgl_state_destroy(this->GetState());
|
|
148
148
|
this->state_ = nullptr;
|
|
@@ -17,7 +17,7 @@ const CanvasGPUComputePassEncoder *GPUComputePassEncoderImpl::GetComputePass() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
void GPUComputePassEncoderImpl::Init(v8::Local
|
|
20
|
+
void GPUComputePassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
21
21
|
v8::Locker locker(isolate);
|
|
22
22
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
23
23
|
v8::HandleScope handle_scope(isolate);
|
|
@@ -31,7 +31,7 @@ void GPUComputePassEncoderImpl::Init(v8::Local <v8::Object> canvasModule, v8::Is
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
GPUComputePassEncoderImpl *
|
|
34
|
-
GPUComputePassEncoderImpl::GetPointer(const v8::Local
|
|
34
|
+
GPUComputePassEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
35
35
|
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
36
36
|
if (ptr == nullptr) {
|
|
37
37
|
return nullptr;
|
|
@@ -39,14 +39,14 @@ GPUComputePassEncoderImpl::GetPointer(const v8::Local <v8::Object> &object) {
|
|
|
39
39
|
return static_cast<GPUComputePassEncoderImpl *>(ptr);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
v8::Local
|
|
42
|
+
v8::Local<v8::FunctionTemplate> GPUComputePassEncoderImpl::GetCtor(v8::Isolate *isolate) {
|
|
43
43
|
auto cache = Caches::Get(isolate);
|
|
44
44
|
auto ctor = cache->GPUComputePassEncoderTmpl.get();
|
|
45
45
|
if (ctor != nullptr) {
|
|
46
46
|
return ctor->Get(isolate);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
v8::Local
|
|
49
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
50
50
|
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
51
51
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUComputePassEncoder"));
|
|
52
52
|
|
|
@@ -92,14 +92,14 @@ v8::Local <v8::FunctionTemplate> GPUComputePassEncoderImpl::GetCtor(v8::Isolate
|
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
cache->GPUComputePassEncoderTmpl =
|
|
95
|
-
std::make_unique<v8::Persistent
|
|
96
|
-
|
|
95
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>
|
|
96
|
+
(isolate, ctorTmpl);
|
|
97
97
|
return ctorTmpl;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
void
|
|
101
|
-
GPUComputePassEncoderImpl::GetLabel(v8::Local
|
|
102
|
-
const v8::PropertyCallbackInfo
|
|
101
|
+
GPUComputePassEncoderImpl::GetLabel(v8::Local<v8::Name> name,
|
|
102
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
103
103
|
auto ptr = GetPointer(info.This());
|
|
104
104
|
if (ptr != nullptr) {
|
|
105
105
|
auto label = canvas_native_webgpu_compute_pass_encoder_get_label(ptr->computePass_);
|
|
@@ -119,7 +119,7 @@ GPUComputePassEncoderImpl::GetLabel(v8::Local <v8::Name> name,
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
void
|
|
122
|
-
GPUComputePassEncoderImpl::DispatchWorkgroups(const v8::FunctionCallbackInfo
|
|
122
|
+
GPUComputePassEncoderImpl::DispatchWorkgroups(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
123
123
|
auto *ptr = GetPointer(args.This());
|
|
124
124
|
if (ptr == nullptr) {
|
|
125
125
|
return;
|
|
@@ -154,7 +154,7 @@ GPUComputePassEncoderImpl::DispatchWorkgroups(const v8::FunctionCallbackInfo <v8
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
void GPUComputePassEncoderImpl::DispatchWorkgroupsIndirect(
|
|
157
|
-
const v8::FunctionCallbackInfo
|
|
157
|
+
const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
158
158
|
auto *ptr = GetPointer(args.This());
|
|
159
159
|
if (ptr == nullptr) {
|
|
160
160
|
return;
|
|
@@ -178,7 +178,7 @@ void GPUComputePassEncoderImpl::DispatchWorkgroupsIndirect(
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
|
|
181
|
-
void GPUComputePassEncoderImpl::End(const v8::FunctionCallbackInfo
|
|
181
|
+
void GPUComputePassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
182
182
|
auto *ptr = GetPointer(args.This());
|
|
183
183
|
if (ptr == nullptr) {
|
|
184
184
|
return;
|
|
@@ -188,7 +188,7 @@ void GPUComputePassEncoderImpl::End(const v8::FunctionCallbackInfo <v8::Value> &
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
void
|
|
191
|
-
GPUComputePassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo
|
|
191
|
+
GPUComputePassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
192
192
|
auto *ptr = GetPointer(args.This());
|
|
193
193
|
if (ptr == nullptr) {
|
|
194
194
|
return;
|
|
@@ -204,7 +204,7 @@ GPUComputePassEncoderImpl::InsertDebugMarker(const v8::FunctionCallbackInfo <v8:
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
void GPUComputePassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo
|
|
207
|
+
void GPUComputePassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
208
208
|
auto *ptr = GetPointer(args.This());
|
|
209
209
|
if (ptr == nullptr) {
|
|
210
210
|
return;
|
|
@@ -213,7 +213,7 @@ void GPUComputePassEncoderImpl::PopDebugGroup(const v8::FunctionCallbackInfo <v8
|
|
|
213
213
|
canvas_native_webgpu_compute_pass_encoder_pop_debug_group(ptr->GetComputePass());
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
void GPUComputePassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo
|
|
216
|
+
void GPUComputePassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
217
217
|
auto *ptr = GetPointer(args.This());
|
|
218
218
|
if (ptr == nullptr) {
|
|
219
219
|
return;
|
|
@@ -229,7 +229,7 @@ void GPUComputePassEncoderImpl::PushDebugGroup(const v8::FunctionCallbackInfo <v
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
void GPUComputePassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo
|
|
232
|
+
void GPUComputePassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
233
233
|
auto *ptr = GetPointer(args.This());
|
|
234
234
|
if (ptr == nullptr) {
|
|
235
235
|
return;
|
|
@@ -244,34 +244,39 @@ void GPUComputePassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo <v8:
|
|
|
244
244
|
auto dynamicOffsetsStart = args[3];
|
|
245
245
|
auto dynamicOffsetsLength = args[4];
|
|
246
246
|
|
|
247
|
+
const CanvasGPUBindGroup *bindGroup = nullptr;
|
|
248
|
+
|
|
247
249
|
auto type = GetNativeType(bindGroupVal);
|
|
248
250
|
|
|
249
251
|
if (type == NativeType::GPUBindGroup) {
|
|
250
|
-
auto
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
252
|
+
auto group = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
253
|
+
bindGroup = group->GetBindGroup();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
auto index = indexVal->Uint32Value(context).FromJust();
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
if (dynamicOffsets->IsUint8Array()) {
|
|
260
|
+
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
261
|
+
auto buffer = buf->Buffer();
|
|
262
|
+
auto store = buffer->GetBackingStore();
|
|
263
|
+
auto offset = buf->ByteOffset();
|
|
264
|
+
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
265
|
+
auto size = buf->Length();
|
|
266
|
+
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
267
|
+
auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
|
|
268
|
+
canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
|
|
269
|
+
bindGroup,
|
|
270
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
271
|
+
size, start, offset_length);
|
|
272
|
+
} else {
|
|
273
|
+
canvas_native_webgpu_compute_pass_encoder_set_bind_group(ptr->GetComputePass(), index,
|
|
274
|
+
bindGroup,
|
|
275
|
+
nullptr, 0, 0, 0);
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
278
|
|
|
274
|
-
void GPUComputePassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo
|
|
279
|
+
void GPUComputePassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
275
280
|
auto *ptr = GetPointer(args.This());
|
|
276
281
|
if (ptr == nullptr) {
|
|
277
282
|
return;
|
|
@@ -91,7 +91,7 @@ v8::Local<v8::FunctionTemplate> GPUQueueImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
91
91
|
|
|
92
92
|
void
|
|
93
93
|
GPUQueueImpl::GetLabel(v8::Local<v8::Name> name,
|
|
94
|
-
|
|
94
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
95
95
|
auto ptr = GetPointer(info.This());
|
|
96
96
|
if (ptr != nullptr) {
|
|
97
97
|
auto label = canvas_native_webgpu_queue_get_label(ptr->queue_);
|
|
@@ -136,7 +136,9 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
136
136
|
U8Buffer *buffer = nullptr;
|
|
137
137
|
uint32_t width = 0;
|
|
138
138
|
uint32_t height = 0;
|
|
139
|
-
const ImageAsset*
|
|
139
|
+
const ImageAsset *imageAsset = nullptr;
|
|
140
|
+
const WebGLState *gl = nullptr;
|
|
141
|
+
const CanvasRenderingContext2D *c2d = nullptr;
|
|
140
142
|
if (sourceType == NativeType::ImageBitmap) {
|
|
141
143
|
auto bitmap = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
142
144
|
imageAsset = bitmap->GetImageAsset();
|
|
@@ -149,12 +151,14 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
149
151
|
width = canvas_native_image_data_get_width(imageData->GetImageData());
|
|
150
152
|
height = canvas_native_image_data_get_height(imageData->GetImageData());
|
|
151
153
|
} else if (sourceType == NativeType::CanvasRenderingContext2D) {
|
|
152
|
-
auto
|
|
154
|
+
auto ctx = CanvasRenderingContext2DImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
155
|
+
c2d = ctx->GetContext();
|
|
153
156
|
} else if (sourceType == NativeType::WebGLRenderingContextBase) {
|
|
154
157
|
auto webgl = WebGLRenderingContextBase::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
158
|
+
gl = webgl->GetState();
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
if (buffer == nullptr && imageAsset == nullptr) {
|
|
161
|
+
if (buffer == nullptr && imageAsset == nullptr && gl == nullptr && c2d == nullptr) {
|
|
158
162
|
// todo error ??
|
|
159
163
|
return;
|
|
160
164
|
}
|
|
@@ -260,7 +264,7 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
260
264
|
|
|
261
265
|
CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
|
|
262
266
|
|
|
263
|
-
if (imageAsset != nullptr){
|
|
267
|
+
if (imageAsset != nullptr) {
|
|
264
268
|
CanvasImageCopyImageAsset source{
|
|
265
269
|
imageAsset,
|
|
266
270
|
sourceOrigin,
|
|
@@ -269,8 +273,37 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
269
273
|
|
|
270
274
|
|
|
271
275
|
canvas_native_webgpu_queue_copy_image_asset_to_texture(ptr->GetGPUQueue(), &source,
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
&destination,
|
|
277
|
+
&extent3D);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
if (c2d != nullptr) {
|
|
283
|
+
CanvasImageCopyCanvasRenderingContext2D source{
|
|
284
|
+
c2d,
|
|
285
|
+
sourceOrigin,
|
|
286
|
+
flipY,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
canvas_native_webgpu_queue_copy_context_to_texture(ptr->GetGPUQueue(), &source,
|
|
291
|
+
&destination,
|
|
292
|
+
&extent3D);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (gl != nullptr) {
|
|
297
|
+
CanvasImageCopyWebGL source{
|
|
298
|
+
gl,
|
|
299
|
+
sourceOrigin,
|
|
300
|
+
flipY,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
canvas_native_webgpu_queue_copy_webgl_to_texture(ptr->GetGPUQueue(), &source,
|
|
305
|
+
&destination,
|
|
306
|
+
&extent3D);
|
|
274
307
|
return;
|
|
275
308
|
}
|
|
276
309
|
|
|
@@ -279,7 +312,6 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
279
312
|
auto size = canvas_native_u8_buffer_get_length(buffer);
|
|
280
313
|
|
|
281
314
|
|
|
282
|
-
|
|
283
315
|
if (data == nullptr || size == 0) {
|
|
284
316
|
// todo error
|
|
285
317
|
return;
|
|
@@ -118,7 +118,7 @@ v8::Local<v8::FunctionTemplate> GPURenderBundleEncoderImpl::GetCtor(v8::Isolate
|
|
|
118
118
|
|
|
119
119
|
void
|
|
120
120
|
GPURenderBundleEncoderImpl::GetLabel(v8::Local<v8::Name> name,
|
|
121
|
-
|
|
121
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
122
122
|
auto ptr = GetPointer(info.This());
|
|
123
123
|
if (ptr != nullptr) {
|
|
124
124
|
auto label = canvas_native_webgpu_render_bundle_encoder_get_label(ptr->encoder_);
|
|
@@ -369,30 +369,33 @@ void GPURenderBundleEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8:
|
|
|
369
369
|
auto dynamicOffsetsStart = args[3];
|
|
370
370
|
auto dynamicOffsetsLength = args[4];
|
|
371
371
|
|
|
372
|
+
const CanvasGPUBindGroup *bindGroup = nullptr;
|
|
372
373
|
auto type = GetNativeType(bindGroupVal);
|
|
373
374
|
|
|
375
|
+
auto index = indexVal->Uint32Value(context).FromJust();
|
|
376
|
+
|
|
374
377
|
if (type == NativeType::GPUBindGroup) {
|
|
375
|
-
auto
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
378
|
+
auto group = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
379
|
+
bindGroup = group->GetBindGroup();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (dynamicOffsets->IsUint32Array()) {
|
|
383
|
+
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
384
|
+
auto buffer = buf->Buffer();
|
|
385
|
+
auto store = buffer->GetBackingStore();
|
|
386
|
+
auto offset = buf->ByteOffset();
|
|
387
|
+
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
388
|
+
auto size = buf->Length();
|
|
389
|
+
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
390
|
+
auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
|
|
391
|
+
canvas_native_webgpu_render_bundle_encoder_set_bind_group(ptr->GetEncoder(), index,
|
|
392
|
+
bindGroup,
|
|
393
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
394
|
+
size, start, offset_length);
|
|
395
|
+
} else {
|
|
396
|
+
canvas_native_webgpu_render_bundle_encoder_set_bind_group(ptr->GetEncoder(), index,
|
|
397
|
+
bindGroup,
|
|
398
|
+
nullptr, 0, 0, 0);
|
|
396
399
|
}
|
|
397
400
|
|
|
398
401
|
}
|
|
@@ -450,7 +453,7 @@ void GPURenderBundleEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::
|
|
|
450
453
|
}
|
|
451
454
|
|
|
452
455
|
auto pipelineVal = args[0];
|
|
453
|
-
if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
|
|
456
|
+
if (GetNativeType(pipelineVal) == NativeType::GPURenderPipeline) {
|
|
454
457
|
auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
|
|
455
458
|
if (pipeline != nullptr) {
|
|
456
459
|
canvas_native_webgpu_render_bundle_encoder_set_pipeline(ptr->GetEncoder(),
|
|
@@ -79,6 +79,14 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
|
|
|
79
79
|
ConvertToV8String(isolate, "drawIndirect"),
|
|
80
80
|
v8::FunctionTemplate::New(isolate, &DrawIndirect));
|
|
81
81
|
|
|
82
|
+
tmpl->Set(
|
|
83
|
+
ConvertToV8String(isolate, "multiDrawIndexedIndirect"),
|
|
84
|
+
v8::FunctionTemplate::New(isolate, &MultiDrawIndexedIndirect));
|
|
85
|
+
|
|
86
|
+
tmpl->Set(
|
|
87
|
+
ConvertToV8String(isolate, "multiDrawIndirect"),
|
|
88
|
+
v8::FunctionTemplate::New(isolate, &MultiDrawIndirect));
|
|
89
|
+
|
|
82
90
|
tmpl->Set(
|
|
83
91
|
ConvertToV8String(isolate, "end"),
|
|
84
92
|
v8::FunctionTemplate::New(isolate, &End));
|
|
@@ -291,6 +299,36 @@ GPURenderPassEncoderImpl::DrawIndexedIndirect(const v8::FunctionCallbackInfo<v8:
|
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void
|
|
305
|
+
GPURenderPassEncoderImpl::MultiDrawIndexedIndirect(
|
|
306
|
+
const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
307
|
+
auto *ptr = GetPointer(args.This());
|
|
308
|
+
if (ptr == nullptr) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
auto isolate = args.GetIsolate();
|
|
313
|
+
auto context = isolate->GetCurrentContext();
|
|
314
|
+
|
|
315
|
+
auto indirectBufferVal = args[0];
|
|
316
|
+
auto indirectOffsetVal = args[1];
|
|
317
|
+
auto countVal = args[2];
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
auto indirectBufferType = GetNativeType(indirectBufferVal);
|
|
321
|
+
|
|
322
|
+
if (indirectBufferType == NativeType::GPUBuffer) {
|
|
323
|
+
auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
|
|
324
|
+
uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
|
|
325
|
+
uint32_t count = countVal->Uint32Value(context).FromJust();
|
|
326
|
+
canvas_native_webgpu_render_pass_encoder_multi_draw_indexed_indirect(ptr->GetPass(),
|
|
327
|
+
indirectBuffer->GetGPUBuffer(),
|
|
328
|
+
offset, count);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
|
|
294
332
|
}
|
|
295
333
|
|
|
296
334
|
void
|
|
@@ -318,6 +356,35 @@ GPURenderPassEncoderImpl::DrawIndirect(const v8::FunctionCallbackInfo<v8::Value>
|
|
|
318
356
|
}
|
|
319
357
|
|
|
320
358
|
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
void
|
|
362
|
+
GPURenderPassEncoderImpl::MultiDrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
363
|
+
auto *ptr = GetPointer(args.This());
|
|
364
|
+
if (ptr == nullptr) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
auto isolate = args.GetIsolate();
|
|
369
|
+
auto context = isolate->GetCurrentContext();
|
|
370
|
+
|
|
371
|
+
auto indirectBufferVal = args[0];
|
|
372
|
+
auto indirectOffsetVal = args[1];
|
|
373
|
+
auto countVal = args[2];
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
auto indirectBufferType = GetNativeType(indirectBufferVal);
|
|
377
|
+
|
|
378
|
+
if (indirectBufferType == NativeType::GPUBuffer) {
|
|
379
|
+
auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
|
|
380
|
+
uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
|
|
381
|
+
uint32_t count = countVal->Uint32Value(context).FromJust();
|
|
382
|
+
canvas_native_webgpu_render_pass_encoder_multi_draw_indirect(ptr->GetPass(),
|
|
383
|
+
indirectBuffer->GetGPUBuffer(),
|
|
384
|
+
offset, count);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
321
388
|
}
|
|
322
389
|
|
|
323
390
|
void GPURenderPassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
@@ -428,30 +495,34 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
|
|
|
428
495
|
auto dynamicOffsetsStart = args[3];
|
|
429
496
|
auto dynamicOffsetsLength = args[4];
|
|
430
497
|
|
|
498
|
+
const CanvasGPUBindGroup *bindGroup = nullptr;
|
|
499
|
+
|
|
431
500
|
auto type = GetNativeType(bindGroupVal);
|
|
432
501
|
|
|
502
|
+
auto index = indexVal->Uint32Value(context).FromJust();
|
|
503
|
+
|
|
433
504
|
if (type == NativeType::GPUBindGroup) {
|
|
434
|
-
auto
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
505
|
+
auto group = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
506
|
+
bindGroup = group->GetBindGroup();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (dynamicOffsets->IsUint32Array()) {
|
|
510
|
+
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
511
|
+
auto buffer = buf->Buffer();
|
|
512
|
+
auto store = buffer->GetBackingStore();
|
|
513
|
+
auto offset = buf->ByteOffset();
|
|
514
|
+
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
515
|
+
auto size = buf->Length();
|
|
516
|
+
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
517
|
+
auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
|
|
518
|
+
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
519
|
+
bindGroup,
|
|
520
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
521
|
+
size, start, offset_length);
|
|
522
|
+
} else {
|
|
523
|
+
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
524
|
+
bindGroup,
|
|
525
|
+
nullptr, 0, 0, 0);
|
|
455
526
|
}
|
|
456
527
|
}
|
|
457
528
|
|
|
@@ -596,8 +667,7 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
|
|
|
596
667
|
if (type == NativeType::GPUBuffer) {
|
|
597
668
|
auto context = isolate->GetCurrentContext();
|
|
598
669
|
auto slot = slotVal->ToUint32(context).ToLocalChecked();
|
|
599
|
-
|
|
600
|
-
|
|
670
|
+
|
|
601
671
|
|
|
602
672
|
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
603
673
|
|
|
@@ -51,6 +51,10 @@ public:
|
|
|
51
51
|
|
|
52
52
|
static void DrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
53
53
|
|
|
54
|
+
static void MultiDrawIndexedIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
55
|
+
|
|
56
|
+
static void MultiDrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
57
|
+
|
|
54
58
|
static void End(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
55
59
|
|
|
56
60
|
static void EndOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
|
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): value is Uint32Array |
|
|
7
|
+
static isTypedArray(value: any): value is Uint32Array | Uint8ClampedArray | Uint8Array | Int32Array | Float32Array | Int8Array | Uint16Array | Int16Array;
|
|
8
8
|
}
|
|
9
9
|
export default function lazy<T>(action: () => T): () => T;
|