@nativescript/canvas 2.0.0-webgpu.10 → 2.0.0-webgpu.12
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 +3 -1
- package/Canvas/common.js +10 -0
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.js +7 -7
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +11 -3
- package/Canvas/index.ios.js +14 -3
- package/Canvas/index.ios.js.map +1 -1
- package/ImageAsset/index.js +39 -17
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.js +18 -21
- package/ImageBitmap/index.js.map +1 -1
- 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 +3 -2
- package/WebGPU/GPUAdapter.js +6 -0
- package/WebGPU/GPUAdapter.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +1 -0
- package/WebGPU/GPUCanvasContext.js +17 -0
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +3 -3
- package/WebGPU/GPUDevice.js +77 -15
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUQueue.js +8 -0
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderBundleEncoder.d.ts +3 -2
- package/WebGPU/GPURenderBundleEncoder.js +4 -3
- package/WebGPU/GPURenderBundleEncoder.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 +1 -0
- 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 +170 -55
- 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 +67 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +1 -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 +647 -645
- 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_ios.h +7 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +170 -55
- 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 +67 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +67 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +26 -26
- 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 +649 -647
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +687 -685
- 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 +116 -44
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +16 -24
- package/platforms/ios/src/cpp/ImageAssetImpl.h +3 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +22 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +6 -3
- package/platforms/ios/src/cpp/PromiseCallback.h +1 -2
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +3 -3
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +7 -6
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +437 -439
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +35 -55
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +2 -1
- package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +23 -9
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +12 -9
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +1 -1
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
#include "GPUQuerySetImpl.h"
|
|
22
22
|
#include "GPURenderBundleEncoderImpl.h"
|
|
23
23
|
#include "GPUUtils.h"
|
|
24
|
+
#include "GPULabel.h"
|
|
24
25
|
|
|
25
26
|
GPUDeviceImpl::GPUDeviceImpl(const CanvasGPUDevice *device) : device_(device) {}
|
|
26
27
|
|
|
@@ -432,7 +433,7 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
432
433
|
}
|
|
433
434
|
auto isolate = args.GetIsolate();
|
|
434
435
|
auto context = isolate->GetCurrentContext();
|
|
435
|
-
|
|
436
|
+
GPULabel label;
|
|
436
437
|
|
|
437
438
|
auto optionsVal = args[0];
|
|
438
439
|
|
|
@@ -444,7 +445,7 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
444
445
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
445
446
|
|
|
446
447
|
|
|
447
|
-
label =
|
|
448
|
+
label = GPULabel(isolate, labelVal);
|
|
448
449
|
|
|
449
450
|
const CanvasGPUBindGroupLayout *layout = nullptr;
|
|
450
451
|
|
|
@@ -466,7 +467,7 @@ void GPUDeviceImpl::CreateBindGroup(const v8::FunctionCallbackInfo<v8::Value> &a
|
|
|
466
467
|
entries = ParseBindGroupEntries(isolate, entriesVal);
|
|
467
468
|
|
|
468
469
|
auto bind_group = canvas_native_webgpu_device_create_bind_group(ptr->GetGPUDevice(),
|
|
469
|
-
label
|
|
470
|
+
*label,
|
|
470
471
|
layout, entries.data(),
|
|
471
472
|
entries.size());
|
|
472
473
|
|
|
@@ -487,7 +488,7 @@ void GPUDeviceImpl::CreateBindGroupLayout(const v8::FunctionCallbackInfo<v8::Val
|
|
|
487
488
|
}
|
|
488
489
|
auto isolate = args.GetIsolate();
|
|
489
490
|
auto context = isolate->GetCurrentContext();
|
|
490
|
-
|
|
491
|
+
GPULabel label;
|
|
491
492
|
|
|
492
493
|
auto optionsVal = args[0];
|
|
493
494
|
|
|
@@ -496,7 +497,7 @@ void GPUDeviceImpl::CreateBindGroupLayout(const v8::FunctionCallbackInfo<v8::Val
|
|
|
496
497
|
v8::Local<v8::Value> labelVal;
|
|
497
498
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
498
499
|
|
|
499
|
-
label =
|
|
500
|
+
label = GPULabel(isolate, labelVal);
|
|
500
501
|
|
|
501
502
|
v8::Local<v8::Value> entriesVal;
|
|
502
503
|
options->Get(context, ConvertToV8String(isolate, "entries")).ToLocal(&entriesVal);
|
|
@@ -505,7 +506,7 @@ void GPUDeviceImpl::CreateBindGroupLayout(const v8::FunctionCallbackInfo<v8::Val
|
|
|
505
506
|
entriesVal);
|
|
506
507
|
|
|
507
508
|
auto bind_group = canvas_native_webgpu_device_create_bind_group_layout(ptr->GetGPUDevice(),
|
|
508
|
-
label
|
|
509
|
+
*label,
|
|
509
510
|
entries.data(),
|
|
510
511
|
entries.size());
|
|
511
512
|
|
|
@@ -527,7 +528,7 @@ void GPUDeviceImpl::CreateBuffer(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
527
528
|
}
|
|
528
529
|
auto isolate = args.GetIsolate();
|
|
529
530
|
auto context = isolate->GetCurrentContext();
|
|
530
|
-
|
|
531
|
+
GPULabel label;
|
|
531
532
|
bool mappedAtCreation = false;
|
|
532
533
|
uint64_t size = 0;
|
|
533
534
|
uint32_t usage = 0;
|
|
@@ -539,7 +540,7 @@ void GPUDeviceImpl::CreateBuffer(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
539
540
|
v8::Local<v8::Value> labelVal;
|
|
540
541
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
541
542
|
|
|
542
|
-
label =
|
|
543
|
+
label = GPULabel(isolate, labelVal);
|
|
543
544
|
v8::Local<v8::Value> mappedAtCreationVal;
|
|
544
545
|
|
|
545
546
|
options->Get(context, ConvertToV8String(isolate, "mappedAtCreation")).ToLocal(
|
|
@@ -565,7 +566,7 @@ void GPUDeviceImpl::CreateBuffer(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
565
566
|
}
|
|
566
567
|
}
|
|
567
568
|
|
|
568
|
-
auto buffer = canvas_native_webgpu_device_create_buffer(ptr->GetGPUDevice(), label
|
|
569
|
+
auto buffer = canvas_native_webgpu_device_create_buffer(ptr->GetGPUDevice(), *label,
|
|
569
570
|
size, usage,
|
|
570
571
|
mappedAtCreation);
|
|
571
572
|
|
|
@@ -587,14 +588,10 @@ void GPUDeviceImpl::CreateCommandEncoder(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
587
588
|
}
|
|
588
589
|
auto isolate = args.GetIsolate();
|
|
589
590
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
auto labelVal = args[0];
|
|
593
|
-
|
|
594
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
591
|
+
auto label = GPULabel(isolate, args[0]);
|
|
595
592
|
|
|
596
593
|
auto encoder = canvas_native_webgpu_device_create_command_encoder(ptr->GetGPUDevice(),
|
|
597
|
-
label
|
|
594
|
+
*label);
|
|
598
595
|
|
|
599
596
|
if (encoder != nullptr) {
|
|
600
597
|
auto instance = new GPUCommandEncoderImpl(encoder);
|
|
@@ -626,9 +623,7 @@ void GPUDeviceImpl::CreateComputePipeline(const v8::FunctionCallbackInfo<v8::Val
|
|
|
626
623
|
v8::Local<v8::Value> labelVal;
|
|
627
624
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
628
625
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
626
|
+
GPULabel label(isolate, labelVal);
|
|
632
627
|
|
|
633
628
|
CanvasGPUPipelineLayoutOrGPUAutoLayoutMode layout{
|
|
634
629
|
CanvasGPUPipelineLayoutOrGPUAutoLayoutModeAuto
|
|
@@ -714,7 +709,7 @@ void GPUDeviceImpl::CreateComputePipeline(const v8::FunctionCallbackInfo<v8::Val
|
|
|
714
709
|
};
|
|
715
710
|
|
|
716
711
|
auto pipeline = canvas_native_webgpu_device_create_compute_pipeline(ptr->GetGPUDevice(),
|
|
717
|
-
label
|
|
712
|
+
*label, layout,
|
|
718
713
|
&stage);
|
|
719
714
|
|
|
720
715
|
if (entry_point != nullptr) {
|
|
@@ -785,9 +780,7 @@ void GPUDeviceImpl::CreateComputePipelineAsync(const v8::FunctionCallbackInfo<v8
|
|
|
785
780
|
v8::Local<v8::Value> labelVal;
|
|
786
781
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
787
782
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
783
|
+
auto label = GPULabel(isolate, labelVal);
|
|
791
784
|
|
|
792
785
|
CanvasGPUPipelineLayoutOrGPUAutoLayoutMode layout{
|
|
793
786
|
CanvasGPUPipelineLayoutOrGPUAutoLayoutModeAuto
|
|
@@ -995,7 +988,7 @@ void GPUDeviceImpl::CreateComputePipelineAsync(const v8::FunctionCallbackInfo<v8
|
|
|
995
988
|
};
|
|
996
989
|
async_callback->prepare();
|
|
997
990
|
canvas_native_webgpu_device_create_compute_pipeline_async(ptr->GetGPUDevice(),
|
|
998
|
-
label
|
|
991
|
+
*label, layout, &stage,
|
|
999
992
|
[](const struct CanvasGPUComputePipeline *pipeline,
|
|
1000
993
|
enum CanvasGPUErrorType type,
|
|
1001
994
|
char *message,
|
|
@@ -1039,9 +1032,7 @@ void GPUDeviceImpl::CreatePipelineLayout(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1039
1032
|
v8::Local<v8::Value> labelVal;
|
|
1040
1033
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
1041
1034
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
1035
|
+
auto label = GPULabel(isolate, labelVal);
|
|
1045
1036
|
|
|
1046
1037
|
|
|
1047
1038
|
std::vector<const CanvasGPUBindGroupLayout *> group_layouts;
|
|
@@ -1064,7 +1055,7 @@ void GPUDeviceImpl::CreatePipelineLayout(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1064
1055
|
}
|
|
1065
1056
|
|
|
1066
1057
|
auto layout = canvas_native_webgpu_device_create_pipeline_layout(ptr->GetGPUDevice(),
|
|
1067
|
-
label
|
|
1058
|
+
*label,
|
|
1068
1059
|
group_layouts.data(),
|
|
1069
1060
|
group_layouts.size());
|
|
1070
1061
|
|
|
@@ -1099,9 +1090,7 @@ void GPUDeviceImpl::CreateQuerySet(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
1099
1090
|
v8::Local<v8::Value> labelVal;
|
|
1100
1091
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
1101
1092
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
1093
|
+
auto label = GPULabel(isolate, labelVal);
|
|
1105
1094
|
v8::Local<v8::Value> typeVal;
|
|
1106
1095
|
options->Get(context, ConvertToV8String(isolate, "type")).ToLocal(&typeVal);
|
|
1107
1096
|
|
|
@@ -1113,12 +1102,12 @@ void GPUDeviceImpl::CreateQuerySet(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
1113
1102
|
|
|
1114
1103
|
const CanvasGPUQuerySet *query_set = nullptr;
|
|
1115
1104
|
if (typeStr == "occlusion") {
|
|
1116
|
-
query_set = canvas_native_webgpu_device_create_query_set(ptr->GetGPUDevice(), label
|
|
1105
|
+
query_set = canvas_native_webgpu_device_create_query_set(ptr->GetGPUDevice(), *label,
|
|
1117
1106
|
CanvasQueryTypeOcclusion,
|
|
1118
1107
|
countVal->Uint32Value(
|
|
1119
1108
|
context).FromJust());
|
|
1120
1109
|
} else if (typeStr == "timestamp") {
|
|
1121
|
-
query_set = canvas_native_webgpu_device_create_query_set(ptr->GetGPUDevice(), label
|
|
1110
|
+
query_set = canvas_native_webgpu_device_create_query_set(ptr->GetGPUDevice(), *label,
|
|
1122
1111
|
CanvasQueryTypeTimestamp,
|
|
1123
1112
|
countVal->Uint32Value(
|
|
1124
1113
|
context).FromJust());
|
|
@@ -1156,9 +1145,7 @@ void GPUDeviceImpl::CreateRenderBundleEncoder(const v8::FunctionCallbackInfo<v8:
|
|
|
1156
1145
|
v8::Local<v8::Value> labelVal;
|
|
1157
1146
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
1158
1147
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
1148
|
+
auto label = GPULabel(isolate, labelVal);
|
|
1162
1149
|
|
|
1163
1150
|
std::vector<CanvasGPUTextureFormat> colorFormats;
|
|
1164
1151
|
|
|
@@ -1204,7 +1191,7 @@ void GPUDeviceImpl::CreateRenderBundleEncoder(const v8::FunctionCallbackInfo<v8:
|
|
|
1204
1191
|
bool stencilReadOnly = false;
|
|
1205
1192
|
|
|
1206
1193
|
CanvasCreateRenderBundleEncoderDescriptor descriptor{
|
|
1207
|
-
label
|
|
1194
|
+
*label,
|
|
1208
1195
|
colorFormats.data(),
|
|
1209
1196
|
colorFormats.size(),
|
|
1210
1197
|
depthStencilFormat,
|
|
@@ -1307,7 +1294,7 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1307
1294
|
}
|
|
1308
1295
|
auto options = optionsVal.As<v8::Object>();
|
|
1309
1296
|
|
|
1310
|
-
|
|
1297
|
+
GPULabel label;
|
|
1311
1298
|
|
|
1312
1299
|
v8::Local<v8::Value> stencilValue;
|
|
1313
1300
|
options->Get(context, ConvertToV8String(isolate, "depthStencil")).ToLocal(
|
|
@@ -1720,11 +1707,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1720
1707
|
&labelVal);
|
|
1721
1708
|
|
|
1722
1709
|
|
|
1723
|
-
label =
|
|
1710
|
+
label = GPULabel(isolate, labelVal);
|
|
1724
1711
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}
|
|
1712
|
+
|
|
1713
|
+
descriptor.label = *label;
|
|
1728
1714
|
|
|
1729
1715
|
|
|
1730
1716
|
v8::Local<v8::Value> layoutVal;
|
|
@@ -2227,7 +2213,7 @@ void GPUDeviceImpl::CreateRenderPipelineAsync(const v8::FunctionCallbackInfo<v8:
|
|
|
2227
2213
|
return;
|
|
2228
2214
|
}
|
|
2229
2215
|
auto options = optionsVal.As<v8::Object>();
|
|
2230
|
-
|
|
2216
|
+
GPULabel label;
|
|
2231
2217
|
|
|
2232
2218
|
v8::Local<v8::Value> stencilValue;
|
|
2233
2219
|
options->Get(context, ConvertToV8String(isolate, "depthStencil")).ToLocal(
|
|
@@ -2639,12 +2625,10 @@ void GPUDeviceImpl::CreateRenderPipelineAsync(const v8::FunctionCallbackInfo<v8:
|
|
|
2639
2625
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(
|
|
2640
2626
|
&labelVal);
|
|
2641
2627
|
|
|
2642
|
-
label =
|
|
2643
|
-
|
|
2628
|
+
label = GPULabel(isolate, labelVal);
|
|
2644
2629
|
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
}
|
|
2630
|
+
descriptor.label = *label;
|
|
2631
|
+
|
|
2648
2632
|
|
|
2649
2633
|
|
|
2650
2634
|
v8::Local<v8::Value> layoutVal;
|
|
@@ -3268,9 +3252,7 @@ void GPUDeviceImpl::CreateSampler(const v8::FunctionCallbackInfo<v8::Value> &arg
|
|
|
3268
3252
|
v8::Local<v8::Value> labelVal;
|
|
3269
3253
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
3270
3254
|
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
3255
|
+
GPULabel label(isolate, labelVal);
|
|
3274
3256
|
|
|
3275
3257
|
auto addressModeU = CanvasAddressModeClampToEdge;
|
|
3276
3258
|
|
|
@@ -3405,7 +3387,7 @@ void GPUDeviceImpl::CreateSampler(const v8::FunctionCallbackInfo<v8::Value> &arg
|
|
|
3405
3387
|
|
|
3406
3388
|
|
|
3407
3389
|
CanvasCreateSamplerDescriptor descriptor{
|
|
3408
|
-
label
|
|
3390
|
+
*label,
|
|
3409
3391
|
addressModeU,
|
|
3410
3392
|
addressModeV,
|
|
3411
3393
|
addressModeW,
|
|
@@ -3456,9 +3438,7 @@ void GPUDeviceImpl::CreateShaderModule(const v8::FunctionCallbackInfo<v8::Value>
|
|
|
3456
3438
|
v8::Local<v8::Value> labelVal;
|
|
3457
3439
|
desc->Get(context, ConvertToV8String(isolate, "label")).ToLocal(&labelVal);
|
|
3458
3440
|
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
label = ConvertFromV8String(isolate, labelVal);
|
|
3441
|
+
GPULabel label(isolate, labelVal);
|
|
3462
3442
|
|
|
3463
3443
|
v8::Local<v8::Value> codeVal;
|
|
3464
3444
|
|
|
@@ -3469,7 +3449,7 @@ void GPUDeviceImpl::CreateShaderModule(const v8::FunctionCallbackInfo<v8::Value>
|
|
|
3469
3449
|
}
|
|
3470
3450
|
|
|
3471
3451
|
auto module = canvas_native_webgpu_device_create_shader_module(ptr->GetGPUDevice(),
|
|
3472
|
-
label
|
|
3452
|
+
*label,
|
|
3473
3453
|
code.c_str());
|
|
3474
3454
|
|
|
3475
3455
|
if (module != nullptr) {
|
|
@@ -154,8 +154,9 @@ void GPUImpl::RequestAdapter(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
154
154
|
callback->Call(context, context->Global(),
|
|
155
155
|
2,
|
|
156
156
|
args); // ignore JS return value
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
delete static_cast<AsyncCallback *>(data);
|
|
159
|
+
|
|
159
160
|
} else {
|
|
160
161
|
v8::Local<v8::Value> args[1] = {
|
|
161
162
|
v8::Null(isolate)};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 19/08/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPULABEL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPULABEL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
|
|
11
|
+
class GPULabel {
|
|
12
|
+
public:
|
|
13
|
+
GPULabel(){}
|
|
14
|
+
GPULabel(v8::Isolate *isolate, const v8::Local<v8::Value> &label) {
|
|
15
|
+
if (label->IsString() || label->IsStringObject()) {
|
|
16
|
+
label_ = ConvertFromV8String(isolate, label);
|
|
17
|
+
hasLabel_ = true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const char *operator*() {
|
|
22
|
+
if (hasLabel_) {
|
|
23
|
+
return label_.c_str();
|
|
24
|
+
}
|
|
25
|
+
return nullptr;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
std::string label_;
|
|
30
|
+
bool hasLabel_ = false;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#endif //CANVAS_ANDROID_GPULABEL_H
|
|
@@ -136,16 +136,13 @@ 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* imageAsset = nullptr;
|
|
139
140
|
if (sourceType == NativeType::ImageBitmap) {
|
|
140
|
-
auto
|
|
141
|
-
|
|
142
|
-
width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
|
|
143
|
-
height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
|
|
141
|
+
auto bitmap = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
142
|
+
imageAsset = bitmap->GetImageAsset();
|
|
144
143
|
} else if (sourceType == NativeType::ImageAsset) {
|
|
145
|
-
auto
|
|
146
|
-
|
|
147
|
-
width = canvas_native_image_asset_width(imageAsset->GetImageAsset());
|
|
148
|
-
height = canvas_native_image_asset_height(imageAsset->GetImageAsset());
|
|
144
|
+
auto asset = ImageAssetImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
145
|
+
imageAsset = asset->GetImageAsset();
|
|
149
146
|
} else if (sourceType == NativeType::ImageData) {
|
|
150
147
|
auto imageData = ImageDataImpl::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
151
148
|
buffer = canvas_native_image_data_get_data(imageData->GetImageData());
|
|
@@ -157,7 +154,7 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
157
154
|
auto webgl = WebGLRenderingContextBase::GetPointer(sourceSourceValue.As<v8::Object>());
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
if (buffer == nullptr) {
|
|
157
|
+
if (buffer == nullptr && imageAsset == nullptr) {
|
|
161
158
|
// todo error ??
|
|
162
159
|
return;
|
|
163
160
|
}
|
|
@@ -262,10 +259,27 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
|
|
|
262
259
|
|
|
263
260
|
|
|
264
261
|
CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
|
|
262
|
+
|
|
263
|
+
if (imageAsset != nullptr){
|
|
264
|
+
CanvasImageCopyImageAsset source{
|
|
265
|
+
imageAsset,
|
|
266
|
+
sourceOrigin,
|
|
267
|
+
flipY,
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
canvas_native_webgpu_queue_copy_image_asset_to_texture(ptr->GetGPUQueue(), &source,
|
|
272
|
+
&destination,
|
|
273
|
+
&extent3D);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
265
277
|
|
|
266
278
|
auto data = canvas_native_u8_buffer_get_bytes(buffer);
|
|
267
279
|
auto size = canvas_native_u8_buffer_get_length(buffer);
|
|
268
280
|
|
|
281
|
+
|
|
282
|
+
|
|
269
283
|
if (data == nullptr || size == 0) {
|
|
270
284
|
// todo error
|
|
271
285
|
return;
|
|
@@ -190,12 +190,16 @@ void GPURenderBundleEncoderImpl::DrawIndexed(const v8::FunctionCallbackInfo<v8::
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
auto indexCountVal = args[0];
|
|
193
|
-
auto
|
|
194
|
-
auto
|
|
195
|
-
auto
|
|
193
|
+
auto instanceCountVal = args[1];
|
|
194
|
+
auto firstIndexVal = args[2];
|
|
195
|
+
auto baseVertexVal = args[3];
|
|
196
|
+
auto firstInstanceVal = args[4];
|
|
196
197
|
|
|
197
198
|
if (indexCountVal->IsUint32()) {
|
|
198
199
|
|
|
200
|
+
if (instanceCountVal->IsUint32()) {
|
|
201
|
+
instanceCount = instanceCountVal.As<v8::Uint32>()->Value();
|
|
202
|
+
}
|
|
199
203
|
|
|
200
204
|
if (firstIndexVal->IsUint32()) {
|
|
201
205
|
firstIndex = firstIndexVal.As<v8::Uint32>()->Value();
|
|
@@ -370,7 +374,7 @@ void GPURenderBundleEncoderImpl::SetBindGroup(const v8::FunctionCallbackInfo<v8:
|
|
|
370
374
|
auto index = indexVal->Uint32Value(context).FromJust();
|
|
371
375
|
auto bindGroup = GPUBindGroupImpl::GetPointer(bindGroupVal.As<v8::Object>());
|
|
372
376
|
|
|
373
|
-
if (dynamicOffsets->
|
|
377
|
+
if (dynamicOffsets->IsUint32Array()) {
|
|
374
378
|
auto buf = dynamicOffsets.As<v8::Uint32Array>();
|
|
375
379
|
auto buffer = buf->Buffer();
|
|
376
380
|
auto store = buffer->GetBackingStore();
|
|
@@ -399,7 +403,6 @@ void GPURenderBundleEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v
|
|
|
399
403
|
}
|
|
400
404
|
|
|
401
405
|
auto isolate = args.GetIsolate();
|
|
402
|
-
auto context = isolate->GetCurrentContext();
|
|
403
406
|
|
|
404
407
|
auto bufferVal = args[0];
|
|
405
408
|
auto indexFormatVal = args[1];
|
|
@@ -410,7 +413,7 @@ void GPURenderBundleEncoderImpl::SetIndexBuffer(const v8::FunctionCallbackInfo<v
|
|
|
410
413
|
|
|
411
414
|
auto type = GetNativeType(bufferVal);
|
|
412
415
|
|
|
413
|
-
if (type == NativeType::
|
|
416
|
+
if (type == NativeType::GPUBuffer) {
|
|
414
417
|
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
415
418
|
auto indexFormat = ConvertFromV8String(isolate, indexFormatVal);
|
|
416
419
|
if (offsetVal->IsNumber()) {
|
|
@@ -446,7 +449,7 @@ void GPURenderBundleEncoderImpl::SetPipeline(const v8::FunctionCallbackInfo<v8::
|
|
|
446
449
|
}
|
|
447
450
|
|
|
448
451
|
auto pipelineVal = args[0];
|
|
449
|
-
if
|
|
452
|
+
if(GetNativeType(pipelineVal) == NativeType::GPURenderPipeline){
|
|
450
453
|
auto pipeline = GPURenderPipelineImpl::GetPointer(pipelineVal.As<v8::Object>());
|
|
451
454
|
if (pipeline != nullptr) {
|
|
452
455
|
canvas_native_webgpu_render_bundle_encoder_set_pipeline(ptr->GetEncoder(),
|
|
@@ -470,11 +473,11 @@ void GPURenderBundleEncoderImpl::SetVertexBuffer(const v8::FunctionCallbackInfo<
|
|
|
470
473
|
|
|
471
474
|
if (slotVal->IsUint32() && bufferVal->IsObject()) {
|
|
472
475
|
auto slot = slotVal.As<v8::Uint32>()->Value();
|
|
473
|
-
|
|
474
|
-
if (buffer == nullptr) {
|
|
476
|
+
if (GetNativeType(bufferVal) != NativeType::GPUBuffer) {
|
|
475
477
|
// todo throw ??
|
|
476
478
|
return;
|
|
477
479
|
}
|
|
480
|
+
auto buffer = GPUBufferImpl::GetPointer(bufferVal.As<v8::Object>());
|
|
478
481
|
|
|
479
482
|
if (offsetVal->IsNumber()) {
|
|
480
483
|
offset = (int64_t) offsetVal.As<v8::Number>()->Value();
|
|
@@ -354,7 +354,7 @@ void GPURenderPassEncoderImpl::ExecuteBundles(const v8::FunctionCallbackInfo<v8:
|
|
|
354
354
|
std::vector<const CanvasGPURenderBundle *> bundles;
|
|
355
355
|
for (int i = 0; i < len; i++) {
|
|
356
356
|
v8::Local<v8::Value> bundleVal;
|
|
357
|
-
bundlesArray->Get(context, i).ToLocal(&
|
|
357
|
+
bundlesArray->Get(context, i).ToLocal(&bundleVal);
|
|
358
358
|
auto type = GetNativeType(bundleVal);
|
|
359
359
|
if (type == NativeType::GPURenderBundle) {
|
|
360
360
|
auto bundle = GPURenderBundleImpl::GetPointer(bundleVal.As<v8::Object>());
|