@aardworx/wombat.rendering 0.19.12 → 0.19.13

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.
@@ -16,11 +16,15 @@ export declare class DerivedUniformsScene {
16
16
  * scene-wide; records partition by chunk so each dispatch binds
17
17
  * the right chunk's main heap. */
18
18
  private readonly recordsByChunk;
19
- /** Scene-wide CHAIN records (GPU transform propagation). Dispatched BEFORE
20
- * the §7 per-chunk passes they write per-RO Model constituents that §7
21
- * then reads. Scene-wide (not per-chunk) because they target the shared
22
- * constituents buffer, not any chunk's main heap. */
23
- readonly chainRecords: RecordsBuffer;
19
+ /** CHAIN records partitioned by trie LEVEL (GPU transform propagation). A
20
+ * trie node at level L computes `link · parentNode.world` reading its
21
+ * parent (level L-1) output so levels must dispatch in ascending order,
22
+ * BEFORE the §7 per-chunk passes. Scene-wide: they target the shared
23
+ * constituents buffer (per-node Model), not any chunk's main heap.
24
+ * Prefix-sharing: sibling chains share trie nodes (see TrafoTree). */
25
+ private readonly chainByLevel;
26
+ /** The suffix trie that dedups shared ancestor sub-chains across ROs. */
27
+ readonly trafoTree: TrafoTree;
24
28
  readonly dispatcher: DerivedUniformsDispatcher;
25
29
  /** Constituents storage GPU buffer (`array<vec2<f32>>` — df32 mat4 halves). */
26
30
  constituentsBuf: GPUBuffer;
@@ -30,6 +34,8 @@ export declare class DerivedUniformsScene {
30
34
  /** Bumped each time a shared GPU buffer is replaced. */
31
35
  bufferEpoch: number;
32
36
  constructor(device: GPUDevice, opts?: DerivedUniformsSceneOptions);
37
+ /** Get-or-create the CHAIN records buffer for trie `level`. */
38
+ chainRecordsFor(level: number): RecordsBuffer;
33
39
  /** Register (or replace) the GPUBuffer getter for a chunk's main
34
40
  * heap. Called by the scene factory at construction and whenever
35
41
  * a new chunk opens or an existing chunk's buffer reallocates. */
@@ -55,6 +61,29 @@ export declare class DerivedUniformsScene {
55
61
  encode(enc: GPUCommandEncoder): boolean;
56
62
  dispose(): void;
57
63
  }
64
+ export interface TrieNode {
65
+ readonly id: number;
66
+ readonly key: string;
67
+ readonly modelPair: PairedSlots;
68
+ readonly level: number;
69
+ readonly parent: TrieNode | undefined;
70
+ refcount: number;
71
+ }
72
+ export declare class TrafoTree {
73
+ private readonly scene;
74
+ private readonly byKey;
75
+ private nextId;
76
+ constructor(scene: DerivedUniformsScene);
77
+ /** Number of live trie nodes — diagnostics / tests (prefix-sharing check). */
78
+ get nodeCount(): number;
79
+ /** Intern a chain (array order `[leaf, …, root]`); returns the LEAF trie node
80
+ * whose Model is the full product. increfs every node on the path so shared
81
+ * ancestor nodes survive while any RO references them. */
82
+ intern(linkPairs: readonly PairedSlots[]): TrieNode;
83
+ /** Decref every node on the leaf→root path; free those that hit 0. */
84
+ release(leaf: TrieNode): void;
85
+ private internOne;
86
+ }
58
87
  export interface RoDerivedRequest {
59
88
  /** Derived rules to install, keyed by the uniform name each produces. */
60
89
  readonly rules: ReadonlyMap<string, DerivedRule>;
@@ -90,9 +119,9 @@ export interface RoRegistration {
90
119
  readonly ruleHashes: readonly string[];
91
120
  /** Chunk this registration was placed into — used by deregister. */
92
121
  readonly chunkIdx: number;
93
- /** Per-RO Model output constituent pair (transform propagation); freed on
122
+ /** This RO's leaf trie node (transform propagation); its path is decref'd on
94
123
  * deregister. Present iff the request carried a `modelChain`. */
95
- readonly modelPair?: PairedSlots;
124
+ readonly modelLeaf?: TrieNode;
96
125
  }
97
126
  export declare function registerRoDerivations(scene: DerivedUniformsScene, owner: object, req: RoDerivedRequest): RoRegistration;
98
127
  export declare function deregisterRoDerivations(scene: DerivedUniformsScene, reg: RoRegistration): void;
@@ -1 +1 @@
1
- {"version":3,"file":"sceneIntegration.d.ts","sourceRoot":"","sources":["../../../src/runtime/derivedUniforms/sceneIntegration.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,KAAK,EAAE,OA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AAC;IACpD,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;sEACkE;IAClE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,gBAAgB,GACpB,cAAc,CAiFhB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAK9F"}
@@ -31,11 +31,15 @@ export class DerivedUniformsScene {
31
31
  * scene-wide; records partition by chunk so each dispatch binds
32
32
  * the right chunk's main heap. */
33
33
  recordsByChunk = new Map();
34
- /** Scene-wide CHAIN records (GPU transform propagation). Dispatched BEFORE
35
- * the §7 per-chunk passes they write per-RO Model constituents that §7
36
- * then reads. Scene-wide (not per-chunk) because they target the shared
37
- * constituents buffer, not any chunk's main heap. */
38
- chainRecords = new RecordsBuffer();
34
+ /** CHAIN records partitioned by trie LEVEL (GPU transform propagation). A
35
+ * trie node at level L computes `link · parentNode.world` reading its
36
+ * parent (level L-1) output so levels must dispatch in ascending order,
37
+ * BEFORE the §7 per-chunk passes. Scene-wide: they target the shared
38
+ * constituents buffer (per-node Model), not any chunk's main heap.
39
+ * Prefix-sharing: sibling chains share trie nodes (see TrafoTree). */
40
+ chainByLevel = new Map();
41
+ /** The suffix trie that dedups shared ancestor sub-chains across ROs. */
42
+ trafoTree;
39
43
  dispatcher;
40
44
  /** Constituents storage GPU buffer (`array<vec2<f32>>` — df32 mat4 halves). */
41
45
  constituentsBuf;
@@ -56,6 +60,16 @@ export class DerivedUniformsScene {
56
60
  this.dispatcher = new DerivedUniformsDispatcher(device, {
57
61
  constituentsBuf: () => this.constituentsBuf,
58
62
  });
63
+ this.trafoTree = new TrafoTree(this);
64
+ }
65
+ /** Get-or-create the CHAIN records buffer for trie `level`. */
66
+ chainRecordsFor(level) {
67
+ let r = this.chainByLevel.get(level);
68
+ if (r === undefined) {
69
+ r = new RecordsBuffer();
70
+ this.chainByLevel.set(level, r);
71
+ }
72
+ return r;
59
73
  }
60
74
  /** Register (or replace) the GPUBuffer getter for a chunk's main
61
75
  * heap. Called by the scene factory at construction and whenever
@@ -130,16 +144,23 @@ export class DerivedUniformsScene {
130
144
  * main heap buffer. */
131
145
  encode(enc) {
132
146
  let any = false;
133
- // Phase 1: chain pass — writes per-RO Model constituents (fwd+inv) into the
134
- // shared constituents buffer. Must run BEFORE the §7 passes that read them.
135
- // The MainHeap binding is unused by the chain arm; bind any registered heap.
136
- if (this.chainRecords.recordCount > 0) {
147
+ // Chain pass — writes per-RO/per-node Model constituents (fwd+inv) into the
148
+ // shared constituents buffer. Dispatch trie LEVELS in ascending order: a
149
+ // level-L node reads its parent's (level L-1) output. Must run BEFORE the
150
+ // §7 passes that read the Models. MainHeap binding is unused here; bind any.
151
+ const levels = [...this.chainByLevel.keys()].sort((a, b) => a - b);
152
+ if (levels.length > 0) {
137
153
  const anyHeap = this.firstHeapGetter();
138
154
  if (anyHeap === undefined) {
139
155
  throw new Error("derivedUniforms.encode: chain records present but no chunk main-heap registered to bind.");
140
156
  }
141
- if (this.dispatcher.encodeChunk(enc, this.registry, this.chainRecords, anyHeap))
142
- any = true;
157
+ for (const lvl of levels) {
158
+ const recs = this.chainByLevel.get(lvl);
159
+ if (recs.recordCount === 0)
160
+ continue;
161
+ if (this.dispatcher.encodeChunk(enc, this.registry, recs, anyHeap))
162
+ any = true;
163
+ }
143
164
  }
144
165
  // Phase 2: §7 per-chunk (reads constituents incl. the chain-written Model).
145
166
  for (const [chunkIdx, records] of this.recordsByChunk) {
@@ -160,6 +181,67 @@ export class DerivedUniformsScene {
160
181
  this.constituentsBuf.destroy();
161
182
  }
162
183
  }
184
+ export class TrafoTree {
185
+ scene;
186
+ byKey = new Map();
187
+ nextId = 0;
188
+ constructor(scene) {
189
+ this.scene = scene;
190
+ }
191
+ /** Number of live trie nodes — diagnostics / tests (prefix-sharing check). */
192
+ get nodeCount() { return this.byKey.size; }
193
+ /** Intern a chain (array order `[leaf, …, root]`); returns the LEAF trie node
194
+ * whose Model is the full product. increfs every node on the path so shared
195
+ * ancestor nodes survive while any RO references them. */
196
+ intern(linkPairs) {
197
+ let parent;
198
+ // Root end (last) → leaf (first), so shared ancestor suffixes share nodes.
199
+ for (let i = linkPairs.length - 1; i >= 0; i--) {
200
+ parent = this.internOne(parent, linkPairs[i]);
201
+ }
202
+ if (parent === undefined)
203
+ throw new Error("TrafoTree.intern: empty chain");
204
+ return parent;
205
+ }
206
+ /** Decref every node on the leaf→root path; free those that hit 0. */
207
+ release(leaf) {
208
+ let n = leaf;
209
+ while (n !== undefined) {
210
+ const parent = n.parent;
211
+ if (--n.refcount === 0) {
212
+ this.byKey.delete(n.key);
213
+ this.scene.chainRecordsFor(n.level).removeAllForOwner(n);
214
+ this.scene.constituents.freeOutputPair(n.modelPair);
215
+ }
216
+ n = parent;
217
+ }
218
+ }
219
+ internOne(parent, link) {
220
+ const key = `${parent?.id ?? -1}:${link.fwd}`;
221
+ const existing = this.byKey.get(key);
222
+ if (existing !== undefined) {
223
+ existing.refcount++;
224
+ return existing;
225
+ }
226
+ const level = parent === undefined ? 0 : parent.level + 1;
227
+ const modelPair = this.scene.constituents.allocOutputPair();
228
+ const node = { id: this.nextId++, key, modelPair, level, parent, refcount: 1 };
229
+ this.byKey.set(key, node);
230
+ const h = (s) => makeHandle(SlotTag.Constituent, s);
231
+ const recs = this.scene.chainRecordsFor(level);
232
+ // node.world.fwd = link.fwd · parent.world.fwd (just link at the root end).
233
+ // node.world.inv = parent.world.inv · link.inv (reversed; just link at root).
234
+ if (parent === undefined) {
235
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.fwd), [1, h(link.fwd)]);
236
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.inv), [1, h(link.inv)]);
237
+ }
238
+ else {
239
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.fwd), [2, h(link.fwd), h(parent.modelPair.fwd)]);
240
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.inv), [2, h(parent.modelPair.inv), h(link.inv)]);
241
+ }
242
+ return node;
243
+ }
244
+ }
163
245
  export function registerRoDerivations(scene, owner, req) {
164
246
  if (req.rules.size === 0 && req.modelChain === undefined) {
165
247
  return { owner, constituentAvals: [], ruleHashes: [], chunkIdx: req.chunkIdx };
@@ -204,19 +286,17 @@ export function registerRoDerivations(scene, owner, req) {
204
286
  // from its ancestor chain, and point §7's `Model` leaf at it. The chain pass
205
287
  // (a separate, earlier dispatch) writes the fwd half from the links and the
206
288
  // inv half from the reversed inverse links.
207
- let modelPair;
208
- if (req.modelChain !== undefined) {
209
- modelPair = scene.constituents.allocOutputPair();
210
- pairByName.set("Model", modelPair);
289
+ let modelLeaf;
290
+ if (req.modelChain !== undefined && req.modelChain.length > 0) {
211
291
  const linkPairs = req.modelChain.map((av) => {
212
292
  acquiredAvals.push(av);
213
293
  return scene.constituents.acquire(av);
214
294
  });
215
- const n = linkPairs.length;
216
- // Model.fwd = link0·link1·…·link(n-1) (forward order, fwd slots).
217
- scene.chainRecords.add(owner, CHAIN_RULE_ID, makeHandle(SlotTag.Constituent, modelPair.fwd), [n, ...linkPairs.map((p) => makeHandle(SlotTag.Constituent, p.fwd))]);
218
- // Model.inv = link(n-1)⁻¹·…·link0⁻¹ (reversed order, inv slots).
219
- scene.chainRecords.add(owner, CHAIN_RULE_ID, makeHandle(SlotTag.Constituent, modelPair.inv), [n, ...linkPairs.slice().reverse().map((p) => makeHandle(SlotTag.Constituent, p.inv))]);
295
+ // Intern the chain into the suffix trie — siblings share ancestor nodes,
296
+ // each composed once (link · parent.world) at its level. The RO's Model is
297
+ // the leaf node's per-node Model constituent.
298
+ modelLeaf = scene.trafoTree.intern(linkPairs);
299
+ pairByName.set("Model", modelLeaf.modelPair);
220
300
  }
221
301
  for (const [outName, rule] of req.rules) {
222
302
  // `flatten` returns the same Expr object when nothing was substituted (the common case —
@@ -237,17 +317,16 @@ export function registerRoDerivations(scene, owner, req) {
237
317
  scene.ensureConstituentsCapacity(scene.constituents.slotCount * DF32_MAT4_BYTES);
238
318
  return {
239
319
  owner, constituentAvals: acquiredAvals, ruleHashes, chunkIdx: req.chunkIdx,
240
- ...(modelPair !== undefined ? { modelPair } : {}),
320
+ ...(modelLeaf !== undefined ? { modelLeaf } : {}),
241
321
  };
242
322
  }
243
323
  export function deregisterRoDerivations(scene, reg) {
244
324
  scene.recordsFor(reg.chunkIdx).removeAllForOwner(reg.owner);
245
- scene.chainRecords.removeAllForOwner(reg.owner);
246
325
  for (const h of reg.ruleHashes)
247
326
  scene.registry.release(h);
248
327
  for (const av of reg.constituentAvals)
249
328
  scene.constituents.release(av);
250
- if (reg.modelPair !== undefined)
251
- scene.constituents.freeOutputPair(reg.modelPair);
329
+ if (reg.modelLeaf !== undefined)
330
+ scene.trafoTree.release(reg.modelLeaf);
252
331
  }
253
332
  //# sourceMappingURL=sceneIntegration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sceneIntegration.js","sourceRoot":"","sources":["../../../src/runtime/derivedUniforms/sceneIntegration.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,yDAAyD;AACzD,EAAE;AACF,uEAAuE;AACvE,0FAA0F;AAC1F,wEAAwE;AACxE,8EAA8E;AAC9E,sDAAsD;AACtD,2CAA2C;AAI3C,OAAO,EACL,gBAAgB,EAAE,eAAe,GAElC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,c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AAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtE,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACpF,CAAC"}
1
+ {"version":3,"file":"sceneIntegration.js","sourceRoot":"","sources":["../../../src/runtime/derivedUniforms/sceneIntegration.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,yDAAyD;AACzD,EAAE;AACF,uEAAuE;AACvE,0FAA0F;AAC1F,wEAAwE;AACxE,8EAA8E;AAC9E,sDAAsD;AACtD,2CAA2C;AAI3C,OAAO,EACL,gBAAgB,EAAE,eAAe,GAElC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AAMzD,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAY;IAClB,YAAY,CAAmB;IAC/B,QAAQ,GAAG,IAAI,sBAAsB,EAAE,CAAC;IACjD;;uCAEmC;IAClB,cAAc,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnE;;;;;2EAKuE;IACtD,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;IACjE,yEAAyE;IAChE,SAAS,CAAY;IACrB,UAAU,CAA4B;IAC/C,+EAA+E;IAC/E,eAAe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AAQ,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5D,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,UAAU;QAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1D,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,gBAAgB;QAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtE,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC1E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aardworx/wombat.rendering",
3
- "version": "0.19.12",
3
+ "version": "0.19.13",
4
4
  "description": "WebGPU rendering layer for the Wombat TypeScript stack — RenderObject/RenderTask/runtime + window glue, port of Aardvark.Rendering's lower layers on top of WebGPU and wombat.shader.",
5
5
  "license": "MIT",
6
6
  "author": "krauthaufen",
@@ -42,11 +42,15 @@ export class DerivedUniformsScene {
42
42
  * scene-wide; records partition by chunk so each dispatch binds
43
43
  * the right chunk's main heap. */
44
44
  private readonly recordsByChunk = new Map<number, RecordsBuffer>();
45
- /** Scene-wide CHAIN records (GPU transform propagation). Dispatched BEFORE
46
- * the §7 per-chunk passes they write per-RO Model constituents that §7
47
- * then reads. Scene-wide (not per-chunk) because they target the shared
48
- * constituents buffer, not any chunk's main heap. */
49
- readonly chainRecords = new RecordsBuffer();
45
+ /** CHAIN records partitioned by trie LEVEL (GPU transform propagation). A
46
+ * trie node at level L computes `link · parentNode.world` reading its
47
+ * parent (level L-1) output so levels must dispatch in ascending order,
48
+ * BEFORE the §7 per-chunk passes. Scene-wide: they target the shared
49
+ * constituents buffer (per-node Model), not any chunk's main heap.
50
+ * Prefix-sharing: sibling chains share trie nodes (see TrafoTree). */
51
+ private readonly chainByLevel = new Map<number, RecordsBuffer>();
52
+ /** The suffix trie that dedups shared ancestor sub-chains across ROs. */
53
+ readonly trafoTree: TrafoTree;
50
54
  readonly dispatcher: DerivedUniformsDispatcher;
51
55
  /** Constituents storage GPU buffer (`array<vec2<f32>>` — df32 mat4 halves). */
52
56
  constituentsBuf: GPUBuffer;
@@ -68,6 +72,17 @@ export class DerivedUniformsScene {
68
72
  this.dispatcher = new DerivedUniformsDispatcher(device, {
69
73
  constituentsBuf: () => this.constituentsBuf,
70
74
  });
75
+ this.trafoTree = new TrafoTree(this);
76
+ }
77
+
78
+ /** Get-or-create the CHAIN records buffer for trie `level`. */
79
+ chainRecordsFor(level: number): RecordsBuffer {
80
+ let r = this.chainByLevel.get(level);
81
+ if (r === undefined) {
82
+ r = new RecordsBuffer();
83
+ this.chainByLevel.set(level, r);
84
+ }
85
+ return r;
71
86
  }
72
87
 
73
88
  /** Register (or replace) the GPUBuffer getter for a chunk's main
@@ -147,15 +162,21 @@ export class DerivedUniformsScene {
147
162
  * main heap buffer. */
148
163
  encode(enc: GPUCommandEncoder): boolean {
149
164
  let any = false;
150
- // Phase 1: chain pass — writes per-RO Model constituents (fwd+inv) into the
151
- // shared constituents buffer. Must run BEFORE the §7 passes that read them.
152
- // The MainHeap binding is unused by the chain arm; bind any registered heap.
153
- if (this.chainRecords.recordCount > 0) {
165
+ // Chain pass — writes per-RO/per-node Model constituents (fwd+inv) into the
166
+ // shared constituents buffer. Dispatch trie LEVELS in ascending order: a
167
+ // level-L node reads its parent's (level L-1) output. Must run BEFORE the
168
+ // §7 passes that read the Models. MainHeap binding is unused here; bind any.
169
+ const levels = [...this.chainByLevel.keys()].sort((a, b) => a - b);
170
+ if (levels.length > 0) {
154
171
  const anyHeap = this.firstHeapGetter();
155
172
  if (anyHeap === undefined) {
156
173
  throw new Error("derivedUniforms.encode: chain records present but no chunk main-heap registered to bind.");
157
174
  }
158
- if (this.dispatcher.encodeChunk(enc, this.registry, this.chainRecords, anyHeap)) any = true;
175
+ for (const lvl of levels) {
176
+ const recs = this.chainByLevel.get(lvl)!;
177
+ if (recs.recordCount === 0) continue;
178
+ if (this.dispatcher.encodeChunk(enc, this.registry, recs, anyHeap)) any = true;
179
+ }
159
180
  }
160
181
  // Phase 2: §7 per-chunk (reads constituents incl. the chain-written Model).
161
182
  for (const [chunkIdx, records] of this.recordsByChunk) {
@@ -178,6 +199,84 @@ export class DerivedUniformsScene {
178
199
  }
179
200
  }
180
201
 
202
+ // ─── Trafo suffix-trie (prefix sharing) ───────────────────────────────
203
+ //
204
+ // Dedups shared ancestor sub-chains across ROs. Each RO's chain is interned
205
+ // from the ROOT end, so sibling chains share trie nodes for their common
206
+ // ancestor suffix. A trie node owns a per-node Model constituent (fwd+inv) and
207
+ // two CHAIN records computing `node.world = link · parent.world` (and the
208
+ // reversed inverse) — at the node's depth LEVEL, so a shared ancestor is
209
+ // composed ONCE and every descendant reads it. Levels dispatch in ascending
210
+ // order (DerivedUniformsScene.encode). Refcounted: a node is freed when no RO
211
+ // path references it. See docs/gpu-transform-propagation.md (Phase 2).
212
+
213
+ export interface TrieNode {
214
+ readonly id: number;
215
+ readonly key: string;
216
+ readonly modelPair: PairedSlots;
217
+ readonly level: number;
218
+ readonly parent: TrieNode | undefined;
219
+ refcount: number;
220
+ }
221
+
222
+ export class TrafoTree {
223
+ private readonly byKey = new Map<string, TrieNode>();
224
+ private nextId = 0;
225
+ constructor(private readonly scene: DerivedUniformsScene) {}
226
+
227
+ /** Number of live trie nodes — diagnostics / tests (prefix-sharing check). */
228
+ get nodeCount(): number { return this.byKey.size; }
229
+
230
+ /** Intern a chain (array order `[leaf, …, root]`); returns the LEAF trie node
231
+ * whose Model is the full product. increfs every node on the path so shared
232
+ * ancestor nodes survive while any RO references them. */
233
+ intern(linkPairs: readonly PairedSlots[]): TrieNode {
234
+ let parent: TrieNode | undefined;
235
+ // Root end (last) → leaf (first), so shared ancestor suffixes share nodes.
236
+ for (let i = linkPairs.length - 1; i >= 0; i--) {
237
+ parent = this.internOne(parent, linkPairs[i]!);
238
+ }
239
+ if (parent === undefined) throw new Error("TrafoTree.intern: empty chain");
240
+ return parent;
241
+ }
242
+
243
+ /** Decref every node on the leaf→root path; free those that hit 0. */
244
+ release(leaf: TrieNode): void {
245
+ let n: TrieNode | undefined = leaf;
246
+ while (n !== undefined) {
247
+ const parent: TrieNode | undefined = n.parent;
248
+ if (--n.refcount === 0) {
249
+ this.byKey.delete(n.key);
250
+ this.scene.chainRecordsFor(n.level).removeAllForOwner(n);
251
+ this.scene.constituents.freeOutputPair(n.modelPair);
252
+ }
253
+ n = parent;
254
+ }
255
+ }
256
+
257
+ private internOne(parent: TrieNode | undefined, link: PairedSlots): TrieNode {
258
+ const key = `${parent?.id ?? -1}:${link.fwd}`;
259
+ const existing = this.byKey.get(key);
260
+ if (existing !== undefined) { existing.refcount++; return existing; }
261
+ const level = parent === undefined ? 0 : parent.level + 1;
262
+ const modelPair = this.scene.constituents.allocOutputPair();
263
+ const node: TrieNode = { id: this.nextId++, key, modelPair, level, parent, refcount: 1 };
264
+ this.byKey.set(key, node);
265
+ const h = (s: number): number => makeHandle(SlotTag.Constituent, s);
266
+ const recs = this.scene.chainRecordsFor(level);
267
+ // node.world.fwd = link.fwd · parent.world.fwd (just link at the root end).
268
+ // node.world.inv = parent.world.inv · link.inv (reversed; just link at root).
269
+ if (parent === undefined) {
270
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.fwd), [1, h(link.fwd)]);
271
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.inv), [1, h(link.inv)]);
272
+ } else {
273
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.fwd), [2, h(link.fwd), h(parent.modelPair.fwd)]);
274
+ recs.add(node, CHAIN_RULE_ID, h(modelPair.inv), [2, h(parent.modelPair.inv), h(link.inv)]);
275
+ }
276
+ return node;
277
+ }
278
+ }
279
+
181
280
  // ─── Per-RO registration ──────────────────────────────────────────────
182
281
 
183
282
  export interface RoDerivedRequest {
@@ -216,9 +315,9 @@ export interface RoRegistration {
216
315
  readonly ruleHashes: readonly string[];
217
316
  /** Chunk this registration was placed into — used by deregister. */
218
317
  readonly chunkIdx: number;
219
- /** Per-RO Model output constituent pair (transform propagation); freed on
318
+ /** This RO's leaf trie node (transform propagation); its path is decref'd on
220
319
  * deregister. Present iff the request carried a `modelChain`. */
221
- readonly modelPair?: PairedSlots;
320
+ readonly modelLeaf?: TrieNode;
222
321
  }
223
322
 
224
323
  export function registerRoDerivations(
@@ -271,21 +370,17 @@ export function registerRoDerivations(
271
370
  // from its ancestor chain, and point §7's `Model` leaf at it. The chain pass
272
371
  // (a separate, earlier dispatch) writes the fwd half from the links and the
273
372
  // inv half from the reversed inverse links.
274
- let modelPair: PairedSlots | undefined;
275
- if (req.modelChain !== undefined) {
276
- modelPair = scene.constituents.allocOutputPair();
277
- pairByName.set("Model", modelPair);
373
+ let modelLeaf: TrieNode | undefined;
374
+ if (req.modelChain !== undefined && req.modelChain.length > 0) {
278
375
  const linkPairs = req.modelChain.map((av) => {
279
376
  acquiredAvals.push(av);
280
377
  return scene.constituents.acquire(av);
281
378
  });
282
- const n = linkPairs.length;
283
- // Model.fwd = link0·link1·…·link(n-1) (forward order, fwd slots).
284
- scene.chainRecords.add(owner, CHAIN_RULE_ID, makeHandle(SlotTag.Constituent, modelPair.fwd),
285
- [n, ...linkPairs.map((p) => makeHandle(SlotTag.Constituent, p.fwd))]);
286
- // Model.inv = link(n-1)⁻¹·…·link0⁻¹ (reversed order, inv slots).
287
- scene.chainRecords.add(owner, CHAIN_RULE_ID, makeHandle(SlotTag.Constituent, modelPair.inv),
288
- [n, ...linkPairs.slice().reverse().map((p) => makeHandle(SlotTag.Constituent, p.inv))]);
379
+ // Intern the chain into the suffix trie — siblings share ancestor nodes,
380
+ // each composed once (link · parent.world) at its level. The RO's Model is
381
+ // the leaf node's per-node Model constituent.
382
+ modelLeaf = scene.trafoTree.intern(linkPairs);
383
+ pairByName.set("Model", modelLeaf.modelPair);
289
384
  }
290
385
 
291
386
  for (const [outName, rule] of req.rules) {
@@ -308,14 +403,13 @@ export function registerRoDerivations(
308
403
  scene.ensureConstituentsCapacity(scene.constituents.slotCount * DF32_MAT4_BYTES);
309
404
  return {
310
405
  owner, constituentAvals: acquiredAvals, ruleHashes, chunkIdx: req.chunkIdx,
311
- ...(modelPair !== undefined ? { modelPair } : {}),
406
+ ...(modelLeaf !== undefined ? { modelLeaf } : {}),
312
407
  };
313
408
  }
314
409
 
315
410
  export function deregisterRoDerivations(scene: DerivedUniformsScene, reg: RoRegistration): void {
316
411
  scene.recordsFor(reg.chunkIdx).removeAllForOwner(reg.owner);
317
- scene.chainRecords.removeAllForOwner(reg.owner);
318
412
  for (const h of reg.ruleHashes) scene.registry.release(h);
319
413
  for (const av of reg.constituentAvals) scene.constituents.release(av);
320
- if (reg.modelPair !== undefined) scene.constituents.freeOutputPair(reg.modelPair);
414
+ if (reg.modelLeaf !== undefined) scene.trafoTree.release(reg.modelLeaf);
321
415
  }