react-native-webgpu 0.5.11 → 0.5.13
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/README.md +84 -0
- package/android/CMakeLists.txt +2 -0
- package/android/cpp/AndroidPlatformContext.h +121 -0
- package/apple/ApplePlatformContext.h +13 -0
- package/apple/ApplePlatformContext.mm +145 -0
- package/apple/AppleVideoPlayer.h +31 -0
- package/apple/AppleVideoPlayer.mm +314 -0
- package/cpp/rnwgpu/ArrayBuffer.h +51 -7
- package/cpp/rnwgpu/PlatformContext.h +81 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +12 -0
- package/cpp/rnwgpu/api/Convertors.h +33 -11
- package/cpp/rnwgpu/api/GPU.cpp +27 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +109 -33
- package/cpp/rnwgpu/api/GPUDevice.cpp +58 -5
- package/cpp/rnwgpu/api/GPUDevice.h +6 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.cpp +335 -0
- package/cpp/rnwgpu/api/GPUExternalTexture.h +47 -2
- package/cpp/rnwgpu/api/GPUFeatures.h +4 -1
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +2 -3
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +80 -0
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +71 -0
- package/cpp/rnwgpu/api/ImageBitmap.h +8 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +63 -21
- package/cpp/rnwgpu/api/RnFeatures.h +53 -0
- package/cpp/rnwgpu/api/VideoFrame.h +76 -0
- package/cpp/rnwgpu/api/VideoPlayer.h +69 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +4 -1
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +57 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +18 -3
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +35 -33
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +62 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +10 -0
- package/cpp/webgpu/webgpu.h +78 -17
- package/cpp/webgpu/webgpu_cpp.h +1014 -1249
- package/cpp/webgpu/webgpu_cpp_print.h +99 -10
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Canvas.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/Canvas.d.ts +0 -10
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +20 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +32 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +6 -6
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +0 -0
- package/package.json +3 -3
- package/src/Canvas.tsx +0 -15
- package/src/index.tsx +62 -2
- package/src/types.ts +83 -1
|
@@ -275,6 +275,89 @@ namespace wgpu {
|
|
|
275
275
|
return o;
|
|
276
276
|
}
|
|
277
277
|
template <typename CharT, typename Traits>
|
|
278
|
+
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& o, ColorSpacePrimariesDawn value) {
|
|
279
|
+
switch (value) {
|
|
280
|
+
case ColorSpacePrimariesDawn::SRGB:
|
|
281
|
+
o << "ColorSpacePrimariesDawn::SRGB";
|
|
282
|
+
break;
|
|
283
|
+
case ColorSpacePrimariesDawn::Rec601:
|
|
284
|
+
o << "ColorSpacePrimariesDawn::Rec601";
|
|
285
|
+
break;
|
|
286
|
+
case ColorSpacePrimariesDawn::Rec2020:
|
|
287
|
+
o << "ColorSpacePrimariesDawn::Rec2020";
|
|
288
|
+
break;
|
|
289
|
+
case ColorSpacePrimariesDawn::DisplayP3:
|
|
290
|
+
o << "ColorSpacePrimariesDawn::DisplayP3";
|
|
291
|
+
break;
|
|
292
|
+
default:
|
|
293
|
+
o << "ColorSpacePrimariesDawn::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<ColorSpacePrimariesDawn>::type>(value);
|
|
294
|
+
}
|
|
295
|
+
return o;
|
|
296
|
+
}
|
|
297
|
+
template <typename CharT, typename Traits>
|
|
298
|
+
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& o, ColorSpaceTransferDawn value) {
|
|
299
|
+
switch (value) {
|
|
300
|
+
case ColorSpaceTransferDawn::Identity:
|
|
301
|
+
o << "ColorSpaceTransferDawn::Identity";
|
|
302
|
+
break;
|
|
303
|
+
case ColorSpaceTransferDawn::SRGB:
|
|
304
|
+
o << "ColorSpaceTransferDawn::SRGB";
|
|
305
|
+
break;
|
|
306
|
+
case ColorSpaceTransferDawn::DisplayP3:
|
|
307
|
+
o << "ColorSpaceTransferDawn::DisplayP3";
|
|
308
|
+
break;
|
|
309
|
+
case ColorSpaceTransferDawn::SMPTE_170M:
|
|
310
|
+
o << "ColorSpaceTransferDawn::SMPTE_170M";
|
|
311
|
+
break;
|
|
312
|
+
case ColorSpaceTransferDawn::HLG:
|
|
313
|
+
o << "ColorSpaceTransferDawn::HLG";
|
|
314
|
+
break;
|
|
315
|
+
case ColorSpaceTransferDawn::PQ:
|
|
316
|
+
o << "ColorSpaceTransferDawn::PQ";
|
|
317
|
+
break;
|
|
318
|
+
default:
|
|
319
|
+
o << "ColorSpaceTransferDawn::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<ColorSpaceTransferDawn>::type>(value);
|
|
320
|
+
}
|
|
321
|
+
return o;
|
|
322
|
+
}
|
|
323
|
+
template <typename CharT, typename Traits>
|
|
324
|
+
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& o, ColorSpaceYCbCrMatrixDawn value) {
|
|
325
|
+
switch (value) {
|
|
326
|
+
case ColorSpaceYCbCrMatrixDawn::Identity:
|
|
327
|
+
o << "ColorSpaceYCbCrMatrixDawn::Identity";
|
|
328
|
+
break;
|
|
329
|
+
case ColorSpaceYCbCrMatrixDawn::Rec601:
|
|
330
|
+
o << "ColorSpaceYCbCrMatrixDawn::Rec601";
|
|
331
|
+
break;
|
|
332
|
+
case ColorSpaceYCbCrMatrixDawn::Rec709:
|
|
333
|
+
o << "ColorSpaceYCbCrMatrixDawn::Rec709";
|
|
334
|
+
break;
|
|
335
|
+
case ColorSpaceYCbCrMatrixDawn::Rec2020:
|
|
336
|
+
o << "ColorSpaceYCbCrMatrixDawn::Rec2020";
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
o << "ColorSpaceYCbCrMatrixDawn::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<ColorSpaceYCbCrMatrixDawn>::type>(value);
|
|
340
|
+
}
|
|
341
|
+
return o;
|
|
342
|
+
}
|
|
343
|
+
template <typename CharT, typename Traits>
|
|
344
|
+
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& o, ColorSpaceYCbCrRangeDawn value) {
|
|
345
|
+
switch (value) {
|
|
346
|
+
case ColorSpaceYCbCrRangeDawn::Identity:
|
|
347
|
+
o << "ColorSpaceYCbCrRangeDawn::Identity";
|
|
348
|
+
break;
|
|
349
|
+
case ColorSpaceYCbCrRangeDawn::Narrow:
|
|
350
|
+
o << "ColorSpaceYCbCrRangeDawn::Narrow";
|
|
351
|
+
break;
|
|
352
|
+
case ColorSpaceYCbCrRangeDawn::Full:
|
|
353
|
+
o << "ColorSpaceYCbCrRangeDawn::Full";
|
|
354
|
+
break;
|
|
355
|
+
default:
|
|
356
|
+
o << "ColorSpaceYCbCrRangeDawn::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<ColorSpaceYCbCrRangeDawn>::type>(value);
|
|
357
|
+
}
|
|
358
|
+
return o;
|
|
359
|
+
}
|
|
360
|
+
template <typename CharT, typename Traits>
|
|
278
361
|
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& o, CompareFunction value) {
|
|
279
362
|
switch (value) {
|
|
280
363
|
case CompareFunction::Undefined:
|
|
@@ -772,8 +855,8 @@ namespace wgpu {
|
|
|
772
855
|
case FeatureName::ChromiumExperimentalSamplingResourceTable:
|
|
773
856
|
o << "FeatureName::ChromiumExperimentalSamplingResourceTable";
|
|
774
857
|
break;
|
|
775
|
-
case FeatureName::
|
|
776
|
-
o << "FeatureName::
|
|
858
|
+
case FeatureName::SubgroupSizeControl:
|
|
859
|
+
o << "FeatureName::SubgroupSizeControl";
|
|
777
860
|
break;
|
|
778
861
|
case FeatureName::AtomicVec2uMinMax:
|
|
779
862
|
o << "FeatureName::AtomicVec2uMinMax";
|
|
@@ -789,6 +872,9 @@ namespace wgpu {
|
|
|
789
872
|
break;
|
|
790
873
|
case FeatureName::RenderPassRenderArea:
|
|
791
874
|
o << "FeatureName::RenderPassRenderArea";
|
|
875
|
+
break;
|
|
876
|
+
case FeatureName::AdapterPropertiesDrm:
|
|
877
|
+
o << "FeatureName::AdapterPropertiesDrm";
|
|
792
878
|
break;
|
|
793
879
|
default:
|
|
794
880
|
o << "FeatureName::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<FeatureName>::type>(value);
|
|
@@ -982,6 +1068,12 @@ namespace wgpu {
|
|
|
982
1068
|
break;
|
|
983
1069
|
case PredefinedColorSpace::DisplayP3:
|
|
984
1070
|
o << "PredefinedColorSpace::DisplayP3";
|
|
1071
|
+
break;
|
|
1072
|
+
case PredefinedColorSpace::SRGBLinear:
|
|
1073
|
+
o << "PredefinedColorSpace::SRGBLinear";
|
|
1074
|
+
break;
|
|
1075
|
+
case PredefinedColorSpace::DisplayP3Linear:
|
|
1076
|
+
o << "PredefinedColorSpace::DisplayP3Linear";
|
|
985
1077
|
break;
|
|
986
1078
|
default:
|
|
987
1079
|
o << "PredefinedColorSpace::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<PredefinedColorSpace>::type>(value);
|
|
@@ -1528,8 +1620,8 @@ namespace wgpu {
|
|
|
1528
1620
|
case SType::PipelineLayoutResourceTable:
|
|
1529
1621
|
o << "SType::PipelineLayoutResourceTable";
|
|
1530
1622
|
break;
|
|
1531
|
-
case SType::
|
|
1532
|
-
o << "SType::
|
|
1623
|
+
case SType::AdapterPropertiesDrm:
|
|
1624
|
+
o << "SType::AdapterPropertiesDrm";
|
|
1533
1625
|
break;
|
|
1534
1626
|
default:
|
|
1535
1627
|
o << "SType::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<SType>::type>(value);
|
|
@@ -2259,6 +2351,9 @@ namespace wgpu {
|
|
|
2259
2351
|
case WGSLLanguageFeatureName::TextureFormatsTier1:
|
|
2260
2352
|
o << "WGSLLanguageFeatureName::TextureFormatsTier1";
|
|
2261
2353
|
break;
|
|
2354
|
+
case WGSLLanguageFeatureName::LinearIndexing:
|
|
2355
|
+
o << "WGSLLanguageFeatureName::LinearIndexing";
|
|
2356
|
+
break;
|
|
2262
2357
|
case WGSLLanguageFeatureName::ChromiumTestingUnimplemented:
|
|
2263
2358
|
o << "WGSLLanguageFeatureName::ChromiumTestingUnimplemented";
|
|
2264
2359
|
break;
|
|
@@ -2292,14 +2387,8 @@ namespace wgpu {
|
|
|
2292
2387
|
case WGSLLanguageFeatureName::BufferView:
|
|
2293
2388
|
o << "WGSLLanguageFeatureName::BufferView";
|
|
2294
2389
|
break;
|
|
2295
|
-
case WGSLLanguageFeatureName::FilteringParameters:
|
|
2296
|
-
o << "WGSLLanguageFeatureName::FilteringParameters";
|
|
2297
|
-
break;
|
|
2298
2390
|
case WGSLLanguageFeatureName::SwizzleAssignment:
|
|
2299
2391
|
o << "WGSLLanguageFeatureName::SwizzleAssignment";
|
|
2300
|
-
break;
|
|
2301
|
-
case WGSLLanguageFeatureName::LinearIndexing:
|
|
2302
|
-
o << "WGSLLanguageFeatureName::LinearIndexing";
|
|
2303
2392
|
break;
|
|
2304
2393
|
default:
|
|
2305
2394
|
o << "WGSLLanguageFeatureName::" << std::showbase << std::hex << std::setfill('0') << std::setw(4) << static_cast<typename std::underlying_type<WGSLLanguageFeatureName>::type>(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_WebGPUViewNativeComponent","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","useRef","contextId","_","useState","useImperativeHandle","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","View","collapsable","style","flex","exports"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,0BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA2D,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MA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AAA,CAAAE,CAAA,aAAAC,CAAA,KAAAa,QAAA,CAAAK,KAAA,OAAAF,SAAA;AAE3D,IAAIG,eAAe,GAAG,CAAC;AACvB,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,eAAe,EAAE;AAC1B;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_WebGPUViewNativeComponent","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","useRef","contextId","_","useState","useImperativeHandle","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","View","collapsable","style","flex","exports"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,0BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA2D,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAK,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,C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AAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_main","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"names":["_main","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/module/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useImperativeHandle","useRef","useState","View","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","contextId","_","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","_extends","collapsable","style","flex"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpE,SAASC,IAAI,QAAQ,cAAc;AAEnC,OAAOC,gBAAgB,MAAM,6BAA6B;AAE1D,IAAIC,eAAe,GAAG,CAAC;AACvB,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,eAAe,EAAE;AAC1B;
|
|
1
|
+
{"version":3,"names":["React","useImperativeHandle","useRef","useState","View","WebGPUNativeView","CONTEXT_COUNTER","generateContextId","Canvas","transparent","ref","props","viewRef","contextId","_","getContextId","getNativeSurface","RNWebGPU","getContext","contextName","Error","current","view","size","getBoundingClientRect","unstable_getBoundingClientRect","MakeWebGPUCanvasContext","width","height","createElement","_extends","collapsable","style","flex"],"sourceRoot":"../../src","sources":["Canvas.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpE,SAASC,IAAI,QAAQ,cAAc;AAEnC,OAAOC,gBAAgB,MAAM,6BAA6B;AAE1D,IAAIC,eAAe,GAAG,CAAC;AACvB,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,eAAe,EAAE;AAC1B;AA2BA,OAAO,MAAME,MAAM,GAAGA,CAAC;EAAEC,WAAW;EAAEC,GAAG;EAAE,GAAGC;AAAmB,CAAC,KAAK;EACrE,MAAMC,OAAO,GAAGV,MAAM,CAAC,IAAI,CAAC;EAC5B,MAAM,CAACW,SAAS,EAAEC,CAAC,CAAC,GAAGX,QAAQ,CAAC,MAAMI,iBAAiB,CAAC,CAAC,CAAC;EAC1DN,mBAAmB,CAACS,GAAG,EAAE,OAAO;IAC9BK,YAAY,EAAEA,CAAA,KAAMF,SAAS;IAC7BG,gBAAgB,EAAEA,CAAA,KAAM;MACtB,OAAOC,QAAQ,CAACD,gBAAgB,CAACH,SAAS,CAAC;IAC7C,CAAC;IACDK,UAAUA,CAACC,WAAqB,EAA0B;MACxD,IAAIA,WAAW,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIC,KAAK,CAAC,iCAAiCD,WAAW,EAAE,CAAC;MACjE;MACA,IAAI,CAACP,OAAO,CAACS,OAAO,EAAE;QACpB,MAAM,IAAID,KAAK,CAAC,0CAA0C,CAAC;MAC7D;MACA;MACA;MACA,MAAME,IAAI,GAAGV,OAAO,CAACS,OAAc;MACnC,MAAME,IAAI,GACR,uBAAuB,IAAID,IAAI,GAC3BA,IAAI,CAACE,qBAAqB,CAAC,CAAC,GAC5BF,IAAI,CAACG,8BAA8B,CAAC,CAAC;MAC3C,OAAOR,QAAQ,CAACS,uBAAuB,CACrCb,SAAS,EACTU,IAAI,CAACI,KAAK,EACVJ,IAAI,CAACK,MACP,CAAC;IACH;EACF,CAAC,CAAC,CAAC;EAEH,oBACE5B,KAAA,CAAA6B,aAAA,CAACzB,IAAI,EAAA0B,QAAA;IAACC,WAAW,EAAE,KAAM;IAACrB,GAAG,EAAEE;EAAQ,GAAKD,KAAK,gBAC/CX,KAAA,CAAA6B,aAAA,CAACxB,gBAAgB;IACf2B,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IACnBpB,SAAS,EAAEA,SAAU;IACrBJ,WAAW,EAAE,CAAC,CAACA;EAAY,CAC5B,CACG,CAAC;AAEX,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;;AAYA,cAAc,QAAQ;AAAC","ignoreList":[]}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ViewProps } from "react-native";
|
|
3
|
-
declare global {
|
|
4
|
-
var RNWebGPU: {
|
|
5
|
-
gpu: GPU;
|
|
6
|
-
fabric: boolean;
|
|
7
|
-
getNativeSurface: (contextId: number) => NativeCanvas;
|
|
8
|
-
MakeWebGPUCanvasContext: (contextId: number, width: number, height: number) => RNCanvasContext;
|
|
9
|
-
DecodeToUTF8: (buffer: NodeJS.ArrayBufferView | ArrayBuffer) => string;
|
|
10
|
-
createImageBitmap: typeof createImageBitmap;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
3
|
type SurfacePointer = bigint;
|
|
14
4
|
export interface NativeCanvas {
|
|
15
5
|
surface: SurfacePointer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACtC;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,MAAM,GAAI,gCAAgC,WAAW,sBAuCjE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { NativeCanvas, RNCanvasContext } from "./types";
|
|
1
|
+
import type { GPUDawnTogglesDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
2
2
|
export * from "./main";
|
|
3
|
+
export type { NativeVideoFrame, VideoPlayer, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUDawnTogglesDescriptor, } from "./types";
|
|
3
4
|
declare global {
|
|
4
5
|
interface Navigator {
|
|
5
6
|
gpu: GPU;
|
|
@@ -12,7 +13,25 @@ declare global {
|
|
|
12
13
|
MakeWebGPUCanvasContext: (contextId: number, width: number, height: number) => RNCanvasContext;
|
|
13
14
|
DecodeToUTF8: (buffer: NodeJS.ArrayBufferView | ArrayBuffer) => string;
|
|
14
15
|
createImageBitmap: typeof createImageBitmap;
|
|
16
|
+
loadVideoFrame: (path: string) => NativeVideoFrame;
|
|
17
|
+
createTestVideoFrame: (width: number, height: number) => NativeVideoFrame;
|
|
18
|
+
createVideoFrameFromNativeBuffer: (pointer: bigint) => NativeVideoFrame;
|
|
19
|
+
createVideoPlayer: (path: string, pixelFormat?: NativeVideoPixelFormat) => VideoPlayer;
|
|
20
|
+
writeTestVideoFile: () => string;
|
|
15
21
|
};
|
|
22
|
+
interface GPUDevice {
|
|
23
|
+
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
24
|
+
}
|
|
25
|
+
interface GPUDeviceDescriptor {
|
|
26
|
+
dawnToggles?: GPUDawnTogglesDescriptor;
|
|
27
|
+
}
|
|
28
|
+
interface GPUExternalTextureDescriptor {
|
|
29
|
+
rotation?: 0 | 90 | 180 | 270;
|
|
30
|
+
mirrored?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface GPUExternalTexture {
|
|
33
|
+
destroy(): void;
|
|
34
|
+
}
|
|
16
35
|
function createImageBitmap(image: ArrayBuffer | ArrayBufferView): Promise<ImageBitmap>;
|
|
17
36
|
}
|
|
18
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,gCAAgC,EAChC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,cAAc,QAAQ,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,SAAS;QACjB,GAAG,EAAE,GAAG,CAAC;KACV;IAED,IAAI,SAAS,EAAE,SAAS,CAAC;IAEzB,IAAI,QAAQ,EAAE;QACZ,GAAG,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,CAAC;QACtD,uBAAuB,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,eAAe,CAAC;QACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,GAAG,WAAW,KAAK,MAAM,CAAC;QACvE,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;QAC5C,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,CAAC;QACnD,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,gBAAgB,CAAC;QAI1E,gCAAgC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,gBAAgB,CAAC;QACxE,iBAAiB,EAAE,CACjB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,sBAAsB,KACjC,WAAW,CAAC;QACjB,kBAAkB,EAAE,MAAM,MAAM,CAAC;KAClC,CAAC;IAEF,UAAU,SAAS;QACjB,yBAAyB,CACvB,UAAU,EAAE,gCAAgC,GAC3C,sBAAsB,CAAC;KAC3B;IAID,UAAU,mBAAmB;QAC3B,WAAW,CAAC,EAAE,wBAAwB,CAAC;KACxC;IAMD,UAAU,4BAA4B;QACpC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IASD,UAAU,kBAAkB;QAC1B,OAAO,IAAI,IAAI,CAAC;KACjB;IAGD,SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,GACnC,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
|
|
@@ -13,7 +13,38 @@ export interface CanvasRef {
|
|
|
13
13
|
getContextId: () => number;
|
|
14
14
|
getContext(contextName: "webgpu"): RNCanvasContext | null;
|
|
15
15
|
getNativeSurface: () => NativeCanvas;
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
export type NativeVideoPixelFormat = "bgra8" | "nv12";
|
|
18
|
+
export interface NativeVideoFrame {
|
|
19
|
+
readonly handle: bigint;
|
|
20
|
+
readonly width: number;
|
|
21
|
+
readonly height: number;
|
|
22
|
+
readonly pixelFormat: NativeVideoPixelFormat;
|
|
23
|
+
release(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface VideoPlayer {
|
|
26
|
+
copyLatestFrame(): NativeVideoFrame | null;
|
|
27
|
+
play(): void;
|
|
28
|
+
pause(): void;
|
|
29
|
+
release(): void;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateVideoPlayerOptions {
|
|
32
|
+
pixelFormat?: NativeVideoPixelFormat;
|
|
33
|
+
}
|
|
34
|
+
export interface GPUSharedTextureMemoryDescriptor {
|
|
35
|
+
handle: bigint;
|
|
36
|
+
label?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface GPUDawnTogglesDescriptor {
|
|
39
|
+
enabledToggles?: string[];
|
|
40
|
+
disabledToggles?: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface GPUSharedTextureMemory {
|
|
43
|
+
readonly __brand: "GPUSharedTextureMemory";
|
|
44
|
+
label: string;
|
|
45
|
+
createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;
|
|
46
|
+
beginAccess(texture: GPUTexture, initialized: boolean): boolean;
|
|
47
|
+
endAccess(texture: GPUTexture): boolean;
|
|
17
48
|
}
|
|
18
49
|
export {};
|
|
19
50
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC;IAC1D,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAA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C;IAI7D,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC;IAChE,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CACzC"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libwebgpu_dawn.a</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>
|
|
11
|
+
<string>macos-arm64_x86_64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libwebgpu_dawn.a</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
<string>x86_64</string>
|
|
18
18
|
</array>
|
|
19
19
|
<key>SupportedPlatform</key>
|
|
20
|
-
<string>
|
|
21
|
-
<key>SupportedPlatformVariant</key>
|
|
22
|
-
<string>simulator</string>
|
|
20
|
+
<string>macos</string>
|
|
23
21
|
</dict>
|
|
24
22
|
<dict>
|
|
25
23
|
<key>BinaryPath</key>
|
|
@@ -39,7 +37,7 @@
|
|
|
39
37
|
<key>BinaryPath</key>
|
|
40
38
|
<string>libwebgpu_dawn.a</string>
|
|
41
39
|
<key>LibraryIdentifier</key>
|
|
42
|
-
<string>
|
|
40
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
43
41
|
<key>LibraryPath</key>
|
|
44
42
|
<string>libwebgpu_dawn.a</string>
|
|
45
43
|
<key>SupportedArchitectures</key>
|
|
@@ -48,7 +46,9 @@
|
|
|
48
46
|
<string>x86_64</string>
|
|
49
47
|
</array>
|
|
50
48
|
<key>SupportedPlatform</key>
|
|
51
|
-
<string>
|
|
49
|
+
<string>ios</string>
|
|
50
|
+
<key>SupportedPlatformVariant</key>
|
|
51
|
+
<string>simulator</string>
|
|
52
52
|
</dict>
|
|
53
53
|
</array>
|
|
54
54
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webgpu",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"libs/**",
|
|
21
21
|
"*.podspec"
|
|
22
22
|
],
|
|
23
|
-
"dawn": "chromium/
|
|
23
|
+
"dawn": "chromium/7849",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"test": "NODE_OPTIONS='--experimental-require-module' jest -i",
|
|
26
26
|
"test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react-native-builder-bob": "^0.23.2",
|
|
85
85
|
"react-native-reanimated": "^4.2.1",
|
|
86
86
|
"react-native-web": "^0.21.2",
|
|
87
|
-
"react-native-worklets": "
|
|
87
|
+
"react-native-worklets": "0.8.3",
|
|
88
88
|
"rimraf": "^5.0.7",
|
|
89
89
|
"seedrandom": "^3.0.5",
|
|
90
90
|
"teapot": "^1.0.0",
|
package/src/Canvas.tsx
CHANGED
|
@@ -9,21 +9,6 @@ function generateContextId() {
|
|
|
9
9
|
return CONTEXT_COUNTER++;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
declare global {
|
|
13
|
-
var RNWebGPU: {
|
|
14
|
-
gpu: GPU;
|
|
15
|
-
fabric: boolean;
|
|
16
|
-
getNativeSurface: (contextId: number) => NativeCanvas;
|
|
17
|
-
MakeWebGPUCanvasContext: (
|
|
18
|
-
contextId: number,
|
|
19
|
-
width: number,
|
|
20
|
-
height: number,
|
|
21
|
-
) => RNCanvasContext;
|
|
22
|
-
DecodeToUTF8: (buffer: NodeJS.ArrayBufferView | ArrayBuffer) => string;
|
|
23
|
-
createImageBitmap: typeof createImageBitmap;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
12
|
type SurfacePointer = bigint;
|
|
28
13
|
|
|
29
14
|
export interface NativeCanvas {
|
package/src/index.tsx
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
GPUDawnTogglesDescriptor,
|
|
4
|
+
GPUSharedTextureMemory,
|
|
5
|
+
GPUSharedTextureMemoryDescriptor,
|
|
6
|
+
NativeCanvas,
|
|
7
|
+
RNCanvasContext,
|
|
8
|
+
VideoPlayer,
|
|
9
|
+
NativeVideoFrame,
|
|
10
|
+
NativeVideoPixelFormat,
|
|
11
|
+
} from "./types";
|
|
4
12
|
|
|
5
13
|
export * from "./main";
|
|
14
|
+
export type {
|
|
15
|
+
NativeVideoFrame,
|
|
16
|
+
VideoPlayer,
|
|
17
|
+
NativeVideoPixelFormat,
|
|
18
|
+
CreateVideoPlayerOptions,
|
|
19
|
+
GPUSharedTextureMemory,
|
|
20
|
+
GPUSharedTextureMemoryDescriptor,
|
|
21
|
+
GPUDawnTogglesDescriptor,
|
|
22
|
+
} from "./types";
|
|
6
23
|
|
|
7
24
|
declare global {
|
|
8
25
|
interface Navigator {
|
|
@@ -22,8 +39,51 @@ declare global {
|
|
|
22
39
|
) => RNCanvasContext;
|
|
23
40
|
DecodeToUTF8: (buffer: NodeJS.ArrayBufferView | ArrayBuffer) => string;
|
|
24
41
|
createImageBitmap: typeof createImageBitmap;
|
|
42
|
+
loadVideoFrame: (path: string) => NativeVideoFrame;
|
|
43
|
+
createTestVideoFrame: (width: number, height: number) => NativeVideoFrame;
|
|
44
|
+
// Wrap a NativeBuffer.pointer (CVPixelBufferRef on iOS / AHardwareBuffer*
|
|
45
|
+
// on Android) into a NativeVideoFrame. Matches the shape used by libraries
|
|
46
|
+
// that emit NativeBuffer (e.g. react-native-vision-camera).
|
|
47
|
+
createVideoFrameFromNativeBuffer: (pointer: bigint) => NativeVideoFrame;
|
|
48
|
+
createVideoPlayer: (
|
|
49
|
+
path: string,
|
|
50
|
+
pixelFormat?: NativeVideoPixelFormat,
|
|
51
|
+
) => VideoPlayer;
|
|
52
|
+
writeTestVideoFile: () => string;
|
|
25
53
|
};
|
|
26
54
|
|
|
55
|
+
interface GPUDevice {
|
|
56
|
+
importSharedTextureMemory(
|
|
57
|
+
descriptor: GPUSharedTextureMemoryDescriptor,
|
|
58
|
+
): GPUSharedTextureMemory;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Non-standard, Dawn-only. Lets callers set Dawn device-stage toggles at
|
|
62
|
+
// device creation: adapter.requestDevice({ dawnToggles: { ... } }).
|
|
63
|
+
interface GPUDeviceDescriptor {
|
|
64
|
+
dawnToggles?: GPUDawnTogglesDescriptor;
|
|
65
|
+
}
|
|
66
|
+
// Non-spec extension: camera frames arrive in the sensor's native
|
|
67
|
+
// orientation, which differs between iOS and Android. `rotation` (degrees,
|
|
68
|
+
// one of 0/90/180/270) and `mirrored` (horizontal flip) are baked into the
|
|
69
|
+
// sampling transform by Dawn, so the shader sees an upright frame. Maps
|
|
70
|
+
// directly onto VisionCamera's `frame.orientation` / `frame.isMirrored`.
|
|
71
|
+
interface GPUExternalTextureDescriptor {
|
|
72
|
+
rotation?: 0 | 90 | 180 | 270;
|
|
73
|
+
mirrored?: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Non-spec extension: a GPUExternalTexture imported from a native surface
|
|
77
|
+
// holds an open shared-memory access window on that surface until this
|
|
78
|
+
// wrapper is destroyed. Call destroy() right after the queue.submit() that
|
|
79
|
+
// sampled it (never before) to release the surface back to its producer
|
|
80
|
+
// immediately, instead of waiting for garbage collection. Forgetting to call
|
|
81
|
+
// it is not fatal (GC still cleans up), but it can starve a producer's buffer
|
|
82
|
+
// pool (e.g. a camera/video player) and pile up GPU resources.
|
|
83
|
+
interface GPUExternalTexture {
|
|
84
|
+
destroy(): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
27
87
|
// Extend createImageBitmap to accept ArrayBuffer/TypedArray (encoded image bytes)
|
|
28
88
|
function createImageBitmap(
|
|
29
89
|
image: ArrayBuffer | ArrayBufferView,
|
package/src/types.ts
CHANGED
|
@@ -16,5 +16,87 @@ export interface CanvasRef {
|
|
|
16
16
|
getContextId: () => number;
|
|
17
17
|
getContext(contextName: "webgpu"): RNCanvasContext | null;
|
|
18
18
|
getNativeSurface: () => NativeCanvas;
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Pixel layout of a NativeVideoFrame. NOT the WebCodecs `VideoPixelFormat`
|
|
22
|
+
// enum — these are the two native surface layouts we support, lower-cased to
|
|
23
|
+
// avoid being mistaken for the spec values ("NV12", "BGRA", …).
|
|
24
|
+
export type NativeVideoPixelFormat = "bgra8" | "nv12";
|
|
25
|
+
|
|
26
|
+
// A native, GPU-shareable handle to a single video frame.
|
|
27
|
+
//
|
|
28
|
+
// NOT the WebCodecs `VideoFrame`: there is no `close()`/`format`/`timestamp`,
|
|
29
|
+
// the surface is referenced by a raw native pointer, and disposal is
|
|
30
|
+
// `release()`. Named with a `Native` prefix so it doesn't shadow the global
|
|
31
|
+
// WebCodecs type or imply spec semantics it doesn't have.
|
|
32
|
+
//
|
|
33
|
+
// - handle is the raw pointer (IOSurfaceRef on Apple, AHardwareBuffer* on
|
|
34
|
+
// Android) encoded as a BigInt. Pass it to
|
|
35
|
+
// GPUDevice.importSharedTextureMemory.
|
|
36
|
+
// - pixelFormat describes the surface layout: 'bgra8' for a sampled
|
|
37
|
+
// GPUTexture; 'nv12' (biplanar Y + CbCr) for the importExternalTexture
|
|
38
|
+
// path.
|
|
39
|
+
// - release() drops the underlying backing object (a CVPixelBuffer on Apple).
|
|
40
|
+
// The frame is also released when the JS wrapper is garbage-collected; call
|
|
41
|
+
// release() eagerly when you know you're done.
|
|
42
|
+
export interface NativeVideoFrame {
|
|
43
|
+
readonly handle: bigint;
|
|
44
|
+
readonly width: number;
|
|
45
|
+
readonly height: number;
|
|
46
|
+
readonly pixelFormat: NativeVideoPixelFormat;
|
|
47
|
+
release(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// A handle to a decoded video stream. Poll copyLatestFrame() each render tick
|
|
51
|
+
// to obtain the most recently decoded frame as an IOSurface/AHardwareBuffer
|
|
52
|
+
// (returns null between frames so callers can skip the import work).
|
|
53
|
+
export interface VideoPlayer {
|
|
54
|
+
copyLatestFrame(): NativeVideoFrame | null;
|
|
55
|
+
play(): void;
|
|
56
|
+
pause(): void;
|
|
57
|
+
release(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CreateVideoPlayerOptions {
|
|
61
|
+
// 'bgra8' (default): emit a single-plane BGRA surface, suitable for
|
|
62
|
+
// SharedTextureMemory and a regular sampled GPUTexture.
|
|
63
|
+
// 'nv12': emit biplanar Y + CbCr surfaces, suitable for
|
|
64
|
+
// GPUDevice.importExternalTexture.
|
|
65
|
+
pixelFormat?: NativeVideoPixelFormat;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface GPUSharedTextureMemoryDescriptor {
|
|
69
|
+
// Raw native handle (IOSurfaceRef on Apple, AHardwareBuffer* on Android),
|
|
70
|
+
// encoded as a BigInt. The caller is responsible for keeping the underlying
|
|
71
|
+
// object alive for as long as the shared memory (and any textures derived
|
|
72
|
+
// from it) are in use. Using NativeVideoFrame.handle handles this
|
|
73
|
+
// automatically.
|
|
74
|
+
handle: bigint;
|
|
75
|
+
label?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Non-standard, Dawn-only device toggles. Mirrors Dawn's DawnTogglesDescriptor
|
|
79
|
+
// and is chained onto the native device descriptor at requestDevice time.
|
|
80
|
+
// Pass it via the (augmented) GPUDeviceDescriptor: adapter.requestDevice({
|
|
81
|
+
// dawnToggles: { enabledToggles: ["dump_shaders"] } }). Toggle names are open
|
|
82
|
+
// strings (see Dawn's Toggles.cpp); these flags are Dawn-specific and
|
|
83
|
+
// non-portable.
|
|
84
|
+
export interface GPUDawnTogglesDescriptor {
|
|
85
|
+
enabledToggles?: string[];
|
|
86
|
+
disabledToggles?: string[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// A piece of shared GPU memory backed by a native surface. Use createTexture()
|
|
90
|
+
// to obtain a regular GPUTexture that aliases the surface's pixels. The
|
|
91
|
+
// returned texture must be bracketed by beginAccess/endAccess around any
|
|
92
|
+
// command-buffer submission that uses it.
|
|
93
|
+
export interface GPUSharedTextureMemory {
|
|
94
|
+
readonly __brand: "GPUSharedTextureMemory";
|
|
95
|
+
label: string;
|
|
96
|
+
createTexture(descriptor?: GPUTextureDescriptor): GPUTexture;
|
|
97
|
+
// `initialized` declares whether the surface already holds meaningful pixels
|
|
98
|
+
// (true for an incoming video/camera frame, false if the next pass will fully
|
|
99
|
+
// overwrite it).
|
|
100
|
+
beginAccess(texture: GPUTexture, initialized: boolean): boolean;
|
|
101
|
+
endAccess(texture: GPUTexture): boolean;
|
|
20
102
|
}
|