react-native-webgpu 0.5.11 → 0.5.14
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 +89 -5
- package/android/CMakeLists.txt +3 -1
- package/android/build.gradle +1 -1
- package/android/cpp/AndroidPlatformContext.h +121 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +1 -1
- 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/apple/WebGPUModule.mm +2 -2
- 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 +24 -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/commonjs/main/index.js +1 -1
- package/lib/commonjs/main/index.js.map +1 -1
- package/lib/module/Canvas.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/main/index.js +1 -1
- package/lib/module/main/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/{react-native-wgpu.podspec → react-native-webgpu.podspec} +5 -1
- package/src/Canvas.tsx +0 -15
- package/src/index.tsx +62 -2
- package/src/main/index.tsx +1 -1
- package/src/types.ts +83 -1
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
|
}
|