react-native-webgpu 0.25.0 → 0.27.0
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 +9 -1
- package/android/CMakeLists.txt +2 -0
- package/cpp/rnwgpu/ArrayBuffer.h +47 -2
- package/cpp/rnwgpu/DawnEventPump.cpp +227 -0
- package/cpp/rnwgpu/DawnEventPump.h +173 -0
- package/cpp/rnwgpu/WebGPURuntime.cpp +6 -8
- package/cpp/rnwgpu/api/GPU.cpp +1 -1
- package/cpp/rnwgpu/api/GPUAdapter.cpp +1 -1
- package/cpp/rnwgpu/api/GPUBuffer.cpp +100 -27
- package/cpp/rnwgpu/api/GPUBuffer.h +55 -6
- package/cpp/rnwgpu/api/GPUDevice.cpp +57 -55
- package/cpp/rnwgpu/api/GPUDevice.h +6 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +7 -2
- package/cpp/rnwgpu/api/GPUQueue.h +8 -2
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/RNWebGPU.h +26 -5
- package/cpp/rnwgpu/api/descriptors/CreateNativeBufferFromPointerOptions.h +46 -0
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +21 -15
- package/cpp/rnwgpu/async/AsyncTaskHandle.h +3 -2
- package/cpp/rnwgpu/async/DeviceTicker.cpp +105 -0
- package/cpp/rnwgpu/async/DeviceTicker.h +71 -0
- package/cpp/rnwgpu/async/RuntimeContext.cpp +56 -70
- package/cpp/rnwgpu/async/RuntimeContext.h +37 -18
- package/lib/commonjs/NativeBufferView.js.map +1 -1
- package/lib/commonjs/NativeBufferViewNativeComponent.web.js +114 -0
- package/lib/commonjs/NativeBufferViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/WebPolyfillGPUModule.js +79 -0
- package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/main/index.web.js +11 -0
- package/lib/commonjs/main/index.web.js.map +1 -1
- package/lib/commonjs/utils.js +29 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/video.js +1 -1
- package/lib/commonjs/video.js.map +1 -1
- package/lib/module/NativeBufferView.js.map +1 -1
- package/lib/module/NativeBufferViewNativeComponent.web.js +107 -0
- package/lib/module/NativeBufferViewNativeComponent.web.js.map +1 -0
- package/lib/module/WebPolyfillGPUModule.js +80 -1
- package/lib/module/WebPolyfillGPUModule.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/main/index.web.js +1 -0
- package/lib/module/main/index.web.js.map +1 -1
- package/lib/module/utils.js +27 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/video.js +1 -1
- package/lib/module/video.js.map +1 -1
- package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.web.d.ts +4 -0
- package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/utils.d.ts +2 -0
- package/lib/typescript/lib/commonjs/utils.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/video.d.ts +1 -1
- package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
- package/lib/typescript/lib/module/NativeBufferViewNativeComponent.web.d.ts +5 -0
- package/lib/typescript/lib/module/NativeBufferViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/lib/module/main/index.web.d.ts +1 -0
- package/lib/typescript/lib/module/utils.d.ts +2 -0
- package/lib/typescript/lib/module/utils.d.ts.map +1 -1
- package/lib/typescript/lib/module/video.d.ts +1 -1
- package/lib/typescript/lib/module/video.d.ts.map +1 -1
- package/lib/typescript/src/NativeBufferView.d.ts +6 -1
- package/lib/typescript/src/NativeBufferView.d.ts.map +1 -1
- package/lib/typescript/src/NativeBufferViewNativeComponent.web.d.ts +14 -0
- package/lib/typescript/src/NativeBufferViewNativeComponent.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/main/index.web.d.ts +1 -0
- package/lib/typescript/src/main/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +12 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/video.d.ts +2 -2
- package/lib/typescript/src/video.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/prepare-apple-binaries.sh +9 -3
- package/src/NativeBufferView.tsx +6 -1
- package/src/NativeBufferViewNativeComponent.web.ts +119 -0
- package/src/WebPolyfillGPUModule.ts +75 -1
- package/src/index.tsx +7 -2
- package/src/main/index.web.tsx +1 -0
- package/src/types.ts +13 -0
- package/src/utils.ts +25 -0
- package/src/video.ts +6 -1
package/src/main/index.web.tsx
CHANGED
package/src/types.ts
CHANGED
|
@@ -328,6 +328,19 @@ export interface GPUSharedTextureMemory {
|
|
|
328
328
|
destroy(): void;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
/**
|
|
332
|
+
* The options of `createNativeBufferFromPointer()`.
|
|
333
|
+
*/
|
|
334
|
+
export interface CreateNativeBufferFromPointerOptions {
|
|
335
|
+
/**
|
|
336
|
+
* How to read a YUV buffer that carries no color information of its own
|
|
337
|
+
* (an AHardwareBuffer from a MediaCodec ImageReader, for instance), as
|
|
338
|
+
* `sourceColorSpace` in `importExternalTexture()`. The members it sets
|
|
339
|
+
* replace what the buffer says.
|
|
340
|
+
*/
|
|
341
|
+
colorSpace?: NativeBufferColorSpace;
|
|
342
|
+
}
|
|
343
|
+
|
|
331
344
|
/**
|
|
332
345
|
* The options of `createNativeBuffer()`. The buffer holds premultiplied
|
|
333
346
|
* pixels.
|
package/src/utils.ts
CHANGED
|
@@ -2,3 +2,28 @@
|
|
|
2
2
|
export function contextIdToId(contextId: number) {
|
|
3
3
|
return "rnwgpu-canvas-" + contextId;
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
// Only used on the web
|
|
7
|
+
export function nativeBufferViewIdToId(viewId: number) {
|
|
8
|
+
return "rnwgpu-native-buffer-view-" + viewId;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Only used on the web: fits the canvas of a NativeBufferView in its
|
|
12
|
+
// container according to its resize mode (data-resize-mode). The drawing
|
|
13
|
+
// buffer of the canvas is the presented buffer, in physical pixels.
|
|
14
|
+
export function layoutNativeBufferViewCanvas(canvas: HTMLCanvasElement) {
|
|
15
|
+
const mode = canvas.dataset.resizeMode;
|
|
16
|
+
const { style } = canvas;
|
|
17
|
+
if (mode === "topLeft") {
|
|
18
|
+
// Not scaled: one pixel of the buffer on one pixel of the display. The
|
|
19
|
+
// container crops what overflows.
|
|
20
|
+
const dpr = window.devicePixelRatio || 1;
|
|
21
|
+
style.width = `${canvas.width / dpr}px`;
|
|
22
|
+
style.height = `${canvas.height / dpr}px`;
|
|
23
|
+
style.objectFit = "fill";
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
style.width = "100%";
|
|
27
|
+
style.height = "100%";
|
|
28
|
+
style.objectFit = mode === "contain" || mode === "cover" ? mode : "fill";
|
|
29
|
+
}
|
package/src/video.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
CreateNativeBufferFromPointerOptions,
|
|
2
3
|
CreateNativeBufferOptions,
|
|
3
4
|
CreateTestVideoPlayerOptions,
|
|
4
5
|
NativeBuffer,
|
|
@@ -58,9 +59,13 @@ export const createTestVideoPlayer = (
|
|
|
58
59
|
* VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeBuffer`
|
|
59
60
|
* that keeps it alive until released.
|
|
60
61
|
*/
|
|
61
|
-
export const createNativeBufferFromPointer = (
|
|
62
|
+
export const createNativeBufferFromPointer = (
|
|
63
|
+
pointer: bigint,
|
|
64
|
+
options?: CreateNativeBufferFromPointerOptions,
|
|
65
|
+
): NativeBuffer =>
|
|
62
66
|
native("createNativeBufferFromPointer").createNativeBufferFromPointer(
|
|
63
67
|
pointer,
|
|
68
|
+
options,
|
|
64
69
|
);
|
|
65
70
|
|
|
66
71
|
/**
|