gpu-atlas 0.1.0 → 0.2.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/README.md +287 -248
- package/dist/gpu-atlas.js +182 -167
- 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 Bt = 5, $t = 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,14 +84,14 @@ 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) {
|
|
@@ -102,21 +102,36 @@ async function Te() {
|
|
|
102
102
|
} catch {
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const s =
|
|
105
|
+
const s = Re(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 ?? $e(e),
|
|
111
111
|
browser: i ?? s.browser,
|
|
112
112
|
browserVersion: a ?? s.version,
|
|
113
|
-
mobile: n ??
|
|
113
|
+
mobile: n ?? Be(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
|
+
return /Mobi|Android|iPhone|iPad|iPod/i.test(e) ? !0 : ye(e);
|
|
121
|
+
}
|
|
122
|
+
function $e(e) {
|
|
123
|
+
if (ye(e)) return "iPadOS";
|
|
124
|
+
if (/iPhone|iPod/i.test(e)) return "iOS";
|
|
125
|
+
if (/iPad/i.test(e)) return "iPadOS";
|
|
126
|
+
if (/Android/i.test(e)) return "Android";
|
|
127
|
+
if (/Macintosh|Mac OS X/i.test(e)) return "macOS";
|
|
128
|
+
if (/Windows/i.test(e)) return "Windows";
|
|
129
|
+
if (/Linux/i.test(e)) return "Linux";
|
|
130
|
+
}
|
|
131
|
+
function ye(e) {
|
|
132
|
+
return /Macintosh|Mac OS X/i.test(e) ? (typeof navigator < "u" ? navigator.maxTouchPoints ?? 0 : 0) > 1 : !1;
|
|
133
|
+
}
|
|
134
|
+
function Re(e) {
|
|
120
135
|
const t = [
|
|
121
136
|
["Edge", /Edg(?:e|A|iOS)?\/([\d.]+)/],
|
|
122
137
|
["Opera", /OPR\/([\d.]+)/],
|
|
@@ -130,7 +145,7 @@ function Ae(e) {
|
|
|
130
145
|
}
|
|
131
146
|
return { browser: "unknown", version: "" };
|
|
132
147
|
}
|
|
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 },
|
|
148
|
+
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 }, _e = { renderable: !1, blendable: !1, storage: !0 }, ie = [
|
|
134
149
|
// ── 8-bit ──
|
|
135
150
|
d("r8unorm", "f32", !0, A),
|
|
136
151
|
d("r8snorm", "f32", !0, I),
|
|
@@ -154,7 +169,7 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
154
169
|
d("rg16float", "f32", !0, A),
|
|
155
170
|
d("rgba8unorm", "f32", !0, ae),
|
|
156
171
|
d("rgba8unorm-srgb", "f32", !0, A),
|
|
157
|
-
d("rgba8snorm", "f32", !0,
|
|
172
|
+
d("rgba8snorm", "f32", !0, _e),
|
|
158
173
|
d("rgba8uint", "u32", !1, x),
|
|
159
174
|
d("rgba8sint", "i32", !1, x),
|
|
160
175
|
d("bgra8unorm", "f32", !0, A),
|
|
@@ -227,7 +242,7 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
227
242
|
expect: y
|
|
228
243
|
},
|
|
229
244
|
// ── Compressed: BC (desktop) ──
|
|
230
|
-
...
|
|
245
|
+
...N([
|
|
231
246
|
"bc1-rgba-unorm",
|
|
232
247
|
"bc3-rgba-unorm",
|
|
233
248
|
"bc4-r-unorm",
|
|
@@ -236,16 +251,16 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
236
251
|
"bc7-rgba-unorm"
|
|
237
252
|
], "texture-compression-bc", [4, 4]),
|
|
238
253
|
// ── Compressed: ETC2 (mobile) ──
|
|
239
|
-
...
|
|
254
|
+
...N(
|
|
240
255
|
["etc2-rgb8unorm", "etc2-rgba8unorm", "eac-r11unorm"],
|
|
241
256
|
"texture-compression-etc2",
|
|
242
257
|
[4, 4]
|
|
243
258
|
),
|
|
244
259
|
// ── Compressed: ASTC (mobile) ──
|
|
245
|
-
...
|
|
246
|
-
...
|
|
260
|
+
...N(["astc-4x4-unorm"], "texture-compression-astc", [4, 4]),
|
|
261
|
+
...N(["astc-8x8-unorm"], "texture-compression-astc", [8, 8])
|
|
247
262
|
];
|
|
248
|
-
function
|
|
263
|
+
function N(e, t, r) {
|
|
249
264
|
return e.map((n) => ({
|
|
250
265
|
format: n,
|
|
251
266
|
kind: "compressed",
|
|
@@ -256,7 +271,7 @@ function L(e, t, r) {
|
|
|
256
271
|
expect: I
|
|
257
272
|
}));
|
|
258
273
|
}
|
|
259
|
-
function
|
|
274
|
+
function Ge(e) {
|
|
260
275
|
return ie.find((t) => t.format === e);
|
|
261
276
|
}
|
|
262
277
|
const se = /* @__PURE__ */ new Set([
|
|
@@ -277,47 +292,47 @@ const se = /* @__PURE__ */ new Set([
|
|
|
277
292
|
"rgb10a2unorm",
|
|
278
293
|
"rgb10a2uint",
|
|
279
294
|
"rg11b10ufloat"
|
|
280
|
-
]),
|
|
281
|
-
function
|
|
295
|
+
]), Fe = /* @__PURE__ */ new Set(["r32float", "rg32float", "rgba32float"]);
|
|
296
|
+
function Ue(e, t) {
|
|
282
297
|
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") &&
|
|
298
|
+
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") && Fe.has(e.format) && (r.blendable = !0), t.has("texture-formats-tier2") && e.kind === "color" && (r.storage = r.storage || se.has(e.format)), r;
|
|
284
299
|
}
|
|
285
|
-
function
|
|
300
|
+
function Ce(e) {
|
|
286
301
|
return e.has("texture-formats-tier1") || e.has("texture-formats-tier2");
|
|
287
302
|
}
|
|
288
|
-
function
|
|
303
|
+
function Oe(e) {
|
|
289
304
|
return e.kind === "depth" ? e.hasDepth ? "depth" : "uint" : e.texel === "u32" ? "uint" : e.texel === "i32" ? "sint" : e.filterable ? "float" : "unfilterable-float";
|
|
290
305
|
}
|
|
291
|
-
function
|
|
306
|
+
function qe(e) {
|
|
292
307
|
return e.kind === "depth" && e.hasDepth ? "texture_depth_2d" : `texture_2d<${e.texel}>`;
|
|
293
308
|
}
|
|
294
|
-
const
|
|
295
|
-
async function
|
|
296
|
-
for (const a of
|
|
309
|
+
const X = ["validation", "out-of-memory", "internal"];
|
|
310
|
+
async function V(e, t, r = !1) {
|
|
311
|
+
for (const a of X) e.pushErrorScope(a);
|
|
297
312
|
let n = null;
|
|
298
313
|
const i = [];
|
|
299
314
|
try {
|
|
300
315
|
n = await t();
|
|
301
316
|
} catch (a) {
|
|
302
|
-
i.push({ kind: "exception", message:
|
|
317
|
+
i.push({ kind: "exception", message: Y(a) });
|
|
303
318
|
}
|
|
304
319
|
if (r && i.length === 0)
|
|
305
320
|
try {
|
|
306
321
|
await e.queue.onSubmittedWorkDone();
|
|
307
322
|
} catch (a) {
|
|
308
|
-
i.push({ kind: "queue", message:
|
|
323
|
+
i.push({ kind: "queue", message: Y(a) });
|
|
309
324
|
}
|
|
310
|
-
for (let a =
|
|
325
|
+
for (let a = X.length - 1; a >= 0; a--)
|
|
311
326
|
try {
|
|
312
327
|
const s = await e.popErrorScope();
|
|
313
|
-
s && i.push({ kind:
|
|
328
|
+
s && i.push({ kind: X[a], message: s.message });
|
|
314
329
|
} catch (s) {
|
|
315
|
-
i.push({ kind: "scope-unavailable", message:
|
|
330
|
+
i.push({ kind: "scope-unavailable", message: Y(s) });
|
|
316
331
|
}
|
|
317
332
|
return { value: n, errors: i, ok: i.length === 0 && n !== null };
|
|
318
333
|
}
|
|
319
334
|
async function M(e, t, r = !1) {
|
|
320
|
-
const n = await
|
|
335
|
+
const n = await V(e, async () => {
|
|
321
336
|
const i = await t();
|
|
322
337
|
return i === void 0 ? !0 : i;
|
|
323
338
|
}, r);
|
|
@@ -329,7 +344,7 @@ function _(e, t) {
|
|
|
329
344
|
function O(e) {
|
|
330
345
|
return e[0]?.message ?? "no error reported";
|
|
331
346
|
}
|
|
332
|
-
function
|
|
347
|
+
function Y(e) {
|
|
333
348
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
334
349
|
}
|
|
335
350
|
function v(...e) {
|
|
@@ -344,17 +359,17 @@ const H = `
|
|
|
344
359
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
345
360
|
return vec4f(p[i], 0., 1.);
|
|
346
361
|
}`;
|
|
347
|
-
async function
|
|
362
|
+
async function Le(e, t, r, n) {
|
|
348
363
|
const i = r ? ie.filter((u) => r.includes(u.format)) : ie, a = e.createTexture({
|
|
349
364
|
size: [4, 4],
|
|
350
365
|
format: "rgba8unorm",
|
|
351
366
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
352
367
|
}), s = { view: a.createView() }, o = [];
|
|
353
368
|
for (let u = 0; u < i.length; u++)
|
|
354
|
-
o.push(await
|
|
369
|
+
o.push(await Ne(e, i[u], t, s)), n?.((u + 1) / i.length);
|
|
355
370
|
return v(a), o;
|
|
356
371
|
}
|
|
357
|
-
async function
|
|
372
|
+
async function Ne(e, t, r, n) {
|
|
358
373
|
const i = {
|
|
359
374
|
format: t.format,
|
|
360
375
|
requiresFeature: t.requiresFeature,
|
|
@@ -366,7 +381,7 @@ async function Oe(e, t, r, n) {
|
|
|
366
381
|
storageWritable: !1,
|
|
367
382
|
multisample4x: !1,
|
|
368
383
|
errors: []
|
|
369
|
-
}, [a, s] = t.block ?? [4, 4], o = await
|
|
384
|
+
}, [a, s] = t.block ?? [4, 4], o = await V(
|
|
370
385
|
e,
|
|
371
386
|
() => e.createTexture({
|
|
372
387
|
size: [a, s],
|
|
@@ -376,9 +391,9 @@ async function Oe(e, t, r, n) {
|
|
|
376
391
|
);
|
|
377
392
|
if (i.creatable = o.ok, !o.ok)
|
|
378
393
|
return i.errors.push(..._("create", o.errors)), i;
|
|
379
|
-
const u = o.value, c = await
|
|
394
|
+
const u = o.value, c = await De(e, t, u, n);
|
|
380
395
|
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
|
|
396
|
+
const l = await Ie(e, t);
|
|
382
397
|
i.renderable = l.ok, l.ok || i.errors.push(..._("render", l.errors));
|
|
383
398
|
} else {
|
|
384
399
|
const l = await ue(e, t, !1);
|
|
@@ -388,17 +403,17 @@ async function Oe(e, t, r, n) {
|
|
|
388
403
|
}
|
|
389
404
|
}
|
|
390
405
|
if (t.kind === "color") {
|
|
391
|
-
const l = await
|
|
406
|
+
const l = await We(e, t);
|
|
392
407
|
i.storageWritable = l.ok, l.ok || i.errors.push(..._("storage", l.errors));
|
|
393
408
|
}
|
|
394
409
|
if (i.renderable) {
|
|
395
|
-
const l = await
|
|
410
|
+
const l = await ze(e, t);
|
|
396
411
|
i.multisample4x = l.ok, l.ok || i.errors.push(..._("msaa4x", l.errors));
|
|
397
412
|
}
|
|
398
413
|
return i;
|
|
399
414
|
}
|
|
400
|
-
async function
|
|
401
|
-
const i = t.kind === "compressed", a =
|
|
415
|
+
async function De(e, t, r, n) {
|
|
416
|
+
const i = t.kind === "compressed", a = Oe(t);
|
|
402
417
|
return M(e, async () => {
|
|
403
418
|
const s = [{
|
|
404
419
|
binding: 0,
|
|
@@ -411,7 +426,7 @@ async function qe(e, t, r, n) {
|
|
|
411
426
|
sampler: { type: t.filterable ? "filtering" : "non-filtering" }
|
|
412
427
|
});
|
|
413
428
|
const o = e.createBindGroupLayout({ entries: s }), u = e.createShaderModule({
|
|
414
|
-
code: H +
|
|
429
|
+
code: H + Ve(t, i)
|
|
415
430
|
}), c = e.createRenderPipeline({
|
|
416
431
|
layout: e.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
417
432
|
vertex: { module: u, entryPoint: "vs" },
|
|
@@ -449,7 +464,7 @@ async function ue(e, t, r) {
|
|
|
449
464
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
450
465
|
});
|
|
451
466
|
const o = e.createShaderModule({
|
|
452
|
-
code: H +
|
|
467
|
+
code: H + we(t)
|
|
453
468
|
}), u = e.createRenderPipeline({
|
|
454
469
|
layout: "auto",
|
|
455
470
|
vertex: { module: o, entryPoint: "vs" },
|
|
@@ -466,7 +481,7 @@ async function ue(e, t, r) {
|
|
|
466
481
|
}, !0);
|
|
467
482
|
return v(n), i;
|
|
468
483
|
}
|
|
469
|
-
async function
|
|
484
|
+
async function Ie(e, t) {
|
|
470
485
|
let r = null;
|
|
471
486
|
const n = await M(e, async () => {
|
|
472
487
|
const i = e.createTexture({
|
|
@@ -491,7 +506,7 @@ async function Ne(e, t) {
|
|
|
491
506
|
}, !0);
|
|
492
507
|
return v(r), n;
|
|
493
508
|
}
|
|
494
|
-
async function
|
|
509
|
+
async function We(e, t) {
|
|
495
510
|
let r = null;
|
|
496
511
|
const n = await M(e, async () => {
|
|
497
512
|
const i = e.createTexture({
|
|
@@ -515,7 +530,7 @@ async function Le(e, t) {
|
|
|
515
530
|
}, !0);
|
|
516
531
|
return v(r), n;
|
|
517
532
|
}
|
|
518
|
-
async function
|
|
533
|
+
async function ze(e, t) {
|
|
519
534
|
let r = null;
|
|
520
535
|
const n = await M(e, async () => {
|
|
521
536
|
const i = e.createTexture({
|
|
@@ -524,7 +539,7 @@ async function De(e, t) {
|
|
|
524
539
|
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
525
540
|
sampleCount: 4
|
|
526
541
|
}), a = e.createShaderModule({
|
|
527
|
-
code: H + (t.kind === "depth" ? "" :
|
|
542
|
+
code: H + (t.kind === "depth" ? "" : we(t))
|
|
528
543
|
}), s = {
|
|
529
544
|
layout: "auto",
|
|
530
545
|
vertex: { module: a, entryPoint: "vs" },
|
|
@@ -557,8 +572,8 @@ async function De(e, t) {
|
|
|
557
572
|
}, !0);
|
|
558
573
|
return v(r), n;
|
|
559
574
|
}
|
|
560
|
-
function
|
|
561
|
-
const n = `@group(0) @binding(0) var t: ${
|
|
575
|
+
function Ve(e, t) {
|
|
576
|
+
const n = `@group(0) @binding(0) var t: ${qe(e)};`, i = t ? "@group(0) @binding(1) var s: sampler;" : "";
|
|
562
577
|
let a;
|
|
563
578
|
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
579
|
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 +584,7 @@ ${i}
|
|
|
569
584
|
${a}
|
|
570
585
|
}`;
|
|
571
586
|
}
|
|
572
|
-
function
|
|
587
|
+
function we(e) {
|
|
573
588
|
return e.texel === "u32" ? `
|
|
574
589
|
@fragment fn fs() -> @location(0) vec4u {
|
|
575
590
|
return vec4u(1u, 0u, 0u, 1u);
|
|
@@ -727,7 +742,7 @@ ${G}
|
|
|
727
742
|
}`
|
|
728
743
|
}
|
|
729
744
|
];
|
|
730
|
-
async function
|
|
745
|
+
async function je(e, t, r) {
|
|
731
746
|
const n = [];
|
|
732
747
|
for (let i = 0; i < Q.length; i++) {
|
|
733
748
|
const a = Q[i];
|
|
@@ -747,11 +762,11 @@ async function ze(e, t, r) {
|
|
|
747
762
|
});
|
|
748
763
|
continue;
|
|
749
764
|
}
|
|
750
|
-
n.push(await
|
|
765
|
+
n.push(await He(e, a));
|
|
751
766
|
}
|
|
752
767
|
return n;
|
|
753
768
|
}
|
|
754
|
-
async function
|
|
769
|
+
async function He(e, t) {
|
|
755
770
|
const r = {
|
|
756
771
|
id: t.id,
|
|
757
772
|
description: t.description,
|
|
@@ -760,7 +775,7 @@ async function Ve(e, t) {
|
|
|
760
775
|
pipelineCreated: !1,
|
|
761
776
|
messages: [],
|
|
762
777
|
compileMs: 0
|
|
763
|
-
}, n = performance.now(), i = await
|
|
778
|
+
}, n = performance.now(), i = await V(e, () => e.createShaderModule({ code: t.code }));
|
|
764
779
|
if (!i.ok || !i.value)
|
|
765
780
|
return r.compileMs = performance.now() - n, r.messages.push(...i.errors.map(ce)), r;
|
|
766
781
|
let a = null;
|
|
@@ -777,7 +792,7 @@ async function Ve(e, t) {
|
|
|
777
792
|
lineNum: o.lineNum
|
|
778
793
|
});
|
|
779
794
|
if (r.compiled = !r.messages.some((o) => o.type === "error"), !r.compiled) return r;
|
|
780
|
-
const s = await
|
|
795
|
+
const s = await V(e, () => t.pipeline === "compute" ? e.createComputePipelineAsync({
|
|
781
796
|
layout: "auto",
|
|
782
797
|
compute: { module: i.value, entryPoint: "cs" }
|
|
783
798
|
}) : e.createRenderPipelineAsync({
|
|
@@ -794,7 +809,7 @@ async function Ve(e, t) {
|
|
|
794
809
|
function ce(e) {
|
|
795
810
|
return { type: "error", message: e.message, lineNum: 0 };
|
|
796
811
|
}
|
|
797
|
-
const
|
|
812
|
+
const Ke = 10, Z = [
|
|
798
813
|
{
|
|
799
814
|
limit: "maxBufferSize",
|
|
800
815
|
floor: 256 * 1024 * 1024,
|
|
@@ -905,7 +920,7 @@ var<workgroup> scratch: array<vec4f, ${r}>;
|
|
|
905
920
|
})
|
|
906
921
|
}
|
|
907
922
|
];
|
|
908
|
-
async function
|
|
923
|
+
async function Xe(e, t, r) {
|
|
909
924
|
const n = [];
|
|
910
925
|
for (let i = 0; i < Z.length; i++) {
|
|
911
926
|
const a = Z[i];
|
|
@@ -922,7 +937,7 @@ async function je(e, t, r) {
|
|
|
922
937
|
});
|
|
923
938
|
continue;
|
|
924
939
|
}
|
|
925
|
-
const u = await
|
|
940
|
+
const u = await Ye(e, a, Math.min(a.floor, s), s);
|
|
926
941
|
n.push({
|
|
927
942
|
limit: a.limit,
|
|
928
943
|
declared: s,
|
|
@@ -937,13 +952,13 @@ async function je(e, t, r) {
|
|
|
937
952
|
}
|
|
938
953
|
return n;
|
|
939
954
|
}
|
|
940
|
-
async function
|
|
955
|
+
async function Ye(e, t, r, n) {
|
|
941
956
|
let i = r, a = (await t.test(e, i)).ok;
|
|
942
957
|
for (; !a && i > 1; )
|
|
943
958
|
i = Math.floor(i / 2), a = (await t.test(e, i)).ok;
|
|
944
959
|
if (!a) return 0;
|
|
945
960
|
let s = n;
|
|
946
|
-
for (let o = 0; o <
|
|
961
|
+
for (let o = 0; o < Ke && s - i > 1; o++) {
|
|
947
962
|
const u = i + Math.floor((s - i) / 2);
|
|
948
963
|
(await t.test(e, u)).ok ? i = u : s = u;
|
|
949
964
|
}
|
|
@@ -1019,47 +1034,47 @@ class j {
|
|
|
1019
1034
|
this.querySet = null, this.resolveBuf = null, this.readBuf = null;
|
|
1020
1035
|
}
|
|
1021
1036
|
}
|
|
1022
|
-
function
|
|
1037
|
+
function Qe(e) {
|
|
1023
1038
|
if (e.length === 0) return 0;
|
|
1024
1039
|
const t = [...e].sort((n, i) => n - i), r = t.length >> 1;
|
|
1025
1040
|
return t.length % 2 ? t[r] : (t[r - 1] + t[r]) / 2;
|
|
1026
1041
|
}
|
|
1027
|
-
function
|
|
1042
|
+
function Ze(e) {
|
|
1028
1043
|
if (e.length < 2) return 0;
|
|
1029
1044
|
const t = e.reduce((n, i) => n + i, 0) / e.length;
|
|
1030
1045
|
if (t === 0) return 0;
|
|
1031
1046
|
const r = e.reduce((n, i) => n + (i - t) ** 2, 0) / (e.length - 1);
|
|
1032
1047
|
return Math.sqrt(r) / t;
|
|
1033
1048
|
}
|
|
1034
|
-
const
|
|
1035
|
-
function
|
|
1049
|
+
const Je = 0.9, et = 0.02, tt = 4;
|
|
1050
|
+
function rt(e, t) {
|
|
1036
1051
|
if (t <= 0 || e.length === 0) return !1;
|
|
1037
|
-
const r = t *
|
|
1052
|
+
const r = t * et;
|
|
1038
1053
|
let n = 0;
|
|
1039
1054
|
for (const i of e) {
|
|
1040
1055
|
const a = i % t;
|
|
1041
1056
|
(a <= r || a >= t - r) && n++;
|
|
1042
1057
|
}
|
|
1043
|
-
return n / e.length >=
|
|
1058
|
+
return n / e.length >= Je;
|
|
1044
1059
|
}
|
|
1045
|
-
function
|
|
1060
|
+
function nt(e) {
|
|
1046
1061
|
const t = e.filter((s) => s > 0 && Number.isFinite(s));
|
|
1047
|
-
if (t.length <
|
|
1062
|
+
if (t.length < tt) return null;
|
|
1048
1063
|
const r = Math.min(...t), n = [...new Set(t)].sort((s, o) => s - o);
|
|
1049
1064
|
let i = 1 / 0;
|
|
1050
1065
|
for (let s = 1; s < n.length; s++)
|
|
1051
1066
|
i = Math.min(i, n[s] - n[s - 1]);
|
|
1052
1067
|
const a = Math.min(r, i);
|
|
1053
|
-
return !Number.isFinite(a) || a <= 0 ? null :
|
|
1068
|
+
return !Number.isFinite(a) || a <= 0 ? null : rt(t, a) ? a : null;
|
|
1054
1069
|
}
|
|
1055
|
-
const P = 1024,
|
|
1070
|
+
const P = 1024, ot = 3, ee = 10, it = 100, at = 60, st = 20, fe = 2048, W = `
|
|
1056
1071
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
1057
1072
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
1058
1073
|
return vec4f(p[i], 0., 1.);
|
|
1059
1074
|
}`, te = `
|
|
1060
1075
|
@vertex fn vs() -> @builtin(position) vec4f {
|
|
1061
1076
|
return vec4f(2., 2., 0.5, 1.);
|
|
1062
|
-
}`,
|
|
1077
|
+
}`, z = `
|
|
1063
1078
|
@fragment fn fs() -> @location(0) vec4f { return vec4f(0.25, 0.5, 0.75, 1.); }`, re = {
|
|
1064
1079
|
color: { srcFactor: "one", dstFactor: "one", operation: "add" },
|
|
1065
1080
|
alpha: { srcFactor: "one", dstFactor: "one", operation: "add" }
|
|
@@ -1084,7 +1099,7 @@ const C = 2e3, pe = 1e5, ne = [
|
|
|
1084
1099
|
unit: "draws/s",
|
|
1085
1100
|
timingMode: "wall-clock-only",
|
|
1086
1101
|
setup: async (e, t) => {
|
|
1087
|
-
const r = await B(e, te +
|
|
1102
|
+
const r = await B(e, te + z);
|
|
1088
1103
|
return {
|
|
1089
1104
|
record(n, i, a) {
|
|
1090
1105
|
const s = $(n, t, a);
|
|
@@ -1159,7 +1174,7 @@ ${te}
|
|
|
1159
1174
|
unit: "MPixel/s",
|
|
1160
1175
|
timingMode: "gpu-preferred",
|
|
1161
1176
|
setup: async (e, t) => {
|
|
1162
|
-
const r = await B(e,
|
|
1177
|
+
const r = await B(e, W + z, re);
|
|
1163
1178
|
return {
|
|
1164
1179
|
record(n, i, a) {
|
|
1165
1180
|
const s = $(n, t, a);
|
|
@@ -1179,7 +1194,7 @@ ${te}
|
|
|
1179
1194
|
timingMode: "gpu-preferred",
|
|
1180
1195
|
setup: async (e, t) => {
|
|
1181
1196
|
const r = e.createShaderModule({
|
|
1182
|
-
code:
|
|
1197
|
+
code: W + `
|
|
1183
1198
|
@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
|
1184
1199
|
var p = pos.xyz * 0.001;
|
|
1185
1200
|
var acc = 0.;
|
|
@@ -1218,7 +1233,7 @@ ${te}
|
|
|
1218
1233
|
var off = array<vec2f, 3>(vec2f(0., 0.), vec2f(0.0015, 0.), vec2f(0., 0.0015));
|
|
1219
1234
|
return vec4f(gx + off[corner].x, gy + off[corner].y, 0.5, 1.);
|
|
1220
1235
|
}
|
|
1221
|
-
${
|
|
1236
|
+
${z}`
|
|
1222
1237
|
}), n = await B(e, r);
|
|
1223
1238
|
return {
|
|
1224
1239
|
record(i, a, s) {
|
|
@@ -1248,7 +1263,7 @@ ${V}`
|
|
|
1248
1263
|
code: `
|
|
1249
1264
|
@group(0) @binding(0) var t: texture_2d<f32>;
|
|
1250
1265
|
@group(0) @binding(1) var s: sampler;
|
|
1251
|
-
${
|
|
1266
|
+
${W}
|
|
1252
1267
|
@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
|
1253
1268
|
var acc = vec4f(0.);
|
|
1254
1269
|
let base = pos.xy / ${P}.;
|
|
@@ -1278,7 +1293,7 @@ ${z}
|
|
|
1278
1293
|
}
|
|
1279
1294
|
}
|
|
1280
1295
|
];
|
|
1281
|
-
function
|
|
1296
|
+
function ut() {
|
|
1282
1297
|
let e = 1 / 0;
|
|
1283
1298
|
for (let t = 0; t < 24; t++) {
|
|
1284
1299
|
const r = performance.now();
|
|
@@ -1288,7 +1303,7 @@ function it() {
|
|
|
1288
1303
|
}
|
|
1289
1304
|
return Number.isFinite(e) && e > 0 ? e : 0;
|
|
1290
1305
|
}
|
|
1291
|
-
async function
|
|
1306
|
+
async function ct(e, t) {
|
|
1292
1307
|
if (!t.available) return null;
|
|
1293
1308
|
const r = e.createTexture({
|
|
1294
1309
|
size: [256, 256],
|
|
@@ -1297,7 +1312,7 @@ async function at(e, t) {
|
|
|
1297
1312
|
}), n = r.createView();
|
|
1298
1313
|
let i;
|
|
1299
1314
|
try {
|
|
1300
|
-
i = await B(e,
|
|
1315
|
+
i = await B(e, W + z);
|
|
1301
1316
|
} catch {
|
|
1302
1317
|
return v(r), null;
|
|
1303
1318
|
}
|
|
@@ -1316,16 +1331,16 @@ async function at(e, t) {
|
|
|
1316
1331
|
if (u >= 4 && new Set(a.filter((c) => c > 0)).size >= 2) break;
|
|
1317
1332
|
s *= 4;
|
|
1318
1333
|
}
|
|
1319
|
-
return v(r),
|
|
1334
|
+
return v(r), nt(a);
|
|
1320
1335
|
}
|
|
1321
|
-
async function
|
|
1336
|
+
async function lt(e, t, r) {
|
|
1322
1337
|
const n = performance.now(), i = j.create(e), a = e.createTexture({
|
|
1323
1338
|
size: [P, P],
|
|
1324
1339
|
format: "rgba8unorm",
|
|
1325
1340
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
1326
|
-
}), s = a.createView(), o = await
|
|
1341
|
+
}), s = a.createView(), o = await ct(e, i), u = ut(), c = [];
|
|
1327
1342
|
for (let l = 0; l < ne.length; l++)
|
|
1328
|
-
c.push(await
|
|
1343
|
+
c.push(await ft(
|
|
1329
1344
|
e,
|
|
1330
1345
|
ne[l],
|
|
1331
1346
|
s,
|
|
@@ -1342,7 +1357,7 @@ async function st(e, t, r) {
|
|
|
1342
1357
|
totalMs: Math.round(performance.now() - n)
|
|
1343
1358
|
};
|
|
1344
1359
|
}
|
|
1345
|
-
async function
|
|
1360
|
+
async function ft(e, t, r, n, i, a, s) {
|
|
1346
1361
|
const o = {
|
|
1347
1362
|
id: t.id,
|
|
1348
1363
|
description: t.description,
|
|
@@ -1361,12 +1376,12 @@ async function ut(e, t, r, n, i, a, s) {
|
|
|
1361
1376
|
}
|
|
1362
1377
|
const c = t.timingMode === "gpu-preferred" && n.available;
|
|
1363
1378
|
try {
|
|
1364
|
-
for (let m = 0; m <
|
|
1379
|
+
for (let m = 0; m < ot; m++) {
|
|
1365
1380
|
const S = e.createCommandEncoder();
|
|
1366
1381
|
u.record(S, 1), e.queue.submit([S.finish()]);
|
|
1367
1382
|
}
|
|
1368
1383
|
await e.queue.onSubmittedWorkDone();
|
|
1369
|
-
const l = c ? a ? Math.max(ee, a *
|
|
1384
|
+
const l = c ? a ? Math.max(ee, a * it / 1e6) : ee : Math.max(ee, s * at);
|
|
1370
1385
|
let f = 1;
|
|
1371
1386
|
for (let m = 0; m < 8; m++) {
|
|
1372
1387
|
const { ms: S } = await me(e, u, f, n, c);
|
|
@@ -1382,22 +1397,22 @@ async function ut(e, t, r, n, i, a, s) {
|
|
|
1382
1397
|
}
|
|
1383
1398
|
if (u.dispose?.(), p.length === 0)
|
|
1384
1399
|
return { ...o, failed: "no measurements were obtained" };
|
|
1385
|
-
const w = h > p.length / 2, g = w ? p :
|
|
1400
|
+
const w = h > p.length / 2, g = w ? p : dt(p), T = Qe(g), E = t.unitWorkload * f, k = {
|
|
1386
1401
|
...o,
|
|
1387
1402
|
medianMs: q(T, 4),
|
|
1388
1403
|
minMs: q(Math.min(...g), 4),
|
|
1389
|
-
variation: q(
|
|
1404
|
+
variation: q(Ze(g), 3),
|
|
1390
1405
|
timing: w ? "timestamp-query" : "wall-clock",
|
|
1391
1406
|
samples: g.length,
|
|
1392
1407
|
repetitions: f
|
|
1393
1408
|
}, R = w ? a != null ? a / 1e6 : null : s > 0 ? s : null;
|
|
1394
1409
|
if (R) {
|
|
1395
1410
|
const m = T / R;
|
|
1396
|
-
k.ticks = q(m, 1), k.quantized = m <
|
|
1411
|
+
k.ticks = q(m, 1), k.quantized = m < st;
|
|
1397
1412
|
}
|
|
1398
1413
|
if (T > 0) {
|
|
1399
1414
|
const m = E / (T / 1e3);
|
|
1400
|
-
k.throughput = q(
|
|
1415
|
+
k.throughput = q(pt(m, t.unit), 2), k.throughputUnit = t.unit;
|
|
1401
1416
|
}
|
|
1402
1417
|
return k;
|
|
1403
1418
|
} catch (l) {
|
|
@@ -1414,7 +1429,7 @@ async function me(e, t, r, n, i) {
|
|
|
1414
1429
|
}
|
|
1415
1430
|
return { ms: u, fromGpu: !1 };
|
|
1416
1431
|
}
|
|
1417
|
-
function
|
|
1432
|
+
function dt(e) {
|
|
1418
1433
|
return e.length < 5 ? e : [...e].sort((r, n) => r - n).slice(1, -1);
|
|
1419
1434
|
}
|
|
1420
1435
|
function $(e, t, r) {
|
|
@@ -1428,7 +1443,7 @@ function $(e, t, r) {
|
|
|
1428
1443
|
};
|
|
1429
1444
|
return r && (n.timestampWrites = r), e.beginRenderPass(n);
|
|
1430
1445
|
}
|
|
1431
|
-
function
|
|
1446
|
+
function pt(e, t) {
|
|
1432
1447
|
return t.startsWith("M") ? e / 1e6 : t.startsWith("G") ? e / 1e9 : e;
|
|
1433
1448
|
}
|
|
1434
1449
|
function q(e, t) {
|
|
@@ -1438,10 +1453,10 @@ function q(e, t) {
|
|
|
1438
1453
|
function he(e) {
|
|
1439
1454
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1440
1455
|
}
|
|
1441
|
-
function
|
|
1442
|
-
const a = [], s =
|
|
1456
|
+
function mt(e, t, r, n, i) {
|
|
1457
|
+
const a = [], s = Ce(i);
|
|
1443
1458
|
for (const o of e) {
|
|
1444
|
-
const u =
|
|
1459
|
+
const u = Ge(o.format);
|
|
1445
1460
|
if (o.featureDeclared && !o.creatable) {
|
|
1446
1461
|
a.push({
|
|
1447
1462
|
kind: "format-declared-not-usable",
|
|
@@ -1462,7 +1477,7 @@ function ft(e, t, r, n, i) {
|
|
|
1462
1477
|
detail: `${o.requiresFeature} is not declared, yet texture creation succeeds`,
|
|
1463
1478
|
severity: "note"
|
|
1464
1479
|
}), !u || !o.creatable) continue;
|
|
1465
|
-
const c =
|
|
1480
|
+
const c = Ue(u, i);
|
|
1466
1481
|
c.renderable && !o.renderable && a.push({
|
|
1467
1482
|
kind: "format-declared-not-usable",
|
|
1468
1483
|
subject: o.format,
|
|
@@ -1534,8 +1549,8 @@ function ge(e) {
|
|
|
1534
1549
|
function be(e) {
|
|
1535
1550
|
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
1551
|
}
|
|
1537
|
-
const
|
|
1538
|
-
function
|
|
1552
|
+
const ht = 16;
|
|
1553
|
+
function gt(e) {
|
|
1539
1554
|
const t = e.browserVersion.split(".")[0] ?? "";
|
|
1540
1555
|
return [
|
|
1541
1556
|
e.browser,
|
|
@@ -1547,16 +1562,16 @@ function pt(e) {
|
|
|
1547
1562
|
].join("|");
|
|
1548
1563
|
}
|
|
1549
1564
|
async function ve(e) {
|
|
1550
|
-
const t =
|
|
1565
|
+
const t = gt(e), r = globalThis.crypto?.subtle;
|
|
1551
1566
|
if (r)
|
|
1552
1567
|
try {
|
|
1553
1568
|
const n = await r.digest("SHA-256", new TextEncoder().encode(t));
|
|
1554
|
-
return
|
|
1569
|
+
return vt(new Uint8Array(n).subarray(0, ht));
|
|
1555
1570
|
} catch {
|
|
1556
1571
|
}
|
|
1557
|
-
return
|
|
1572
|
+
return bt(t);
|
|
1558
1573
|
}
|
|
1559
|
-
function
|
|
1574
|
+
function bt(e) {
|
|
1560
1575
|
const r = [2166136261, 16777619, 3421674724, 2216829733];
|
|
1561
1576
|
for (let n = 0; n < e.length; n++) {
|
|
1562
1577
|
const i = e.charCodeAt(n);
|
|
@@ -1565,20 +1580,20 @@ function mt(e) {
|
|
|
1565
1580
|
}
|
|
1566
1581
|
return r.map((n) => n.toString(16).padStart(8, "0")).join("");
|
|
1567
1582
|
}
|
|
1568
|
-
function
|
|
1583
|
+
function vt(e) {
|
|
1569
1584
|
let t = "";
|
|
1570
1585
|
for (const r of e) t += r.toString(16).padStart(2, "0");
|
|
1571
1586
|
return t;
|
|
1572
1587
|
}
|
|
1573
1588
|
const F = { formats: 0.25, shaders: 0.1, limits: 0.15, bench: 0.5 };
|
|
1574
|
-
async function
|
|
1589
|
+
async function Rt(e = {}) {
|
|
1575
1590
|
const {
|
|
1576
1591
|
powerPreference: t,
|
|
1577
1592
|
benchmark: r = !0,
|
|
1578
1593
|
onProgress: n,
|
|
1579
1594
|
formats: i
|
|
1580
|
-
} = e, a =
|
|
1581
|
-
schema:
|
|
1595
|
+
} = e, a = yt(e.benchSamples ?? 7, 1, 99), s = performance.now(), o = await Ae(), u = {
|
|
1596
|
+
schema: 5,
|
|
1582
1597
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1583
1598
|
fingerprint: "",
|
|
1584
1599
|
environment: o,
|
|
@@ -1591,7 +1606,7 @@ async function At(e = {}) {
|
|
|
1591
1606
|
};
|
|
1592
1607
|
let c;
|
|
1593
1608
|
try {
|
|
1594
|
-
c = await
|
|
1609
|
+
c = await Se(t);
|
|
1595
1610
|
} catch (b) {
|
|
1596
1611
|
return {
|
|
1597
1612
|
...u,
|
|
@@ -1619,23 +1634,23 @@ async function At(e = {}) {
|
|
|
1619
1634
|
n?.(b, K);
|
|
1620
1635
|
} catch {
|
|
1621
1636
|
}
|
|
1622
|
-
}, R = (b, K) => (
|
|
1637
|
+
}, R = (b, K) => (ke) => k(b, E + K * ke), m = {
|
|
1623
1638
|
formats: [],
|
|
1624
1639
|
shaders: [],
|
|
1625
1640
|
limits: [],
|
|
1626
1641
|
deviceLost: !1
|
|
1627
1642
|
};
|
|
1628
1643
|
try {
|
|
1629
|
-
k("formats", E), m.formats = await
|
|
1644
|
+
k("formats", E), m.formats = await Le(
|
|
1630
1645
|
l,
|
|
1631
1646
|
T,
|
|
1632
1647
|
i,
|
|
1633
1648
|
R("formats", F.formats)
|
|
1634
|
-
), E += F.formats, k("shaders", E), m.shaders = await
|
|
1649
|
+
), E += F.formats, k("shaders", E), m.shaders = await je(
|
|
1635
1650
|
l,
|
|
1636
1651
|
T,
|
|
1637
1652
|
R("shaders", F.shaders)
|
|
1638
|
-
), E += F.shaders, k("limits", E), m.limits = await
|
|
1653
|
+
), E += F.shaders, k("limits", E), m.limits = await Xe(
|
|
1639
1654
|
l,
|
|
1640
1655
|
p.limits,
|
|
1641
1656
|
R("limits", F.limits)
|
|
@@ -1647,13 +1662,13 @@ async function At(e = {}) {
|
|
|
1647
1662
|
if (r && !m.deviceLost) {
|
|
1648
1663
|
k("benchmarks", E);
|
|
1649
1664
|
try {
|
|
1650
|
-
S = await
|
|
1665
|
+
S = await lt(l, a, R("benchmarks", F.bench));
|
|
1651
1666
|
} catch (b) {
|
|
1652
1667
|
m.deviceLostReason = g ?? oe(b);
|
|
1653
1668
|
}
|
|
1654
1669
|
}
|
|
1655
1670
|
k("done", 1), g && (m.deviceLost = !0, m.deviceLostReason = g);
|
|
1656
|
-
const U =
|
|
1671
|
+
const U = mt(
|
|
1657
1672
|
m.formats,
|
|
1658
1673
|
m.shaders,
|
|
1659
1674
|
m.limits,
|
|
@@ -1667,7 +1682,7 @@ async function At(e = {}) {
|
|
|
1667
1682
|
detail: "requestDevice refused values the adapter itself advertised",
|
|
1668
1683
|
severity: "degraded"
|
|
1669
1684
|
});
|
|
1670
|
-
const
|
|
1685
|
+
const xe = {
|
|
1671
1686
|
...u,
|
|
1672
1687
|
fingerprint: await ve({
|
|
1673
1688
|
browser: o.browser,
|
|
@@ -1684,15 +1699,15 @@ async function At(e = {}) {
|
|
|
1684
1699
|
discrepancies: U,
|
|
1685
1700
|
elapsedMs: Math.round(performance.now() - s)
|
|
1686
1701
|
};
|
|
1687
|
-
return l.destroy(),
|
|
1702
|
+
return l.destroy(), xe;
|
|
1688
1703
|
}
|
|
1689
|
-
function
|
|
1704
|
+
function yt(e, t, r) {
|
|
1690
1705
|
return Number.isFinite(e) ? Math.min(r, Math.max(t, Math.round(e))) : t;
|
|
1691
1706
|
}
|
|
1692
1707
|
function oe(e) {
|
|
1693
1708
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1694
1709
|
}
|
|
1695
|
-
function
|
|
1710
|
+
function wt(e) {
|
|
1696
1711
|
return {
|
|
1697
1712
|
profile: e,
|
|
1698
1713
|
features: new Set(e.declared.features),
|
|
@@ -1701,15 +1716,15 @@ function bt(e) {
|
|
|
1701
1716
|
benchmarks: new Map((e.benchmarks?.results ?? []).map((t) => [t.id, t]))
|
|
1702
1717
|
};
|
|
1703
1718
|
}
|
|
1704
|
-
const
|
|
1719
|
+
const xt = [
|
|
1705
1720
|
"creatable",
|
|
1706
1721
|
"sampleable",
|
|
1707
1722
|
"renderable",
|
|
1708
1723
|
"blendable",
|
|
1709
1724
|
"storageWritable",
|
|
1710
1725
|
"multisample4x"
|
|
1711
|
-
],
|
|
1712
|
-
function
|
|
1726
|
+
], kt = 0.15;
|
|
1727
|
+
function _t(e) {
|
|
1713
1728
|
const t = [], r = [], n = [], i = /* @__PURE__ */ new Set();
|
|
1714
1729
|
e.forEach((s, o) => {
|
|
1715
1730
|
if (s.unavailable) {
|
|
@@ -1731,28 +1746,28 @@ function Bt(e) {
|
|
|
1731
1746
|
const u = typeof s.schema == "number" ? s.schema : 0;
|
|
1732
1747
|
t.push({
|
|
1733
1748
|
fingerprint: s.fingerprint,
|
|
1734
|
-
label:
|
|
1749
|
+
label: St(s),
|
|
1735
1750
|
mobile: s.environment.mobile,
|
|
1736
1751
|
index: o,
|
|
1737
1752
|
schema: u,
|
|
1738
1753
|
staleBenchmarks: u < 2
|
|
1739
1754
|
}), r.push(s);
|
|
1740
1755
|
});
|
|
1741
|
-
const a = r.map(
|
|
1756
|
+
const a = r.map(wt);
|
|
1742
1757
|
return {
|
|
1743
1758
|
devices: t,
|
|
1744
|
-
...
|
|
1745
|
-
formats:
|
|
1746
|
-
limits:
|
|
1747
|
-
benchmarks:
|
|
1759
|
+
...Mt(a),
|
|
1760
|
+
formats: Pt(a),
|
|
1761
|
+
limits: Et(a),
|
|
1762
|
+
benchmarks: Tt(a),
|
|
1748
1763
|
excluded: n
|
|
1749
1764
|
};
|
|
1750
1765
|
}
|
|
1751
|
-
function
|
|
1752
|
-
const t = [e.adapter?.vendor, e.adapter?.architecture].filter(Boolean).join(" ") || e.adapter?.description || "unknown GPU", r = [e.environment.browser,
|
|
1766
|
+
function St(e) {
|
|
1767
|
+
const t = [e.adapter?.vendor, e.adapter?.architecture].filter(Boolean).join(" ") || e.adapter?.description || "unknown GPU", r = [e.environment.browser, At(e.environment.browserVersion)].filter(Boolean).join(" ");
|
|
1753
1768
|
return r ? `${t} / ${r}` : t;
|
|
1754
1769
|
}
|
|
1755
|
-
function
|
|
1770
|
+
function Mt(e) {
|
|
1756
1771
|
const t = /* @__PURE__ */ new Set();
|
|
1757
1772
|
for (const i of e) for (const a of i.features) t.add(a);
|
|
1758
1773
|
const r = [], n = [];
|
|
@@ -1764,13 +1779,13 @@ function xt(e) {
|
|
|
1764
1779
|
}
|
|
1765
1780
|
return { features: r, sharedFeatures: n };
|
|
1766
1781
|
}
|
|
1767
|
-
function
|
|
1782
|
+
function Pt(e) {
|
|
1768
1783
|
const t = /* @__PURE__ */ new Set();
|
|
1769
1784
|
for (const n of e)
|
|
1770
1785
|
for (const i of n.formats.keys()) t.add(i);
|
|
1771
1786
|
const r = [];
|
|
1772
1787
|
for (const n of [...t].sort())
|
|
1773
|
-
for (const i of
|
|
1788
|
+
for (const i of xt) {
|
|
1774
1789
|
const a = [], s = [];
|
|
1775
1790
|
for (const o of e) {
|
|
1776
1791
|
const u = o.formats.get(n);
|
|
@@ -1780,7 +1795,7 @@ function kt(e) {
|
|
|
1780
1795
|
}
|
|
1781
1796
|
return r;
|
|
1782
1797
|
}
|
|
1783
|
-
function
|
|
1798
|
+
function Et(e) {
|
|
1784
1799
|
const t = /* @__PURE__ */ new Set();
|
|
1785
1800
|
for (const n of e) for (const i of n.limits.keys()) t.add(i);
|
|
1786
1801
|
const r = [];
|
|
@@ -1797,7 +1812,7 @@ function St(e) {
|
|
|
1797
1812
|
}
|
|
1798
1813
|
return r.sort((n, i) => i.ratio - n.ratio);
|
|
1799
1814
|
}
|
|
1800
|
-
function
|
|
1815
|
+
function Tt(e) {
|
|
1801
1816
|
const t = /* @__PURE__ */ new Map();
|
|
1802
1817
|
for (const n of e)
|
|
1803
1818
|
for (const [i, a] of n.benchmarks)
|
|
@@ -1811,7 +1826,7 @@ function Mt(e) {
|
|
|
1811
1826
|
a[p] = null;
|
|
1812
1827
|
continue;
|
|
1813
1828
|
}
|
|
1814
|
-
a[p] = h.throughput, ((f.profile.schema ?? 0) < 2 || h.quantized || h.variation >
|
|
1829
|
+
a[p] = h.throughput, ((f.profile.schema ?? 0) < 2 || h.quantized || h.variation > kt) && s.push(p);
|
|
1815
1830
|
}
|
|
1816
1831
|
const o = Object.entries(a).filter((f) => f[1] != null);
|
|
1817
1832
|
let u = null, c = null, l = null;
|
|
@@ -1834,7 +1849,7 @@ function Mt(e) {
|
|
|
1834
1849
|
}
|
|
1835
1850
|
return r.sort((n, i) => (i.ratio ?? 0) - (n.ratio ?? 0));
|
|
1836
1851
|
}
|
|
1837
|
-
function
|
|
1852
|
+
function Gt(e, t = {}) {
|
|
1838
1853
|
const r = Math.max(1, t.limit ?? 20), n = [], i = (o) => o.slice(0, 8), a = (o) => ({
|
|
1839
1854
|
shown: o.slice(0, r),
|
|
1840
1855
|
hidden: Math.max(0, o.length - r)
|
|
@@ -1892,22 +1907,22 @@ function $t(e, t = {}) {
|
|
|
1892
1907
|
return n.join(`
|
|
1893
1908
|
`);
|
|
1894
1909
|
}
|
|
1895
|
-
function
|
|
1910
|
+
function At(e) {
|
|
1896
1911
|
return e.split(".")[0] ?? "";
|
|
1897
1912
|
}
|
|
1898
|
-
function
|
|
1913
|
+
function Ft(e) {
|
|
1899
1914
|
return e.unavailable !== void 0;
|
|
1900
1915
|
}
|
|
1901
|
-
function
|
|
1916
|
+
function Ut(e) {
|
|
1902
1917
|
return e.discrepancies.filter((t) => t.severity === "breaking");
|
|
1903
1918
|
}
|
|
1904
|
-
function
|
|
1919
|
+
function Ct(e) {
|
|
1905
1920
|
return (e.verified?.formats ?? []).filter((t) => t.renderable).map((t) => t.format);
|
|
1906
1921
|
}
|
|
1907
|
-
function
|
|
1922
|
+
function Ot(e) {
|
|
1908
1923
|
return (e.verified?.formats ?? []).filter((t) => t.sampleable).map((t) => t.format);
|
|
1909
1924
|
}
|
|
1910
|
-
function
|
|
1925
|
+
function qt(e, t, r = "render") {
|
|
1911
1926
|
const n = e.verified?.formats ?? [];
|
|
1912
1927
|
for (const i of t) {
|
|
1913
1928
|
const a = n.find((s) => s.format === i);
|
|
@@ -1916,23 +1931,23 @@ function Ut(e, t, r = "render") {
|
|
|
1916
1931
|
}
|
|
1917
1932
|
return null;
|
|
1918
1933
|
}
|
|
1919
|
-
function
|
|
1934
|
+
function Lt(e, t) {
|
|
1920
1935
|
return e.benchmarks?.results.find((r) => r.id === t) ?? null;
|
|
1921
1936
|
}
|
|
1922
1937
|
export {
|
|
1923
1938
|
ie as FORMATS,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1939
|
+
$t as MIN_COMPARABLE_BENCHMARK_SCHEMA,
|
|
1940
|
+
Bt as SCHEMA_VERSION,
|
|
1941
|
+
Lt as benchmark,
|
|
1942
|
+
Ut as breakingIssues,
|
|
1943
|
+
_t as compareProfiles,
|
|
1944
|
+
St as describeDevice,
|
|
1945
|
+
Ge as findMeta,
|
|
1946
|
+
Gt as formatComparison,
|
|
1947
|
+
Ft as isUnavailable,
|
|
1948
|
+
qt as pickFormat,
|
|
1949
|
+
Rt as probe,
|
|
1950
|
+
Ct as renderableFormats,
|
|
1951
|
+
Ot as sampleableFormats
|
|
1937
1952
|
};
|
|
1938
1953
|
//# sourceMappingURL=gpu-atlas.js.map
|