@nativescript/canvas 2.0.0-webgpu.0 → 2.0.0-webgpu.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Canvas/common.d.ts +2 -3
- package/Canvas/common.js +8 -10
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.js +1 -0
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.js +1 -0
- package/Canvas/index.ios.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +3 -1
- package/WebGPU/GPUCanvasContext.js +13 -4
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.js +6 -1
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUDevice.js +37 -62
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.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/Utils.d.ts +1 -1
- package/common.d.ts +0 -3
- package/common.js +1 -5
- package/common.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/canvas_native.h +40 -2
- 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 -602
- 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/canvas_native.h +40 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +2 -2
- 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 -604
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -638
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +207 -72
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +26 -17
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +21 -51
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +69 -2
|
@@ -28,7 +28,7 @@ void GPUCommandEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate
|
|
|
28
28
|
auto context = isolate->GetCurrentContext();
|
|
29
29
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
30
30
|
|
|
31
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandEncoder"), func).FromJust()
|
|
31
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandEncoder"), func).FromJust();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
GPUCommandEncoderImpl *GPUCommandEncoderImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
@@ -257,45 +257,18 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
257
257
|
v8::Local<v8::Value> clearValueVal;
|
|
258
258
|
colorAttachment->Get(context, ConvertToV8String(isolate, "clearValue")).ToLocal(
|
|
259
259
|
&clearValueVal);
|
|
260
|
-
auto clearValue = CanvasColor{0, 0, 0, 0};
|
|
261
|
-
if (!clearValueVal.IsEmpty() && clearValueVal->IsObject()) {
|
|
262
|
-
auto clearValueObj = clearValueVal.As<v8::Object>();
|
|
263
|
-
|
|
264
|
-
v8::Local<v8::Value> r;
|
|
265
|
-
v8::Local<v8::Value> g;
|
|
266
|
-
v8::Local<v8::Value> b;
|
|
267
|
-
v8::Local<v8::Value> a;
|
|
268
|
-
|
|
269
|
-
clearValueObj->Get(context, ConvertToV8String(isolate, "r")).ToLocal(&r);
|
|
270
|
-
clearValueObj->Get(context, ConvertToV8String(isolate, "g")).ToLocal(&g);
|
|
271
|
-
clearValueObj->Get(context, ConvertToV8String(isolate, "b")).ToLocal(&b);
|
|
272
|
-
clearValueObj->Get(context, ConvertToV8String(isolate, "a")).ToLocal(&a);
|
|
273
|
-
|
|
274
|
-
if (!r.IsEmpty() && r->IsNumber()) {
|
|
275
|
-
clearValue.r = r.As<v8::Number>()->Value();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (!g.IsEmpty() && g->IsNumber()) {
|
|
279
|
-
clearValue.g = g.As<v8::Number>()->Value();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (!b.IsEmpty() && b->IsNumber()) {
|
|
284
|
-
clearValue.b = b.As<v8::Number>()->Value();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (!a.IsEmpty() && a->IsNumber()) {
|
|
288
|
-
clearValue.a = a.As<v8::Number>()->Value();
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
260
|
|
|
261
|
+
auto clearValue = ParseColor(isolate, clearValueVal);
|
|
292
262
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
auto view = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
|
|
297
|
-
|
|
263
|
+
v8::Local<v8::Value> viewVal;
|
|
264
|
+
colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
265
|
+
"view")).ToLocal(&viewVal);
|
|
298
266
|
|
|
267
|
+
const CanvasGPUTextureView *view = nullptr;
|
|
268
|
+
|
|
269
|
+
auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
|
|
270
|
+
view = viewPtr->GetTextureView();
|
|
271
|
+
|
|
299
272
|
const CanvasGPUTextureView *resolve_target = nullptr;
|
|
300
273
|
|
|
301
274
|
v8::Local<v8::Value> resolve_target_val;
|
|
@@ -313,34 +286,37 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
313
286
|
// default
|
|
314
287
|
CanvasLoadOp load = CanvasLoadOp::CanvasLoadOpClear;
|
|
315
288
|
CanvasStoreOp store = CanvasStoreOp::CanvasStoreOpStore;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
load
|
|
289
|
+
v8::Local<v8::Value> loadVal;
|
|
290
|
+
|
|
291
|
+
if(colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
292
|
+
"loadOp")).ToLocal(&loadVal)){
|
|
293
|
+
if (loadVal->IsUint32()) {
|
|
294
|
+
load = (CanvasLoadOp) loadVal->Uint32Value(
|
|
295
|
+
context).ToChecked();
|
|
296
|
+
} else if (loadVal->IsString()) {
|
|
297
|
+
auto val = ConvertFromV8String(isolate, loadVal);
|
|
298
|
+
if (val == "clear") {
|
|
299
|
+
load = CanvasLoadOp::CanvasLoadOpClear;
|
|
300
|
+
} else if (val == "load") {
|
|
301
|
+
load = CanvasLoadOp::CanvasLoadOpLoad;
|
|
302
|
+
}
|
|
328
303
|
}
|
|
329
304
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
v8::Local<v8::Value> storeVal;
|
|
308
|
+
if(colorAttachment->Get(context, ConvertToV8String(isolate,
|
|
309
|
+
"storeOp")).ToLocal(&storeVal)){
|
|
310
|
+
if (storeVal->IsUint32()) {
|
|
311
|
+
store = (CanvasStoreOp) storeVal->Uint32Value(
|
|
312
|
+
context).ToChecked();
|
|
313
|
+
} else if (storeVal->IsString()) {
|
|
314
|
+
auto val = ConvertFromV8String(isolate, storeVal);
|
|
315
|
+
if (val == "discard") {
|
|
316
|
+
store = CanvasStoreOp::CanvasStoreOpDiscard;
|
|
317
|
+
} else if (val == "store") {
|
|
318
|
+
store = CanvasStoreOp::CanvasStoreOpStore;
|
|
319
|
+
}
|
|
344
320
|
}
|
|
345
321
|
}
|
|
346
322
|
|
|
@@ -352,7 +328,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
352
328
|
};
|
|
353
329
|
|
|
354
330
|
auto attachment = CanvasRenderPassColorAttachment{
|
|
355
|
-
view
|
|
331
|
+
view,
|
|
356
332
|
resolve_target,
|
|
357
333
|
channel
|
|
358
334
|
};
|
|
@@ -362,8 +338,8 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
362
338
|
}
|
|
363
339
|
|
|
364
340
|
|
|
341
|
+
// todo add when supported
|
|
365
342
|
v8::Local<v8::Value> maxDrawCountVal;
|
|
366
|
-
|
|
367
343
|
desc->Get(context, ConvertToV8String(isolate, "maxDrawCount")).ToLocal(&maxDrawCountVal);
|
|
368
344
|
|
|
369
345
|
|
|
@@ -376,8 +352,164 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
376
352
|
|
|
377
353
|
if (!depthStencilAttachmentVal.IsEmpty() && depthStencilAttachmentVal->IsObject()) {
|
|
378
354
|
auto depthStencilAttachmentObj = depthStencilAttachmentVal.As<v8::Object>();
|
|
379
|
-
|
|
355
|
+
depthStencilAttachment = new CanvasRenderPassDepthStencilAttachment{};
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
v8::Local<v8::Value> viewVal;
|
|
359
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
360
|
+
"view")).ToLocal(&viewVal);
|
|
380
361
|
|
|
362
|
+
auto viewPtr = GPUTextureViewImpl::GetPointer(viewVal.As<v8::Object>());
|
|
363
|
+
depthStencilAttachment->view = viewPtr->GetTextureView();
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
v8::Local<v8::Value> depthClearValue;
|
|
367
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
368
|
+
"depthClearValue")).ToLocal(
|
|
369
|
+
&depthClearValue);
|
|
370
|
+
|
|
371
|
+
depthStencilAttachment->depth_clear_value = 0;
|
|
372
|
+
|
|
373
|
+
if (!depthClearValue.IsEmpty() && depthClearValue->IsNumber()) {
|
|
374
|
+
depthStencilAttachment->depth_clear_value = (float) depthClearValue->NumberValue(
|
|
375
|
+
context).FromJust();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
v8::Local<v8::Value> depthLoadOp;
|
|
379
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
380
|
+
"depthLoadOp")).ToLocal(
|
|
381
|
+
&depthLoadOp);
|
|
382
|
+
|
|
383
|
+
depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
|
|
384
|
+
CanvasOptionalLoadOpNone
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
if (!depthLoadOp.IsEmpty() && depthLoadOp->IsString()) {
|
|
388
|
+
auto value = ConvertFromV8String(isolate, depthLoadOp);
|
|
389
|
+
if (value == "load") {
|
|
390
|
+
depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
|
|
391
|
+
CanvasOptionalLoadOpSome,
|
|
392
|
+
CanvasLoadOpLoad
|
|
393
|
+
};
|
|
394
|
+
} else if (value == "clear") {
|
|
395
|
+
depthStencilAttachment->depth_load_op = CanvasOptionalLoadOp{
|
|
396
|
+
CanvasOptionalLoadOpSome,
|
|
397
|
+
CanvasLoadOpClear
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
v8::Local<v8::Value> depthStoreOp;
|
|
404
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
405
|
+
"depthStoreOp")).ToLocal(
|
|
406
|
+
&depthStoreOp);
|
|
407
|
+
|
|
408
|
+
depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
|
|
409
|
+
CanvasOptionalStoreOpNone
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
if (!depthStoreOp.IsEmpty() && depthStoreOp->IsString()) {
|
|
413
|
+
auto value = ConvertFromV8String(isolate, depthStoreOp);
|
|
414
|
+
if (value == "store") {
|
|
415
|
+
depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
|
|
416
|
+
CanvasOptionalStoreOpSome,
|
|
417
|
+
CanvasStoreOpStore
|
|
418
|
+
};
|
|
419
|
+
} else if (value == "discard") {
|
|
420
|
+
depthStencilAttachment->depth_store_op = depthStencilAttachment->depth_store_op = CanvasOptionalStoreOp{
|
|
421
|
+
CanvasOptionalStoreOpSome,
|
|
422
|
+
CanvasStoreOpDiscard
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
v8::Local<v8::Value> depthReadOnly;
|
|
429
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
430
|
+
"depthReadOnly")).ToLocal(
|
|
431
|
+
&depthReadOnly);
|
|
432
|
+
|
|
433
|
+
depthStencilAttachment->depth_read_only = false;
|
|
434
|
+
if (!depthReadOnly.IsEmpty() && depthReadOnly->IsBoolean()) {
|
|
435
|
+
depthStencilAttachment->depth_read_only = depthReadOnly->BooleanValue(isolate);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
v8::Local<v8::Value> stencilClearValue;
|
|
440
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
441
|
+
"stencilClearValue")).ToLocal(
|
|
442
|
+
&stencilClearValue);
|
|
443
|
+
|
|
444
|
+
depthStencilAttachment->stencil_clear_value = 0;
|
|
445
|
+
|
|
446
|
+
if (!stencilClearValue.IsEmpty() && stencilClearValue->IsUint32()) {
|
|
447
|
+
depthStencilAttachment->stencil_clear_value = stencilClearValue->Uint32Value(
|
|
448
|
+
context).FromJust();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
v8::Local<v8::Value> stencilLoadOp;
|
|
453
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
454
|
+
"stencilLoadOp")).ToLocal(
|
|
455
|
+
&stencilLoadOp);
|
|
456
|
+
|
|
457
|
+
depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
|
|
458
|
+
CanvasOptionalLoadOpNone
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
if (!stencilLoadOp.IsEmpty() && stencilLoadOp->IsString()) {
|
|
462
|
+
auto value = ConvertFromV8String(isolate, stencilLoadOp);
|
|
463
|
+
if (value == "load") {
|
|
464
|
+
depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
|
|
465
|
+
CanvasOptionalLoadOpSome,
|
|
466
|
+
CanvasLoadOpLoad
|
|
467
|
+
};
|
|
468
|
+
} else if (value == "clear") {
|
|
469
|
+
depthStencilAttachment->stencil_load_op = CanvasOptionalLoadOp{
|
|
470
|
+
CanvasOptionalLoadOpSome,
|
|
471
|
+
CanvasLoadOpClear
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
v8::Local<v8::Value> stencilStoreOp;
|
|
478
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
479
|
+
"stencilStoreOp")).ToLocal(
|
|
480
|
+
&stencilStoreOp);
|
|
481
|
+
|
|
482
|
+
depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
|
|
483
|
+
CanvasOptionalStoreOpNone
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
if (!stencilStoreOp.IsEmpty() && stencilStoreOp->IsString()) {
|
|
487
|
+
auto value = ConvertFromV8String(isolate, stencilStoreOp);
|
|
488
|
+
if (value == "store") {
|
|
489
|
+
depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
|
|
490
|
+
CanvasOptionalStoreOpSome,
|
|
491
|
+
CanvasStoreOpStore
|
|
492
|
+
};
|
|
493
|
+
} else if (value == "discard") {
|
|
494
|
+
depthStencilAttachment->stencil_store_op = CanvasOptionalStoreOp{
|
|
495
|
+
CanvasOptionalStoreOpSome,
|
|
496
|
+
CanvasStoreOpDiscard
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
v8::Local<v8::Value> stencilReadOnly;
|
|
503
|
+
depthStencilAttachmentObj->Get(context, ConvertToV8String(isolate,
|
|
504
|
+
"stencilReadOnly")).ToLocal(
|
|
505
|
+
&stencilReadOnly);
|
|
506
|
+
|
|
507
|
+
depthStencilAttachment->stencil_read_only = false;
|
|
508
|
+
if (!stencilReadOnly.IsEmpty() && stencilReadOnly->IsBoolean()) {
|
|
509
|
+
depthStencilAttachment->stencil_read_only = stencilReadOnly->BooleanValue(isolate);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
}
|
|
381
513
|
|
|
382
514
|
const CanvasGPUQuerySet *occlusion_query_set = nullptr;
|
|
383
515
|
v8::Local<v8::Value> occlusionQuerySetVal;
|
|
@@ -386,8 +518,8 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
386
518
|
desc->Get(context, ConvertToV8String(isolate, "occlusionQuerySet")).ToLocal(
|
|
387
519
|
&occlusionQuerySetVal);
|
|
388
520
|
|
|
389
|
-
|
|
390
|
-
if (
|
|
521
|
+
|
|
522
|
+
if (GetNativeType(occlusionQuerySetVal) == NativeType::GPUQuerySet) {
|
|
391
523
|
auto occlusionQuerySet = GPUQuerySetImpl::GetPointer(
|
|
392
524
|
occlusionQuerySetVal.As<v8::Object>());
|
|
393
525
|
occlusion_query_set = occlusionQuerySet->GetQuerySet();
|
|
@@ -410,7 +542,7 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
410
542
|
&querySetVal);
|
|
411
543
|
|
|
412
544
|
|
|
413
|
-
if (
|
|
545
|
+
if (GetNativeType(querySetVal) == NativeType::GPUQuerySet) {
|
|
414
546
|
auto queryPtr = GPUQuerySetImpl::GetPointer(querySetVal.As<v8::Object>());
|
|
415
547
|
if (queryPtr != nullptr) {
|
|
416
548
|
querySet = queryPtr->GetQuerySet();
|
|
@@ -451,6 +583,10 @@ void GPUCommandEncoderImpl::BeginRenderPass(const v8::FunctionCallbackInfo<v8::V
|
|
|
451
583
|
querySet, beginningOfPassWriteIndex, endOfPassWriteIndex
|
|
452
584
|
);
|
|
453
585
|
|
|
586
|
+
if (depthStencilAttachment != nullptr) {
|
|
587
|
+
delete depthStencilAttachment;
|
|
588
|
+
}
|
|
589
|
+
|
|
454
590
|
|
|
455
591
|
}
|
|
456
592
|
|
|
@@ -970,10 +1106,9 @@ void GPUCommandEncoderImpl::Finish(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
970
1106
|
if (descVal->IsObject()) {
|
|
971
1107
|
auto desc = descVal.As<v8::Object>();
|
|
972
1108
|
v8::Local<v8::Value> labelVal;
|
|
973
|
-
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
974
|
-
if (
|
|
1109
|
+
didSet = desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
1110
|
+
if (didSet && labelVal->IsString()) {
|
|
975
1111
|
label = ConvertFromV8String(isolate, labelVal);
|
|
976
|
-
didSet = true;
|
|
977
1112
|
}
|
|
978
1113
|
}
|
|
979
1114
|
|
|
@@ -377,6 +377,8 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
377
377
|
char *label = nullptr;
|
|
378
378
|
|
|
379
379
|
auto optionsVal = args[0];
|
|
380
|
+
|
|
381
|
+
std::vector<CanvasBindGroupEntry> entries;
|
|
380
382
|
|
|
381
383
|
if (optionsVal->IsObject()) {
|
|
382
384
|
auto options = optionsVal.As<v8::Object>();
|
|
@@ -401,7 +403,6 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
405
|
|
|
404
|
-
std::vector<CanvasBindGroupEntry> entries;
|
|
405
406
|
|
|
406
407
|
v8::Local<v8::Value> entriesVal;
|
|
407
408
|
options->Get(context, ConvertToV8String(isolate, "entries")).ToLocal(&entriesVal);
|
|
@@ -466,7 +467,8 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
466
467
|
int64_t offset = -1;
|
|
467
468
|
|
|
468
469
|
v8::Local<v8::Value> offsetVal;
|
|
469
|
-
|
|
470
|
+
|
|
471
|
+
resourceObj->Get(context,
|
|
470
472
|
ConvertToV8String(isolate,
|
|
471
473
|
"offset")).ToLocal(
|
|
472
474
|
&offsetVal);
|
|
@@ -478,9 +480,9 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
478
480
|
int64_t size = -1;
|
|
479
481
|
|
|
480
482
|
v8::Local<v8::Value> sizeVal;
|
|
481
|
-
|
|
483
|
+
resourceObj->Get(context,
|
|
482
484
|
ConvertToV8String(isolate, "size")).ToLocal(
|
|
483
|
-
&
|
|
485
|
+
&sizeVal);
|
|
484
486
|
if (!sizeVal.IsEmpty() && sizeVal->IsNumber()) {
|
|
485
487
|
size = (int64_t) sizeVal->NumberValue(
|
|
486
488
|
context).ToChecked();
|
|
@@ -595,7 +597,7 @@ void GPUDeviceImpl::CreateBindGroupLayout(const v8::FunctionCallbackInfo<v8::Val
|
|
|
595
597
|
|
|
596
598
|
v8::Local<v8::Value> hasDynamicOffsetVal;
|
|
597
599
|
bufferObj->Get(context,
|
|
598
|
-
ConvertToV8String(isolate, "hasDynamicOffset
|
|
600
|
+
ConvertToV8String(isolate, "hasDynamicOffset")).ToLocal(
|
|
599
601
|
&hasDynamicOffsetVal);
|
|
600
602
|
|
|
601
603
|
|
|
@@ -607,7 +609,7 @@ void GPUDeviceImpl::CreateBindGroupLayout(const v8::FunctionCallbackInfo<v8::Val
|
|
|
607
609
|
|
|
608
610
|
v8::Local<v8::Value> minBindingSizeVal;
|
|
609
611
|
bufferObj->Get(context,
|
|
610
|
-
ConvertToV8String(isolate, "minBindingSize
|
|
612
|
+
ConvertToV8String(isolate, "minBindingSize")).ToLocal(
|
|
611
613
|
&minBindingSizeVal);
|
|
612
614
|
|
|
613
615
|
|
|
@@ -1086,9 +1088,10 @@ void GPUDeviceImpl::CreateComputePipeline(const v8::FunctionCallbackInfo<v8::Val
|
|
|
1086
1088
|
|
|
1087
1089
|
if (!keyVal.IsEmpty() && keyVal->IsString() && !valueVal.IsEmpty() &&
|
|
1088
1090
|
valueVal->IsNumber()) {
|
|
1091
|
+
auto val = ConvertFromV8String(isolate, keyVal);
|
|
1089
1092
|
canvas_native_webgpu_constants_insert(
|
|
1090
1093
|
store,
|
|
1091
|
-
|
|
1094
|
+
val.c_str(),
|
|
1092
1095
|
valueVal.As<v8::Number>()->Value()
|
|
1093
1096
|
);
|
|
1094
1097
|
}
|
|
@@ -1412,9 +1415,9 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1412
1415
|
|
|
1413
1416
|
stencilObj->Get(context, ConvertToV8String(isolate, "format")).ToLocal(&formatValue);
|
|
1414
1417
|
if (!formatValue.IsEmpty() && formatValue->IsString()) {
|
|
1415
|
-
auto val =
|
|
1418
|
+
auto val = ConvertFromV8String(isolate, formatValue);
|
|
1416
1419
|
auto format = canvas_native_webgpu_enum_string_to_gpu_texture(
|
|
1417
|
-
val);
|
|
1420
|
+
val.c_str());
|
|
1418
1421
|
if (format.tag ==
|
|
1419
1422
|
CanvasOptionalGPUTextureFormat_Tag::CanvasOptionalGPUTextureFormatSome) {
|
|
1420
1423
|
stencil->format = format.some;
|
|
@@ -1434,8 +1437,8 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1434
1437
|
stencilObj->Get(context, ConvertToV8String(isolate, "depthBiasClamp")).ToLocal(
|
|
1435
1438
|
&depthBiasClampVal);
|
|
1436
1439
|
|
|
1437
|
-
if (!depthBiasClampVal.IsEmpty() && depthBiasClampVal->
|
|
1438
|
-
stencil->depth_bias_clamp = depthBiasClampVal->
|
|
1440
|
+
if (!depthBiasClampVal.IsEmpty() && depthBiasClampVal->IsNumber()) {
|
|
1441
|
+
stencil->depth_bias_clamp = (float)depthBiasClampVal->NumberValue(context).FromJust();
|
|
1439
1442
|
}
|
|
1440
1443
|
|
|
1441
1444
|
|
|
@@ -1443,8 +1446,8 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1443
1446
|
stencilObj->Get(context, ConvertToV8String(isolate, "depthBiasSlopeScale")).ToLocal(
|
|
1444
1447
|
&depthBiasSlopeScaleVal);
|
|
1445
1448
|
|
|
1446
|
-
if (!depthBiasSlopeScaleVal.IsEmpty() && depthBiasSlopeScaleVal->
|
|
1447
|
-
stencil->depth_bias_slope_scale = depthBiasSlopeScaleVal->
|
|
1449
|
+
if (!depthBiasSlopeScaleVal.IsEmpty() && depthBiasSlopeScaleVal->IsNumber()) {
|
|
1450
|
+
stencil->depth_bias_slope_scale = (float)depthBiasSlopeScaleVal->NumberValue(
|
|
1448
1451
|
context).FromJust();
|
|
1449
1452
|
}
|
|
1450
1453
|
|
|
@@ -1570,6 +1573,8 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1570
1573
|
if (!stencilWriteMaskVal.IsEmpty() && stencilWriteMaskVal->IsUint32()) {
|
|
1571
1574
|
stencil->stencil_write_mask = stencilWriteMaskVal->Uint32Value(context).FromJust();
|
|
1572
1575
|
}
|
|
1576
|
+
|
|
1577
|
+
descriptor.depth_stencil = stencil;
|
|
1573
1578
|
|
|
1574
1579
|
}
|
|
1575
1580
|
|
|
@@ -1907,6 +1912,8 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1907
1912
|
case 2:
|
|
1908
1913
|
primitive->cull_mode = CanvasCullMode::CanvasCullModeBack;
|
|
1909
1914
|
break;
|
|
1915
|
+
default:
|
|
1916
|
+
break;
|
|
1910
1917
|
}
|
|
1911
1918
|
} else if (cullModeValue->IsString()) {
|
|
1912
1919
|
|
|
@@ -2059,7 +2066,6 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2059
2066
|
|
|
2060
2067
|
std::vector<std::vector<CanvasVertexAttribute>> attributes;
|
|
2061
2068
|
|
|
2062
|
-
|
|
2063
2069
|
if (!vertexValue.IsEmpty() && vertexValue->IsObject()) {
|
|
2064
2070
|
auto vertexObj = vertexValue.As<v8::Object>();
|
|
2065
2071
|
vertex = new CanvasVertexState{};
|
|
@@ -2256,6 +2262,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2256
2262
|
}
|
|
2257
2263
|
|
|
2258
2264
|
}
|
|
2265
|
+
|
|
2266
|
+
if(descriptor.depth_stencil != nullptr){
|
|
2267
|
+
delete descriptor.depth_stencil;
|
|
2268
|
+
}
|
|
2259
2269
|
|
|
2260
2270
|
|
|
2261
2271
|
if (pipeline != nullptr) {
|
|
@@ -2599,10 +2609,9 @@ void GPUDeviceImpl::CreateTexture(const v8::FunctionCallbackInfo<v8::Value> &arg
|
|
|
2599
2609
|
|
|
2600
2610
|
|
|
2601
2611
|
v8::Local<v8::Value> formatVal;
|
|
2602
|
-
options->Get(context, ConvertToV8String(isolate, "format")).ToLocal(
|
|
2603
|
-
&formatVal);
|
|
2604
2612
|
|
|
2605
|
-
if (
|
|
2613
|
+
if (options->Get(context, ConvertToV8String(isolate, "format")).ToLocal(
|
|
2614
|
+
&formatVal) && formatVal->IsString()) {
|
|
2606
2615
|
auto format = ConvertFromV8String(isolate, formatVal);
|
|
2607
2616
|
|
|
2608
2617
|
// todo use enum
|
|
@@ -27,7 +27,8 @@ void GPURenderPassEncoderImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isol
|
|
|
27
27
|
auto context = isolate->GetCurrentContext();
|
|
28
28
|
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
29
29
|
|
|
30
|
-
canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"),
|
|
30
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPURenderPassEncoder"),
|
|
31
|
+
func).FromJust();;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
GPURenderPassEncoderImpl *
|
|
@@ -53,7 +54,6 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
|
|
|
53
54
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
54
55
|
tmpl->SetInternalFieldCount(2);
|
|
55
56
|
|
|
56
|
-
|
|
57
57
|
tmpl->Set(
|
|
58
58
|
ConvertToV8String(isolate, "beginOcclusionQuery"),
|
|
59
59
|
v8::FunctionTemplate::New(isolate, &BeginOcclusionQuery));
|
|
@@ -66,7 +66,6 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
|
|
|
66
66
|
ConvertToV8String(isolate, "drawIndexed"),
|
|
67
67
|
v8::FunctionTemplate::New(isolate, &DrawIndexed));
|
|
68
68
|
|
|
69
|
-
|
|
70
69
|
tmpl->Set(
|
|
71
70
|
ConvertToV8String(isolate, "drawIndexedIndirect"),
|
|
72
71
|
v8::FunctionTemplate::New(isolate, &DrawIndexedIndirect));
|
|
@@ -75,12 +74,10 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
|
|
|
75
74
|
ConvertToV8String(isolate, "drawIndirect"),
|
|
76
75
|
v8::FunctionTemplate::New(isolate, &DrawIndirect));
|
|
77
76
|
|
|
78
|
-
|
|
79
77
|
tmpl->Set(
|
|
80
78
|
ConvertToV8String(isolate, "end"),
|
|
81
79
|
v8::FunctionTemplate::New(isolate, &End));
|
|
82
80
|
|
|
83
|
-
|
|
84
81
|
tmpl->Set(
|
|
85
82
|
ConvertToV8String(isolate, "endOcclusionQuery"),
|
|
86
83
|
v8::FunctionTemplate::New(isolate, &EndOcclusionQuery));
|
|
@@ -173,7 +170,6 @@ void GPURenderPassEncoderImpl::Draw(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
173
170
|
if (vertexCountVal->IsUint32()) {
|
|
174
171
|
auto vertexCount = vertexCountVal.As<v8::Uint32>()->Value();
|
|
175
172
|
|
|
176
|
-
|
|
177
173
|
if (instanceCountVal->IsUint32()) {
|
|
178
174
|
instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
|
|
179
175
|
}
|
|
@@ -209,12 +205,16 @@ void GPURenderPassEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::Va
|
|
|
209
205
|
|
|
210
206
|
|
|
211
207
|
auto indexCountVal = args[0];
|
|
212
|
-
auto
|
|
213
|
-
auto
|
|
214
|
-
auto
|
|
208
|
+
auto instanceCountVal = args[1];
|
|
209
|
+
auto firstIndexVal = args[2];
|
|
210
|
+
auto baseVertexVal = args[3];
|
|
211
|
+
auto firstInstanceVal = args[4];
|
|
215
212
|
|
|
216
213
|
if (indexCountVal->IsUint32()) {
|
|
217
214
|
|
|
215
|
+
if (instanceCountVal->IsUint32()) {
|
|
216
|
+
instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
|
|
217
|
+
}
|
|
218
218
|
|
|
219
219
|
if (firstIndexVal->IsUint32()) {
|
|
220
220
|
firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
|
|
@@ -415,11 +415,11 @@ void GPURenderPassEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8::V
|
|
|
415
415
|
auto data = static_cast<uint8_t *>(buffer->GetBackingStore()->Data()) + offset;
|
|
416
416
|
auto size = buf->Length();
|
|
417
417
|
auto start = (size_t) dynamicOffsetsStart->NumberValue(context).FromJust();
|
|
418
|
-
auto offset_length = (size_t)
|
|
418
|
+
auto offset_length = (size_t) dynamicOffsetsLength->NumberValue(context).FromJust();
|
|
419
419
|
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
bindgroup->GetBindGroup(),
|
|
421
|
+
static_cast<const uint32_t *>(static_cast<void *>(data)),
|
|
422
|
+
size, start, offset_length);
|
|
423
423
|
} else {
|
|
424
424
|
canvas_native_webgpu_render_pass_encoder_set_bind_group(ptr->GetPass(), index,
|
|
425
425
|
bindgroup->GetBindGroup(),
|
|
@@ -435,7 +435,6 @@ void GPURenderPassEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v8:
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
auto isolate = args.GetIsolate();
|
|
438
|
-
auto context = isolate->GetCurrentContext();
|
|
439
438
|
|
|
440
439
|
auto bufferVal = args[0];
|
|
441
440
|
auto indexFormatVal = args[1];
|
|
@@ -482,41 +481,13 @@ void GPURenderPassEncoderImpl::SetBlendConstant(const v8::FunctionCallbackInfo<v
|
|
|
482
481
|
}
|
|
483
482
|
|
|
484
483
|
auto isolate = args.GetIsolate();
|
|
485
|
-
auto context = isolate->GetCurrentContext();
|
|
486
484
|
|
|
487
485
|
auto colorVal = args[0];
|
|
488
486
|
|
|
489
|
-
if (colorVal->IsObject()) {
|
|
490
|
-
|
|
491
|
-
auto color = CanvasColor{0, 0, 0, 0};
|
|
492
|
-
auto colorObj = colorVal.As<v8::Object>();
|
|
487
|
+
if (colorVal->IsObject() || colorVal->IsArray()) {
|
|
493
488
|
|
|
494
|
-
|
|
495
|
-
v8::Local<v8::Value> g;
|
|
496
|
-
v8::Local<v8::Value> b;
|
|
497
|
-
v8::Local<v8::Value> a;
|
|
489
|
+
auto color = ParseColor(isolate, colorVal);
|
|
498
490
|
|
|
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
491
|
|
|
521
492
|
canvas_native_webgpu_render_pass_encoder_set_blend_constant(ptr->GetPass(), &color);
|
|
522
493
|
}
|
|
@@ -530,12 +501,10 @@ void GPURenderPassEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::Va
|
|
|
530
501
|
}
|
|
531
502
|
|
|
532
503
|
auto pipelineVal = args[0];
|
|
533
|
-
if
|
|
504
|
+
if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
|
|
534
505
|
auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
pipeline->GetGPUPipeline());
|
|
538
|
-
}
|
|
506
|
+
canvas_native_webgpu_render_pass_encoder_set_pipeline(ptr->GetPass(),
|
|
507
|
+
pipeline->GetGPUPipeline());
|
|
539
508
|
}
|
|
540
509
|
}
|
|
541
510
|
|
|
@@ -598,12 +567,13 @@ void GPURenderPassEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<v8
|
|
|
598
567
|
|
|
599
568
|
if (slotVal->IsUint32() && bufferVal->IsObject()) {
|
|
600
569
|
auto slot = slotVal.As<v8::Uint32>()->Value();
|
|
601
|
-
|
|
602
|
-
if (buffer == nullptr) {
|
|
570
|
+
if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
|
|
603
571
|
// todo throw ??
|
|
604
572
|
return;
|
|
605
573
|
}
|
|
606
574
|
|
|
575
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
576
|
+
|
|
607
577
|
if (offsetVal->IsNumber()) {
|
|
608
578
|
offset = (int64_t) offsetVal.As<v8::Number>()->Value();
|
|
609
579
|
}
|