react-native-webgpu 0.11.2 → 0.12.1
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 +3 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +17 -43
- package/cpp/rnwgpu/api/GPUDevice.cpp +1 -6
- package/cpp/rnwgpu/api/NativeFrameFeatures.h +40 -0
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +13 -13
- 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 +2 -2
- package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a +2 -2
- package/package.json +2 -2
- package/cpp/rnwgpu/api/RnFeatures.h +0 -66
package/Package.swift
CHANGED
|
@@ -29,7 +29,7 @@ let sibling = { (relative: String) -> String in
|
|
|
29
29
|
// check runs here, at manifest evaluation. SwiftPM caches evaluations, so
|
|
30
30
|
// after changing either package's Dawn version reset the package caches
|
|
31
31
|
// (File > Packages > Reset Package Caches) if this does not re-run.
|
|
32
|
-
let dawnReleaseTag = "dawn-chrome-
|
|
32
|
+
let dawnReleaseTag = "dawn-chrome-m154a"
|
|
33
33
|
// Only Graphite builds of react-native-skia carry this marker (Ganesh builds
|
|
34
34
|
// do not link Dawn and impose no constraint). From v3 the Skia binaries ship
|
|
35
35
|
// in react-native-skia-graphite-apple-ios, which records the tag at
|
|
@@ -109,8 +109,8 @@ let package = Package(
|
|
|
109
109
|
// build-dawn.yml), so SPM exposes them to dependents automatically.
|
|
110
110
|
.binaryTarget(
|
|
111
111
|
name: "WebGPUDawn",
|
|
112
|
-
url: "https://github.com/wcandillon/react-native-webgpu/releases/download/dawn-chrome-
|
|
113
|
-
checksum: "
|
|
112
|
+
url: "https://github.com/wcandillon/react-native-webgpu/releases/download/dawn-chrome-m154a/dawn-apple-dawn-chrome-m154a.xcframework.zip",
|
|
113
|
+
checksum: "ec06936cca08bca5177e41d78a1b190a22d62980e11df8a4c4ca5868de17c36c"
|
|
114
114
|
),
|
|
115
115
|
.target(
|
|
116
116
|
name: "ReactNativeWebGPU",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include "GPUFeatures.h"
|
|
19
19
|
#include "JSIConverter.h"
|
|
20
|
-
#include "
|
|
20
|
+
#include "NativeFrameFeatures.h"
|
|
21
21
|
#include "WGPULogger.h"
|
|
22
22
|
|
|
23
23
|
namespace rnwgpu {
|
|
@@ -25,36 +25,24 @@ namespace rnwgpu {
|
|
|
25
25
|
async::AsyncTaskHandle GPUAdapter::requestDevice(
|
|
26
26
|
jsi::Runtime &runtime,
|
|
27
27
|
std::optional<std::shared_ptr<GPUDeviceDescriptor>> descriptor) {
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// request
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// web/fallback adapter the backing set is empty or unsupported, so this
|
|
36
|
-
// is a no-op and device creation is unaffected.
|
|
37
|
-
// - Requesting a feature the adapter doesn't support makes RequestDevice
|
|
38
|
-
// fail, hence the support check below.
|
|
39
|
-
// Callers can still pass "rnwebgpu/native-texture" explicitly; the dedupe
|
|
40
|
-
// keeps that idempotent.
|
|
41
|
-
// The optional features (rnNativeTextureOptionalFeatures) ride along one by
|
|
42
|
-
// one, each only when the adapter supports it: on Android the YUV frames of
|
|
43
|
-
// the decoder and of the camera cannot be imported without
|
|
44
|
-
// OpaqueYCbCrAndroidForExternalTexture, while RGBA buffers need nothing
|
|
45
|
-
// beyond the backing set.
|
|
28
|
+
// Native frame import (importSharedTextureMemory, importExternalTexture,
|
|
29
|
+
// copyExternalImageToTexture with a NativeVideoFrame) needs no feature
|
|
30
|
+
// request, like importExternalTexture on the web: the Dawn features behind
|
|
31
|
+
// it are added to requiredFeatures here, each one when the adapter supports
|
|
32
|
+
// it. Requesting a feature the adapter lacks would make RequestDevice fail,
|
|
33
|
+
// so a fallback adapter (emulators, the web) still gets a device, without
|
|
34
|
+
// the capability; the first import then reports what is missing.
|
|
46
35
|
{
|
|
47
|
-
auto
|
|
48
|
-
if (!
|
|
36
|
+
auto native = nativeFrameImportFeatures();
|
|
37
|
+
if (!native.empty()) {
|
|
49
38
|
wgpu::SupportedFeatures supported;
|
|
50
39
|
_instance.GetFeatures(&supported);
|
|
51
40
|
std::unordered_set<wgpu::FeatureName> supportedSet(
|
|
52
41
|
supported.features, supported.features + supported.featureCount);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (allSupported) {
|
|
42
|
+
for (auto f : native) {
|
|
43
|
+
if (supportedSet.count(f) == 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
58
46
|
if (!descriptor.has_value()) {
|
|
59
47
|
descriptor = std::make_shared<GPUDeviceDescriptor>();
|
|
60
48
|
}
|
|
@@ -63,18 +51,8 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
|
|
|
63
51
|
desc->requiredFeatures = std::vector<wgpu::FeatureName>{};
|
|
64
52
|
}
|
|
65
53
|
auto &features = desc->requiredFeatures.value();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
features.end()) {
|
|
69
|
-
features.push_back(f);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
for (auto f : rnNativeTextureOptionalFeatures()) {
|
|
73
|
-
if (supportedSet.count(f) > 0 &&
|
|
74
|
-
std::find(features.begin(), features.end(), f) ==
|
|
75
|
-
features.end()) {
|
|
76
|
-
features.push_back(f);
|
|
77
|
-
}
|
|
54
|
+
if (std::find(features.begin(), features.end(), f) == features.end()) {
|
|
55
|
+
features.push_back(f);
|
|
78
56
|
}
|
|
79
57
|
}
|
|
80
58
|
}
|
|
@@ -325,17 +303,13 @@ std::unordered_set<std::string> GPUAdapter::getFeatures() {
|
|
|
325
303
|
wgpu::SupportedFeatures supportedFeatures;
|
|
326
304
|
_instance.GetFeatures(&supportedFeatures);
|
|
327
305
|
std::unordered_set<std::string> result;
|
|
328
|
-
std::unordered_set<wgpu::FeatureName> enabled;
|
|
329
306
|
for (size_t i = 0; i < supportedFeatures.featureCount; ++i) {
|
|
330
|
-
auto feature = supportedFeatures.features[i];
|
|
331
|
-
enabled.insert(feature);
|
|
332
307
|
std::string name;
|
|
333
|
-
convertEnumToJSUnion(
|
|
308
|
+
convertEnumToJSUnion(supportedFeatures.features[i], &name);
|
|
334
309
|
if (name != "") {
|
|
335
310
|
result.insert(name);
|
|
336
311
|
}
|
|
337
312
|
}
|
|
338
|
-
maybeSynthesizeRnNativeTextureFeature(enabled, result);
|
|
339
313
|
return result;
|
|
340
314
|
}
|
|
341
315
|
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
#include "GPUInternalError.h"
|
|
16
16
|
#include "GPUOutOfMemoryError.h"
|
|
17
17
|
#include "GPUValidationError.h"
|
|
18
|
-
#include "RnFeatures.h"
|
|
19
18
|
#include "SurfaceRegistry.h"
|
|
20
19
|
|
|
21
20
|
namespace rnwgpu {
|
|
@@ -570,15 +569,11 @@ std::unordered_set<std::string> GPUDevice::getFeatures() {
|
|
|
570
569
|
wgpu::SupportedFeatures supportedFeatures;
|
|
571
570
|
_instance.GetFeatures(&supportedFeatures);
|
|
572
571
|
std::unordered_set<std::string> result;
|
|
573
|
-
std::unordered_set<wgpu::FeatureName> enabled;
|
|
574
572
|
for (size_t i = 0; i < supportedFeatures.featureCount; ++i) {
|
|
575
|
-
auto feature = supportedFeatures.features[i];
|
|
576
|
-
enabled.insert(feature);
|
|
577
573
|
std::string name;
|
|
578
|
-
convertEnumToJSUnion(
|
|
574
|
+
convertEnumToJSUnion(supportedFeatures.features[i], &name);
|
|
579
575
|
result.insert(name);
|
|
580
576
|
}
|
|
581
|
-
maybeSynthesizeRnNativeTextureFeature(enabled, result);
|
|
582
577
|
return result;
|
|
583
578
|
}
|
|
584
579
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <vector>
|
|
4
|
+
|
|
5
|
+
#include "webgpu/webgpu_cpp.h"
|
|
6
|
+
|
|
7
|
+
namespace rnwgpu {
|
|
8
|
+
|
|
9
|
+
// The Dawn features behind native frame import on the current platform:
|
|
10
|
+
// importSharedTextureMemory, importExternalTexture and
|
|
11
|
+
// copyExternalImageToTexture with a NativeVideoFrame. Like
|
|
12
|
+
// importExternalTexture on the web, the capability needs no feature request:
|
|
13
|
+
// requestDevice() enables each of these the adapter supports (see
|
|
14
|
+
// GPUAdapter::requestDevice). A device created by another library and wrapped
|
|
15
|
+
// with importDevice() has to request them itself for its frames to import.
|
|
16
|
+
inline std::vector<wgpu::FeatureName> nativeFrameImportFeatures() {
|
|
17
|
+
#if defined(__APPLE__)
|
|
18
|
+
return {
|
|
19
|
+
// IOSurface import, and the MTLSharedEvent fence that EndAccess exports
|
|
20
|
+
wgpu::FeatureName::SharedTextureMemoryIOSurface,
|
|
21
|
+
wgpu::FeatureName::SharedFenceMTLSharedEvent,
|
|
22
|
+
// The biplanar NV12 layout of camera frames
|
|
23
|
+
wgpu::FeatureName::DawnMultiPlanarFormats,
|
|
24
|
+
};
|
|
25
|
+
#elif defined(__ANDROID__)
|
|
26
|
+
return {
|
|
27
|
+
// AHardwareBuffer import, and the sync-fd fence that EndAccess exports
|
|
28
|
+
wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer,
|
|
29
|
+
wgpu::FeatureName::SharedFenceSyncFD,
|
|
30
|
+
// The YUV buffers of the video decoder and of the camera: Dawn imports
|
|
31
|
+
// them as OpaqueYCbCrAndroid textures, a format it only accepts, and
|
|
32
|
+
// only samples as an external texture, with this feature
|
|
33
|
+
wgpu::FeatureName::OpaqueYCbCrAndroidForExternalTexture,
|
|
34
|
+
};
|
|
35
|
+
#else
|
|
36
|
+
return {};
|
|
37
|
+
#endif
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} // namespace rnwgpu
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
#include <map>
|
|
4
4
|
#include <memory>
|
|
5
|
+
#include <stdexcept>
|
|
5
6
|
#include <string>
|
|
6
7
|
#include <vector>
|
|
7
8
|
|
|
8
9
|
#include "webgpu/webgpu_cpp.h"
|
|
9
10
|
|
|
10
11
|
#include "JSIConverter.h"
|
|
11
|
-
#include "RnFeatures.h"
|
|
12
12
|
#include "WGPULogger.h"
|
|
13
13
|
|
|
14
14
|
#include "GPUDawnTogglesDescriptor.h"
|
|
@@ -57,13 +57,14 @@ template <> struct JSIConverter<std::vector<wgpu::FeatureName>> {
|
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
auto str = elementValue.asString(runtime).utf8(runtime);
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
// The umbrella feature of earlier versions. Native frame import is on
|
|
61
|
+
// by default now and the name is gone; say so rather than reject it as
|
|
62
|
+
// an unknown feature.
|
|
63
|
+
if (str == "rnwebgpu/native-texture") {
|
|
64
|
+
throw std::runtime_error(
|
|
65
|
+
"requestDevice: the 'rnwebgpu/native-texture' feature has been "
|
|
66
|
+
"removed. Native frame import is enabled by default whenever the "
|
|
67
|
+
"adapter supports it; drop the name from requiredFeatures.");
|
|
67
68
|
}
|
|
68
69
|
vector.emplace_back(JSIConverter<wgpu::FeatureName>::fromJSI(
|
|
69
70
|
runtime, elementValue, outOfBounds));
|
|
@@ -109,13 +110,12 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUDeviceDescriptor>> {
|
|
|
109
110
|
}
|
|
110
111
|
if (value.hasProperty(runtime, "dawnToggles")) {
|
|
111
112
|
auto prop = value.getProperty(runtime, "dawnToggles");
|
|
112
|
-
result->dawnToggles = JSIConverter<
|
|
113
|
-
std::
|
|
114
|
-
|
|
113
|
+
result->dawnToggles = JSIConverter<std::optional<
|
|
114
|
+
std::shared_ptr<GPUDawnTogglesDescriptor>>>::fromJSI(runtime, prop,
|
|
115
|
+
false);
|
|
115
116
|
}
|
|
116
117
|
if (value.hasProperty(runtime, "implicitDeviceSynchronization")) {
|
|
117
|
-
auto prop =
|
|
118
|
-
value.getProperty(runtime, "implicitDeviceSynchronization");
|
|
118
|
+
auto prop = value.getProperty(runtime, "implicitDeviceSynchronization");
|
|
119
119
|
result->implicitDeviceSynchronization =
|
|
120
120
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, prop, false);
|
|
121
121
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<key>HeadersPath</key>
|
|
11
11
|
<string>Headers</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>
|
|
13
|
+
<string>macos-arm64_x86_64</string>
|
|
14
14
|
<key>LibraryPath</key>
|
|
15
15
|
<string>libwebgpu_dawn.a</string>
|
|
16
16
|
<key>SupportedArchitectures</key>
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
<string>x86_64</string>
|
|
20
20
|
</array>
|
|
21
21
|
<key>SupportedPlatform</key>
|
|
22
|
-
<string>
|
|
23
|
-
<key>SupportedPlatformVariant</key>
|
|
24
|
-
<string>simulator</string>
|
|
22
|
+
<string>macos</string>
|
|
25
23
|
</dict>
|
|
26
24
|
<dict>
|
|
27
25
|
<key>BinaryPath</key>
|
|
@@ -45,7 +43,7 @@
|
|
|
45
43
|
<key>HeadersPath</key>
|
|
46
44
|
<string>Headers</string>
|
|
47
45
|
<key>LibraryIdentifier</key>
|
|
48
|
-
<string>
|
|
46
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
49
47
|
<key>LibraryPath</key>
|
|
50
48
|
<string>libwebgpu_dawn.a</string>
|
|
51
49
|
<key>SupportedArchitectures</key>
|
|
@@ -54,7 +52,9 @@
|
|
|
54
52
|
<string>x86_64</string>
|
|
55
53
|
</array>
|
|
56
54
|
<key>SupportedPlatform</key>
|
|
57
|
-
<string>
|
|
55
|
+
<string>ios</string>
|
|
56
|
+
<key>SupportedPlatformVariant</key>
|
|
57
|
+
<string>simulator</string>
|
|
58
58
|
</dict>
|
|
59
59
|
</array>
|
|
60
60
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/libs/apple/libwebgpu_dawn.xcframework/ios-arm64_x86_64-simulator/libwebgpu_dawn.a
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 42690144 bytes
|
|
4
|
+
sha256: 62ee6161dc9938a0241df7aabb437cc5c012b16c271eb1b9e795c46825b46bbc
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/libs/apple/libwebgpu_dawn.xcframework/macos-arm64_x86_64/libwebgpu_dawn.a
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 44227600 bytes
|
|
4
|
+
sha256: 838e315fa20bb88ede8442ae144fba1d4085b8587512466a8fb6ce2efbab7af1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"app.plugin.js",
|
|
26
26
|
"plugin/build/**"
|
|
27
27
|
],
|
|
28
|
-
"dawn": "chrome-
|
|
28
|
+
"dawn": "chrome-m154a",
|
|
29
29
|
"dawnCommit": "3d786993a7ded64c4ebb4884b9b079db9ad0e580",
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "NODE_OPTIONS='--experimental-require-module' jest -i",
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <string>
|
|
4
|
-
#include <unordered_set>
|
|
5
|
-
#include <vector>
|
|
6
|
-
|
|
7
|
-
#include "webgpu/webgpu_cpp.h"
|
|
8
|
-
|
|
9
|
-
namespace rnwgpu {
|
|
10
|
-
|
|
11
|
-
// Umbrella feature name owned by react-native-wgpu. Backed by a
|
|
12
|
-
// platform-specific pair of Dawn features. The prefix is intentional: this
|
|
13
|
-
// string is not part of the WebGPU spec, it is our API surface for the
|
|
14
|
-
// "import a native surface as a sampleable texture" capability.
|
|
15
|
-
inline constexpr const char *kRnNativeTextureFeature =
|
|
16
|
-
"rnwebgpu/native-texture";
|
|
17
|
-
|
|
18
|
-
// Dawn features that back the umbrella on the current platform. Empty on
|
|
19
|
-
// platforms where the capability is not available, in which case the umbrella
|
|
20
|
-
// behaves as a no-op (it won't appear in adapter.features and asking for it
|
|
21
|
-
// in requiredFeatures expands to nothing).
|
|
22
|
-
inline std::vector<wgpu::FeatureName> rnNativeTextureBackingFeatures() {
|
|
23
|
-
#if defined(__APPLE__)
|
|
24
|
-
return {wgpu::FeatureName::SharedTextureMemoryIOSurface,
|
|
25
|
-
wgpu::FeatureName::SharedFenceMTLSharedEvent};
|
|
26
|
-
#elif defined(__ANDROID__)
|
|
27
|
-
return {wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer,
|
|
28
|
-
wgpu::FeatureName::SharedFenceSyncFD};
|
|
29
|
-
#else
|
|
30
|
-
return {};
|
|
31
|
-
#endif
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Dawn features that complete the umbrella on the current platform. They are
|
|
35
|
-
// requested by default when the adapter supports them, but they are not part
|
|
36
|
-
// of the all-or-nothing backing set: on Android, Dawn imports the YUV buffers
|
|
37
|
-
// of the video decoder and of the camera as OpaqueYCbCrAndroid textures, a
|
|
38
|
-
// format it only accepts, and only samples as an external texture, with
|
|
39
|
-
// OpaqueYCbCrAndroidForExternalTexture; RGBA buffers import without it.
|
|
40
|
-
inline std::vector<wgpu::FeatureName> rnNativeTextureOptionalFeatures() {
|
|
41
|
-
#if defined(__ANDROID__)
|
|
42
|
-
return {wgpu::FeatureName::OpaqueYCbCrAndroidForExternalTexture};
|
|
43
|
-
#else
|
|
44
|
-
return {};
|
|
45
|
-
#endif
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// If every Dawn feature backing the umbrella is in `enabled`, add the
|
|
49
|
-
// umbrella name to `out`. Used by adapter.features / device.features so JS
|
|
50
|
-
// callers can see (and call .has on) the same name they pass in.
|
|
51
|
-
inline void maybeSynthesizeRnNativeTextureFeature(
|
|
52
|
-
const std::unordered_set<wgpu::FeatureName> &enabled,
|
|
53
|
-
std::unordered_set<std::string> &out) {
|
|
54
|
-
auto backing = rnNativeTextureBackingFeatures();
|
|
55
|
-
if (backing.empty()) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
for (auto f : backing) {
|
|
59
|
-
if (enabled.find(f) == enabled.end()) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
out.insert(kRnNativeTextureFeature);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
} // namespace rnwgpu
|