gpu-atlas 0.2.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/dist/gpu-atlas.js +127 -122
- package/dist/gpu-atlas.js.map +1 -1
- package/package.json +1 -1
package/dist/gpu-atlas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
@@ -97,29 +97,34 @@ async function Ae() {
|
|
|
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
119
|
function Be(e) {
|
|
120
|
-
|
|
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];
|
|
121
123
|
}
|
|
122
124
|
function $e(e) {
|
|
125
|
+
return /Mobi|Android|iPhone|iPad|iPod/i.test(e) ? !0 : ye(e);
|
|
126
|
+
}
|
|
127
|
+
function Re(e) {
|
|
123
128
|
if (ye(e)) return "iPadOS";
|
|
124
129
|
if (/iPhone|iPod/i.test(e)) return "iOS";
|
|
125
130
|
if (/iPad/i.test(e)) return "iPadOS";
|
|
@@ -131,7 +136,7 @@ function $e(e) {
|
|
|
131
136
|
function ye(e) {
|
|
132
137
|
return /Macintosh|Mac OS X/i.test(e) ? (typeof navigator < "u" ? navigator.maxTouchPoints ?? 0 : 0) > 1 : !1;
|
|
133
138
|
}
|
|
134
|
-
function
|
|
139
|
+
function _e(e) {
|
|
135
140
|
const t = [
|
|
136
141
|
["Edge", /Edg(?:e|A|iOS)?\/([\d.]+)/],
|
|
137
142
|
["Opera", /OPR\/([\d.]+)/],
|
|
@@ -145,7 +150,7 @@ function Re(e) {
|
|
|
145
150
|
}
|
|
146
151
|
return { browser: "unknown", version: "" };
|
|
147
152
|
}
|
|
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 },
|
|
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 = [
|
|
149
154
|
// ── 8-bit ──
|
|
150
155
|
d("r8unorm", "f32", !0, A),
|
|
151
156
|
d("r8snorm", "f32", !0, I),
|
|
@@ -169,7 +174,7 @@ const d = (e, t, r, n, i) => ({ format: e, kind: "color", texel: t, filterable:
|
|
|
169
174
|
d("rg16float", "f32", !0, A),
|
|
170
175
|
d("rgba8unorm", "f32", !0, ae),
|
|
171
176
|
d("rgba8unorm-srgb", "f32", !0, A),
|
|
172
|
-
d("rgba8snorm", "f32", !0,
|
|
177
|
+
d("rgba8snorm", "f32", !0, Ge),
|
|
173
178
|
d("rgba8uint", "u32", !1, x),
|
|
174
179
|
d("rgba8sint", "i32", !1, x),
|
|
175
180
|
d("bgra8unorm", "f32", !0, A),
|
|
@@ -271,7 +276,7 @@ function N(e, t, r) {
|
|
|
271
276
|
expect: I
|
|
272
277
|
}));
|
|
273
278
|
}
|
|
274
|
-
function
|
|
279
|
+
function Fe(e) {
|
|
275
280
|
return ie.find((t) => t.format === e);
|
|
276
281
|
}
|
|
277
282
|
const se = /* @__PURE__ */ new Set([
|
|
@@ -292,18 +297,18 @@ const se = /* @__PURE__ */ new Set([
|
|
|
292
297
|
"rgb10a2unorm",
|
|
293
298
|
"rgb10a2uint",
|
|
294
299
|
"rg11b10ufloat"
|
|
295
|
-
]),
|
|
296
|
-
function
|
|
300
|
+
]), Ue = /* @__PURE__ */ new Set(["r32float", "rg32float", "rgba32float"]);
|
|
301
|
+
function Ce(e, t) {
|
|
297
302
|
const r = { ...e.expect };
|
|
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") &&
|
|
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;
|
|
299
304
|
}
|
|
300
|
-
function
|
|
305
|
+
function Oe(e) {
|
|
301
306
|
return e.has("texture-formats-tier1") || e.has("texture-formats-tier2");
|
|
302
307
|
}
|
|
303
|
-
function
|
|
308
|
+
function qe(e) {
|
|
304
309
|
return e.kind === "depth" ? e.hasDepth ? "depth" : "uint" : e.texel === "u32" ? "uint" : e.texel === "i32" ? "sint" : e.filterable ? "float" : "unfilterable-float";
|
|
305
310
|
}
|
|
306
|
-
function
|
|
311
|
+
function Le(e) {
|
|
307
312
|
return e.kind === "depth" && e.hasDepth ? "texture_depth_2d" : `texture_2d<${e.texel}>`;
|
|
308
313
|
}
|
|
309
314
|
const X = ["validation", "out-of-memory", "internal"];
|
|
@@ -359,17 +364,17 @@ const H = `
|
|
|
359
364
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
360
365
|
return vec4f(p[i], 0., 1.);
|
|
361
366
|
}`;
|
|
362
|
-
async function
|
|
367
|
+
async function Ne(e, t, r, n) {
|
|
363
368
|
const i = r ? ie.filter((u) => r.includes(u.format)) : ie, a = e.createTexture({
|
|
364
369
|
size: [4, 4],
|
|
365
370
|
format: "rgba8unorm",
|
|
366
371
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
367
372
|
}), s = { view: a.createView() }, o = [];
|
|
368
373
|
for (let u = 0; u < i.length; u++)
|
|
369
|
-
o.push(await
|
|
374
|
+
o.push(await De(e, i[u], t, s)), n?.((u + 1) / i.length);
|
|
370
375
|
return v(a), o;
|
|
371
376
|
}
|
|
372
|
-
async function
|
|
377
|
+
async function De(e, t, r, n) {
|
|
373
378
|
const i = {
|
|
374
379
|
format: t.format,
|
|
375
380
|
requiresFeature: t.requiresFeature,
|
|
@@ -391,9 +396,9 @@ async function Ne(e, t, r, n) {
|
|
|
391
396
|
);
|
|
392
397
|
if (i.creatable = o.ok, !o.ok)
|
|
393
398
|
return i.errors.push(..._("create", o.errors)), i;
|
|
394
|
-
const u = o.value, c = await
|
|
399
|
+
const u = o.value, c = await Ie(e, t, u, n);
|
|
395
400
|
if (i.sampleable = c.ok, c.ok || i.errors.push(..._("sample", c.errors)), v(u), t.kind !== "compressed") if (t.kind === "depth") {
|
|
396
|
-
const l = await
|
|
401
|
+
const l = await We(e, t);
|
|
397
402
|
i.renderable = l.ok, l.ok || i.errors.push(..._("render", l.errors));
|
|
398
403
|
} else {
|
|
399
404
|
const l = await ue(e, t, !1);
|
|
@@ -403,17 +408,17 @@ async function Ne(e, t, r, n) {
|
|
|
403
408
|
}
|
|
404
409
|
}
|
|
405
410
|
if (t.kind === "color") {
|
|
406
|
-
const l = await
|
|
411
|
+
const l = await ze(e, t);
|
|
407
412
|
i.storageWritable = l.ok, l.ok || i.errors.push(..._("storage", l.errors));
|
|
408
413
|
}
|
|
409
414
|
if (i.renderable) {
|
|
410
|
-
const l = await
|
|
415
|
+
const l = await Ve(e, t);
|
|
411
416
|
i.multisample4x = l.ok, l.ok || i.errors.push(..._("msaa4x", l.errors));
|
|
412
417
|
}
|
|
413
418
|
return i;
|
|
414
419
|
}
|
|
415
|
-
async function
|
|
416
|
-
const i = t.kind === "compressed", a =
|
|
420
|
+
async function Ie(e, t, r, n) {
|
|
421
|
+
const i = t.kind === "compressed", a = qe(t);
|
|
417
422
|
return M(e, async () => {
|
|
418
423
|
const s = [{
|
|
419
424
|
binding: 0,
|
|
@@ -426,7 +431,7 @@ async function De(e, t, r, n) {
|
|
|
426
431
|
sampler: { type: t.filterable ? "filtering" : "non-filtering" }
|
|
427
432
|
});
|
|
428
433
|
const o = e.createBindGroupLayout({ entries: s }), u = e.createShaderModule({
|
|
429
|
-
code: H +
|
|
434
|
+
code: H + je(t, i)
|
|
430
435
|
}), c = e.createRenderPipeline({
|
|
431
436
|
layout: e.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
432
437
|
vertex: { module: u, entryPoint: "vs" },
|
|
@@ -481,7 +486,7 @@ async function ue(e, t, r) {
|
|
|
481
486
|
}, !0);
|
|
482
487
|
return v(n), i;
|
|
483
488
|
}
|
|
484
|
-
async function
|
|
489
|
+
async function We(e, t) {
|
|
485
490
|
let r = null;
|
|
486
491
|
const n = await M(e, async () => {
|
|
487
492
|
const i = e.createTexture({
|
|
@@ -506,7 +511,7 @@ async function Ie(e, t) {
|
|
|
506
511
|
}, !0);
|
|
507
512
|
return v(r), n;
|
|
508
513
|
}
|
|
509
|
-
async function
|
|
514
|
+
async function ze(e, t) {
|
|
510
515
|
let r = null;
|
|
511
516
|
const n = await M(e, async () => {
|
|
512
517
|
const i = e.createTexture({
|
|
@@ -530,7 +535,7 @@ async function We(e, t) {
|
|
|
530
535
|
}, !0);
|
|
531
536
|
return v(r), n;
|
|
532
537
|
}
|
|
533
|
-
async function
|
|
538
|
+
async function Ve(e, t) {
|
|
534
539
|
let r = null;
|
|
535
540
|
const n = await M(e, async () => {
|
|
536
541
|
const i = e.createTexture({
|
|
@@ -572,8 +577,8 @@ async function ze(e, t) {
|
|
|
572
577
|
}, !0);
|
|
573
578
|
return v(r), n;
|
|
574
579
|
}
|
|
575
|
-
function
|
|
576
|
-
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;" : "";
|
|
577
582
|
let a;
|
|
578
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);
|
|
579
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);
|
|
@@ -742,7 +747,7 @@ ${G}
|
|
|
742
747
|
}`
|
|
743
748
|
}
|
|
744
749
|
];
|
|
745
|
-
async function
|
|
750
|
+
async function He(e, t, r) {
|
|
746
751
|
const n = [];
|
|
747
752
|
for (let i = 0; i < Q.length; i++) {
|
|
748
753
|
const a = Q[i];
|
|
@@ -762,11 +767,11 @@ async function je(e, t, r) {
|
|
|
762
767
|
});
|
|
763
768
|
continue;
|
|
764
769
|
}
|
|
765
|
-
n.push(await
|
|
770
|
+
n.push(await Ke(e, a));
|
|
766
771
|
}
|
|
767
772
|
return n;
|
|
768
773
|
}
|
|
769
|
-
async function
|
|
774
|
+
async function Ke(e, t) {
|
|
770
775
|
const r = {
|
|
771
776
|
id: t.id,
|
|
772
777
|
description: t.description,
|
|
@@ -809,7 +814,7 @@ async function He(e, t) {
|
|
|
809
814
|
function ce(e) {
|
|
810
815
|
return { type: "error", message: e.message, lineNum: 0 };
|
|
811
816
|
}
|
|
812
|
-
const
|
|
817
|
+
const Xe = 10, Z = [
|
|
813
818
|
{
|
|
814
819
|
limit: "maxBufferSize",
|
|
815
820
|
floor: 256 * 1024 * 1024,
|
|
@@ -920,7 +925,7 @@ var<workgroup> scratch: array<vec4f, ${r}>;
|
|
|
920
925
|
})
|
|
921
926
|
}
|
|
922
927
|
];
|
|
923
|
-
async function
|
|
928
|
+
async function Ye(e, t, r) {
|
|
924
929
|
const n = [];
|
|
925
930
|
for (let i = 0; i < Z.length; i++) {
|
|
926
931
|
const a = Z[i];
|
|
@@ -937,7 +942,7 @@ async function Xe(e, t, r) {
|
|
|
937
942
|
});
|
|
938
943
|
continue;
|
|
939
944
|
}
|
|
940
|
-
const u = await
|
|
945
|
+
const u = await Qe(e, a, Math.min(a.floor, s), s);
|
|
941
946
|
n.push({
|
|
942
947
|
limit: a.limit,
|
|
943
948
|
declared: s,
|
|
@@ -952,13 +957,13 @@ async function Xe(e, t, r) {
|
|
|
952
957
|
}
|
|
953
958
|
return n;
|
|
954
959
|
}
|
|
955
|
-
async function
|
|
960
|
+
async function Qe(e, t, r, n) {
|
|
956
961
|
let i = r, a = (await t.test(e, i)).ok;
|
|
957
962
|
for (; !a && i > 1; )
|
|
958
963
|
i = Math.floor(i / 2), a = (await t.test(e, i)).ok;
|
|
959
964
|
if (!a) return 0;
|
|
960
965
|
let s = n;
|
|
961
|
-
for (let o = 0; o <
|
|
966
|
+
for (let o = 0; o < Xe && s - i > 1; o++) {
|
|
962
967
|
const u = i + Math.floor((s - i) / 2);
|
|
963
968
|
(await t.test(e, u)).ok ? i = u : s = u;
|
|
964
969
|
}
|
|
@@ -1034,40 +1039,40 @@ class j {
|
|
|
1034
1039
|
this.querySet = null, this.resolveBuf = null, this.readBuf = null;
|
|
1035
1040
|
}
|
|
1036
1041
|
}
|
|
1037
|
-
function
|
|
1042
|
+
function Ze(e) {
|
|
1038
1043
|
if (e.length === 0) return 0;
|
|
1039
1044
|
const t = [...e].sort((n, i) => n - i), r = t.length >> 1;
|
|
1040
1045
|
return t.length % 2 ? t[r] : (t[r - 1] + t[r]) / 2;
|
|
1041
1046
|
}
|
|
1042
|
-
function
|
|
1047
|
+
function Je(e) {
|
|
1043
1048
|
if (e.length < 2) return 0;
|
|
1044
1049
|
const t = e.reduce((n, i) => n + i, 0) / e.length;
|
|
1045
1050
|
if (t === 0) return 0;
|
|
1046
1051
|
const r = e.reduce((n, i) => n + (i - t) ** 2, 0) / (e.length - 1);
|
|
1047
1052
|
return Math.sqrt(r) / t;
|
|
1048
1053
|
}
|
|
1049
|
-
const
|
|
1050
|
-
function
|
|
1054
|
+
const et = 0.9, tt = 0.02, rt = 4;
|
|
1055
|
+
function nt(e, t) {
|
|
1051
1056
|
if (t <= 0 || e.length === 0) return !1;
|
|
1052
|
-
const r = t *
|
|
1057
|
+
const r = t * tt;
|
|
1053
1058
|
let n = 0;
|
|
1054
1059
|
for (const i of e) {
|
|
1055
1060
|
const a = i % t;
|
|
1056
1061
|
(a <= r || a >= t - r) && n++;
|
|
1057
1062
|
}
|
|
1058
|
-
return n / e.length >=
|
|
1063
|
+
return n / e.length >= et;
|
|
1059
1064
|
}
|
|
1060
|
-
function
|
|
1065
|
+
function ot(e) {
|
|
1061
1066
|
const t = e.filter((s) => s > 0 && Number.isFinite(s));
|
|
1062
|
-
if (t.length <
|
|
1067
|
+
if (t.length < rt) return null;
|
|
1063
1068
|
const r = Math.min(...t), n = [...new Set(t)].sort((s, o) => s - o);
|
|
1064
1069
|
let i = 1 / 0;
|
|
1065
1070
|
for (let s = 1; s < n.length; s++)
|
|
1066
1071
|
i = Math.min(i, n[s] - n[s - 1]);
|
|
1067
1072
|
const a = Math.min(r, i);
|
|
1068
|
-
return !Number.isFinite(a) || a <= 0 ? null :
|
|
1073
|
+
return !Number.isFinite(a) || a <= 0 ? null : nt(t, a) ? a : null;
|
|
1069
1074
|
}
|
|
1070
|
-
const P = 1024,
|
|
1075
|
+
const P = 1024, it = 3, ee = 10, at = 100, st = 60, ut = 20, fe = 2048, W = `
|
|
1071
1076
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
1072
1077
|
var p = array<vec2f, 3>(vec2f(-1., -1.), vec2f(3., -1.), vec2f(-1., 3.));
|
|
1073
1078
|
return vec4f(p[i], 0., 1.);
|
|
@@ -1293,7 +1298,7 @@ ${W}
|
|
|
1293
1298
|
}
|
|
1294
1299
|
}
|
|
1295
1300
|
];
|
|
1296
|
-
function
|
|
1301
|
+
function ct() {
|
|
1297
1302
|
let e = 1 / 0;
|
|
1298
1303
|
for (let t = 0; t < 24; t++) {
|
|
1299
1304
|
const r = performance.now();
|
|
@@ -1303,7 +1308,7 @@ function ut() {
|
|
|
1303
1308
|
}
|
|
1304
1309
|
return Number.isFinite(e) && e > 0 ? e : 0;
|
|
1305
1310
|
}
|
|
1306
|
-
async function
|
|
1311
|
+
async function lt(e, t) {
|
|
1307
1312
|
if (!t.available) return null;
|
|
1308
1313
|
const r = e.createTexture({
|
|
1309
1314
|
size: [256, 256],
|
|
@@ -1331,16 +1336,16 @@ async function ct(e, t) {
|
|
|
1331
1336
|
if (u >= 4 && new Set(a.filter((c) => c > 0)).size >= 2) break;
|
|
1332
1337
|
s *= 4;
|
|
1333
1338
|
}
|
|
1334
|
-
return v(r),
|
|
1339
|
+
return v(r), ot(a);
|
|
1335
1340
|
}
|
|
1336
|
-
async function
|
|
1341
|
+
async function ft(e, t, r) {
|
|
1337
1342
|
const n = performance.now(), i = j.create(e), a = e.createTexture({
|
|
1338
1343
|
size: [P, P],
|
|
1339
1344
|
format: "rgba8unorm",
|
|
1340
1345
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
1341
|
-
}), s = a.createView(), o = await
|
|
1346
|
+
}), s = a.createView(), o = await lt(e, i), u = ct(), c = [];
|
|
1342
1347
|
for (let l = 0; l < ne.length; l++)
|
|
1343
|
-
c.push(await
|
|
1348
|
+
c.push(await dt(
|
|
1344
1349
|
e,
|
|
1345
1350
|
ne[l],
|
|
1346
1351
|
s,
|
|
@@ -1357,7 +1362,7 @@ async function lt(e, t, r) {
|
|
|
1357
1362
|
totalMs: Math.round(performance.now() - n)
|
|
1358
1363
|
};
|
|
1359
1364
|
}
|
|
1360
|
-
async function
|
|
1365
|
+
async function dt(e, t, r, n, i, a, s) {
|
|
1361
1366
|
const o = {
|
|
1362
1367
|
id: t.id,
|
|
1363
1368
|
description: t.description,
|
|
@@ -1376,12 +1381,12 @@ async function ft(e, t, r, n, i, a, s) {
|
|
|
1376
1381
|
}
|
|
1377
1382
|
const c = t.timingMode === "gpu-preferred" && n.available;
|
|
1378
1383
|
try {
|
|
1379
|
-
for (let m = 0; m <
|
|
1384
|
+
for (let m = 0; m < it; m++) {
|
|
1380
1385
|
const S = e.createCommandEncoder();
|
|
1381
1386
|
u.record(S, 1), e.queue.submit([S.finish()]);
|
|
1382
1387
|
}
|
|
1383
1388
|
await e.queue.onSubmittedWorkDone();
|
|
1384
|
-
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);
|
|
1385
1390
|
let f = 1;
|
|
1386
1391
|
for (let m = 0; m < 8; m++) {
|
|
1387
1392
|
const { ms: S } = await me(e, u, f, n, c);
|
|
@@ -1397,22 +1402,22 @@ async function ft(e, t, r, n, i, a, s) {
|
|
|
1397
1402
|
}
|
|
1398
1403
|
if (u.dispose?.(), p.length === 0)
|
|
1399
1404
|
return { ...o, failed: "no measurements were obtained" };
|
|
1400
|
-
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 = {
|
|
1401
1406
|
...o,
|
|
1402
1407
|
medianMs: q(T, 4),
|
|
1403
1408
|
minMs: q(Math.min(...g), 4),
|
|
1404
|
-
variation: q(
|
|
1409
|
+
variation: q(Je(g), 3),
|
|
1405
1410
|
timing: w ? "timestamp-query" : "wall-clock",
|
|
1406
1411
|
samples: g.length,
|
|
1407
1412
|
repetitions: f
|
|
1408
1413
|
}, R = w ? a != null ? a / 1e6 : null : s > 0 ? s : null;
|
|
1409
1414
|
if (R) {
|
|
1410
1415
|
const m = T / R;
|
|
1411
|
-
k.ticks = q(m, 1), k.quantized = m <
|
|
1416
|
+
k.ticks = q(m, 1), k.quantized = m < ut;
|
|
1412
1417
|
}
|
|
1413
1418
|
if (T > 0) {
|
|
1414
1419
|
const m = E / (T / 1e3);
|
|
1415
|
-
k.throughput = q(
|
|
1420
|
+
k.throughput = q(mt(m, t.unit), 2), k.throughputUnit = t.unit;
|
|
1416
1421
|
}
|
|
1417
1422
|
return k;
|
|
1418
1423
|
} catch (l) {
|
|
@@ -1429,7 +1434,7 @@ async function me(e, t, r, n, i) {
|
|
|
1429
1434
|
}
|
|
1430
1435
|
return { ms: u, fromGpu: !1 };
|
|
1431
1436
|
}
|
|
1432
|
-
function
|
|
1437
|
+
function pt(e) {
|
|
1433
1438
|
return e.length < 5 ? e : [...e].sort((r, n) => r - n).slice(1, -1);
|
|
1434
1439
|
}
|
|
1435
1440
|
function $(e, t, r) {
|
|
@@ -1443,7 +1448,7 @@ function $(e, t, r) {
|
|
|
1443
1448
|
};
|
|
1444
1449
|
return r && (n.timestampWrites = r), e.beginRenderPass(n);
|
|
1445
1450
|
}
|
|
1446
|
-
function
|
|
1451
|
+
function mt(e, t) {
|
|
1447
1452
|
return t.startsWith("M") ? e / 1e6 : t.startsWith("G") ? e / 1e9 : e;
|
|
1448
1453
|
}
|
|
1449
1454
|
function q(e, t) {
|
|
@@ -1453,10 +1458,10 @@ function q(e, t) {
|
|
|
1453
1458
|
function he(e) {
|
|
1454
1459
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1455
1460
|
}
|
|
1456
|
-
function
|
|
1457
|
-
const a = [], s =
|
|
1461
|
+
function ht(e, t, r, n, i) {
|
|
1462
|
+
const a = [], s = Oe(i);
|
|
1458
1463
|
for (const o of e) {
|
|
1459
|
-
const u =
|
|
1464
|
+
const u = Fe(o.format);
|
|
1460
1465
|
if (o.featureDeclared && !o.creatable) {
|
|
1461
1466
|
a.push({
|
|
1462
1467
|
kind: "format-declared-not-usable",
|
|
@@ -1477,7 +1482,7 @@ function mt(e, t, r, n, i) {
|
|
|
1477
1482
|
detail: `${o.requiresFeature} is not declared, yet texture creation succeeds`,
|
|
1478
1483
|
severity: "note"
|
|
1479
1484
|
}), !u || !o.creatable) continue;
|
|
1480
|
-
const c =
|
|
1485
|
+
const c = Ce(u, i);
|
|
1481
1486
|
c.renderable && !o.renderable && a.push({
|
|
1482
1487
|
kind: "format-declared-not-usable",
|
|
1483
1488
|
subject: o.format,
|
|
@@ -1549,8 +1554,8 @@ function ge(e) {
|
|
|
1549
1554
|
function be(e) {
|
|
1550
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);
|
|
1551
1556
|
}
|
|
1552
|
-
const
|
|
1553
|
-
function
|
|
1557
|
+
const gt = 16;
|
|
1558
|
+
function bt(e) {
|
|
1554
1559
|
const t = e.browserVersion.split(".")[0] ?? "";
|
|
1555
1560
|
return [
|
|
1556
1561
|
e.browser,
|
|
@@ -1562,16 +1567,16 @@ function gt(e) {
|
|
|
1562
1567
|
].join("|");
|
|
1563
1568
|
}
|
|
1564
1569
|
async function ve(e) {
|
|
1565
|
-
const t =
|
|
1570
|
+
const t = bt(e), r = globalThis.crypto?.subtle;
|
|
1566
1571
|
if (r)
|
|
1567
1572
|
try {
|
|
1568
1573
|
const n = await r.digest("SHA-256", new TextEncoder().encode(t));
|
|
1569
|
-
return
|
|
1574
|
+
return yt(new Uint8Array(n).subarray(0, gt));
|
|
1570
1575
|
} catch {
|
|
1571
1576
|
}
|
|
1572
|
-
return
|
|
1577
|
+
return vt(t);
|
|
1573
1578
|
}
|
|
1574
|
-
function
|
|
1579
|
+
function vt(e) {
|
|
1575
1580
|
const r = [2166136261, 16777619, 3421674724, 2216829733];
|
|
1576
1581
|
for (let n = 0; n < e.length; n++) {
|
|
1577
1582
|
const i = e.charCodeAt(n);
|
|
@@ -1580,19 +1585,19 @@ function bt(e) {
|
|
|
1580
1585
|
}
|
|
1581
1586
|
return r.map((n) => n.toString(16).padStart(8, "0")).join("");
|
|
1582
1587
|
}
|
|
1583
|
-
function
|
|
1588
|
+
function yt(e) {
|
|
1584
1589
|
let t = "";
|
|
1585
1590
|
for (const r of e) t += r.toString(16).padStart(2, "0");
|
|
1586
1591
|
return t;
|
|
1587
1592
|
}
|
|
1588
1593
|
const F = { formats: 0.25, shaders: 0.1, limits: 0.15, bench: 0.5 };
|
|
1589
|
-
async function
|
|
1594
|
+
async function _t(e = {}) {
|
|
1590
1595
|
const {
|
|
1591
1596
|
powerPreference: t,
|
|
1592
1597
|
benchmark: r = !0,
|
|
1593
1598
|
onProgress: n,
|
|
1594
1599
|
formats: i
|
|
1595
|
-
} = e, a =
|
|
1600
|
+
} = e, a = wt(e.benchSamples ?? 7, 1, 99), s = performance.now(), o = await Ae(), u = {
|
|
1596
1601
|
schema: 5,
|
|
1597
1602
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1598
1603
|
fingerprint: "",
|
|
@@ -1641,16 +1646,16 @@ async function Rt(e = {}) {
|
|
|
1641
1646
|
deviceLost: !1
|
|
1642
1647
|
};
|
|
1643
1648
|
try {
|
|
1644
|
-
k("formats", E), m.formats = await
|
|
1649
|
+
k("formats", E), m.formats = await Ne(
|
|
1645
1650
|
l,
|
|
1646
1651
|
T,
|
|
1647
1652
|
i,
|
|
1648
1653
|
R("formats", F.formats)
|
|
1649
|
-
), E += F.formats, k("shaders", E), m.shaders = await
|
|
1654
|
+
), E += F.formats, k("shaders", E), m.shaders = await He(
|
|
1650
1655
|
l,
|
|
1651
1656
|
T,
|
|
1652
1657
|
R("shaders", F.shaders)
|
|
1653
|
-
), E += F.shaders, k("limits", E), m.limits = await
|
|
1658
|
+
), E += F.shaders, k("limits", E), m.limits = await Ye(
|
|
1654
1659
|
l,
|
|
1655
1660
|
p.limits,
|
|
1656
1661
|
R("limits", F.limits)
|
|
@@ -1662,13 +1667,13 @@ async function Rt(e = {}) {
|
|
|
1662
1667
|
if (r && !m.deviceLost) {
|
|
1663
1668
|
k("benchmarks", E);
|
|
1664
1669
|
try {
|
|
1665
|
-
S = await
|
|
1670
|
+
S = await ft(l, a, R("benchmarks", F.bench));
|
|
1666
1671
|
} catch (b) {
|
|
1667
1672
|
m.deviceLostReason = g ?? oe(b);
|
|
1668
1673
|
}
|
|
1669
1674
|
}
|
|
1670
1675
|
k("done", 1), g && (m.deviceLost = !0, m.deviceLostReason = g);
|
|
1671
|
-
const U =
|
|
1676
|
+
const U = ht(
|
|
1672
1677
|
m.formats,
|
|
1673
1678
|
m.shaders,
|
|
1674
1679
|
m.limits,
|
|
@@ -1701,13 +1706,13 @@ async function Rt(e = {}) {
|
|
|
1701
1706
|
};
|
|
1702
1707
|
return l.destroy(), xe;
|
|
1703
1708
|
}
|
|
1704
|
-
function
|
|
1709
|
+
function wt(e, t, r) {
|
|
1705
1710
|
return Number.isFinite(e) ? Math.min(r, Math.max(t, Math.round(e))) : t;
|
|
1706
1711
|
}
|
|
1707
1712
|
function oe(e) {
|
|
1708
1713
|
return e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
|
1709
1714
|
}
|
|
1710
|
-
function
|
|
1715
|
+
function xt(e) {
|
|
1711
1716
|
return {
|
|
1712
1717
|
profile: e,
|
|
1713
1718
|
features: new Set(e.declared.features),
|
|
@@ -1716,15 +1721,15 @@ function wt(e) {
|
|
|
1716
1721
|
benchmarks: new Map((e.benchmarks?.results ?? []).map((t) => [t.id, t]))
|
|
1717
1722
|
};
|
|
1718
1723
|
}
|
|
1719
|
-
const
|
|
1724
|
+
const kt = [
|
|
1720
1725
|
"creatable",
|
|
1721
1726
|
"sampleable",
|
|
1722
1727
|
"renderable",
|
|
1723
1728
|
"blendable",
|
|
1724
1729
|
"storageWritable",
|
|
1725
1730
|
"multisample4x"
|
|
1726
|
-
],
|
|
1727
|
-
function
|
|
1731
|
+
], St = 0.15;
|
|
1732
|
+
function Gt(e) {
|
|
1728
1733
|
const t = [], r = [], n = [], i = /* @__PURE__ */ new Set();
|
|
1729
1734
|
e.forEach((s, o) => {
|
|
1730
1735
|
if (s.unavailable) {
|
|
@@ -1746,28 +1751,28 @@ function _t(e) {
|
|
|
1746
1751
|
const u = typeof s.schema == "number" ? s.schema : 0;
|
|
1747
1752
|
t.push({
|
|
1748
1753
|
fingerprint: s.fingerprint,
|
|
1749
|
-
label:
|
|
1754
|
+
label: Mt(s),
|
|
1750
1755
|
mobile: s.environment.mobile,
|
|
1751
1756
|
index: o,
|
|
1752
1757
|
schema: u,
|
|
1753
1758
|
staleBenchmarks: u < 2
|
|
1754
1759
|
}), r.push(s);
|
|
1755
1760
|
});
|
|
1756
|
-
const a = r.map(
|
|
1761
|
+
const a = r.map(xt);
|
|
1757
1762
|
return {
|
|
1758
1763
|
devices: t,
|
|
1759
|
-
...
|
|
1760
|
-
formats:
|
|
1761
|
-
limits:
|
|
1762
|
-
benchmarks:
|
|
1764
|
+
...Pt(a),
|
|
1765
|
+
formats: Et(a),
|
|
1766
|
+
limits: Tt(a),
|
|
1767
|
+
benchmarks: At(a),
|
|
1763
1768
|
excluded: n
|
|
1764
1769
|
};
|
|
1765
1770
|
}
|
|
1766
|
-
function
|
|
1767
|
-
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(" ");
|
|
1768
1773
|
return r ? `${t} / ${r}` : t;
|
|
1769
1774
|
}
|
|
1770
|
-
function
|
|
1775
|
+
function Pt(e) {
|
|
1771
1776
|
const t = /* @__PURE__ */ new Set();
|
|
1772
1777
|
for (const i of e) for (const a of i.features) t.add(a);
|
|
1773
1778
|
const r = [], n = [];
|
|
@@ -1779,13 +1784,13 @@ function Mt(e) {
|
|
|
1779
1784
|
}
|
|
1780
1785
|
return { features: r, sharedFeatures: n };
|
|
1781
1786
|
}
|
|
1782
|
-
function
|
|
1787
|
+
function Et(e) {
|
|
1783
1788
|
const t = /* @__PURE__ */ new Set();
|
|
1784
1789
|
for (const n of e)
|
|
1785
1790
|
for (const i of n.formats.keys()) t.add(i);
|
|
1786
1791
|
const r = [];
|
|
1787
1792
|
for (const n of [...t].sort())
|
|
1788
|
-
for (const i of
|
|
1793
|
+
for (const i of kt) {
|
|
1789
1794
|
const a = [], s = [];
|
|
1790
1795
|
for (const o of e) {
|
|
1791
1796
|
const u = o.formats.get(n);
|
|
@@ -1795,7 +1800,7 @@ function Pt(e) {
|
|
|
1795
1800
|
}
|
|
1796
1801
|
return r;
|
|
1797
1802
|
}
|
|
1798
|
-
function
|
|
1803
|
+
function Tt(e) {
|
|
1799
1804
|
const t = /* @__PURE__ */ new Set();
|
|
1800
1805
|
for (const n of e) for (const i of n.limits.keys()) t.add(i);
|
|
1801
1806
|
const r = [];
|
|
@@ -1812,7 +1817,7 @@ function Et(e) {
|
|
|
1812
1817
|
}
|
|
1813
1818
|
return r.sort((n, i) => i.ratio - n.ratio);
|
|
1814
1819
|
}
|
|
1815
|
-
function
|
|
1820
|
+
function At(e) {
|
|
1816
1821
|
const t = /* @__PURE__ */ new Map();
|
|
1817
1822
|
for (const n of e)
|
|
1818
1823
|
for (const [i, a] of n.benchmarks)
|
|
@@ -1826,7 +1831,7 @@ function Tt(e) {
|
|
|
1826
1831
|
a[p] = null;
|
|
1827
1832
|
continue;
|
|
1828
1833
|
}
|
|
1829
|
-
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);
|
|
1830
1835
|
}
|
|
1831
1836
|
const o = Object.entries(a).filter((f) => f[1] != null);
|
|
1832
1837
|
let u = null, c = null, l = null;
|
|
@@ -1849,7 +1854,7 @@ function Tt(e) {
|
|
|
1849
1854
|
}
|
|
1850
1855
|
return r.sort((n, i) => (i.ratio ?? 0) - (n.ratio ?? 0));
|
|
1851
1856
|
}
|
|
1852
|
-
function
|
|
1857
|
+
function Ft(e, t = {}) {
|
|
1853
1858
|
const r = Math.max(1, t.limit ?? 20), n = [], i = (o) => o.slice(0, 8), a = (o) => ({
|
|
1854
1859
|
shown: o.slice(0, r),
|
|
1855
1860
|
hidden: Math.max(0, o.length - r)
|
|
@@ -1907,22 +1912,22 @@ function Gt(e, t = {}) {
|
|
|
1907
1912
|
return n.join(`
|
|
1908
1913
|
`);
|
|
1909
1914
|
}
|
|
1910
|
-
function
|
|
1915
|
+
function Bt(e) {
|
|
1911
1916
|
return e.split(".")[0] ?? "";
|
|
1912
1917
|
}
|
|
1913
|
-
function
|
|
1918
|
+
function Ut(e) {
|
|
1914
1919
|
return e.unavailable !== void 0;
|
|
1915
1920
|
}
|
|
1916
|
-
function
|
|
1921
|
+
function Ct(e) {
|
|
1917
1922
|
return e.discrepancies.filter((t) => t.severity === "breaking");
|
|
1918
1923
|
}
|
|
1919
|
-
function
|
|
1924
|
+
function Ot(e) {
|
|
1920
1925
|
return (e.verified?.formats ?? []).filter((t) => t.renderable).map((t) => t.format);
|
|
1921
1926
|
}
|
|
1922
|
-
function
|
|
1927
|
+
function qt(e) {
|
|
1923
1928
|
return (e.verified?.formats ?? []).filter((t) => t.sampleable).map((t) => t.format);
|
|
1924
1929
|
}
|
|
1925
|
-
function
|
|
1930
|
+
function Lt(e, t, r = "render") {
|
|
1926
1931
|
const n = e.verified?.formats ?? [];
|
|
1927
1932
|
for (const i of t) {
|
|
1928
1933
|
const a = n.find((s) => s.format === i);
|
|
@@ -1931,23 +1936,23 @@ function qt(e, t, r = "render") {
|
|
|
1931
1936
|
}
|
|
1932
1937
|
return null;
|
|
1933
1938
|
}
|
|
1934
|
-
function
|
|
1939
|
+
function Nt(e, t) {
|
|
1935
1940
|
return e.benchmarks?.results.find((r) => r.id === t) ?? null;
|
|
1936
1941
|
}
|
|
1937
1942
|
export {
|
|
1938
1943
|
ie as FORMATS,
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
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
|
|
1952
1957
|
};
|
|
1953
1958
|
//# sourceMappingURL=gpu-atlas.js.map
|