react-native-webgpu 0.10.4 → 0.11.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/Package.swift +24 -10
- package/android/cpp/AndroidPlatformContext.h +60 -3
- package/android/cpp/cpp-adapter.cpp +66 -6
- package/android/src/main/java/com/webgpu/ViewSnapshot.java +162 -0
- package/android/src/main/java/com/webgpu/WebGPUModule.java +68 -0
- package/apple/ApplePlatformContext.h +14 -1
- package/apple/ApplePlatformContext.mm +176 -1
- package/apple/WebGPUModule.mm +20 -1
- package/cpp/rnwgpu/PlatformContext.h +55 -0
- package/cpp/rnwgpu/RNWebGPUManager.cpp +7 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +21 -2
- package/cpp/rnwgpu/api/GPU.cpp +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +14 -2
- package/cpp/rnwgpu/api/GPUCanvasContext.h +8 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +187 -0
- package/cpp/rnwgpu/api/GPUQueue.h +16 -0
- package/cpp/rnwgpu/api/descriptors/GPUDrawElementImageDestination.h +60 -0
- package/cpp/rnwgpu/api/descriptors/GPUDrawElementImageSource.h +106 -0
- package/lib/commonjs/WebPolyfillGPUModule.js +7 -0
- package/lib/commonjs/WebPolyfillGPUModule.js.map +1 -1
- package/lib/commonjs/importDevice.js +3 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/main/index.js +33 -0
- package/lib/commonjs/main/index.js.map +1 -1
- package/lib/module/WebPolyfillGPUModule.js +7 -0
- package/lib/module/WebPolyfillGPUModule.js.map +1 -1
- package/lib/module/importDevice.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/main/index.js +33 -0
- package/lib/module/main/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/importDevice.d.ts +3 -3
- package/lib/typescript/src/importDevice.d.ts +3 -3
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/main/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +13 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/WebPolyfillGPUModule.ts +10 -2
- package/src/importDevice.ts +3 -3
- package/src/index.tsx +29 -0
- package/src/main/index.tsx +49 -0
- package/src/types.ts +29 -0
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
#include "ArrayBuffer.h"
|
|
17
17
|
#include "GPUBuffer.h"
|
|
18
18
|
#include "GPUCommandBuffer.h"
|
|
19
|
+
#include "GPUDrawElementImageDestination.h"
|
|
20
|
+
#include "GPUDrawElementImageSource.h"
|
|
19
21
|
#include "GPUImageCopyExternalImage.h"
|
|
20
22
|
#include "GPUImageCopyTextureTagged.h"
|
|
21
23
|
|
|
@@ -51,6 +53,18 @@ public:
|
|
|
51
53
|
std::shared_ptr<GPUImageCopyTextureTagged> destination,
|
|
52
54
|
std::shared_ptr<GPUExtent3D> copySize);
|
|
53
55
|
|
|
56
|
+
// Non-spec React Native extension modeled on the html-in-canvas proposal's
|
|
57
|
+
// GPUQueue.drawElementImageToTexture: rasterizes a native view (the
|
|
58
|
+
// "element") and writes the pixels into `destination.texture`. Unlike the
|
|
59
|
+
// web API it returns a Promise, because the view can only be rasterized on
|
|
60
|
+
// the platform UI thread; the texture write is issued on the calling
|
|
61
|
+
// runtime's thread right before the promise resolves, so work submitted
|
|
62
|
+
// after `await` observes the new contents.
|
|
63
|
+
async::AsyncTaskHandle drawElementImageToTexture(
|
|
64
|
+
jsi::Runtime &runtime,
|
|
65
|
+
std::shared_ptr<GPUDrawElementImageSource> source,
|
|
66
|
+
std::shared_ptr<GPUDrawElementImageDestination> destination);
|
|
67
|
+
|
|
54
68
|
std::string getLabel() { return _label; }
|
|
55
69
|
void setLabel(const std::string &label) {
|
|
56
70
|
_label = label;
|
|
@@ -66,6 +80,8 @@ public:
|
|
|
66
80
|
installMethod(runtime, prototype, "writeTexture", &GPUQueue::writeTexture);
|
|
67
81
|
installMethod(runtime, prototype, "copyExternalImageToTexture",
|
|
68
82
|
&GPUQueue::copyExternalImageToTexture);
|
|
83
|
+
installMethodWithRuntime(runtime, prototype, "drawElementImageToTexture",
|
|
84
|
+
&GPUQueue::drawElementImageToTexture);
|
|
69
85
|
installGetterSetter(runtime, prototype, "label", &GPUQueue::getLabel,
|
|
70
86
|
&GPUQueue::setLabel);
|
|
71
87
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
|
|
6
|
+
#include "JSIConverter.h"
|
|
7
|
+
|
|
8
|
+
#include "GPUExtent3D.h"
|
|
9
|
+
#include "GPUImageCopyTextureTagged.h"
|
|
10
|
+
|
|
11
|
+
namespace jsi = facebook::jsi;
|
|
12
|
+
|
|
13
|
+
namespace rnwgpu {
|
|
14
|
+
|
|
15
|
+
// The `destination` argument of GPUQueue.drawElementImageToTexture:
|
|
16
|
+
// dictionary GPUDrawElementImageDestination : GPUCopyExternalImageDestInfo {
|
|
17
|
+
// GPUExtent3D size;
|
|
18
|
+
// };
|
|
19
|
+
// `size` is the pixel size of the region the view is drawn into. When omitted
|
|
20
|
+
// it is the source rectangle's natural pixel size (points times the device
|
|
21
|
+
// pixel ratio).
|
|
22
|
+
struct GPUDrawElementImageDestination {
|
|
23
|
+
std::shared_ptr<GPUImageCopyTextureTagged> info;
|
|
24
|
+
std::optional<std::shared_ptr<GPUExtent3D>> size;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
} // namespace rnwgpu
|
|
28
|
+
|
|
29
|
+
namespace rnwgpu {
|
|
30
|
+
|
|
31
|
+
template <>
|
|
32
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUDrawElementImageDestination>> {
|
|
33
|
+
static std::shared_ptr<rnwgpu::GPUDrawElementImageDestination>
|
|
34
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
35
|
+
auto result = std::make_unique<rnwgpu::GPUDrawElementImageDestination>();
|
|
36
|
+
if (outOfBounds || !arg.isObject()) {
|
|
37
|
+
throw std::runtime_error(
|
|
38
|
+
"drawElementImageToTexture: expected a destination dictionary");
|
|
39
|
+
}
|
|
40
|
+
result->info =
|
|
41
|
+
JSIConverter<std::shared_ptr<GPUImageCopyTextureTagged>>::fromJSI(
|
|
42
|
+
runtime, arg, false);
|
|
43
|
+
auto obj = arg.getObject(runtime);
|
|
44
|
+
if (obj.hasProperty(runtime, "size")) {
|
|
45
|
+
result->size =
|
|
46
|
+
JSIConverter<std::optional<std::shared_ptr<GPUExtent3D>>>::fromJSI(
|
|
47
|
+
runtime, obj.getProperty(runtime, "size"), false);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static jsi::Value
|
|
53
|
+
toJSI(jsi::Runtime &runtime,
|
|
54
|
+
std::shared_ptr<rnwgpu::GPUDrawElementImageDestination> arg) {
|
|
55
|
+
throw std::runtime_error(
|
|
56
|
+
"Invalid GPUDrawElementImageDestination::toJSI()");
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "JSIConverter.h"
|
|
8
|
+
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
|
|
11
|
+
namespace rnwgpu {
|
|
12
|
+
|
|
13
|
+
// The `source` argument of GPUQueue.drawElementImageToTexture, modeled on the
|
|
14
|
+
// html-in-canvas proposal's GPUDrawElementImageSource. On the web `source` is
|
|
15
|
+
// an Element; here it is a native React Native view, identified by its React
|
|
16
|
+
// tag. The optional rectangle selects the part of the view to draw, in the
|
|
17
|
+
// view's own coordinate space and in density-independent points (React Native
|
|
18
|
+
// layout units); it defaults to the whole view.
|
|
19
|
+
struct GPUDrawElementImageSource {
|
|
20
|
+
int viewTag = 0; // resolved from `source`
|
|
21
|
+
std::optional<double> sourceX; // float
|
|
22
|
+
std::optional<double> sourceY; // float
|
|
23
|
+
std::optional<double> sourceWidth; // float
|
|
24
|
+
std::optional<double> sourceHeight; // float
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
} // namespace rnwgpu
|
|
28
|
+
|
|
29
|
+
namespace rnwgpu {
|
|
30
|
+
|
|
31
|
+
template <>
|
|
32
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUDrawElementImageSource>> {
|
|
33
|
+
// Resolve `source` to a React tag. Accepted shapes:
|
|
34
|
+
// - a number: the tag itself (what findNodeHandle returns)
|
|
35
|
+
// - a React Native host component instance: on the New Architecture these
|
|
36
|
+
// carry the tag as `__nativeTag` (ReactFabricHostComponent /
|
|
37
|
+
// ReactNativeElement), which is also what findNodeHandle reads
|
|
38
|
+
// - a ref object (`{ current }`) wrapping either of the above
|
|
39
|
+
// The JS wrapper on the main runtime additionally runs findNodeHandle so
|
|
40
|
+
// class components and legacy instances resolve too; this native fallback is
|
|
41
|
+
// what worklet runtimes (no findNodeHandle) get.
|
|
42
|
+
static int resolveViewTag(jsi::Runtime &runtime, const jsi::Value &value,
|
|
43
|
+
int depth = 0) {
|
|
44
|
+
if (value.isNumber()) {
|
|
45
|
+
return static_cast<int>(value.getNumber());
|
|
46
|
+
}
|
|
47
|
+
if (value.isObject() && depth < 2) {
|
|
48
|
+
auto obj = value.getObject(runtime);
|
|
49
|
+
if (obj.hasProperty(runtime, "__nativeTag")) {
|
|
50
|
+
auto tag = obj.getProperty(runtime, "__nativeTag");
|
|
51
|
+
if (tag.isNumber()) {
|
|
52
|
+
return static_cast<int>(tag.getNumber());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (obj.hasProperty(runtime, "current")) {
|
|
56
|
+
return resolveViewTag(runtime, obj.getProperty(runtime, "current"),
|
|
57
|
+
depth + 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw std::runtime_error(
|
|
61
|
+
"drawElementImageToTexture: `source` must be a React Native view "
|
|
62
|
+
"(a host component ref, its instance, or the tag returned by "
|
|
63
|
+
"findNodeHandle)");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static std::shared_ptr<rnwgpu::GPUDrawElementImageSource>
|
|
67
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
68
|
+
auto result = std::make_unique<rnwgpu::GPUDrawElementImageSource>();
|
|
69
|
+
if (outOfBounds || !arg.isObject()) {
|
|
70
|
+
throw std::runtime_error(
|
|
71
|
+
"drawElementImageToTexture: expected a source dictionary");
|
|
72
|
+
}
|
|
73
|
+
auto obj = arg.getObject(runtime);
|
|
74
|
+
if (!obj.hasProperty(runtime, "source")) {
|
|
75
|
+
throw std::runtime_error(
|
|
76
|
+
"drawElementImageToTexture: `source.source` is required");
|
|
77
|
+
}
|
|
78
|
+
result->viewTag =
|
|
79
|
+
resolveViewTag(runtime, obj.getProperty(runtime, "source"));
|
|
80
|
+
if (obj.hasProperty(runtime, "sourceX")) {
|
|
81
|
+
result->sourceX = JSIConverter<std::optional<double>>::fromJSI(
|
|
82
|
+
runtime, obj.getProperty(runtime, "sourceX"), false);
|
|
83
|
+
}
|
|
84
|
+
if (obj.hasProperty(runtime, "sourceY")) {
|
|
85
|
+
result->sourceY = JSIConverter<std::optional<double>>::fromJSI(
|
|
86
|
+
runtime, obj.getProperty(runtime, "sourceY"), false);
|
|
87
|
+
}
|
|
88
|
+
if (obj.hasProperty(runtime, "sourceWidth")) {
|
|
89
|
+
result->sourceWidth = JSIConverter<std::optional<double>>::fromJSI(
|
|
90
|
+
runtime, obj.getProperty(runtime, "sourceWidth"), false);
|
|
91
|
+
}
|
|
92
|
+
if (obj.hasProperty(runtime, "sourceHeight")) {
|
|
93
|
+
result->sourceHeight = JSIConverter<std::optional<double>>::fromJSI(
|
|
94
|
+
runtime, obj.getProperty(runtime, "sourceHeight"), false);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static jsi::Value
|
|
100
|
+
toJSI(jsi::Runtime &runtime,
|
|
101
|
+
std::shared_ptr<rnwgpu::GPUDrawElementImageSource> arg) {
|
|
102
|
+
throw std::runtime_error("Invalid GPUDrawElementImageSource::toJSI()");
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
} // namespace rnwgpu
|
|
@@ -32,6 +32,11 @@ function makeWebGPUCanvasContext(contextId, width, height) {
|
|
|
32
32
|
canvas.setAttribute("height", pixelHeight);
|
|
33
33
|
}
|
|
34
34
|
const context = canvas.getContext("webgpu");
|
|
35
|
+
// null when the browser has no WebGPU support (e.g. Safari with the WebGPU
|
|
36
|
+
// flag off).
|
|
37
|
+
if (!context) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
35
40
|
// On web there is no manual present; expose a no-op so RNCanvasContext's
|
|
36
41
|
// present() (called after queue.submit() on native) is callable here too.
|
|
37
42
|
return Object.assign(context, {
|
|
@@ -42,6 +47,8 @@ function makeWebGPUCanvasContext(contextId, width, height) {
|
|
|
42
47
|
// @ts-expect-error - polyfill for RNWebGPU native module
|
|
43
48
|
window.RNWebGPU = {
|
|
44
49
|
getNativeSurface,
|
|
50
|
+
// Unlike native, this can return null; Canvas.getContext() is typed
|
|
51
|
+
// `RNCanvasContext | null` and passes it through.
|
|
45
52
|
MakeWebGPUCanvasContext: makeWebGPUCanvasContext,
|
|
46
53
|
// On web the browser owns the canvas/context lifecycle; nothing to retire.
|
|
47
54
|
destroyContext: _contextId => {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","fabric","getNativeSurface","contextId","canvas","document","getElementById","contextIdToId","height","width","getBoundingClientRect","surface","BigInt","clientHeight","clientWidth","addEventListener","bind","removeEventListener","dispatchEvent","setPointerCapture","releasePointerCapture","makeWebGPUCanvasContext","dpr","window","devicePixelRatio","pixelWidth","toString","pixelHeight","getAttribute","setAttribute","context","getContext","Object","assign","present","RNWebGPU","MakeWebGPUCanvasContext","destroyContext","_contextId"],"sourceRoot":"../../src","sources":["WebPolyfillGPUModule.ts"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,MAAM,GAAG,IAAI;AAEnB,SAASC,gBAAgBA,CAACC,SAAiB,EAAE;EAC3C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpC,IAAAC,oBAAa,EAACJ,SAAS,CACzB,CAAsB;EAEtB,MAAM;IAAEK,MAAM;IAAEC;EAAM,CAAC,GAAGL,MAAM,CAACM,qBAAqB,CAAC,CAAE;EAEzD,OAAO;IACLC,OAAO,EAAEC,MAAM,CAACT,SAAS,CAAC;IAC1BK,MAAM;IACNC,KAAK;IACLI,YAAY,EAAEL,MAAM;IACpBM,WAAW,EAAEL,KAAK;IAClB;IACAM,gBAAgB,EAAEX,MAAM,CAACW,gBAAgB,CAACC,IAAI,CAACZ,MAAM,CAAC;IACtDa,mBAAmB,EAAEb,MAAM,CAACa,mBAAmB,CAACD,IAAI,CAACZ,MAAM,CAAC;IAC5Dc,aAAa,EAAEd,MAAM,CAACc,aAAa,CAACF,IAAI,CAACZ,MAAM,CAAC;IAChDe,iBAAiB,EAAEf,MAAM,CAACe,iBAAiB,CAACH,IAAI,CAACZ,MAAM,CAAC;IACxDgB,qBAAqB,EAAEhB,MAAM,CAACgB,qBAAqB,CAACJ,IAAI,CAACZ,MAAM;EACjE,CAAC;AACH;AAEA,SAASiB,uBAAuBA,CAC9BlB,SAAiB,EACjBM,KAAa,EACbD,MAAc,EACd;EACA,MAAMJ,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpC,IAAAC,oBAAa,EAACJ,SAAS,CACzB,CAAsB;EAEtB,MAAMmB,GAAG,GAAGC,MAAM,CAACC,gBAAgB,IAAI,CAAC;EACxC,MAAMC,UAAU,GAAG,CAAChB,KAAK,GAAGa,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAC3C,MAAMC,WAAW,GAAG,CAACnB,MAAM,GAAGc,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAE7C,IACEtB,MAAM,CAACwB,YAAY,CAAC,OAAO,CAAC,KAAKH,UAAU,IAC3CrB,MAAM,CAACwB,YAAY,CAAC,QAAQ,CAAC,KAAKD,WAAW,EAC7C;IACAvB,MAAM,CAACyB,YAAY,CAAC,OAAO,EAAEJ,UAAU,CAAC;IACxCrB,MAAM,CAACyB,YAAY,CAAC,QAAQ,EAAEF,WAAW,CAAC;EAC5C;EAEA,MAAMG,OAAO,GAAG1B,MAAM,CAAC2B,UAAU,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"names":["_utils","require","fabric","getNativeSurface","contextId","canvas","document","getElementById","contextIdToId","height","width","getBoundingClientRect","surface","BigInt","clientHeight","clientWidth","addEventListener","bind","removeEventListener","dispatchEvent","setPointerCapture","releasePointerCapture","makeWebGPUCanvasContext","dpr","window","devicePixelRatio","pixelWidth","toString","pixelHeight","getAttribute","setAttribute","context","getContext","Object","assign","present","RNWebGPU","MakeWebGPUCanvasContext","destroyContext","_contextId"],"sourceRoot":"../../src","sources":["WebPolyfillGPUModule.ts"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,MAAM,GAAG,IAAI;AAEnB,SAASC,gBAAgBA,CAACC,SAAiB,EAAE;EAC3C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpC,IAAAC,oBAAa,EAACJ,SAAS,CACzB,CAAsB;EAEtB,MAAM;IAAEK,MAAM;IAAEC;EAAM,CAAC,GAAGL,MAAM,CAACM,qBAAqB,CAAC,CAAE;EAEzD,OAAO;IACLC,OAAO,EAAEC,MAAM,CAACT,SAAS,CAAC;IAC1BK,MAAM;IACNC,KAAK;IACLI,YAAY,EAAEL,MAAM;IACpB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AAO,EAAE;IAAEI,OAAO,EAAEA,CAAA,KAAM,CAAC;EAAE,CAAC,CAAC;AACtD;;AAEA;AACAX,MAAM,CAACY,QAAQ,GAAG;EAChBjC,gBAAgB;EAChB;EACA;EACAkC,uBAAuB,EACrBf,uBAAkE;EACpE;EACAgB,cAAc,EAAGC,UAAkB,IAAK,CAAC,CAAC;EAC1CrC;AACF,CAAC","ignoreList":[]}
|
|
@@ -7,8 +7,8 @@ exports.importDevice = exports.adoptTexture = void 0;
|
|
|
7
7
|
/**
|
|
8
8
|
* Wraps an externally created WGPUDevice pointer into a GPUDevice.
|
|
9
9
|
*
|
|
10
|
-
* The canonical use case is adopting the Graphite device
|
|
11
|
-
*
|
|
10
|
+
* The canonical use case is adopting the Graphite device of react-native-skia
|
|
11
|
+
* (v3 and above):
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
14
|
* const device = importDevice(Skia.getNativeDevice());
|
|
@@ -16,7 +16,7 @@ exports.importDevice = exports.adoptTexture = void 0;
|
|
|
16
16
|
*
|
|
17
17
|
* This is only sound when the exporting library links the same single Dawn
|
|
18
18
|
* copy as react-native-webgpu and shares its wgpu::Instance (react-native-skia
|
|
19
|
-
*
|
|
19
|
+
* does both).
|
|
20
20
|
*/
|
|
21
21
|
const importDevice = pointer => {
|
|
22
22
|
if (typeof RNWebGPU === "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_main","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_constants","_install"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"names":["_main","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_constants","_install"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,UAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,QAAA,GAAAd,OAAA","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "WebGPUModule", {
|
|
|
12
12
|
return _NativeWebGPUModule.default;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
var _reactNative = require("react-native");
|
|
15
16
|
var _external = require("../external");
|
|
16
17
|
var _install = require("../install");
|
|
17
18
|
var _NativeWebGPUModule = _interopRequireDefault(require("../NativeWebGPUModule"));
|
|
@@ -100,6 +101,37 @@ Object.keys(_formats).forEach(function (key) {
|
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
104
|
+
// Resolve the `source` of drawElementImageToTexture to a React tag on the
|
|
105
|
+
// main JS runtime, where findNodeHandle is available: it handles class
|
|
106
|
+
// components and legacy host instances that the native fallback (a number or
|
|
107
|
+
// an instance carrying `__nativeTag`) does not.
|
|
108
|
+
const resolveElementSource = source => {
|
|
109
|
+
if (typeof source === "number") {
|
|
110
|
+
return source;
|
|
111
|
+
}
|
|
112
|
+
const instance = source !== null && typeof source === "object" && "current" in source ? source.current : source;
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const tag = instance == null ? null : (0, _reactNative.findNodeHandle)(instance);
|
|
115
|
+
if (tag === null || tag === undefined) {
|
|
116
|
+
throw new Error("[WebGPU] drawElementImageToTexture: `source` does not resolve to a " + "mounted native view (pass a host component ref rendered with " + "collapsable={false})");
|
|
117
|
+
}
|
|
118
|
+
return tag;
|
|
119
|
+
};
|
|
120
|
+
const installDrawElementImageToTexture = () => {
|
|
121
|
+
if (typeof GPUQueue === "undefined") {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const native = GPUQueue.prototype.drawElementImageToTexture;
|
|
125
|
+
if (typeof native !== "function") {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
GPUQueue.prototype.drawElementImageToTexture = function (source, destination) {
|
|
129
|
+
return native.call(this, {
|
|
130
|
+
...source,
|
|
131
|
+
source: resolveElementSource(source.source)
|
|
132
|
+
}, destination);
|
|
133
|
+
};
|
|
134
|
+
};
|
|
103
135
|
const _installOk = _NativeWebGPUModule.default.install();
|
|
104
136
|
(0, _external.registerWebGPUForReanimated)();
|
|
105
137
|
if (typeof RNWebGPU !== "undefined") {
|
|
@@ -122,6 +154,7 @@ if (typeof RNWebGPU !== "undefined") {
|
|
|
122
154
|
}
|
|
123
155
|
}
|
|
124
156
|
global.createImageBitmap = global.createImageBitmap ?? RNWebGPU.createImageBitmap.bind(RNWebGPU);
|
|
157
|
+
installDrawElementImageToTexture();
|
|
125
158
|
// Let installWebGPU() put navigator.gpu on other runtimes (see install.ts).
|
|
126
159
|
(0, _install.provideGPUForInstall)(RNWebGPU.gpu);
|
|
127
160
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_external","_install","_NativeWebGPUModule","_interopRequireDefault","_Canvas","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Offscreen","_WebGPUViewNativeComponent","_hooks","_GPUDeviceProvider","_importDevice","_formats","e","__esModule","default","resolveElementSource","source","instance","current","tag","findNodeHandle","undefined","Error","installDrawElementImageToTexture","GPUQueue","native","drawElementImageToTexture","destination","_installOk","WebGPUModule","install","registerWebGPUForReanimated","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind","provideGPUForInstall","console","warn"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAgDA,IAAAK,OAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAl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AAEA,MAAM,EAAED,oBAAoB,CAACC,MAAM,CAACA,MAAM;IAAE,CAAC,EAC1DW,WACF,CAAC;EACH,CAAC;AACH,CAAC;AAYD,MAAMC,UAAU,GAAGC,2BAAY,CAACC,OAAO,CAAC,CAAC;AAEzC,IAAAC,qCAA2B,EAAC,CAAC;AAE7B,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACnC,IAAI,CAACC,SAAS,EAAE;IACd;IACAA,SAAS,GAAG;MACVC,GAAG,EAAEF,QAAQ,CAACE,GAAG;MACjBC,SAAS,EAAE;IACb,CAAC;EACH,CAAC,MAAM;IACLF,SAAS,CAACC,GAAG,GAAGF,QAAQ,CAACE,GAAG;IAC5B,IAAI,OAAOD,SAAS,CAACE,SAAS,KAAK,QAAQ,EAAE;MAC3C,IAAI;QACF;QACA;QACAF,SAAS,CAACE,SAAS,GAAG,cAAc;MACtC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF;EACAC,MAAM,CAACC,iBAAiB,GACtBD,MAAM,CAACC,iBAAiB,IAAIL,QAAQ,CAACK,iBAAiB,CAACC,IAAI,CAACN,QAAQ,CAAC;EACvET,gCAAgC,CAAC,CAAC;EAClC;EACA,IAAAgB,6BAAoB,EAACP,QAAQ,CAACE,GAAG,CAAC;AACpC,CAAC,MAAM;EACLM,OAAO,CAACC,IAAI,CACV,4CAA4Cb,UAAU,uCACxD,CAAC;AACH","ignoreList":[]}
|
|
@@ -30,6 +30,11 @@ function makeWebGPUCanvasContext(contextId, width, height) {
|
|
|
30
30
|
canvas.setAttribute("height", pixelHeight);
|
|
31
31
|
}
|
|
32
32
|
const context = canvas.getContext("webgpu");
|
|
33
|
+
// null when the browser has no WebGPU support (e.g. Safari with the WebGPU
|
|
34
|
+
// flag off).
|
|
35
|
+
if (!context) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
33
38
|
// On web there is no manual present; expose a no-op so RNCanvasContext's
|
|
34
39
|
// present() (called after queue.submit() on native) is callable here too.
|
|
35
40
|
return Object.assign(context, {
|
|
@@ -40,6 +45,8 @@ function makeWebGPUCanvasContext(contextId, width, height) {
|
|
|
40
45
|
// @ts-expect-error - polyfill for RNWebGPU native module
|
|
41
46
|
window.RNWebGPU = {
|
|
42
47
|
getNativeSurface,
|
|
48
|
+
// Unlike native, this can return null; Canvas.getContext() is typed
|
|
49
|
+
// `RNCanvasContext | null` and passes it through.
|
|
43
50
|
MakeWebGPUCanvasContext: makeWebGPUCanvasContext,
|
|
44
51
|
// On web the browser owns the canvas/context lifecycle; nothing to retire.
|
|
45
52
|
destroyContext: _contextId => {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["contextIdToId","fabric","getNativeSurface","contextId","canvas","document","getElementById","height","width","getBoundingClientRect","surface","BigInt","clientHeight","clientWidth","addEventListener","bind","removeEventListener","dispatchEvent","setPointerCapture","releasePointerCapture","makeWebGPUCanvasContext","dpr","window","devicePixelRatio","pixelWidth","toString","pixelHeight","getAttribute","setAttribute","context","getContext","Object","assign","present","RNWebGPU","MakeWebGPUCanvasContext","destroyContext","_contextId"],"sourceRoot":"../../src","sources":["WebPolyfillGPUModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,MAAMC,MAAM,GAAG,IAAI;AAEnB,SAASC,gBAAgBA,CAACC,SAAiB,EAAE;EAC3C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpCN,aAAa,CAACG,SAAS,CACzB,CAAsB;EAEtB,MAAM;IAAEI,MAAM;IAAEC;EAAM,CAAC,GAAGJ,MAAM,CAACK,qBAAqB,CAAC,CAAE;EAEzD,OAAO;IACLC,OAAO,EAAEC,MAAM,CAACR,SAAS,CAAC;IAC1BI,MAAM;IACNC,KAAK;IACLI,YAAY,EAAEL,MAAM;IACpBM,WAAW,EAAEL,KAAK;IAClB;IACAM,gBAAgB,EAAEV,MAAM,CAACU,gBAAgB,CAACC,IAAI,CAACX,MAAM,CAAC;IACtDY,mBAAmB,EAAEZ,MAAM,CAACY,mBAAmB,CAACD,IAAI,CAACX,MAAM,CAAC;IAC5Da,aAAa,EAAEb,MAAM,CAACa,aAAa,CAACF,IAAI,CAACX,MAAM,CAAC;IAChDc,iBAAiB,EAAEd,MAAM,CAACc,iBAAiB,CAACH,IAAI,CAACX,MAAM,CAAC;IACxDe,qBAAqB,EAAEf,MAAM,CAACe,qBAAqB,CAACJ,IAAI,CAACX,MAAM;EACjE,CAAC;AACH;AAEA,SAASgB,uBAAuBA,CAC9BjB,SAAiB,EACjBK,KAAa,EACbD,MAAc,EACd;EACA,MAAMH,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpCN,aAAa,CAACG,SAAS,CACzB,CAAsB;EAEtB,MAAMkB,GAAG,GAAGC,MAAM,CAACC,gBAAgB,IAAI,CAAC;EACxC,MAAMC,UAAU,GAAG,CAAChB,KAAK,GAAGa,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAC3C,MAAMC,WAAW,GAAG,CAACnB,MAAM,GAAGc,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAE7C,IACErB,MAAM,CAACuB,YAAY,CAAC,OAAO,CAAC,KAAKH,UAAU,IAC3CpB,MAAM,CAACuB,YAAY,CAAC,QAAQ,CAAC,KAAKD,WAAW,EAC7C;IACAtB,MAAM,CAACwB,YAAY,CAAC,OAAO,EAAEJ,UAAU,CAAC;IACxCpB,MAAM,CAACwB,YAAY,CAAC,QAAQ,EAAEF,WAAW,CAAC;EAC5C;EAEA,MAAMG,OAAO,GAAGzB,MAAM,CAAC0B,UAAU,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"names":["contextIdToId","fabric","getNativeSurface","contextId","canvas","document","getElementById","height","width","getBoundingClientRect","surface","BigInt","clientHeight","clientWidth","addEventListener","bind","removeEventListener","dispatchEvent","setPointerCapture","releasePointerCapture","makeWebGPUCanvasContext","dpr","window","devicePixelRatio","pixelWidth","toString","pixelHeight","getAttribute","setAttribute","context","getContext","Object","assign","present","RNWebGPU","MakeWebGPUCanvasContext","destroyContext","_contextId"],"sourceRoot":"../../src","sources":["WebPolyfillGPUModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,MAAMC,MAAM,GAAG,IAAI;AAEnB,SAASC,gBAAgBA,CAACC,SAAiB,EAAE;EAC3C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpCN,aAAa,CAACG,SAAS,CACzB,CAAsB;EAEtB,MAAM;IAAEI,MAAM;IAAEC;EAAM,CAAC,GAAGJ,MAAM,CAACK,qBAAqB,CAAC,CAAE;EAEzD,OAAO;IACLC,OAAO,EAAEC,MAAM,CAACR,SAAS,CAAC;IAC1BI,MAAM;IACNC,KAAK;IACLI,YAAY,EAAEL,MAAM;IACpBM,WAAW,EAAEL,KAAK;IAClB;IACAM,gBAAgB,EAAEV,MAAM,CAACU,gBAAgB,CAACC,IAAI,CAACX,MAAM,CAAC;IACtDY,mBAAmB,EAAEZ,MAAM,CAACY,mBAAmB,CAACD,IAAI,CAACX,MAAM,CAAC;IAC5Da,aAAa,EAAEb,MAAM,CAACa,aAAa,CAACF,IAAI,CAACX,MAAM,CAAC;IAChDc,iBAAiB,EAAEd,MAAM,CAACc,iBAAiB,CAACH,IAAI,CAACX,MAAM,CAAC;IACxDe,qBAAqB,EAAEf,MAAM,CAACe,qBAAqB,CAACJ,IAAI,CAACX,MAAM;EACjE,CAAC;AACH;AAEA,SAASgB,uBAAuBA,CAC9BjB,SAAiB,EACjBK,KAAa,EACbD,MAAc,EACd;EACA,MAAMH,MAAM,GAAGC,QAAQ,CAACC,cAAc,CACpCN,aAAa,CAACG,SAAS,CACzB,CAAsB;EAEtB,MAAMkB,GAAG,GAAGC,MAAM,CAACC,gBAAgB,IAAI,CAAC;EACxC,MAAMC,UAAU,GAAG,CAAChB,KAAK,GAAGa,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAC3C,MAAMC,WAAW,GAAG,CAACnB,MAAM,GAAGc,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAE7C,IACErB,MAAM,CAACuB,YAAY,CAAC,OAAO,CAAC,KAAKH,UAAU,IAC3CpB,MAAM,CAACuB,YAAY,CAAC,QAAQ,CAAC,KAAKD,WAAW,EAC7C;IACAtB,MAAM,CAACwB,YAAY,CAAC,OAAO,EAAEJ,UAAU,CAAC;IACxCpB,MAAM,CAACwB,YAAY,CAAC,QAAQ,EAAEF,WAAW,CAAC;EAC5C;EAEA,MAAMG,OAAO,GAAGzB,MAAM,CAAC0B,UAAU,CAAC,QAAQ,CAAC;EAC3C;EACA;EACA,IAAI,CAACD,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EACA;EACA;EACA,OAAOE,MAAM,CAACC,MAAM,CAACH,OAAO,EAAE;IAAEI,OAAO,EAAEA,CAAA,KAAM,CAAC;EAAE,CAAC,CAAC;AACtD;;AAEA;AACAX,MAAM,CAACY,QAAQ,GAAG;EAChBhC,gBAAgB;EAChB;EACA;EACAiC,uBAAuB,EACrBf,uBAAkE;EACpE;EACAgB,cAAc,EAAGC,UAAkB,IAAK,CAAC,CAAC;EAC1CpC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wraps an externally created WGPUDevice pointer into a GPUDevice.
|
|
3
3
|
*
|
|
4
|
-
* The canonical use case is adopting the Graphite device
|
|
5
|
-
*
|
|
4
|
+
* The canonical use case is adopting the Graphite device of react-native-skia
|
|
5
|
+
* (v3 and above):
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* const device = importDevice(Skia.getNativeDevice());
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This is only sound when the exporting library links the same single Dawn
|
|
12
12
|
* copy as react-native-webgpu and shares its wgpu::Instance (react-native-skia
|
|
13
|
-
*
|
|
13
|
+
* does both).
|
|
14
14
|
*/
|
|
15
15
|
export const importDevice = pointer => {
|
|
16
16
|
if (typeof RNWebGPU === "undefined") {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["installWebGPU"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"names":["installWebGPU"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;;AAgBA,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,SAASA,aAAa,QAAQ,WAAW","ignoreList":[]}
|
package/lib/module/main/index.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
|
+
import { findNodeHandle } from "react-native";
|
|
1
2
|
import { registerWebGPUForReanimated } from "../external";
|
|
2
3
|
import { provideGPUForInstall } from "../install";
|
|
3
4
|
import WebGPUModule from "../NativeWebGPUModule";
|
|
5
|
+
// Resolve the `source` of drawElementImageToTexture to a React tag on the
|
|
6
|
+
// main JS runtime, where findNodeHandle is available: it handles class
|
|
7
|
+
// components and legacy host instances that the native fallback (a number or
|
|
8
|
+
// an instance carrying `__nativeTag`) does not.
|
|
9
|
+
const resolveElementSource = source => {
|
|
10
|
+
if (typeof source === "number") {
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
13
|
+
const instance = source !== null && typeof source === "object" && "current" in source ? source.current : source;
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const tag = instance == null ? null : findNodeHandle(instance);
|
|
16
|
+
if (tag === null || tag === undefined) {
|
|
17
|
+
throw new Error("[WebGPU] drawElementImageToTexture: `source` does not resolve to a " + "mounted native view (pass a host component ref rendered with " + "collapsable={false})");
|
|
18
|
+
}
|
|
19
|
+
return tag;
|
|
20
|
+
};
|
|
21
|
+
const installDrawElementImageToTexture = () => {
|
|
22
|
+
if (typeof GPUQueue === "undefined") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const native = GPUQueue.prototype.drawElementImageToTexture;
|
|
26
|
+
if (typeof native !== "function") {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
GPUQueue.prototype.drawElementImageToTexture = function (source, destination) {
|
|
30
|
+
return native.call(this, {
|
|
31
|
+
...source,
|
|
32
|
+
source: resolveElementSource(source.source)
|
|
33
|
+
}, destination);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
4
36
|
export * from "../Canvas";
|
|
5
37
|
export * from "../Offscreen";
|
|
6
38
|
export * from "../WebGPUViewNativeComponent";
|
|
@@ -31,6 +63,7 @@ if (typeof RNWebGPU !== "undefined") {
|
|
|
31
63
|
}
|
|
32
64
|
}
|
|
33
65
|
global.createImageBitmap = global.createImageBitmap ?? RNWebGPU.createImageBitmap.bind(RNWebGPU);
|
|
66
|
+
installDrawElementImageToTexture();
|
|
34
67
|
// Let installWebGPU() put navigator.gpu on other runtimes (see install.ts).
|
|
35
68
|
provideGPUForInstall(RNWebGPU.gpu);
|
|
36
69
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerWebGPUForReanimated","provideGPUForInstall","WebGPUModule","default","_installOk","install","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind","console","warn"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,aAAa;AACzD,SAASC,oBAAoB,QAAQ,YAAY;AACjD,OAAOC,YAAY,MAAM,uBAAuB;
|
|
1
|
+
{"version":3,"names":["findNodeHandle","registerWebGPUForReanimated","provideGPUForInstall","WebGPUModule","resolveElementSource","source","instance","current","tag","undefined","Error","installDrawElementImageToTexture","GPUQueue","native","prototype","drawElementImageToTexture","destination","call","default","_installOk","install","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind","console","warn"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":"AAAA,SAASA,cAAc,QAAQ,cAAc;AAE7C,SAASC,2BAA2B,QAAQ,aAAa;AACzD,SAASC,oBAAoB,QAAQ,YAAY;AACjD,OAAOC,YAAY,MAAM,uBAAuB;AAGhD;AACA;AACA;AACA;A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AA2B,CAAC,CAAC;AAE7B,IAAI,OAAOoB,QAAQ,KAAK,WAAW,EAAE;EACnC,IAAI,CAACC,SAAS,EAAE;IACd;IACAA,SAAS,GAAG;MACVC,GAAG,EAAEF,QAAQ,CAACE,GAAG;MACjBC,SAAS,EAAE;IACb,CAAC;EACH,CAAC,MAAM;IACLF,SAAS,CAACC,GAAG,GAAGF,QAAQ,CAACE,GAAG;IAC5B,IAAI,OAAOD,SAAS,CAACE,SAAS,KAAK,QAAQ,EAAE;MAC3C,IAAI;QACF;QACA;QACAF,SAAS,CAACE,SAAS,GAAG,cAAc;MACtC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF;EACAC,MAAM,CAACC,iBAAiB,GACtBD,MAAM,CAACC,iBAAiB,IAAIL,QAAQ,CAACK,iBAAiB,CAACC,IAAI,CAACN,QAAQ,CAAC;EACvEV,gCAAgC,CAAC,CAAC;EAClC;EACAT,oBAAoB,CAACmB,QAAQ,CAACE,GAAG,CAAC;AACpC,CAAC,MAAM;EACLK,OAAO,CAACC,IAAI,CACV,4CAA4CV,UAAU,uCACxD,CAAC;AACH","ignoreList":[]}
|
|
@@ -2,8 +2,8 @@ export const __esModule: boolean;
|
|
|
2
2
|
/**
|
|
3
3
|
* Wraps an externally created WGPUDevice pointer into a GPUDevice.
|
|
4
4
|
*
|
|
5
|
-
* The canonical use case is adopting the Graphite device
|
|
6
|
-
*
|
|
5
|
+
* The canonical use case is adopting the Graphite device of react-native-skia
|
|
6
|
+
* (v3 and above):
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* const device = importDevice(Skia.getNativeDevice());
|
|
@@ -11,7 +11,7 @@ export const __esModule: boolean;
|
|
|
11
11
|
*
|
|
12
12
|
* This is only sound when the exporting library links the same single Dawn
|
|
13
13
|
* copy as react-native-webgpu and shares its wgpu::Instance (react-native-skia
|
|
14
|
-
*
|
|
14
|
+
* does both).
|
|
15
15
|
*/
|
|
16
16
|
export function importDevice(pointer: any): GPUDevice;
|
|
17
17
|
export function adoptTexture(pointer: any): GPUTexture;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wraps an externally created WGPUDevice pointer into a GPUDevice.
|
|
3
3
|
*
|
|
4
|
-
* The canonical use case is adopting the Graphite device
|
|
5
|
-
*
|
|
4
|
+
* The canonical use case is adopting the Graphite device of react-native-skia
|
|
5
|
+
* (v3 and above):
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* const device = importDevice(Skia.getNativeDevice());
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This is only sound when the exporting library links the same single Dawn
|
|
12
12
|
* copy as react-native-webgpu and shares its wgpu::Instance (react-native-skia
|
|
13
|
-
*
|
|
13
|
+
* does both).
|
|
14
14
|
*/
|
|
15
15
|
export declare const importDevice: (pointer: bigint) => GPUDevice;
|
|
16
16
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
1
|
+
import type { GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
|
|
2
2
|
export * from "./main";
|
|
3
3
|
export * from "./constants";
|
|
4
4
|
export { installWebGPU } from "./install";
|
|
5
|
-
export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUDawnTogglesDescriptor, } from "./types";
|
|
5
|
+
export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUDawnTogglesDescriptor, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUDrawElementImageSourceView, } from "./types";
|
|
6
6
|
declare global {
|
|
7
7
|
interface Navigator {
|
|
8
8
|
gpu: GPU;
|
|
@@ -31,6 +31,9 @@ declare global {
|
|
|
31
31
|
importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
|
|
32
32
|
importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
|
|
33
33
|
}
|
|
34
|
+
interface GPUQueue {
|
|
35
|
+
drawElementImageToTexture(source: GPUDrawElementImageSource, destination: GPUDrawElementImageDestination): Promise<void>;
|
|
36
|
+
}
|
|
34
37
|
interface GPUDeviceDescriptor {
|
|
35
38
|
dawnToggles?: GPUDawnTogglesDescriptor;
|
|
36
39
|
implicitDeviceSynchronization?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,gCAAgC,EAChC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,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EAAE,MAAM,EAAE,CAAC;KACnC;IAGD,SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,EACpC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/index.tsx"],"names":[],"mappings":"AAoDA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -45,6 +45,19 @@ export interface VideoPlayer {
|
|
|
45
45
|
export interface CreateVideoPlayerOptions {
|
|
46
46
|
pixelFormat?: NativeVideoPixelFormat;
|
|
47
47
|
}
|
|
48
|
+
export type GPUDrawElementImageSourceView = number | {
|
|
49
|
+
current: unknown;
|
|
50
|
+
} | React.Component | object;
|
|
51
|
+
export interface GPUDrawElementImageSource {
|
|
52
|
+
source: GPUDrawElementImageSourceView;
|
|
53
|
+
sourceX?: number;
|
|
54
|
+
sourceY?: number;
|
|
55
|
+
sourceWidth?: number;
|
|
56
|
+
sourceHeight?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface GPUDrawElementImageDestination extends GPUCopyExternalImageDestInfo {
|
|
59
|
+
size?: GPUExtent3DStrict;
|
|
60
|
+
}
|
|
48
61
|
export interface GPUSharedTextureMemoryDescriptor {
|
|
49
62
|
handle: bigint;
|
|
50
63
|
label?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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gB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,IAAI,wBAAwB,CAAC;CACpC;AAGD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAID,MAAM,WAAW,oCAAoC;IACnD,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAQD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAMD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,UAAU,CAAC;IAM7D,WAAW,CACT,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAC7B,IAAI,CAAC;IAGR,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,oCAAoC,CAAC;CACtE"}
|
package/package.json
CHANGED
|
@@ -45,7 +45,12 @@ function makeWebGPUCanvasContext(
|
|
|
45
45
|
canvas.setAttribute("height", pixelHeight);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const context = canvas.getContext("webgpu")
|
|
48
|
+
const context = canvas.getContext("webgpu");
|
|
49
|
+
// null when the browser has no WebGPU support (e.g. Safari with the WebGPU
|
|
50
|
+
// flag off).
|
|
51
|
+
if (!context) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
49
54
|
// On web there is no manual present; expose a no-op so RNCanvasContext's
|
|
50
55
|
// present() (called after queue.submit() on native) is callable here too.
|
|
51
56
|
return Object.assign(context, { present: () => {} });
|
|
@@ -54,7 +59,10 @@ function makeWebGPUCanvasContext(
|
|
|
54
59
|
// @ts-expect-error - polyfill for RNWebGPU native module
|
|
55
60
|
window.RNWebGPU = {
|
|
56
61
|
getNativeSurface,
|
|
57
|
-
|
|
62
|
+
// Unlike native, this can return null; Canvas.getContext() is typed
|
|
63
|
+
// `RNCanvasContext | null` and passes it through.
|
|
64
|
+
MakeWebGPUCanvasContext:
|
|
65
|
+
makeWebGPUCanvasContext as typeof RNWebGPU.MakeWebGPUCanvasContext,
|
|
58
66
|
// On web the browser owns the canvas/context lifecycle; nothing to retire.
|
|
59
67
|
destroyContext: (_contextId: number) => {},
|
|
60
68
|
fabric,
|