react-native-webgpu 0.10.0 → 0.10.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.
|
@@ -240,8 +240,7 @@ std::shared_ptr<GPUExternalTexture> GPUExternalTexture::Create(
|
|
|
240
240
|
|
|
241
241
|
auto external = device.CreateExternalTexture(&extDesc);
|
|
242
242
|
if (external == nullptr) {
|
|
243
|
-
|
|
244
|
-
(void)memory.EndAccess(texture, &state);
|
|
243
|
+
endAccess(memory, texture);
|
|
245
244
|
throw std::runtime_error(
|
|
246
245
|
"GPUExternalTexture::Create(): CreateExternalTexture returned "
|
|
247
246
|
"null");
|
|
@@ -345,8 +344,7 @@ std::shared_ptr<GPUExternalTexture> GPUExternalTexture::Create(
|
|
|
345
344
|
|
|
346
345
|
auto external = device.CreateExternalTexture(&extDesc);
|
|
347
346
|
if (external == nullptr) {
|
|
348
|
-
|
|
349
|
-
(void)memory.EndAccess(texture, &state);
|
|
347
|
+
endAccess(memory, texture);
|
|
350
348
|
throw std::runtime_error(
|
|
351
349
|
"GPUExternalTexture::Create(): CreateExternalTexture returned "
|
|
352
350
|
"null");
|
|
@@ -58,19 +58,39 @@ public:
|
|
|
58
58
|
// destroy() the producer's surface (e.g. an AVPlayer IOSurface) stays claimed
|
|
59
59
|
// until GC runs. EndAccess is the designed post-submit call: Dawn keeps the
|
|
60
60
|
// texture alive for in-flight GPU work via the fences it returns.
|
|
61
|
+
// Destroying the texture and the external texture is what actually frees
|
|
62
|
+
// the import: the ExternalTexture's views keep the imported VkImage /
|
|
63
|
+
// IOSurface texture alive until the object itself is destroyed, which
|
|
64
|
+
// otherwise only happens once the JS wrapper (and any bind group that
|
|
65
|
+
// sampled it) is garbage-collected.
|
|
61
66
|
void destroy() {
|
|
62
67
|
if (_memory && _texture) {
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
endAccess(_memory, _texture);
|
|
69
|
+
}
|
|
70
|
+
if (_texture) {
|
|
71
|
+
_texture.Destroy();
|
|
72
|
+
}
|
|
73
|
+
if (_instance) {
|
|
74
|
+
_instance.Destroy();
|
|
75
|
+
}
|
|
76
|
+
if (_texture) {
|
|
77
|
+
_texture.Destroy();
|
|
78
|
+
}
|
|
79
|
+
if (_instance) {
|
|
80
|
+
_instance.Destroy();
|
|
65
81
|
}
|
|
66
82
|
_texture = nullptr;
|
|
67
83
|
_memory = nullptr;
|
|
84
|
+
_instance = nullptr;
|
|
85
|
+
_source = nullptr;
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
std::string getLabel() { return _label; }
|
|
71
89
|
void setLabel(const std::string &label) {
|
|
72
90
|
_label = label;
|
|
73
|
-
_instance
|
|
91
|
+
if (_instance) {
|
|
92
|
+
_instance.SetLabel(_label.c_str());
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
// Non-spec extension. A 3x4 row-major matrix mapping the *sampled* texel
|
|
@@ -97,6 +117,23 @@ public:
|
|
|
97
117
|
|
|
98
118
|
inline const wgpu::ExternalTexture get() { return _instance; }
|
|
99
119
|
|
|
120
|
+
// End the shared-memory access window on `texture`. Shared by destroy() and
|
|
121
|
+
// the Create() error paths so every EndAccess carries the same chain: Dawn's
|
|
122
|
+
// Vulkan backend rejects the call unless a
|
|
123
|
+
// SharedTextureMemoryVkImageLayoutEndState is chained (it writes the
|
|
124
|
+
// released VkImage layouts there), while the Metal backend only accepts its
|
|
125
|
+
// own optional end state. The returned fences are dropped: Dawn keeps the
|
|
126
|
+
// texture alive for in-flight GPU work on its own.
|
|
127
|
+
static void endAccess(const wgpu::SharedTextureMemory &memory,
|
|
128
|
+
const wgpu::Texture &texture) {
|
|
129
|
+
wgpu::SharedTextureMemoryEndAccessState state{};
|
|
130
|
+
#if defined(__ANDROID__)
|
|
131
|
+
wgpu::SharedTextureMemoryVkImageLayoutEndState vkLayout{};
|
|
132
|
+
state.nextInChain = &vkLayout;
|
|
133
|
+
#endif
|
|
134
|
+
(void)memory.EndAccess(texture, &state);
|
|
135
|
+
}
|
|
136
|
+
|
|
100
137
|
private:
|
|
101
138
|
wgpu::ExternalTexture _instance;
|
|
102
139
|
wgpu::SharedTextureMemory _memory;
|
|
@@ -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;IAGrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9D,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACjE,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C;;;;;;;;OAQG;IACH,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;AAKD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,CAAC;AAkBtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ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GD,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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webgpu",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "React Native WebGPU",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"clang-format": "^1.8.0",
|
|
87
87
|
"del-cli": "^5.1.0",
|
|
88
88
|
"eslint": "9.35.0",
|
|
89
|
-
"eslint-config-react-native-wcandillon": "
|
|
89
|
+
"eslint-config-react-native-wcandillon": "5.0.0",
|
|
90
90
|
"eslint-plugin-import": "2.32.0",
|
|
91
91
|
"eslint-plugin-jest": "^28.8.2",
|
|
92
92
|
"eslint-plugin-prettier": "^5.2.1",
|
package/src/types.ts
CHANGED
|
@@ -96,9 +96,7 @@ export interface GPUSharedTextureMemoryDescriptor {
|
|
|
96
96
|
// targets (iOS/Metal and Android/Vulkan); importSharedFence accepts these and
|
|
97
97
|
// export() reports them.
|
|
98
98
|
export type GPUSharedFenceType =
|
|
99
|
-
|
|
100
|
-
| "sync-fd"
|
|
101
|
-
| "vk-semaphore-opaque-fd";
|
|
99
|
+
"mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
|
|
102
100
|
|
|
103
101
|
export interface GPUSharedFenceDescriptor {
|
|
104
102
|
// The fence kind to import. Must match a shared-fence-* feature enabled on
|