@margoengine/quality 0.1.0 → 1.0.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/dist/demand.js CHANGED
@@ -1,4 +1,4 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
4
  import { r as e } from "./errors-XvcwUnU4.js";
@@ -37,7 +37,7 @@ function n(n, r = {}) {
37
37
  for (let e of i) for (let t of b) e.removeEventListener(t, y);
38
38
  s?.removeEventListener("abort", x), n.sceneOf(S)?.removePlugin(S.name);
39
39
  }
40
- }, S = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
40
+ }, S = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
41
41
  name: `quality-demand-${++t}`,
42
42
  setup() {},
43
43
  onDeviceRestored: () => _(2),
package/dist/features.js CHANGED
@@ -125,7 +125,7 @@ var a = (e, t, n, r, i) => ({
125
125
  });
126
126
  function o({ post: e = [], ssao: t, ssr: n, shadows: r, volumetric: o, lod: s, camera: c }) {
127
127
  let l = e.filter((e) => e.enabled).map((e) => i(e.name, e, "enabled", [!0, !1], 1));
128
- if (t?.enabled && l.push(a("ssao", t, "samples", t.options.samples ?? 32, 1)), n?.enabled && l.push(a("ssr", n, "steps", n.options.steps ?? 64, 1)), r) {
128
+ if (t?.enabled && l.push(a("ssao", t, "samples", t.options.samples ?? 32, 1)), n?.enabled && l.push(a("ssr", n, "steps", n.options.steps ?? 128, 1)), r) {
129
129
  let { options: e } = r, t = typeof e.filter == "object" ? "hard" : e.filter ?? "soft", n = [
130
130
  "soft",
131
131
  "pcf",
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface QualityPreset {
38
38
  enabled?: boolean;
39
39
  samples?: number;
40
40
  };
41
- /** `SSR` (@margoengine/post/ssr): on/off (default on) and Hi-Z march steps (default 64). */
41
+ /** `SSR` (@margoengine/post/ssr): on/off (default on) and Hi-Z march steps (default 128). */
42
42
  ssr?: {
43
43
  enabled?: boolean;
44
44
  steps?: number;
@@ -1,4 +1,4 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
4
  //#region ../core/dist/quality.js
@@ -143,7 +143,7 @@ function S({ request: e = globalThis.requestAnimationFrame?.bind(globalThis), qu
143
143
  }
144
144
  var C = 0;
145
145
  function w(e, t, n = globalThis.requestAnimationFrame?.bind(globalThis)) {
146
- let r = `redraw-after-restore-${++C}`, i = !0, a = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
146
+ let r = `redraw-after-restore-${++C}`, i = !0, a = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
147
147
  name: r,
148
148
  setup() {},
149
149
  onDeviceRestored: () => {
package/dist/ssaa.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const t=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const t=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { n as e } from "./errors-XvcwUnU4.js";
5
5
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
6
6
  //#region src/ssaa.ts
package/dist/warm.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import type { EngineKernel } from '@margoengine/core';
2
2
  /** What {@link warmUp} did. */
3
3
  export interface WarmUpReport {
4
- /** Render and compute pipelines created with the async API ahead of their first visible frame. */
4
+ /**
5
+ * Render and compute pipelines created with the async API ahead of their first visible frame; on the WebGL2 layer's
6
+ * frame route (see {@link warmUp}), the distinct pipelines the warm frames made, whose links the layer held them for.
7
+ */
5
8
  pipelines: number;
6
9
  /** Pipelines that had to be created synchronously after all (the retried call did not match its warmed descriptor). */
7
10
  fallbacks: number;
8
- /** Warm render calls, including the stopped ones that discovered a pipeline. */
11
+ /** Warm render calls, including the stopped ones that discovered a pipeline (on the frame route every one is whole). */
9
12
  rounds: number;
10
13
  /** A feature failed after a stopped warm frame, so the device was restored (`engine.rebootDevice()`) and the
11
14
  * remaining warm frames created their pipelines synchronously. */
@@ -33,6 +36,15 @@ export interface WarmUpOptions {
33
36
  * attach have compiled by then too. Without WebGPU it resolves at once. A feature that stores state before creating its pipeline (so the
34
37
  * retry skips the creation) fails on the retry; then every feature is reset through device restoration and the warm
35
38
  * frames finish with synchronous creation (`report.rebooted`).
39
+ * On the WebGL2 compatibility layer with KHR_parallel_shader_compile (its queue carries the link hold,
40
+ * `Symbol.for('margoengine.queue.holdsLinks')`) no frame is stopped: each warm frame runs whole with the hold on, so the
41
+ * layer keeps that frame's submits, and the writes after them in order, in its queue until every program the frame made
42
+ * has linked and drawn once, and all of a frame's links run side by side on the driver's threads instead of one per
43
+ * round (KB-QUALITY-WARMSERIAL1). It ends after `frames` frames in a row that made no new pipeline.
44
+ * The layer then replays a held frame in tasks of about 50 ms, each after the GPU has run the one before, so the page
45
+ * stays responsive while it plays back.
46
+ * Limit: call it before `engine.start()`. On the layer's frame route the frames a running loop renders meanwhile wait
47
+ * in the queue behind the held frame (their tapes and write copies kept) and replay after it.
36
48
  * ponytail: a feature that is off (`enabled = false`) or attached later is not warmed; call warmUp again after
37
49
  * attaching it.
38
50
  */
package/dist/warm.js CHANGED
@@ -1,11 +1,13 @@
1
- //#region src/warm.ts
2
- var e = [
1
+ //#region ../shared/queue-hold.js
2
+ var e = Symbol.for("margoengine.queue.holdsLinks"), t = [
3
3
  "createRenderPipeline",
4
4
  "createComputePipeline",
5
5
  "createShaderModule",
6
- "createCommandEncoder"
7
- ], t = class extends Error {};
8
- function n(e, t, n) {
6
+ "createCommandEncoder",
7
+ "createBindGroupLayout",
8
+ "createPipelineLayout"
9
+ ], n = class extends Error {};
10
+ function r(e, t, n) {
9
11
  let r = Object.getOwnPropertyDescriptor(e, t);
10
12
  return Object.defineProperty(e, t, {
11
13
  configurable: !0,
@@ -15,87 +17,110 @@ function n(e, t, n) {
15
17
  r ? Object.defineProperty(e, t, r) : delete e[t];
16
18
  };
17
19
  }
18
- async function r(r, { frames: i = 2, maxRounds: a = 256, signal: o } = {}) {
19
- o?.throwIfAborted();
20
- let s = {
20
+ async function i(i, { frames: a = 2, maxRounds: o = 256, signal: s } = {}) {
21
+ s?.throwIfAborted();
22
+ let c = {
21
23
  pipelines: 0,
22
24
  fallbacks: 0,
23
25
  rounds: 0,
24
26
  rebooted: !1
25
- }, c = () => r.gpu, l = c(), u = r.canvas.getContext("webgpu");
26
- if (!l || !u || r.backend !== "webgpu") return s;
27
- let d = Object.fromEntries(e.map((e) => [e, l[e]])), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), g = [], _ = !1, v = "", y = 0, b, x, S = (e, t, n) => e + JSON.stringify(t, (e, t) => {
27
+ }, l = () => i.gpu, u = l(), d = i.canvas.getContext("webgpu");
28
+ if (!u || !d || i.backend !== "webgpu") return c;
29
+ let f = u.queue[e], p = Object.fromEntries(t.map((e) => [e, u[e]])), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), y = [], b = /* @__PURE__ */ new Set(), x = !1, S = !1, C = "", w = 0, T, E, D = (e, t, n) => e + JSON.stringify(t, (e, t) => {
28
30
  if (typeof t != "object" || !t || Array.isArray(t) || Object.getPrototypeOf(t) === Object.prototype) return t;
29
- let r = p.get(t);
30
- return r === void 0 ? n ? "object" : (m.has(t) || m.set(t, y++), "object:" + m.get(t)) : "module" + r;
31
- }), C = (e) => function(n) {
32
- if (!_) return d[e].call(this, n);
33
- let r = S(e, n, !1), i = h.get(r);
31
+ let r = h.get(t);
32
+ if (r !== void 0) return "module" + r;
33
+ let i = g.get(t);
34
+ return i === void 0 ? n ? "object" : (_.has(t) || _.set(t, w++), "object:" + _.get(t)) : "layout" + i;
35
+ }), O = (e) => function(t) {
36
+ if (!S) return p[e].call(this, t);
37
+ if (f) {
38
+ let n = D(e, t, !0);
39
+ return b.has(n) || (b.add(n), c.pipelines++, x = !0), p[e].call(this, t);
40
+ }
41
+ let r = D(e, t, !1), i = v.get(r);
34
42
  if (i) return i;
35
- let a = S(e, n, !0);
36
- if (a === v) return v = "", s.fallbacks++, d[e].call(this, n);
37
- throw v = a, s.pipelines++, b = this[e + "Async"].call(this, n).then((e) => {
38
- h.set(r, e);
39
- }, () => {}), new t(e);
40
- }, w = [
41
- n(l, "createRenderPipeline", C("createRenderPipeline")),
42
- n(l, "createComputePipeline", C("createComputePipeline")),
43
- n(l, "createShaderModule", function(e) {
44
- let t = d.createShaderModule.call(this, e);
45
- return f.has(e.code) || f.set(e.code, f.size), p.set(t, f.get(e.code)), t;
43
+ let a = D(e, t, !0);
44
+ if (a === C) return C = "", c.fallbacks++, p[e].call(this, t);
45
+ throw C = a, c.pipelines++, T = this[e + "Async"].call(this, t).then((e) => {
46
+ v.set(r, e);
47
+ }, () => {}), new n(e);
48
+ }, k = [
49
+ r(u, "createRenderPipeline", O("createRenderPipeline")),
50
+ r(u, "createComputePipeline", O("createComputePipeline")),
51
+ r(u, "createShaderModule", function(e) {
52
+ let t = p.createShaderModule.call(this, e);
53
+ return m.has(e.code) || m.set(e.code, m.size), h.set(t, m.get(e.code)), t;
54
+ }),
55
+ r(u, "createBindGroupLayout", function(e) {
56
+ let t = p.createBindGroupLayout.call(this, e);
57
+ return g.set(t, D("createRenderPipeline", { entries: e.entries }, !1)), t;
46
58
  }),
47
- n(l, "createCommandEncoder", function(e) {
48
- let t = d.createCommandEncoder.call(this, e);
49
- if (!_) return t;
50
- let r = { encoder: t };
51
- g.push(r);
59
+ r(u, "createPipelineLayout", function(e) {
60
+ let t = p.createPipelineLayout.call(this, e);
61
+ return g.set(t, D("createRenderPipeline", { groups: e.bindGroupLayouts }, !1)), t;
62
+ }),
63
+ r(u, "createCommandEncoder", function(e) {
64
+ let t = p.createCommandEncoder.call(this, e);
65
+ if (!S || f) return t;
66
+ let n = { encoder: t };
67
+ y.push(n);
52
68
  for (let e of ["beginRenderPass", "beginComputePass"]) {
53
69
  let i = t[e];
54
- n(t, e, (e) => {
55
- let a = r.pass = i.call(t, e), o = a.end;
56
- return n(a, "end", () => {
57
- r.pass = void 0, o.call(a);
70
+ r(t, e, (e) => {
71
+ let a = n.pass = i.call(t, e), o = a.end;
72
+ return r(a, "end", () => {
73
+ n.pass = void 0, o.call(a);
58
74
  }), a;
59
75
  });
60
76
  }
61
77
  let i = t.finish;
62
- return n(t, "finish", (e) => (r.finished = !0, i.call(t, e))), t;
78
+ return r(t, "finish", (e) => (n.finished = !0, i.call(t, e))), t;
63
79
  }),
64
- n(u, "getCurrentTexture", function() {
65
- if (!_) return GPUCanvasContext.prototype.getCurrentTexture.call(this);
66
- let { width: e, height: t } = r.canvas, { format: n, usage: i = 16 } = u.getConfiguration();
67
- return (x?.width !== e || x.height !== t || x.format !== n) && (x?.destroy(), x = l.createTexture({
80
+ r(d, "getCurrentTexture", function() {
81
+ if (!S) return GPUCanvasContext.prototype.getCurrentTexture.call(this);
82
+ let { width: e, height: t } = i.canvas, { format: n, usage: r = 16 } = d.getConfiguration();
83
+ return (E?.width !== e || E.height !== t || E.format !== n) && (E?.destroy(), E = u.createTexture({
68
84
  size: [e, t],
69
85
  format: n,
70
- usage: i | 16
71
- })), x;
86
+ usage: r | 16
87
+ })), E;
72
88
  })
73
- ], T = () => {
74
- for (let e of w.splice(0)) e();
89
+ ], A = () => {
90
+ for (let e of k.splice(0)) e();
75
91
  };
76
92
  try {
77
- for (let e = 0; e < i && s.rounds < a && !r.disposed;) {
78
- o?.throwIfAborted(), s.rounds++, b = void 0, g.length = 0, _ = c() === l;
93
+ for (let e = 0; f && e < a && c.rounds < o && !i.disposed;) {
94
+ s?.throwIfAborted(), c.rounds++, x = !1, S = l() === u, f(!0);
95
+ try {
96
+ i.render({ delta: 0 });
97
+ } finally {
98
+ S = !1, f(!1);
99
+ }
100
+ await u.queue.onSubmittedWorkDone(), e = x ? 0 : e + 1;
101
+ }
102
+ for (let e = 0; !f && e < a && c.rounds < o && !i.disposed;) {
103
+ s?.throwIfAborted(), c.rounds++, T = void 0, y.length = 0, S = l() === u;
79
104
  try {
80
- r.render({ delta: 0 }), e++;
105
+ i.render({ delta: 0 }), e++;
81
106
  } catch (e) {
82
- if (e instanceof t) {
83
- l.pushErrorScope("validation");
84
- let e = g.filter((e) => !e.finished).map((e) => (e.pass?.end(), e.encoder.finish()));
85
- e.length && l.queue.submit(e), l.popErrorScope();
107
+ if (e instanceof n) {
108
+ u.pushErrorScope("validation");
109
+ let e = y.filter((e) => !e.finished).map((e) => (e.pass?.end(), e.encoder.finish()));
110
+ e.length && u.queue.submit(e), u.popErrorScope();
86
111
  continue;
87
112
  }
88
- if (!s.pipelines || s.rebooted) throw e;
89
- s.rebooted = !0, _ = !1, T(), await r.rebootDevice();
113
+ if (!c.pipelines || c.rebooted) throw e;
114
+ c.rebooted = !0, S = !1, A(), await i.rebootDevice();
90
115
  } finally {
91
- _ = !1, b && await b;
116
+ S = !1, T && await T;
92
117
  }
93
118
  }
94
- r.disposed || await c()?.queue.onSubmittedWorkDone(), o?.throwIfAborted();
119
+ i.disposed || await l()?.queue.onSubmittedWorkDone(), s?.throwIfAborted();
95
120
  } finally {
96
- T(), x?.destroy();
121
+ A(), E?.destroy();
97
122
  }
98
- return s;
123
+ return c;
99
124
  }
100
125
  //#endregion
101
- export { r as warmUp };
126
+ export { i as warmUp };
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "@margoengine/quality",
3
- "version": "0.1.0",
4
- "description": "Measured quality tiers: start light, time the GPU, remember full 4x quality only where it has headroom.",
5
- "keywords": [
6
- "margoengine",
7
- "webgpu",
8
- "3d",
9
- "quality"
10
- ],
11
- "homepage": "https://margoengine.com",
12
- "bugs": {
13
- "url": "https://github.com/scottcampbelldata/margoengine/issues"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/scottcampbelldata/margoengine.git",
18
- "directory": "packages/quality"
19
- },
20
- "license": "Apache-2.0",
21
- "author": "Scott Campbell",
22
- "type": "module",
23
- "sideEffects": false,
24
- "exports": {
25
- ".": {
26
- "types": "./dist/index.d.ts",
27
- "import": "./dist/index.js"
28
- },
29
- "./warm": {
30
- "types": "./dist/warm.d.ts",
31
- "import": "./dist/warm.js"
32
- },
33
- "./ssaa": {
34
- "types": "./dist/ssaa.d.ts",
35
- "import": "./dist/ssaa.js"
36
- },
37
- "./features": {
38
- "types": "./dist/features.d.ts",
39
- "import": "./dist/features.js"
40
- },
41
- "./power": {
42
- "types": "./dist/power.d.ts",
43
- "import": "./dist/power.js"
44
- },
45
- "./demand": {
46
- "types": "./dist/demand.d.ts",
47
- "import": "./dist/demand.js"
48
- },
49
- "./events": {
50
- "types": "./dist/events.d.ts",
51
- "import": "./dist/events.js"
52
- },
53
- "./knobs": {
54
- "types": "./dist/knobs.d.ts",
55
- "import": "./dist/knobs.js"
56
- }
57
- },
58
- "files": [
59
- "dist",
60
- "LICENSE",
61
- "NOTICE"
62
- ],
63
- "publishConfig": {
64
- "access": "public"
65
- },
66
- "peerDependencies": {
67
- "@margoengine/core": "^0.1.0"
68
- },
69
- "scripts": {
70
- "build": "node ../../scripts/build-optional.js quality",
71
- "test": "npm run build && node --test test/*.test.js ../../examples/package-benchmarks/proofs/package-guard.mjs",
72
- "test:gpu": "cd ../.. && node packages/quality/test/browser-check.mjs && node packages/quality/test/ssaa-browser.mjs && node packages/quality/test/features-browser.mjs && node packages/quality/test/power-browser.mjs && node packages/quality/test/scene-owner-browser.mjs && node packages/quality/test/demand-browser.mjs && node packages/quality/test/events-browser.mjs && node packages/quality/test/knobs-browser.mjs",
73
- "prepack": "npm run build"
74
- }
75
- }
1
+ {
2
+ "name": "@margoengine/quality",
3
+ "version": "1.0.0",
4
+ "description": "Measured quality tiers: start light, time the GPU, remember full 4x quality only where it has headroom.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "3d",
9
+ "quality"
10
+ ],
11
+ "homepage": "https://margoengine.com",
12
+ "bugs": {
13
+ "url": "https://github.com/scottcampbelldata/margoengine/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/scottcampbelldata/margoengine.git",
18
+ "directory": "packages/quality"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "author": "Scott Campbell",
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./warm": {
30
+ "types": "./dist/warm.d.ts",
31
+ "import": "./dist/warm.js"
32
+ },
33
+ "./ssaa": {
34
+ "types": "./dist/ssaa.d.ts",
35
+ "import": "./dist/ssaa.js"
36
+ },
37
+ "./features": {
38
+ "types": "./dist/features.d.ts",
39
+ "import": "./dist/features.js"
40
+ },
41
+ "./power": {
42
+ "types": "./dist/power.d.ts",
43
+ "import": "./dist/power.js"
44
+ },
45
+ "./demand": {
46
+ "types": "./dist/demand.d.ts",
47
+ "import": "./dist/demand.js"
48
+ },
49
+ "./events": {
50
+ "types": "./dist/events.d.ts",
51
+ "import": "./dist/events.js"
52
+ },
53
+ "./knobs": {
54
+ "types": "./dist/knobs.d.ts",
55
+ "import": "./dist/knobs.js"
56
+ }
57
+ },
58
+ "files": [
59
+ "dist",
60
+ "LICENSE",
61
+ "NOTICE"
62
+ ],
63
+ "publishConfig": {
64
+ "access": "public"
65
+ },
66
+ "peerDependencies": {
67
+ "@margoengine/core": "^1.0.0"
68
+ },
69
+ "scripts": {
70
+ "build": "node ../../scripts/build-optional.js quality",
71
+ "test": "npm run build && node --test test/*.test.js ../../examples/package-benchmarks/proofs/package-guard.mjs",
72
+ "test:gpu": "cd ../.. && node packages/quality/test/browser-check.mjs && node packages/quality/test/ssaa-browser.mjs && node packages/quality/test/features-browser.mjs && node packages/quality/test/power-browser.mjs && node packages/quality/test/scene-owner-browser.mjs && node packages/quality/test/demand-browser.mjs && node packages/quality/test/events-browser.mjs && node packages/quality/test/knobs-browser.mjs",
73
+ "prepack": "npm run build"
74
+ }
75
+ }