react-native-wgpu 0.2.0 → 0.2.2
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/android/CMakeLists.txt +1 -1
- package/android/build.gradle +2 -1
- package/android/src/main/java/com/webgpu/WebGPUAHBView.java +247 -45
- package/android/src/main/java/com/webgpu/WebGPUView.java +4 -4
- package/apple/ApplePlatformContext.h +1 -0
- package/apple/RNWGUIKit.h +5 -0
- package/apple/platform/ThreadUtils.cpp +1 -0
- package/cpp/WGPULogger.h +1 -0
- package/cpp/dawn/dawn_proc_table.h +31 -10
- package/cpp/dawn/native/D3D11Backend.h +8 -2
- package/cpp/dawn/native/D3DBackend.h +0 -3
- package/cpp/dawn/native/DawnNative.h +4 -0
- package/cpp/dawn/platform/DawnPlatform.h +2 -1
- package/cpp/dawn/webgpu_cpp_print.h +202 -25
- package/cpp/dawn_logging.cpp +3 -6
- package/cpp/jsi/RNFHybridObject.cpp +2 -1
- package/cpp/jsi/RNFJSIConverter.h +5 -2
- package/cpp/jsi/RNFPromise.cpp +2 -0
- package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp +1 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +1 -0
- package/cpp/rnwgpu/api/GPU.cpp +5 -1
- package/cpp/rnwgpu/api/GPU.h +7 -3
- package/cpp/rnwgpu/api/GPUAdapter.cpp +3 -0
- package/cpp/rnwgpu/api/GPUBuffer.cpp +1 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +1 -0
- package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +2 -0
- package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +2 -0
- package/cpp/rnwgpu/api/GPUComputePipeline.cpp +1 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +3 -0
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +1 -0
- package/cpp/rnwgpu/api/GPUQueue.cpp +9 -5
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +3 -0
- package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +4 -0
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -0
- package/cpp/rnwgpu/api/descriptors/Unions.h +3 -2
- package/cpp/threading/Dispatcher.cpp +2 -1
- package/cpp/threading/ThreadPool.cpp +2 -0
- package/cpp/webgpu/webgpu.h +571 -261
- package/cpp/webgpu/webgpu_cpp.h +871 -313
- package/lib/typescript/src/__tests__/setup.d.ts +0 -1
- package/lib/typescript/src/__tests__/setup.d.ts.map +1 -1
- package/libs/android/arm64-v8a/libwebgpu_dawn.a +0 -0
- package/libs/android/arm64-v8a/libwebgpu_dawn.so +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.a +0 -0
- package/libs/android/armeabi-v7a/libwebgpu_dawn.so +0 -0
- package/libs/android/x86/libwebgpu_dawn.a +0 -0
- package/libs/android/x86/libwebgpu_dawn.so +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.a +0 -0
- package/libs/android/x86_64/libwebgpu_dawn.so +0 -0
- package/libs/apple/arm64_iphoneos/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xros/libwebgpu_dawn.a +0 -0
- package/libs/apple/arm64_xrsimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/Info.plist +10 -10
- 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/libs/apple/libwebgpu_dawn.xcframework/xros-arm64/libwebgpu_dawn.a +0 -0
- package/libs/apple/libwebgpu_dawn.xcframework/xros-arm64-simulator/libwebgpu_dawn.a +0 -0
- package/libs/apple/universal_macosx/libwebgpu_dawn.a +0 -0
- package/libs/apple/x86_64_iphonesimulator/libwebgpu_dawn.a +0 -0
- package/libs/dawn.json +422 -206
- package/package.json +1 -1
- package/src/__tests__/Constants.spec.ts +2 -4
- package/src/__tests__/Device.spec.ts +42 -24
- package/src/__tests__/GPU.spec.ts +115 -105
- package/src/__tests__/setup.ts +0 -1
package/package.json
CHANGED
|
@@ -62,16 +62,14 @@ describe("WebGPUConstants", () => {
|
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
it("GPUAdapter", async () => {
|
|
65
|
-
const result = await client.eval(({
|
|
65
|
+
const result = await client.eval(({ device, gpu }) => {
|
|
66
66
|
return [
|
|
67
67
|
gpu instanceof GPU,
|
|
68
|
-
adapter instanceof GPUAdapter,
|
|
69
68
|
device instanceof GPUDevice,
|
|
70
|
-
adapter instanceof GPUDevice,
|
|
71
69
|
device instanceof GPUAdapter,
|
|
72
70
|
];
|
|
73
71
|
});
|
|
74
|
-
expect(result).toEqual([true, true,
|
|
72
|
+
expect(result).toEqual([true, true, false]);
|
|
75
73
|
});
|
|
76
74
|
it("instanceof", async () => {
|
|
77
75
|
const result = await client.eval(
|
|
@@ -2,33 +2,49 @@ import { client } from "./setup";
|
|
|
2
2
|
|
|
3
3
|
describe("Device", () => {
|
|
4
4
|
it("request device (1)", async () => {
|
|
5
|
-
const result = await client.eval(({
|
|
6
|
-
|
|
5
|
+
const result = await client.eval(({ gpu }) =>
|
|
6
|
+
gpu
|
|
7
|
+
.requestAdapter()
|
|
8
|
+
.then((adapter) =>
|
|
9
|
+
adapter!.requestDevice().then((device) => device !== null),
|
|
10
|
+
),
|
|
7
11
|
);
|
|
8
12
|
expect(result).toBe(true);
|
|
9
13
|
});
|
|
10
14
|
|
|
11
15
|
it("request device (2)", async () => {
|
|
12
|
-
const result = await client.eval(({
|
|
13
|
-
|
|
16
|
+
const result = await client.eval(({ gpu }) =>
|
|
17
|
+
gpu
|
|
18
|
+
.requestAdapter()
|
|
19
|
+
.then((adapter) =>
|
|
20
|
+
adapter!.requestDevice(undefined).then((device) => device.label),
|
|
21
|
+
),
|
|
14
22
|
);
|
|
15
23
|
expect(result).toBe("");
|
|
16
24
|
});
|
|
17
25
|
it("request device (3)", async () => {
|
|
18
|
-
const result = await client.eval(({
|
|
19
|
-
|
|
26
|
+
const result = await client.eval(({ gpu }) =>
|
|
27
|
+
gpu
|
|
28
|
+
.requestAdapter()
|
|
29
|
+
.then((adapter) =>
|
|
30
|
+
adapter!
|
|
31
|
+
.requestDevice({ label: "MyGPU" })
|
|
32
|
+
.then((device) => device.label),
|
|
33
|
+
),
|
|
20
34
|
);
|
|
21
35
|
expect(result).toBe("MyGPU");
|
|
22
36
|
});
|
|
23
37
|
it("destroy device (3)", async () => {
|
|
24
|
-
const result = await client.eval(({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
const result = await client.eval(({ gpu }) =>
|
|
39
|
+
gpu.requestAdapter().then((adapter) =>
|
|
40
|
+
adapter!.requestDevice({ label: "MyGPU" }).then((device) => {
|
|
41
|
+
device.destroy();
|
|
42
|
+
return device.lost.then((r) => ({
|
|
43
|
+
reason: r.reason,
|
|
44
|
+
message: r.message,
|
|
45
|
+
}));
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
32
48
|
);
|
|
33
49
|
expect(["unknown", "destroyed"].includes(result.reason)).toBe(true);
|
|
34
50
|
});
|
|
@@ -48,17 +64,19 @@ describe("Device", () => {
|
|
|
48
64
|
});
|
|
49
65
|
|
|
50
66
|
it("resolves an awaited device.lost when device.destroy is called", async () => {
|
|
51
|
-
const result = await client.eval(({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
const result = await client.eval(({ gpu }) =>
|
|
68
|
+
gpu.requestAdapter().then((adapter) =>
|
|
69
|
+
adapter!.requestDevice({ label: "myGPU2" }).then((device) => {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
device.destroy();
|
|
72
|
+
}, 50);
|
|
56
73
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
return device.lost.then((r) => ({
|
|
75
|
+
reason: r.reason,
|
|
76
|
+
message: r.message,
|
|
77
|
+
}));
|
|
78
|
+
}),
|
|
79
|
+
),
|
|
62
80
|
);
|
|
63
81
|
|
|
64
82
|
expect(["unknown", "destroyed"].includes(result.reason)).toBeTruthy();
|
|
@@ -73,61 +73,69 @@ describe("Adapter", () => {
|
|
|
73
73
|
expect(result!.description).toBeDefined();
|
|
74
74
|
});
|
|
75
75
|
it("isFallback", async () => {
|
|
76
|
-
const result = await client.eval(({
|
|
77
|
-
return adapter
|
|
76
|
+
const result = await client.eval(({ gpu }) => {
|
|
77
|
+
return gpu.requestAdapter().then((adapter) => adapter!.isFallbackAdapter);
|
|
78
78
|
});
|
|
79
79
|
expect(result).toBe(false);
|
|
80
80
|
});
|
|
81
81
|
it("features", async () => {
|
|
82
|
-
const result = await client.eval(({
|
|
83
|
-
return
|
|
82
|
+
const result = await client.eval(({ gpu }) => {
|
|
83
|
+
return gpu
|
|
84
|
+
.requestAdapter()
|
|
85
|
+
.then((adapter) => Array.from(adapter!.features));
|
|
84
86
|
});
|
|
85
87
|
expect(result.includes("depth-clip-control")).toBe(true);
|
|
86
88
|
expect(result.includes("rg11b10ufloat-renderable")).toBe(true);
|
|
87
89
|
expect(result.includes("texture-compression-etc2")).toBe(true);
|
|
88
90
|
});
|
|
89
91
|
it("requiredLimits", async () => {
|
|
90
|
-
const result = await client.eval(({
|
|
91
|
-
return adapter
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
const result = await client.eval(({ gpu }) => {
|
|
93
|
+
return gpu.requestAdapter().then((adapter) =>
|
|
94
|
+
adapter!
|
|
95
|
+
.requestDevice({
|
|
96
|
+
requiredLimits: {
|
|
97
|
+
maxBufferSize: 1024 * 1024 * 4,
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
.then((device) => !!device),
|
|
101
|
+
);
|
|
98
102
|
});
|
|
99
103
|
expect(result).toBe(true);
|
|
100
104
|
});
|
|
101
105
|
it("request device with timestamp queries", async () => {
|
|
102
|
-
const result = await client.eval(({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const result = await client.eval(({ gpu }) => {
|
|
107
|
+
return gpu.requestAdapter().then((adapter) => {
|
|
108
|
+
if (adapter!.features.has("timestamp-query")) {
|
|
109
|
+
return adapter!
|
|
110
|
+
.requestDevice({
|
|
111
|
+
requiredFeatures: ["timestamp-query"],
|
|
112
|
+
})
|
|
113
|
+
.then((device) => device.features.has("timestamp-query"));
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
111
117
|
});
|
|
112
118
|
expect(result).toBe(true);
|
|
113
119
|
});
|
|
114
120
|
it("request device faulty input", async () => {
|
|
115
|
-
const result = await client.eval(({
|
|
116
|
-
return adapter
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
const result = await client.eval(({ gpu }) => {
|
|
122
|
+
return gpu.requestAdapter().then((adapter) =>
|
|
123
|
+
adapter!
|
|
124
|
+
.requestDevice({
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
requiredFeatures: [["bgra8unorm-storage"]],
|
|
128
|
+
requiredLimits: {
|
|
129
|
+
maxComputeWorkgroupStorageSize: 16352,
|
|
130
|
+
maxComputeWorkgroupsPerDimension: 65535,
|
|
131
|
+
maxStorageBufferBindingSize: 268435456,
|
|
132
|
+
maxBufferSize: 268435456,
|
|
133
|
+
maxComputeWorkgroupSizeX: 512,
|
|
134
|
+
maxComputeInvocationsPerWorkgroup: 512,
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
.then((device) => !!device),
|
|
138
|
+
);
|
|
131
139
|
});
|
|
132
140
|
expect(result).toBe(true);
|
|
133
141
|
});
|
|
@@ -144,74 +152,76 @@ describe("Adapter", () => {
|
|
|
144
152
|
// expect(result).toBe(true);
|
|
145
153
|
// });
|
|
146
154
|
it("limits", async () => {
|
|
147
|
-
const result = await client.eval(({
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
155
|
+
const result = await client.eval(({ gpu }) => {
|
|
156
|
+
return gpu.requestAdapter().then((adapter) => {
|
|
157
|
+
const {
|
|
158
|
+
maxTextureDimension1D,
|
|
159
|
+
maxTextureDimension2D,
|
|
160
|
+
maxTextureDimension3D,
|
|
161
|
+
maxTextureArrayLayers,
|
|
162
|
+
maxBindGroups,
|
|
163
|
+
maxBindGroupsPlusVertexBuffers,
|
|
164
|
+
maxBindingsPerBindGroup,
|
|
165
|
+
maxDynamicUniformBuffersPerPipelineLayout,
|
|
166
|
+
maxDynamicStorageBuffersPerPipelineLayout,
|
|
167
|
+
maxSampledTexturesPerShaderStage,
|
|
168
|
+
maxSamplersPerShaderStage,
|
|
169
|
+
maxStorageBuffersPerShaderStage,
|
|
170
|
+
maxStorageTexturesPerShaderStage,
|
|
171
|
+
maxUniformBuffersPerShaderStage,
|
|
172
|
+
maxUniformBufferBindingSize,
|
|
173
|
+
maxStorageBufferBindingSize,
|
|
174
|
+
minUniformBufferOffsetAlignment,
|
|
175
|
+
minStorageBufferOffsetAlignment,
|
|
176
|
+
maxVertexBuffers,
|
|
177
|
+
maxBufferSize,
|
|
178
|
+
maxVertexAttributes,
|
|
179
|
+
maxVertexBufferArrayStride,
|
|
180
|
+
maxInterStageShaderVariables,
|
|
181
|
+
maxColorAttachments,
|
|
182
|
+
maxColorAttachmentBytesPerSample,
|
|
183
|
+
maxComputeWorkgroupStorageSize,
|
|
184
|
+
maxComputeInvocationsPerWorkgroup,
|
|
185
|
+
maxComputeWorkgroupSizeX,
|
|
186
|
+
maxComputeWorkgroupSizeY,
|
|
187
|
+
maxComputeWorkgroupSizeZ,
|
|
188
|
+
maxComputeWorkgroupsPerDimension,
|
|
189
|
+
} = adapter!.limits;
|
|
190
|
+
return {
|
|
191
|
+
__brand: adapter!.limits.__brand,
|
|
192
|
+
maxTextureDimension1D,
|
|
193
|
+
maxTextureDimension2D,
|
|
194
|
+
maxTextureDimension3D,
|
|
195
|
+
maxTextureArrayLayers,
|
|
196
|
+
maxBindGroups,
|
|
197
|
+
maxBindGroupsPlusVertexBuffers,
|
|
198
|
+
maxBindingsPerBindGroup,
|
|
199
|
+
maxDynamicUniformBuffersPerPipelineLayout,
|
|
200
|
+
maxDynamicStorageBuffersPerPipelineLayout,
|
|
201
|
+
maxSampledTexturesPerShaderStage,
|
|
202
|
+
maxSamplersPerShaderStage,
|
|
203
|
+
maxStorageBuffersPerShaderStage,
|
|
204
|
+
maxStorageTexturesPerShaderStage,
|
|
205
|
+
maxUniformBuffersPerShaderStage,
|
|
206
|
+
maxUniformBufferBindingSize,
|
|
207
|
+
maxStorageBufferBindingSize,
|
|
208
|
+
minUniformBufferOffsetAlignment,
|
|
209
|
+
minStorageBufferOffsetAlignment,
|
|
210
|
+
maxVertexBuffers,
|
|
211
|
+
maxBufferSize,
|
|
212
|
+
maxVertexAttributes,
|
|
213
|
+
maxVertexBufferArrayStride,
|
|
214
|
+
maxInterStageShaderVariables,
|
|
215
|
+
maxColorAttachments,
|
|
216
|
+
maxColorAttachmentBytesPerSample,
|
|
217
|
+
maxComputeWorkgroupStorageSize,
|
|
218
|
+
maxComputeInvocationsPerWorkgroup,
|
|
219
|
+
maxComputeWorkgroupSizeX,
|
|
220
|
+
maxComputeWorkgroupSizeY,
|
|
221
|
+
maxComputeWorkgroupSizeZ,
|
|
222
|
+
maxComputeWorkgroupsPerDimension,
|
|
223
|
+
};
|
|
224
|
+
});
|
|
215
225
|
});
|
|
216
226
|
if (result.__brand) {
|
|
217
227
|
expect(result.__brand).toBe("GPUSupportedLimits");
|