gpu-atlas 0.1.0 → 0.2.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/README.md +287 -248
- package/dist/gpu-atlas.js +188 -168
- package/dist/gpu-atlas.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/package.json +59 -59
package/dist/gpu-atlas.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const $t = 5, Rt = 2;
|
|
2
2
|
class D extends Error {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
super(t), this.name = "WebGPUUnavailable";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function Se(e) {
|
|
8
8
|
if (typeof navigator > "u" || !navigator.gpu)
|
|
9
9
|
throw new D("navigator.gpu is missing — this browser has no WebGPU");
|
|
10
10
|
const t = await navigator.gpu.requestAdapter(
|
|
@@ -14,16 +14,16 @@ async function ke(e) {
|
|
|
14
14
|
throw new D(
|
|
15
15
|
"requestAdapter returned null — the WebGPU API exists but no usable adapter does"
|
|
16
16
|
);
|
|
17
|
-
const r = await
|
|
18
|
-
let s = await
|
|
19
|
-
if (s || (a.push("requiredLimits (all)"), s = await
|
|
17
|
+
const r = await Me(t, e), n = [...t.features], i = Pe(t.limits), a = [];
|
|
18
|
+
let s = await L(t, n, i);
|
|
19
|
+
if (s || (a.push("requiredLimits (all)"), s = await L(t, n, void 0)), !s) {
|
|
20
20
|
a.push("requiredFeatures (all)");
|
|
21
21
|
const u = [];
|
|
22
22
|
for (const c of n) {
|
|
23
|
-
const l = await
|
|
23
|
+
const l = await L(t, [...u, c], void 0);
|
|
24
24
|
l ? (u.push(c), l.destroy()) : a.push(`feature:${c}`);
|
|
25
25
|
}
|
|
26
|
-
s = await
|
|
26
|
+
s = await L(t, u, void 0);
|
|
27
27
|
}
|
|
28
28
|
if (!s)
|
|
29
29
|
throw new D(
|
|
@@ -32,11 +32,11 @@ async function ke(e) {
|
|
|
32
32
|
const o = {
|
|
33
33
|
features: [...t.features].sort(),
|
|
34
34
|
limits: i,
|
|
35
|
-
preferredCanvasFormat:
|
|
35
|
+
preferredCanvasFormat: Te()
|
|
36
36
|
};
|
|
37
37
|
return { adapter: t, device: s, identity: r, declared: o, denied: a, lost: s.lost };
|
|
38
38
|
}
|
|
39
|
-
async function
|
|
39
|
+
async function L(e, t, r) {
|
|
40
40
|
try {
|
|
41
41
|
const n = { requiredFeatures: t };
|
|
42
42
|
return r && (n.requiredLimits = r), await e.requestDevice(n);
|
|
@@ -44,7 +44,7 @@ async function N(e, t, r) {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
async function
|
|
47
|
+
async function Me(e, t) {
|
|
48
48
|
let r = e.info;
|
|
49
49
|
if (!r) {
|
|
50
50
|
const n = e;
|
|
@@ -65,15 +65,15 @@ async function Se(e, t) {
|
|
|
65
65
|
powerPreference: t ?? "default"
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Pe(e) {
|
|
69
69
|
const t = {};
|
|
70
|
-
for (const r of
|
|
70
|
+
for (const r of Ee(e)) {
|
|
71
71
|
const n = e[r];
|
|
72
72
|
typeof n == "number" && Number.isFinite(n) && (t[r] = n);
|
|
73
73
|
}
|
|
74
74
|
return t;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function Ee(e) {
|
|
77
77
|
const t = /* @__PURE__ */ new Set();
|
|
78
78
|
let r = Object.getPrototypeOf(e);
|
|
79
79
|
for (; r && r !== Object.prototype; ) {
|
|
@@ -84,39 +84,59 @@ function Pe(e) {
|
|
|
84
84
|
for (const n of Object.keys(e)) t.add(n);
|
|
85
85
|
return [...t].sort();
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function Te() {
|
|
88
88
|
try {
|
|
89
89
|
return navigator.gpu.getPreferredCanvasFormat();
|
|
90
90
|
} catch {
|
|
91
91
|
return "";
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
async function
|
|
94
|
+
async function Ae() {
|
|
95
95
|
const e = typeof navigator < "u" ? navigator.userAgent : "", t = navigator.userAgentData;
|
|
96
96
|
let r, n, i, a;
|
|
97
97
|
if (t) {
|
|
98
98
|
n = t.mobile, r = t.platform;
|
|
99
99
|
try {
|
|
100
|
-
const o = await t.getHighEntropyValues(["platformVersion", "fullVersionList"]),
|
|
100
|
+
const o = await t.getHighEntropyValues(["platformVersion", "fullVersionList"]), u = o.fullVersionList ?? t.brands, c = Be(u);
|
|
101
101
|
c && (i = c.brand, a = c.version), o.platformVersion && (r = `${r} ${o.platformVersion}`);
|
|
102
102
|
} catch {
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const s =
|
|
105
|
+
const s = _e(e);
|
|
106
106
|
return {
|
|
107
107
|
// The UA string is parsed above but deliberately not kept: everything the
|
|
108
108
|
// profile needs from it is already broken out, and the raw value only adds
|
|
109
109
|
// identifying detail to something people are asked to share.
|
|
110
|
-
platform: r,
|
|
110
|
+
platform: r ?? Re(e),
|
|
111
111
|
browser: i ?? s.browser,
|
|
112
112
|
browserVersion: a ?? s.version,
|
|
113
|
-
mobile: n ??
|
|
113
|
+
mobile: n ?? $e(e),
|
|
114
114
|
deviceMemoryGB: navigator.deviceMemory,
|
|
115
115
|
hardwareConcurrency: navigator.hardwareConcurrency,
|
|
116
116
|
devicePixelRatio: typeof devicePixelRatio == "number" ? devicePixelRatio : 1
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function Be(e) {
|
|
120
|
+
const t = e?.filter((r) => !/Not.?A.?Brand/i.test(r.brand));
|
|
121
|
+
if (t?.length)
|
|
122
|
+
return t.find((r) => !/^Chromium$/i.test(r.brand)) ?? t[0];
|
|
123
|
+
}
|
|
124
|
+
function $e(e) {
|
|
125
|
+
return /Mobi|Android|iPhone|iPad|iPod/i.test(e) ? !0 : ye(e);
|
|
126
|
+
}
|
|
127
|
+
function Re(e) {
|
|
128
|
+
if (ye(e)) return "iPadOS";
|
|
129
|
+
if (/iPhone|iPod/i.test(e)) return "iOS";
|
|
130
|
+
if (/iPad/i.test(e)) return "iPadOS";
|
|
131
|
+
if (/Android/i.test(e)) return "Android";
|
|
132
|
+
if (/Macintosh|Mac OS X/i.test(e)) return "macOS";
|
|
133
|
+
if (/Windows/i.test(e)) return "Windows";
|
|
134
|
+
if (/Linux/i.test(e)) return "Linux";
|
|
135
|
+
}
|
|
136
|
+
function ye(e) {
|
|
137
|
+
return /Macintosh|Mac OS X/i.test(e) ? (typeof navigator < "u" ? navigator.maxTouchPoints ?? 0 : 0) > 1 : !1;
|
|
138
|
+
}
|
|
139
|
+
function _e(e) {
|
|
120
140
|
const t = [
|
|
121
141
|
["Edge", /Edg(?:e|A|iOS)?\/([\d.]+)/],
|
|
122
142
|
["Opera", /OPR\/([\d.]+)/],
|
|
@@ -130,7 +150,7 @@ function Ae(e) {
|
|
|
130
150
|
}
|
|
131
151
|
return { browser: "unknown", version: "" };
|
|
132
152
|
}
|
|
133
|
-
const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable: r, expect: n, requiresFeature: i }), I = { renderable: !1, blendable: !1, storage: !1 }, A = { renderable: !0, blendable: !0, storage: !1 }, y = { renderable: !0, blendable: !1, storage: !1 }, ae = { renderable: !0, blendable: !0, storage: !0 }, x = { renderable: !0, blendable: !1, storage: !0 },
|
|
153
|
+
const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable: r, expect: n, requiresFeature: i }), I = { renderable: !1, blendable: !1, storage: !1 }, A = { renderable: !0, blendable: !0, storage: !1 }, y = { renderable: !0, blendable: !1, storage: !1 }, ae = { renderable: !0, blendable: !0, storage: !0 }, x = { renderable: !0, blendable: !1, storage: !0 }, Ge = { renderable: !1, blendable: !1, storage: !0 }, ie = [
|
|
134
154
|
// ── 8-bit ──
|
|
135
155
|
d("r8unorm", "f32", !0, A),
|
|
136
156
|
d("r8snorm", "f32", !0, I),
|
|
@@ -154,7 +174,7 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
154
174
|
d("rg16float", "f32", !0, A),
|
|
155
175
|
d("rgba8unorm", "f32", !0, ae),
|
|
156
176
|
d("rgba8unorm-srgb", "f32", !0, A),
|
|
157
|
-
d("rgba8snorm", "f32", !0,
|
|
177
|
+
d("rgba8snorm", "f32", !0, Ge),
|
|
158
178
|
d("rgba8uint", "u32", !1, x),
|
|
159
179
|
d("rgba8sint", "i32", !1, x),
|
|
160
180
|
d("bgra8unorm", "f32", !0, A),
|
|
@@ -227,7 +247,7 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
227
247
|
expect: y
|
|
228
248
|
},
|
|
229
249
|
// ── Compressed: BC (desktop) ──
|
|
230
|
-
...
|
|
250
|
+
...N([
|
|
231
251
|
"bc1-rgba-unorm",
|
|
232
252
|
"bc3-rgba-unorm",
|
|
233
253
|
"bc4-r-unorm",
|
|
@@ -236,16 +256,16 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
236
256
|
"bc7-rgba-unorm"
|
|
237
257
|
], "texture-compression-bc", [4, 4]),
|
|
238
258
|
// ── Compressed: ETC2 (mobile) ──
|
|
239
|
-
...
|
|
259
|
+
...N(
|
|
240
260
|
["etc2-rgb8unorm", "etc2-rgba8unorm", "eac-r11unorm"],
|
|
241
261
|
"texture-compression-etc2",
|
|
242
262
|
[4, 4]
|
|
243
263
|
),
|
|
244
264
|
// ── Compressed: ASTC (mobile) ──
|
|
245
|
-
...
|
|
246
|
-
...
|
|
265
|
+
...N(["astc-4x4-unorm"], "texture-compression-astc", [4, 4]),
|
|
266
|
+
...N(["astc-8x8-unorm"], "texture-compression-astc", [8, 8])
|
|
247
267
|
];
|
|
248
|
-
function
|
|
268
|
+
function N(e, t, r) {
|
|
249
269
|
return e.map((n) => ({
|
|
250
270
|
format: n,
|
|
251
271
|
kind: "compressed",
|
|
@@ -256,7 +276,7 @@ function L(e, t, r) {
|
|
|
256
276
|
expect: I
|
|
257
277
|
}));
|
|
258
278
|
}
|
|
259
|
-
function
|
|
279
|
+
function Fe(e) {
|
|
260
280
|
return ie.find((t) => t.format === e);
|
|
261
281
|
}
|
|
262
282
|
const se = /* @__PURE__ */ new Set([
|
|
@@ -277,47 +297,47 @@ const se = /* @__PURE__ */ new Set([
|
|
|
277
297
|
"rgb10a2unorm",
|
|
278
298
|
"rgb10a2uint",
|
|
279
299
|
"rg11b10ufloat"
|
|
280
|
-
]),
|
|
281
|
-
function
|
|
300
|
+
]), Ue = /* @__PURE__ */ new Set(["r32float", "rg32float", "rgba32float"]);
|
|
301
|
+
function Ce(e, t) {
|
|
282
302
|
const r = { ...e.expect };
|
|
283
|
-
return t.has("texture-formats-tier1") && se.has(e.format) && (r.storage = !0), t.has("rg11b10ufloat-renderable") && e.format === "rg11b10ufloat" && (r.renderable = !0, r.blendable = !0), t.has("bgra8unorm-storage") && e.format === "bgra8unorm" && (r.storage = !0), t.has("float32-blendable") &&
|
|
303
|
+
return t.has("texture-formats-tier1") && se.has(e.format) && (r.storage = !0), t.has("rg11b10ufloat-renderable") && e.format === "rg11b10ufloat" && (r.renderable = !0, r.blendable = !0), t.has("bgra8unorm-storage") && e.format === "bgra8unorm" && (r.storage = !0), t.has("float32-blendable") && Ue.has(e.format) && (r.blendable = !0), t.has("texture-formats-tier2") && e.kind === "color" && (r.storage = r.storage || se.has(e.format)), r;
|
|
284
304
|
}
|
|
285
|
-
function
|
|
305
|
+
function Oe(e) {
|
|
286
306
|
return e.has("texture-formats-tier1") || e.has("texture-formats-tier2");
|
|
287
307
|
}
|
|
288
|
-
function
|
|
308
|
+
function qe(e) {
|
|
289
309
|
return e.kind === "depth" ? e.hasDepth ? "depth" : "uint" : e.texel === "u32" ? "uint" : e.texel === "i32" ? "sint" : e.filterable ? "float" : "unfilterable-float";
|
|
290
310
|
}
|
|
291
|
-
function
|
|
311
|
+
function Le(e) {
|
|
292
312
|
return e.kind === "depth" && e.hasDepth ? "texture_depth_2d" : `texture_2d<${e.texel}>`;
|
|
293
313
|
}
|
|
294
|
-
const
|
|
295
|
-
async function
|
|
296
|
-
for (const a of
|
|
314
|
+
const X = ["validation", "out-of-memory", "internal"];
|
|
315
|
+
async function V(e, t, r = !1) {
|
|
316
|
+
for (const a of X) e.pushErrorScope(a);
|
|
297
317
|
let n = null;
|
|
298
318
|
const i = [];
|
|
299
319
|
try {
|
|
300
320
|
n = await t();
|
|
301
321
|
} catch (a) {
|
|
302
|
-
i.push({ kind: "exception", message:
|
|
322
|
+
i.push({ kind: "exception", message: Y(a) });
|
|
303
323
|
}
|
|
304
324
|
if (r && i.length === 0)
|
|
305
325
|
try {
|
|
306
326
|
await e.queue.onSubmittedWorkDone();
|
|
307
327
|
} catch (a) {
|
|
308
|
-
i.push({ kind: "queue", message:
|
|
328
|
+
i.push({ kind: "queue", message: Y(a) });
|
|
309
329
|
}
|
|
310
|
-
for (let a =
|
|
330
|
+
for (let a = X.length - 1; a >= 0; a--)
|
|
311
331
|
try {
|
|
312
332
|
const s = await e.popErrorScope();
|
|
313
|
-
s && i.push({ kind:
|
|
333
|
+
s && i.push({ kind: X[a], message: s.message });
|
|
314
334
|
} catch (s) {
|
|
315
|
-
i.push({ kind: "scope-unavailable", message:
|
|
335
|
+
i.push({ kind: "scope-unavailable", message: Y(s) });
|
|
316
336
|
}
|
|
317
337
|
return { value: n, errors: i, ok: i.length === 0 && n !== null };
|
|
318
338
|
}
|
|
319
339
|
async function M(e, t, r = !1) {
|
|
320
|
-
const n = await
|
|
340
|
+
const n = await V(e, async () => {
|
|
321
341
|
const i = await t();
|
|
322
342
|
return i === void 0 ? !0 : i;
|
|
323
343
|
}, r);
|
|
@@ -329,7 +349,7 @@ function _(e, t) {
|
|
|
329
349
|
function O(e) {
|
|
330
350
|
return e[0]?.message ?? "no error reported";
|
|
331
351
|
}
|
|
332
|
-
function
|
|
352
|
+
function Y(e) {
|
|
333
353
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
334
354
|
}
|
|
335
355
|
function v(...e) {
|
|
@@ -344,17 +364,17 @@ const H = `
|
|
|
344
364
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
345
365
|
return vec4f(p[i], 0., 1.);
|
|
346
366
|
}`;
|
|
347
|
-
async function
|
|
367
|
+
async function Ne(e, t, r, n) {
|
|
348
368
|
const i = r ? ie.filter((u) => r.includes(u.format)) : ie, a = e.createTexture({
|
|
349
369
|
size: [4, 4],
|
|
350
370
|
format: "rgba8unorm",
|
|
351
371
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
352
372
|
}), s = { view: a.createView() }, o = [];
|
|
353
373
|
for (let u = 0; u < i.length; u++)
|
|
354
|
-
o.push(await
|
|
374
|
+
o.push(await De(e, i[u], t, s)), n?.((u + 1) / i.length);
|
|
355
375
|
return v(a), o;
|
|
356
376
|
}
|
|
357
|
-
async function
|
|
377
|
+
async function De(e, t, r, n) {
|
|
358
378
|
const i = {
|
|
359
379
|
format: t.format,
|
|
360
380
|
requiresFeature: t.requiresFeature,
|
|
@@ -366,7 +386,7 @@ async function Oe(e, t, r, n) {
|
|
|
366
386
|
storageWritable: !1,
|
|
367
387
|
multisample4x: !1,
|
|
368
388
|
errors: []
|
|
369
|
-
}, [a, s] = t.block ?? [4, 4], o = await
|
|
389
|
+
}, [a, s] = t.block ?? [4, 4], o = await V(
|
|
370
390
|
e,
|
|
371
391
|
() => e.createTexture({
|
|
372
392
|
size: [a, s],
|
|
@@ -376,9 +396,9 @@ async function Oe(e, t, r, n) {
|
|
|
376
396
|
);
|
|
377
397
|
if (i.creatable = o.ok, !o.ok)
|
|
378
398
|
return i.errors.push(..._("create", o.errors)), i;
|
|
379
|
-
const u = o.value, c = await
|
|
399
|
+
const u = o.value, c = await Ie(e, t, u, n);
|
|
380
400
|
if (i.sampleable = c.ok, c.ok || i.errors.push(..._("sample", c.errors)), v(u), t.kind !== "compressed") if (t.kind === "depth") {
|
|
381
|
-
const l = await
|
|
401
|
+
const l = await We(e, t);
|
|
382
402
|
i.renderable = l.ok, l.ok || i.errors.push(..._("render", l.errors));
|
|
383
403
|
} else {
|
|
384
404
|
const l = await ue(e, t, !1);
|
|
@@ -388,17 +408,17 @@ async function Oe(e, t, r, n) {
|
|
|
388
408
|
}
|
|
389
409
|
}
|
|
390
410
|
if (t.kind === "color") {
|
|
391
|
-
const l = await
|
|
411
|
+
const l = await ze(e, t);
|
|
392
412
|
i.storageWritable = l.ok, l.ok || i.errors.push(..._("storage", l.errors));
|
|
393
413
|
}
|
|
394
414
|
if (i.renderable) {
|
|
395
|
-
const l = await
|
|
415
|
+
const l = await Ve(e, t);
|
|
396
416
|
i.multisample4x = l.ok, l.ok || i.errors.push(..._("msaa4x", l.errors));
|
|
397
417
|
}
|
|
398
418
|
return i;
|
|
399
419
|
}
|
|
400
|
-
async function
|
|
401
|
-
const i = t.kind === "compressed", a =
|
|
420
|
+
async function Ie(e, t, r, n) {
|
|
421
|
+
const i = t.kind === "compressed", a = qe(t);
|
|
402
422
|
return M(e, async () => {
|
|
403
423
|
const s = [{
|
|
404
424
|
binding: 0,
|
|
@@ -411,7 +431,7 @@ async function qe(e, t, r, n) {
|
|
|
411
431
|
sampler: { type: t.filterable ? "filtering" : "non-filtering" }
|
|
412
432
|
});
|
|
413
433
|
const o = e.createBindGroupLayout({ entries: s }), u = e.createShaderModule({
|
|
414
|
-
code: H +
|
|
434
|
+
code: H + je(t, i)
|
|
415
435
|
}), c = e.createRenderPipeline({
|
|
416
436
|
layout: e.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
417
437
|
vertex: { module: u, entryPoint: "vs" },
|
|
@@ -449,7 +469,7 @@ async function ue(e, t, r) {
|
|
|
449
469
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
450
470
|
});
|
|
451
471
|
const o = e.createShaderModule({
|
|
452
|
-
code: H +
|
|
472
|
+
code: H + we(t)
|
|
453
473
|
}), u = e.createRenderPipeline({
|
|
454
474
|
layout: "auto",
|
|
455
475
|
vertex: { module: o, entryPoint: "vs" },
|
|
@@ -466,7 +486,7 @@ async function ue(e, t, r) {
|
|
|
466
486
|
}, !0);
|
|
467
487
|
return v(n), i;
|
|
468
488
|
}
|
|
469
|
-
async function
|
|
489
|
+
async function We(e, t) {
|
|
470
490
|
let r = null;
|
|
471
491
|
const n = await M(e, async () => {
|
|
472
492
|
const i = e.createTexture({
|
|
@@ -491,7 +511,7 @@ async function Ne(e, t) {
|
|
|
491
511
|
}, !0);
|
|
492
512
|
return v(r), n;
|
|
493
513
|
}
|
|
494
|
-
async function
|
|
514
|
+
async function ze(e, t) {
|
|
495
515
|
let r = null;
|
|
496
516
|
const n = await M(e, async () => {
|
|
497
517
|
const i = e.createTexture({
|
|
@@ -515,7 +535,7 @@ async function Le(e, t) {
|
|
|
515
535
|
}, !0);
|
|
516
536
|
return v(r), n;
|
|
517
537
|
}
|
|
518
|
-
async function
|
|
538
|
+
async function Ve(e, t) {
|
|
519
539
|
let r = null;
|
|
520
540
|
const n = await M(e, async () => {
|
|
521
541
|
const i = e.createTexture({
|
|
@@ -524,7 +544,7 @@ async function De(e, t) {
|
|
|
524
544
|
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
525
545
|
sampleCount: 4
|
|
526
546
|
}), a = e.createShaderModule({
|
|
527
|
-
code: H + (t.kind === "depth" ? "" :
|
|
547
|
+
code: H + (t.kind === "depth" ? "" : we(t))
|
|
528
548
|
}), s = {
|
|
529
549
|
layout: "auto",
|
|
530
550
|
vertex: { module: a, entryPoint: "vs" },
|
|
@@ -557,8 +577,8 @@ async function De(e, t) {
|
|
|
557
577
|
}, !0);
|
|
558
578
|
return v(r), n;
|
|
559
579
|
}
|
|
560
|
-
function
|
|
561
|
-
const n = `@group(0) @binding(0) var t: ${
|
|
580
|
+
function je(e, t) {
|
|
581
|
+
const n = `@group(0) @binding(0) var t: ${Le(e)};`, i = t ? "@group(0) @binding(1) var s: sampler;" : "";
|
|
562
582
|
let a;
|
|
563
583
|
return t ? a = "return textureSample(t, s, vec2f(0.5, 0.5));" : e.kind === "depth" && e.hasDepth ? a = `let v = textureLoad(t, vec2i(0, 0), 0);
|
|
564
584
|
return vec4f(v, 0., 0., 1.);` : e.texel === "f32" ? a = "return textureLoad(t, vec2i(0, 0), 0);" : a = `let v = textureLoad(t, vec2i(0, 0), 0);
|
|
@@ -569,7 +589,7 @@ ${i}
|
|
|
569
589
|
${a}
|
|
570
590
|
}`;
|
|
571
591
|
}
|
|
572
|
-
function
|
|
592
|
+
function we(e) {
|
|
573
593
|
return e.texel === "u32" ? `
|
|
574
594
|
@fragment fn fs() -> @location(0) vec4u {
|
|
575
595
|
return vec4u(1u, 0u, 0u, 1u);
|
|
@@ -727,7 +747,7 @@ ${G}
|
|
|
727
747
|
}`
|
|
728
748
|
}
|
|
729
749
|
];
|
|
730
|
-
async function
|
|
750
|
+
async function He(e, t, r) {
|
|
731
751
|
const n = [];
|
|
732
752
|
for (let i = 0; i < Q.length; i++) {
|
|
733
753
|
const a = Q[i];
|
|
@@ -747,11 +767,11 @@ async function ze(e, t, r) {
|
|
|
747
767
|
});
|
|
748
768
|
continue;
|
|
749
769
|
}
|
|
750
|
-
n.push(await
|
|
770
|
+
n.push(await Ke(e, a));
|
|
751
771
|
}
|
|
752
772
|
return n;
|
|
753
773
|
}
|
|
754
|
-
async function
|
|
774
|
+
async function Ke(e, t) {
|
|
755
775
|
const r = {
|
|
756
776
|
id: t.id,
|
|
757
777
|
description: t.description,
|
|
@@ -760,7 +780,7 @@ async function Ve(e, t) {
|
|
|
760
780
|
pipelineCreated: !1,
|
|
761
781
|
messages: [],
|
|
762
782
|
compileMs: 0
|
|
763
|
-
}, n = performance.now(), i = await
|
|
783
|
+
}, n = performance.now(), i = await V(e, () => e.createShaderModule({ code: t.code }));
|
|
764
784
|
if (!i.ok || !i.value)
|
|
765
785
|
return r.compileMs = performance.now() - n, r.messages.push(...i.errors.map(ce)), r;
|
|
766
786
|
let a = null;
|
|
@@ -777,7 +797,7 @@ async function Ve(e, t) {
|
|
|
777
797
|
lineNum: o.lineNum
|
|
778
798
|
});
|
|
779
799
|
if (r.compiled = !r.messages.some((o) => o.type === "error"), !r.compiled) return r;
|
|
780
|
-
const s = await
|
|
800
|
+
const s = await V(e, () => t.pipeline === "compute" ? e.createComputePipelineAsync({
|
|
781
801
|
layout: "auto",
|
|
782
802
|
compute: { module: i.value, entryPoint: "cs" }
|
|
783
803
|
}) : e.createRenderPipelineAsync({
|
|
@@ -794,7 +814,7 @@ async function Ve(e, t) {
|
|
|
794
814
|
function ce(e) {
|
|
795
815
|
return { type: "error", message: e.message, lineNum: 0 };
|
|
796
816
|
}
|
|
797
|
-
const
|
|
817
|
+
const Xe = 10, Z = [
|
|
798
818
|
{
|
|
799
819
|
limit: "maxBufferSize",
|
|
800
820
|
floor: 256 * 1024 * 1024,
|
|
@@ -905,7 +925,7 @@ var<workgroup> scratch: array<vec4f, ${r}>;
|
|
|
905
925
|
})
|
|
906
926
|
}
|
|
907
927
|
];
|
|
908
|
-
async function
|
|
928
|
+
async function Ye(e, t, r) {
|
|
909
929
|
const n = [];
|
|
910
930
|
for (let i = 0; i < Z.length; i++) {
|
|
911
931
|
const a = Z[i];
|
|
@@ -922,7 +942,7 @@ async function je(e, t, r) {
|
|
|
922
942
|
});
|
|
923
943
|
continue;
|
|
924
944
|
}
|
|
925
|
-
const u = await
|
|
945
|
+
const u = await Qe(e, a, Math.min(a.floor, s), s);
|
|
926
946
|
n.push({
|
|
927
947
|
limit: a.limit,
|
|
928
948
|
declared: s,
|
|
@@ -937,13 +957,13 @@ async function je(e, t, r) {
|
|
|
937
957
|
}
|
|
938
958
|
return n;
|
|
939
959
|
}
|
|
940
|
-
async function
|
|
960
|
+
async function Qe(e, t, r, n) {
|
|
941
961
|
let i = r, a = (await t.test(e, i)).ok;
|
|
942
962
|
for (; !a && i > 1; )
|
|
943
963
|
i = Math.floor(i / 2), a = (await t.test(e, i)).ok;
|
|
944
964
|
if (!a) return 0;
|
|
945
965
|
let s = n;
|
|
946
|
-
for (let o = 0; o <
|
|
966
|
+
for (let o = 0; o < Xe && s - i > 1; o++) {
|
|
947
967
|
const u = i + Math.floor((s - i) / 2);
|
|
948
968
|
(await t.test(e, u)).ok ? i = u : s = u;
|
|
949
969
|
}
|
|
@@ -1019,47 +1039,47 @@ class j {
|
|
|
1019
1039
|
this.querySet = null, this.resolveBuf = null, this.readBuf = null;
|
|
1020
1040
|
}
|
|
1021
1041
|
}
|
|
1022
|
-
function
|
|
1042
|
+
function Ze(e) {
|
|
1023
1043
|
if (e.length === 0) return 0;
|
|
1024
1044
|
const t = [...e].sort((n, i) => n - i), r = t.length >> 1;
|
|
1025
1045
|
return t.length % 2 ? t[r] : (t[r - 1] + t[r]) / 2;
|
|
1026
1046
|
}
|
|
1027
|
-
function
|
|
1047
|
+
function Je(e) {
|
|
1028
1048
|
if (e.length < 2) return 0;
|
|
1029
1049
|
const t = e.reduce((n, i) => n + i, 0) / e.length;
|
|
1030
1050
|
if (t === 0) return 0;
|
|
1031
1051
|
const r = e.reduce((n, i) => n + (i - t) ** 2, 0) / (e.length - 1);
|
|
1032
1052
|
return Math.sqrt(r) / t;
|
|
1033
1053
|
}
|
|
1034
|
-
const
|
|
1035
|
-
function
|
|
1054
|
+
const et = 0.9, tt = 0.02, rt = 4;
|
|
1055
|
+
function nt(e, t) {
|
|
1036
1056
|
if (t <= 0 || e.length === 0) return !1;
|
|
1037
|
-
const r = t *
|
|
1057
|
+
const r = t * tt;
|
|
1038
1058
|
let n = 0;
|
|
1039
1059
|
for (const i of e) {
|
|
1040
1060
|
const a = i % t;
|
|
1041
1061
|
(a <= r || a >= t - r) && n++;
|
|
1042
1062
|
}
|
|
1043
|
-
return n / e.length >=
|
|
1063
|
+
return n / e.length >= et;
|
|
1044
1064
|
}
|
|
1045
|
-
function
|
|
1065
|
+
function ot(e) {
|
|
1046
1066
|
const t = e.filter((s) => s > 0 && Number.isFinite(s));
|
|
1047
|
-
if (t.length <
|
|
1067
|
+
if (t.length < rt) return null;
|
|
1048
1068
|
const r = Math.min(...t), n = [...new Set(t)].sort((s, o) => s - o);
|
|
1049
1069
|
let i = 1 / 0;
|
|
1050
1070
|
for (let s = 1; s < n.length; s++)
|
|
1051
1071
|
i = Math.min(i, n[s] - n[s - 1]);
|
|
1052
1072
|
const a = Math.min(r, i);
|
|
1053
|
-
return !Number.isFinite(a) || a <= 0 ? null :
|
|
1073
|
+
return !Number.isFinite(a) || a <= 0 ? null : nt(t, a) ? a : null;
|
|
1054
1074
|
}
|
|
1055
|
-
const P = 1024,
|
|
1075
|
+
const P = 1024, it = 3, ee = 10, at = 100, st = 60, ut = 20, fe = 2048, W = `
|
|
1056
1076
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
1057
1077
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
1058
1078
|
return vec4f(p[i], 0., 1.);
|
|
1059
1079
|
}`, te = `
|
|
1060
1080
|
@vertex fn vs() -> @builtin(position) vec4f {
|
|
1061
1081
|
return vec4f(2., 2., 0.5, 1.);
|
|
1062
|
-
}`,
|
|
1082
|
+
}`, z = `
|
|
1063
1083
|
@fragment fn fs() -> @location(0) vec4f { return vec4f(0.25, 0.5, 0.75, 1.); }`, re = {
|
|
1064
1084
|
color: { srcFactor: "one", dstFactor: "one", operation: "add" },
|
|
1065
1085
|
alpha: { srcFactor: "one", dstFactor: "one", operation: "add" }
|
|
@@ -1084,7 +1104,7 @@ const C = 2e3, pe = 1e5, ne = [
|
|
|
1084
1104
|
unit: "draws/s",
|
|
1085
1105
|
timingMode: "wall-clock-only",
|
|
1086
1106
|
setup: async (e, t) => {
|
|
1087
|
-
const r = await B(e, te +
|
|
1107
|
+
const r = await B(e, te + z);
|
|
1088
1108
|
return {
|
|
1089
1109
|
record(n, i, a) {
|
|
1090
1110
|
const s = $(n, t, a);
|
|
@@ -1159,7 +1179,7 @@ ${te}
|
|
|
1159
1179
|
unit: "MPixel/s",
|
|
1160
1180
|
timingMode: "gpu-preferred",
|
|
1161
1181
|
setup: async (e, t) => {
|
|
1162
|
-
const r = await B(e,
|
|
1182
|
+
const r = await B(e, W + z, re);
|
|
1163
1183
|
return {
|
|
1164
1184
|
record(n, i, a) {
|
|
1165
1185
|
const s = $(n, t, a);
|
|
@@ -1179,7 +1199,7 @@ ${te}
|
|
|
1179
1199
|
timingMode: "gpu-preferred",
|
|
1180
1200
|
setup: async (e, t) => {
|
|
1181
1201
|
const r = e.createShaderModule({
|
|
1182
|
-
code:
|
|
1202
|
+
code: W + `
|
|
1183
1203
|
@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
|
1184
1204
|
var p = pos.xyz * 0.001;
|
|
1185
1205
|
var acc = 0.;
|
|
@@ -1218,7 +1238,7 @@ ${te}
|
|
|
1218
1238
|
var off = array<vec2f, 3>(vec2f(0., 0.), vec2f(0.0015, 0.), vec2f(0., 0.0015));
|
|
1219
1239
|
return vec4f(gx + off[corner].x, gy + off[corner].y, 0.5, 1.);
|
|
1220
1240
|
}
|
|
1221
|
-
${
|
|
1241
|
+
${z}`
|
|
1222
1242
|
}), n = await B(e, r);
|
|
1223
1243
|
return {
|
|
1224
1244
|
record(i, a, s) {
|
|
@@ -1248,7 +1268,7 @@ ${V}`
|
|
|
1248
1268
|
code: `
|
|
1249
1269
|
@group(0) @binding(0) var t: texture_2d<f32>;
|
|
1250
1270
|
@group(0) @binding(1) var s: sampler;
|
|
1251
|
-
${
|
|
1271
|
+
${W}
|
|
1252
1272
|
@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
|
1253
1273
|
var acc = vec4f(0.);
|
|
1254
1274
|
let base = pos.xy / ${P}.;
|
|
@@ -1278,7 +1298,7 @@ ${z}
|
|
|
1278
1298
|
}
|
|
1279
1299
|
}
|
|
1280
1300
|
];
|
|
1281
|
-
function
|
|
1301
|
+
function ct() {
|
|
1282
1302
|
let e = 1 / 0;
|
|
1283
1303
|
for (let t = 0; t < 24; t++) {
|
|
1284
1304
|
const r = performance.now();
|
|
@@ -1288,7 +1308,7 @@ function it() {
|
|
|
1288
1308
|
}
|
|
1289
1309
|
return Number.isFinite(e) && e > 0 ? e : 0;
|
|
1290
1310
|
}
|
|
1291
|
-
async function
|
|
1311
|
+
async function lt(e, t) {
|
|
1292
1312
|
if (!t.available) return null;
|
|
1293
1313
|
const r = e.createTexture({
|
|
1294
1314
|
size: [256, 256],
|
|
@@ -1297,7 +1317,7 @@ async function at(e, t) {
|
|
|
1297
1317
|
}), n = r.createView();
|
|
1298
1318
|
let i;
|
|
1299
1319
|
try {
|
|
1300
|
-
i = await B(e,
|
|
1320
|
+
i = await B(e, W + z);
|
|
1301
1321
|
} catch {
|
|
1302
1322
|
return v(r), null;
|
|
1303
1323
|
}
|
|
@@ -1316,16 +1336,16 @@ async function at(e, t) {
|
|
|
1316
1336
|
if (u >= 4 && new Set(a.filter((c) => c > 0)).size >= 2) break;
|
|
1317
1337
|
s *= 4;
|
|
1318
1338
|
}
|
|
1319
|
-
return v(r),
|
|
1339
|
+
return v(r), ot(a);
|
|
1320
1340
|
}
|
|
1321
|
-
async function
|
|
1341
|
+
async function ft(e, t, r) {
|
|
1322
1342
|
const n = performance.now(), i = j.create(e), a = e.createTexture({
|
|
1323
1343
|
size: [P, P],
|
|
1324
1344
|
format: "rgba8unorm",
|
|
1325
1345
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
1326
|
-
}), s = a.createView(), o = await
|
|
1346
|
+
}), s = a.createView(), o = await lt(e, i), u = ct(), c = [];
|
|
1327
1347
|
for (let l = 0; l < ne.length; l++)
|
|
1328
|
-
c.push(await
|
|
1348
|
+
c.push(await dt(
|
|
1329
1349
|
e,
|
|
1330
1350
|
ne[l],
|
|
1331
1351
|
s,
|
|
@@ -1342,7 +1362,7 @@ async function st(e, t, r) {
|
|
|
1342
1362
|
totalMs: Math.round(performance.now() - n)
|
|
1343
1363
|
};
|
|
1344
1364
|
}
|
|
1345
|
-
async function
|
|
1365
|
+
async function dt(e, t, r, n, i, a, s) {
|
|
1346
1366
|
const o = {
|
|
1347
1367
|
id: t.id,
|
|
1348
1368
|
description: t.description,
|
|
@@ -1361,12 +1381,12 @@ async function ut(e, t, r, n, i, a, s) {
|
|
|
1361
1381
|
}
|
|
1362
1382
|
const c = t.timingMode === "gpu-preferred" && n.available;
|
|
1363
1383
|
try {
|
|
1364
|
-
for (let m = 0; m <
|
|
1384
|
+
for (let m = 0; m < it; m++) {
|
|
1365
1385
|
const S = e.createCommandEncoder();
|
|
1366
1386
|
u.record(S, 1), e.queue.submit([S.finish()]);
|
|
1367
1387
|
}
|
|
1368
1388
|
await e.queue.onSubmittedWorkDone();
|
|
1369
|
-
const l = c ? a ? Math.max(ee, a *
|
|
1389
|
+
const l = c ? a ? Math.max(ee, a * at / 1e6) : ee : Math.max(ee, s * st);
|
|
1370
1390
|
let f = 1;
|
|
1371
1391
|
for (let m = 0; m < 8; m++) {
|
|
1372
1392
|
const { ms: S } = await me(e, u, f, n, c);
|
|
@@ -1382,22 +1402,22 @@ async function ut(e, t, r, n, i, a, s) {
|
|
|
1382
1402
|
}
|
|
1383
1403
|
if (u.dispose?.(), p.length === 0)
|
|
1384
1404
|
return { ...o, failed: "no measurements were obtained" };
|
|
1385
|
-
const w = h > p.length / 2, g = w ? p :
|
|
1405
|
+
const w = h > p.length / 2, g = w ? p : pt(p), T = Ze(g), E = t.unitWorkload * f, k = {
|
|
1386
1406
|
...o,
|
|
1387
1407
|
medianMs: q(T, 4),
|
|
1388
1408
|
minMs: q(Math.min(...g), 4),
|
|
1389
|
-
variation: q(
|
|
1409
|
+
variation: q(Je(g), 3),
|
|
1390
1410
|
timing: w ? "timestamp-query" : "wall-clock",
|
|
1391
1411
|
samples: g.length,
|
|
1392
1412
|
repetitions: f
|
|
1393
1413
|
}, R = w ? a != null ? a / 1e6 : null : s > 0 ? s : null;
|
|
1394
1414
|
if (R) {
|
|
1395
1415
|
const m = T / R;
|
|
1396
|
-
k.ticks = q(m, 1), k.quantized = m <
|
|
1416
|
+
k.ticks = q(m, 1), k.quantized = m < ut;
|
|
1397
1417
|
}
|
|
1398
1418
|
if (T > 0) {
|
|
1399
1419
|
const m = E / (T / 1e3);
|
|
1400
|
-
k.throughput = q(
|
|
1420
|
+
k.throughput = q(mt(m, t.unit), 2), k.throughputUnit = t.unit;
|
|
1401
1421
|
}
|
|
1402
1422
|
return k;
|
|
1403
1423
|
} catch (l) {
|
|
@@ -1414,7 +1434,7 @@ async function me(e, t, r, n, i) {
|
|
|
1414
1434
|
}
|
|
1415
1435
|
return { ms: u, fromGpu: !1 };
|
|
1416
1436
|
}
|
|
1417
|
-
function
|
|
1437
|
+
function pt(e) {
|
|
1418
1438
|
return e.length < 5 ? e : [...e].sort((r, n) => r - n).slice(1, -1);
|
|
1419
1439
|
}
|
|
1420
1440
|
function $(e, t, r) {
|
|
@@ -1428,7 +1448,7 @@ function $(e, t, r) {
|
|
|
1428
1448
|
};
|
|
1429
1449
|
return r && (n.timestampWrites = r), e.beginRenderPass(n);
|
|
1430
1450
|
}
|
|
1431
|
-
function
|
|
1451
|
+
function mt(e, t) {
|
|
1432
1452
|
return t.startsWith("M") ? e / 1e6 : t.startsWith("G") ? e / 1e9 : e;
|
|
1433
1453
|
}
|
|
1434
1454
|
function q(e, t) {
|
|
@@ -1438,10 +1458,10 @@ function q(e, t) {
|
|
|
1438
1458
|
function he(e) {
|
|
1439
1459
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1440
1460
|
}
|
|
1441
|
-
function
|
|
1442
|
-
const a = [], s =
|
|
1461
|
+
function ht(e, t, r, n, i) {
|
|
1462
|
+
const a = [], s = Oe(i);
|
|
1443
1463
|
for (const o of e) {
|
|
1444
|
-
const u =
|
|
1464
|
+
const u = Fe(o.format);
|
|
1445
1465
|
if (o.featureDeclared && !o.creatable) {
|
|
1446
1466
|
a.push({
|
|
1447
1467
|
kind: "format-declared-not-usable",
|
|
@@ -1462,7 +1482,7 @@ function ft(e, t, r, n, i) {
|
|
|
1462
1482
|
detail: `${o.requiresFeature} is not declared, yet texture creation succeeds`,
|
|
1463
1483
|
severity: "note"
|
|
1464
1484
|
}), !u || !o.creatable) continue;
|
|
1465
|
-
const c =
|
|
1485
|
+
const c = Ce(u, i);
|
|
1466
1486
|
c.renderable && !o.renderable && a.push({
|
|
1467
1487
|
kind: "format-declared-not-usable",
|
|
1468
1488
|
subject: o.format,
|
|
@@ -1534,8 +1554,8 @@ function ge(e) {
|
|
|
1534
1554
|
function be(e) {
|
|
1535
1555
|
return e >= 1024 * 1024 * 1024 ? `${(e / 1024 / 1024 / 1024).toFixed(2)}GB` : e >= 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(1)}MB` : e >= 1024 ? `${(e / 1024).toFixed(1)}KB` : String(e);
|
|
1536
1556
|
}
|
|
1537
|
-
const
|
|
1538
|
-
function
|
|
1557
|
+
const gt = 16;
|
|
1558
|
+
function bt(e) {
|
|
1539
1559
|
const t = e.browserVersion.split(".")[0] ?? "";
|
|
1540
1560
|
return [
|
|
1541
1561
|
e.browser,
|
|
@@ -1547,16 +1567,16 @@ function pt(e) {
|
|
|
1547
1567
|
].join("|");
|
|
1548
1568
|
}
|
|
1549
1569
|
async function ve(e) {
|
|
1550
|
-
const t =
|
|
1570
|
+
const t = bt(e), r = globalThis.crypto?.subtle;
|
|
1551
1571
|
if (r)
|
|
1552
1572
|
try {
|
|
1553
1573
|
const n = await r.digest("SHA-256", new TextEncoder().encode(t));
|
|
1554
|
-
return
|
|
1574
|
+
return yt(new Uint8Array(n).subarray(0, gt));
|
|
1555
1575
|
} catch {
|
|
1556
1576
|
}
|
|
1557
|
-
return
|
|
1577
|
+
return vt(t);
|
|
1558
1578
|
}
|
|
1559
|
-
function
|
|
1579
|
+
function vt(e) {
|
|
1560
1580
|
const r = [2166136261, 16777619, 3421674724, 2216829733];
|
|
1561
1581
|
for (let n = 0; n < e.length; n++) {
|
|
1562
1582
|
const i = e.charCodeAt(n);
|
|
@@ -1565,20 +1585,20 @@ function mt(e) {
|
|
|
1565
1585
|
}
|
|
1566
1586
|
return r.map((n) => n.toString(16).padStart(8, "0")).join("");
|
|
1567
1587
|
}
|
|
1568
|
-
function
|
|
1588
|
+
function yt(e) {
|
|
1569
1589
|
let t = "";
|
|
1570
1590
|
for (const r of e) t += r.toString(16).padStart(2, "0");
|
|
1571
1591
|
return t;
|
|
1572
1592
|
}
|
|
1573
1593
|
const F = { formats: 0.25, shaders: 0.1, limits: 0.15, bench: 0.5 };
|
|
1574
|
-
async function
|
|
1594
|
+
async function _t(e = {}) {
|
|
1575
1595
|
const {
|
|
1576
1596
|
powerPreference: t,
|
|
1577
1597
|
benchmark: r = !0,
|
|
1578
1598
|
onProgress: n,
|
|
1579
1599
|
formats: i
|
|
1580
|
-
} = e, a =
|
|
1581
|
-
schema:
|
|
1600
|
+
} = e, a = wt(e.benchSamples ?? 7, 1, 99), s = performance.now(), o = await Ae(), u = {
|
|
1601
|
+
schema: 5,
|
|
1582
1602
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1583
1603
|
fingerprint: "",
|
|
1584
1604
|
environment: o,
|
|
@@ -1591,7 +1611,7 @@ async function At(e = {}) {
|
|
|
1591
1611
|
};
|
|
1592
1612
|
let c;
|
|
1593
1613
|
try {
|
|
1594
|
-
c = await
|
|
1614
|
+
c = await Se(t);
|
|
1595
1615
|
} catch (b) {
|
|
1596
1616
|
return {
|
|
1597
1617
|
...u,
|
|
@@ -1619,23 +1639,23 @@ async function At(e = {}) {
|
|
|
1619
1639
|
n?.(b, K);
|
|
1620
1640
|
} catch {
|
|
1621
1641
|
}
|
|
1622
|
-
}, R = (b, K) => (
|
|
1642
|
+
}, R = (b, K) => (ke) => k(b, E + K * ke), m = {
|
|
1623
1643
|
formats: [],
|
|
1624
1644
|
shaders: [],
|
|
1625
1645
|
limits: [],
|
|
1626
1646
|
deviceLost: !1
|
|
1627
1647
|
};
|
|
1628
1648
|
try {
|
|
1629
|
-
k("formats", E), m.formats = await
|
|
1649
|
+
k("formats", E), m.formats = await Ne(
|
|
1630
1650
|
l,
|
|
1631
1651
|
T,
|
|
1632
1652
|
i,
|
|
1633
1653
|
R("formats", F.formats)
|
|
1634
|
-
), E += F.formats, k("shaders", E), m.shaders = await
|
|
1654
|
+
), E += F.formats, k("shaders", E), m.shaders = await He(
|
|
1635
1655
|
l,
|
|
1636
1656
|
T,
|
|
1637
1657
|
R("shaders", F.shaders)
|
|
1638
|
-
), E += F.shaders, k("limits", E), m.limits = await
|
|
1658
|
+
), E += F.shaders, k("limits", E), m.limits = await Ye(
|
|
1639
1659
|
l,
|
|
1640
1660
|
p.limits,
|
|
1641
1661
|
R("limits", F.limits)
|
|
@@ -1647,13 +1667,13 @@ async function At(e = {}) {
|
|
|
1647
1667
|
if (r && !m.deviceLost) {
|
|
1648
1668
|
k("benchmarks", E);
|
|
1649
1669
|
try {
|
|
1650
|
-
S = await
|
|
1670
|
+
S = await ft(l, a, R("benchmarks", F.bench));
|
|
1651
1671
|
} catch (b) {
|
|
1652
1672
|
m.deviceLostReason = g ?? oe(b);
|
|
1653
1673
|
}
|
|
1654
1674
|
}
|
|
1655
1675
|
k("done", 1), g && (m.deviceLost = !0, m.deviceLostReason = g);
|
|
1656
|
-
const U =
|
|
1676
|
+
const U = ht(
|
|
1657
1677
|
m.formats,
|
|
1658
1678
|
m.shaders,
|
|
1659
1679
|
m.limits,
|
|
@@ -1667,7 +1687,7 @@ async function At(e = {}) {
|
|
|
1667
1687
|
detail: "requestDevice refused values the adapter itself advertised",
|
|
1668
1688
|
severity: "degraded"
|
|
1669
1689
|
});
|
|
1670
|
-
const
|
|
1690
|
+
const xe = {
|
|
1671
1691
|
...u,
|
|
1672
1692
|
fingerprint: await ve({
|
|
1673
1693
|
browser: o.browser,
|
|
@@ -1684,15 +1704,15 @@ async function At(e = {}) {
|
|
|
1684
1704
|
discrepancies: U,
|
|
1685
1705
|
elapsedMs: Math.round(performance.now() - s)
|
|
1686
1706
|
};
|
|
1687
|
-
return l.destroy(),
|
|
1707
|
+
return l.destroy(), xe;
|
|
1688
1708
|
}
|
|
1689
|
-
function
|
|
1709
|
+
function wt(e, t, r) {
|
|
1690
1710
|
return Number.isFinite(e) ? Math.min(r, Math.max(t, Math.round(e))) : t;
|
|
1691
1711
|
}
|
|
1692
1712
|
function oe(e) {
|
|
1693
1713
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1694
1714
|
}
|
|
1695
|
-
function
|
|
1715
|
+
function xt(e) {
|
|
1696
1716
|
return {
|
|
1697
1717
|
profile: e,
|
|
1698
1718
|
features: new Set(e.declared.features),
|
|
@@ -1701,15 +1721,15 @@ function bt(e) {
|
|
|
1701
1721
|
benchmarks: new Map((e.benchmarks?.results ?? []).map((t) => [t.id, t]))
|
|
1702
1722
|
};
|
|
1703
1723
|
}
|
|
1704
|
-
const
|
|
1724
|
+
const kt = [
|
|
1705
1725
|
"creatable",
|
|
1706
1726
|
"sampleable",
|
|
1707
1727
|
"renderable",
|
|
1708
1728
|
"blendable",
|
|
1709
1729
|
"storageWritable",
|
|
1710
1730
|
"multisample4x"
|
|
1711
|
-
],
|
|
1712
|
-
function
|
|
1731
|
+
], St = 0.15;
|
|
1732
|
+
function Gt(e) {
|
|
1713
1733
|
const t = [], r = [], n = [], i = /* @__PURE__ */ new Set();
|
|
1714
1734
|
e.forEach((s, o) => {
|
|
1715
1735
|
if (s.unavailable) {
|
|
@@ -1731,28 +1751,28 @@ function Bt(e) {
|
|
|
1731
1751
|
const u = typeof s.schema == "number" ? s.schema : 0;
|
|
1732
1752
|
t.push({
|
|
1733
1753
|
fingerprint: s.fingerprint,
|
|
1734
|
-
label:
|
|
1754
|
+
label: Mt(s),
|
|
1735
1755
|
mobile: s.environment.mobile,
|
|
1736
1756
|
index: o,
|
|
1737
1757
|
schema: u,
|
|
1738
1758
|
staleBenchmarks: u < 2
|
|
1739
1759
|
}), r.push(s);
|
|
1740
1760
|
});
|
|
1741
|
-
const a = r.map(
|
|
1761
|
+
const a = r.map(xt);
|
|
1742
1762
|
return {
|
|
1743
1763
|
devices: t,
|
|
1744
|
-
...
|
|
1745
|
-
formats:
|
|
1746
|
-
limits:
|
|
1747
|
-
benchmarks:
|
|
1764
|
+
...Pt(a),
|
|
1765
|
+
formats: Et(a),
|
|
1766
|
+
limits: Tt(a),
|
|
1767
|
+
benchmarks: At(a),
|
|
1748
1768
|
excluded: n
|
|
1749
1769
|
};
|
|
1750
1770
|
}
|
|
1751
|
-
function
|
|
1752
|
-
const t = [e.adapter?.vendor, e.adapter?.architecture].filter(Boolean).join(" ") || e.adapter?.description || "unknown GPU", r = [e.environment.browser,
|
|
1771
|
+
function Mt(e) {
|
|
1772
|
+
const t = [e.adapter?.vendor, e.adapter?.architecture].filter(Boolean).join(" ") || e.adapter?.description || "unknown GPU", r = [e.environment.browser, Bt(e.environment.browserVersion)].filter(Boolean).join(" ");
|
|
1753
1773
|
return r ? `${t} / ${r}` : t;
|
|
1754
1774
|
}
|
|
1755
|
-
function
|
|
1775
|
+
function Pt(e) {
|
|
1756
1776
|
const t = /* @__PURE__ */ new Set();
|
|
1757
1777
|
for (const i of e) for (const a of i.features) t.add(a);
|
|
1758
1778
|
const r = [], n = [];
|
|
@@ -1764,13 +1784,13 @@ function xt(e) {
|
|
|
1764
1784
|
}
|
|
1765
1785
|
return { features: r, sharedFeatures: n };
|
|
1766
1786
|
}
|
|
1767
|
-
function
|
|
1787
|
+
function Et(e) {
|
|
1768
1788
|
const t = /* @__PURE__ */ new Set();
|
|
1769
1789
|
for (const n of e)
|
|
1770
1790
|
for (const i of n.formats.keys()) t.add(i);
|
|
1771
1791
|
const r = [];
|
|
1772
1792
|
for (const n of [...t].sort())
|
|
1773
|
-
for (const i of
|
|
1793
|
+
for (const i of kt) {
|
|
1774
1794
|
const a = [], s = [];
|
|
1775
1795
|
for (const o of e) {
|
|
1776
1796
|
const u = o.formats.get(n);
|
|
@@ -1780,7 +1800,7 @@ function kt(e) {
|
|
|
1780
1800
|
}
|
|
1781
1801
|
return r;
|
|
1782
1802
|
}
|
|
1783
|
-
function
|
|
1803
|
+
function Tt(e) {
|
|
1784
1804
|
const t = /* @__PURE__ */ new Set();
|
|
1785
1805
|
for (const n of e) for (const i of n.limits.keys()) t.add(i);
|
|
1786
1806
|
const r = [];
|
|
@@ -1797,7 +1817,7 @@ function St(e) {
|
|
|
1797
1817
|
}
|
|
1798
1818
|
return r.sort((n, i) => i.ratio - n.ratio);
|
|
1799
1819
|
}
|
|
1800
|
-
function
|
|
1820
|
+
function At(e) {
|
|
1801
1821
|
const t = /* @__PURE__ */ new Map();
|
|
1802
1822
|
for (const n of e)
|
|
1803
1823
|
for (const [i, a] of n.benchmarks)
|
|
@@ -1811,7 +1831,7 @@ function Mt(e) {
|
|
|
1811
1831
|
a[p] = null;
|
|
1812
1832
|
continue;
|
|
1813
1833
|
}
|
|
1814
|
-
a[p] = h.throughput, ((f.profile.schema ?? 0) < 2 || h.quantized || h.variation >
|
|
1834
|
+
a[p] = h.throughput, ((f.profile.schema ?? 0) < 2 || h.quantized || h.variation > St) && s.push(p);
|
|
1815
1835
|
}
|
|
1816
1836
|
const o = Object.entries(a).filter((f) => f[1] != null);
|
|
1817
1837
|
let u = null, c = null, l = null;
|
|
@@ -1834,7 +1854,7 @@ function Mt(e) {
|
|
|
1834
1854
|
}
|
|
1835
1855
|
return r.sort((n, i) => (i.ratio ?? 0) - (n.ratio ?? 0));
|
|
1836
1856
|
}
|
|
1837
|
-
function
|
|
1857
|
+
function Ft(e, t = {}) {
|
|
1838
1858
|
const r = Math.max(1, t.limit ?? 20), n = [], i = (o) => o.slice(0, 8), a = (o) => ({
|
|
1839
1859
|
shown: o.slice(0, r),
|
|
1840
1860
|
hidden: Math.max(0, o.length - r)
|
|
@@ -1892,22 +1912,22 @@ function $t(e, t = {}) {
|
|
|
1892
1912
|
return n.join(`
|
|
1893
1913
|
`);
|
|
1894
1914
|
}
|
|
1895
|
-
function
|
|
1915
|
+
function Bt(e) {
|
|
1896
1916
|
return e.split(".")[0] ?? "";
|
|
1897
1917
|
}
|
|
1898
|
-
function
|
|
1918
|
+
function Ut(e) {
|
|
1899
1919
|
return e.unavailable !== void 0;
|
|
1900
1920
|
}
|
|
1901
|
-
function
|
|
1921
|
+
function Ct(e) {
|
|
1902
1922
|
return e.discrepancies.filter((t) => t.severity === "breaking");
|
|
1903
1923
|
}
|
|
1904
|
-
function
|
|
1924
|
+
function Ot(e) {
|
|
1905
1925
|
return (e.verified?.formats ?? []).filter((t) => t.renderable).map((t) => t.format);
|
|
1906
1926
|
}
|
|
1907
|
-
function
|
|
1927
|
+
function qt(e) {
|
|
1908
1928
|
return (e.verified?.formats ?? []).filter((t) => t.sampleable).map((t) => t.format);
|
|
1909
1929
|
}
|
|
1910
|
-
function
|
|
1930
|
+
function Lt(e, t, r = "render") {
|
|
1911
1931
|
const n = e.verified?.formats ?? [];
|
|
1912
1932
|
for (const i of t) {
|
|
1913
1933
|
const a = n.find((s) => s.format === i);
|
|
@@ -1916,23 +1936,23 @@ function Ut(e, t, r = "render") {
|
|
|
1916
1936
|
}
|
|
1917
1937
|
return null;
|
|
1918
1938
|
}
|
|
1919
|
-
function
|
|
1939
|
+
function Nt(e, t) {
|
|
1920
1940
|
return e.benchmarks?.results.find((r) => r.id === t) ?? null;
|
|
1921
1941
|
}
|
|
1922
1942
|
export {
|
|
1923
1943
|
ie as FORMATS,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1944
|
+
Rt as MIN_COMPARABLE_BENCHMARK_SCHEMA,
|
|
1945
|
+
$t as SCHEMA_VERSION,
|
|
1946
|
+
Nt as benchmark,
|
|
1947
|
+
Ct as breakingIssues,
|
|
1948
|
+
Gt as compareProfiles,
|
|
1949
|
+
Mt as describeDevice,
|
|
1950
|
+
Fe as findMeta,
|
|
1951
|
+
Ft as formatComparison,
|
|
1952
|
+
Ut as isUnavailable,
|
|
1953
|
+
Lt as pickFormat,
|
|
1954
|
+
_t as probe,
|
|
1955
|
+
Ot as renderableFormats,
|
|
1956
|
+
qt as sampleableFormats
|
|
1937
1957
|
};
|
|
1938
1958
|
//# sourceMappingURL=gpu-atlas.js.map
|