@aardworx/wombat.rendering 0.8.0 → 0.9.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.
Files changed (136) hide show
  1. package/dist/core/command.d.ts +7 -9
  2. package/dist/core/command.d.ts.map +1 -1
  3. package/dist/core/renderTask.d.ts +64 -1
  4. package/dist/core/renderTask.d.ts.map +1 -1
  5. package/dist/core/renderTask.js +3 -1
  6. package/dist/core/renderTask.js.map +1 -1
  7. package/dist/resources/preparedRenderObject.js +3 -3
  8. package/dist/resources/preparedRenderObject.js.map +1 -1
  9. package/dist/resources/uniformBuffer.d.ts.map +1 -1
  10. package/dist/resources/uniformBuffer.js +17 -0
  11. package/dist/resources/uniformBuffer.js.map +1 -1
  12. package/dist/runtime/derivedUniforms/dispatch.d.ts +105 -0
  13. package/dist/runtime/derivedUniforms/dispatch.d.ts.map +1 -0
  14. package/dist/runtime/derivedUniforms/dispatch.js +355 -0
  15. package/dist/runtime/derivedUniforms/dispatch.js.map +1 -0
  16. package/dist/runtime/derivedUniforms/index.d.ts +6 -0
  17. package/dist/runtime/derivedUniforms/index.d.ts.map +1 -0
  18. package/dist/runtime/derivedUniforms/index.js +26 -0
  19. package/dist/runtime/derivedUniforms/index.js.map +1 -0
  20. package/dist/runtime/derivedUniforms/recipes.d.ts +42 -0
  21. package/dist/runtime/derivedUniforms/recipes.d.ts.map +1 -0
  22. package/dist/runtime/derivedUniforms/recipes.js +134 -0
  23. package/dist/runtime/derivedUniforms/recipes.js.map +1 -0
  24. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts +56 -0
  25. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts.map +1 -0
  26. package/dist/runtime/derivedUniforms/sceneIntegration.js +171 -0
  27. package/dist/runtime/derivedUniforms/sceneIntegration.js.map +1 -0
  28. package/dist/runtime/derivedUniforms/slotId.d.ts +15 -0
  29. package/dist/runtime/derivedUniforms/slotId.d.ts.map +1 -0
  30. package/dist/runtime/derivedUniforms/slotId.js +30 -0
  31. package/dist/runtime/derivedUniforms/slotId.js.map +1 -0
  32. package/dist/runtime/derivedUniforms/slots.d.ts +49 -0
  33. package/dist/runtime/derivedUniforms/slots.d.ts.map +1 -0
  34. package/dist/runtime/derivedUniforms/slots.js +123 -0
  35. package/dist/runtime/derivedUniforms/slots.js.map +1 -0
  36. package/dist/runtime/derivedUniforms/uberKernel.wgsl.d.ts +13 -0
  37. package/dist/runtime/derivedUniforms/uberKernel.wgsl.d.ts.map +1 -0
  38. package/dist/runtime/derivedUniforms/uberKernel.wgsl.js +218 -0
  39. package/dist/runtime/derivedUniforms/uberKernel.wgsl.js.map +1 -0
  40. package/dist/runtime/flattenTree.d.ts +5 -0
  41. package/dist/runtime/flattenTree.d.ts.map +1 -0
  42. package/dist/runtime/flattenTree.js +45 -0
  43. package/dist/runtime/flattenTree.js.map +1 -0
  44. package/dist/runtime/heapAdapter.d.ts +16 -0
  45. package/dist/runtime/heapAdapter.d.ts.map +1 -0
  46. package/dist/runtime/heapAdapter.js +263 -0
  47. package/dist/runtime/heapAdapter.js.map +1 -0
  48. package/dist/runtime/heapEffect.d.ts +235 -0
  49. package/dist/runtime/heapEffect.d.ts.map +1 -0
  50. package/dist/runtime/heapEffect.js +518 -0
  51. package/dist/runtime/heapEffect.js.map +1 -0
  52. package/dist/runtime/heapEffectIR.d.ts +34 -0
  53. package/dist/runtime/heapEffectIR.d.ts.map +1 -0
  54. package/dist/runtime/heapEffectIR.js +1161 -0
  55. package/dist/runtime/heapEffectIR.js.map +1 -0
  56. package/dist/runtime/heapEligibility.d.ts +9 -0
  57. package/dist/runtime/heapEligibility.d.ts.map +1 -0
  58. package/dist/runtime/heapEligibility.js +195 -0
  59. package/dist/runtime/heapEligibility.js.map +1 -0
  60. package/dist/runtime/heapScene.d.ts +240 -31
  61. package/dist/runtime/heapScene.d.ts.map +1 -1
  62. package/dist/runtime/heapScene.js +3334 -265
  63. package/dist/runtime/heapScene.js.map +1 -1
  64. package/dist/runtime/heapShaderFamily.d.ts +132 -0
  65. package/dist/runtime/heapShaderFamily.d.ts.map +1 -0
  66. package/dist/runtime/heapShaderFamily.js +866 -0
  67. package/dist/runtime/heapShaderFamily.js.map +1 -0
  68. package/dist/runtime/hybridScene.d.ts +133 -0
  69. package/dist/runtime/hybridScene.d.ts.map +1 -0
  70. package/dist/runtime/hybridScene.js +159 -0
  71. package/dist/runtime/hybridScene.js.map +1 -0
  72. package/dist/runtime/index.d.ts +8 -0
  73. package/dist/runtime/index.d.ts.map +1 -1
  74. package/dist/runtime/index.js +9 -0
  75. package/dist/runtime/index.js.map +1 -1
  76. package/dist/runtime/renderTask.d.ts +21 -4
  77. package/dist/runtime/renderTask.d.ts.map +1 -1
  78. package/dist/runtime/renderTask.js +127 -32
  79. package/dist/runtime/renderTask.js.map +1 -1
  80. package/dist/runtime/runtime.d.ts +33 -3
  81. package/dist/runtime/runtime.d.ts.map +1 -1
  82. package/dist/runtime/runtime.js +12 -3
  83. package/dist/runtime/runtime.js.map +1 -1
  84. package/dist/runtime/scenePass.d.ts +28 -3
  85. package/dist/runtime/scenePass.d.ts.map +1 -1
  86. package/dist/runtime/scenePass.js +37 -4
  87. package/dist/runtime/scenePass.js.map +1 -1
  88. package/dist/runtime/textureAtlas/atlasMipGutterKernel.d.ts +35 -0
  89. package/dist/runtime/textureAtlas/atlasMipGutterKernel.d.ts.map +1 -0
  90. package/dist/runtime/textureAtlas/atlasMipGutterKernel.js +247 -0
  91. package/dist/runtime/textureAtlas/atlasMipGutterKernel.js.map +1 -0
  92. package/dist/runtime/textureAtlas/atlasPool.d.ts +240 -0
  93. package/dist/runtime/textureAtlas/atlasPool.d.ts.map +1 -0
  94. package/dist/runtime/textureAtlas/atlasPool.js +798 -0
  95. package/dist/runtime/textureAtlas/atlasPool.js.map +1 -0
  96. package/dist/runtime/textureAtlas/bvhTree2d.d.ts +33 -0
  97. package/dist/runtime/textureAtlas/bvhTree2d.d.ts.map +1 -0
  98. package/dist/runtime/textureAtlas/bvhTree2d.js +501 -0
  99. package/dist/runtime/textureAtlas/bvhTree2d.js.map +1 -0
  100. package/dist/runtime/textureAtlas/packer.d.ts +50 -0
  101. package/dist/runtime/textureAtlas/packer.d.ts.map +1 -0
  102. package/dist/runtime/textureAtlas/packer.js +390 -0
  103. package/dist/runtime/textureAtlas/packer.js.map +1 -0
  104. package/dist/window/loop.d.ts +14 -0
  105. package/dist/window/loop.d.ts.map +1 -1
  106. package/dist/window/loop.js +18 -5
  107. package/dist/window/loop.js.map +1 -1
  108. package/package.json +5 -4
  109. package/src/core/command.ts +9 -9
  110. package/src/core/renderTask.ts +55 -2
  111. package/src/resources/preparedRenderObject.ts +3 -3
  112. package/src/resources/uniformBuffer.ts +15 -0
  113. package/src/runtime/derivedUniforms/dispatch.ts +407 -0
  114. package/src/runtime/derivedUniforms/index.ts +52 -0
  115. package/src/runtime/derivedUniforms/recipes.ts +159 -0
  116. package/src/runtime/derivedUniforms/sceneIntegration.ts +239 -0
  117. package/src/runtime/derivedUniforms/slotId.ts +35 -0
  118. package/src/runtime/derivedUniforms/slots.ts +155 -0
  119. package/src/runtime/derivedUniforms/uberKernel.wgsl.ts +220 -0
  120. package/src/runtime/flattenTree.ts +46 -0
  121. package/src/runtime/heapAdapter.ts +314 -0
  122. package/src/runtime/heapEffect.ts +719 -0
  123. package/src/runtime/heapEffectIR.ts +1211 -0
  124. package/src/runtime/heapEligibility.ts +189 -0
  125. package/src/runtime/heapScene.ts +3981 -349
  126. package/src/runtime/heapShaderFamily.ts +1102 -0
  127. package/src/runtime/hybridScene.ts +310 -0
  128. package/src/runtime/index.ts +46 -0
  129. package/src/runtime/renderTask.ts +167 -32
  130. package/src/runtime/runtime.ts +37 -4
  131. package/src/runtime/scenePass.ts +39 -4
  132. package/src/runtime/textureAtlas/atlasMipGutterKernel.ts +291 -0
  133. package/src/runtime/textureAtlas/atlasPool.ts +991 -0
  134. package/src/runtime/textureAtlas/bvhTree2d.ts +530 -0
  135. package/src/runtime/textureAtlas/packer.ts +429 -0
  136. package/src/window/loop.ts +32 -6
@@ -0,0 +1,218 @@
1
+ // §7 derived-uniforms uber kernel — single flat dispatch over leaves.
2
+ //
3
+ // Records are static-ish (only edited on RO add/remove). Each thread
4
+ // processes one record:
5
+ // 1. Load record (recipe_id, in0, in1, in2, out_byte).
6
+ // 2. Switch on recipe_id, compute inline (df_mul + collapse), write
7
+ // f32 mat4/mat3 to MainHeap at out_byte.
8
+ //
9
+ // No dirty test on the kernel: when constituents don't change, the
10
+ // kernel rewrites identical bits. Saves a CPU writeBuffer + a binding
11
+ // per dispatch. GPU does ~64 FLOPs per record × N records — trivial at
12
+ // the scales this runs at.
13
+ //
14
+ // df32 primitives mirror examples/df32-precision/. Two opacity hooks:
15
+ // - bitcast<f32>(bits & MASK) for Veltkamp split (integer ops, no
16
+ // algebraic identity).
17
+ // - fma(1.0, x, -y) for compensated subtractions.
18
+ export const DERIVED_UBER_KERNEL_WGSL = /* wgsl */ `
19
+
20
+ // ─── Bindings ─────────────────────────────────────────────────────
21
+ @group(0) @binding(0) var<storage, read> Constituents: array<vec2<f32>>;
22
+ @group(0) @binding(1) var<storage, read_write> MainHeap: array<f32>;
23
+
24
+ struct Record {
25
+ recipe_id: u32,
26
+ in0: u32, // constituent slot index
27
+ in1: u32, // constituent slot index, 0 if unused
28
+ in2: u32, // constituent slot index, 0 if unused
29
+ out_byte: u32, // byte offset in MainHeap
30
+ _pad: u32, // bumps stride to 24 (defensively 16-aligned)
31
+ }
32
+ @group(0) @binding(2) var<storage, read> Records: array<Record>;
33
+
34
+ // Live record count. arrayLength(Records) reports the GPU buffer's
35
+ // capacity (rounded up by allocator growth), not the live count —
36
+ // trailing slots hold stale data from swap-removed records. Threads
37
+ // past Count.count would read stale records and trample random
38
+ // MainHeap bytes.
39
+ struct CountUniform { count: u32 }
40
+ @group(0) @binding(3) var<uniform> Count: CountUniform;
41
+
42
+ // ─── df32 primitives ──────────────────────────────────────────────
43
+
44
+ fn split12(a: f32) -> vec2<f32> {
45
+ let hi = bitcast<f32>(bitcast<u32>(a) & 0xFFFFE000u);
46
+ let lo = a - hi;
47
+ return vec2<f32>(hi, lo);
48
+ }
49
+
50
+ fn two_sum(a: f32, b: f32) -> vec2<f32> {
51
+ let s = a + b;
52
+ let bb = fma(1.0, s, -a);
53
+ let t1 = fma(1.0, s, -bb);
54
+ let t2 = fma(1.0, a, -t1);
55
+ let t3 = fma(1.0, b, -bb);
56
+ return vec2<f32>(s, t2 + t3);
57
+ }
58
+
59
+ fn quick_two_sum(a: f32, b: f32) -> vec2<f32> {
60
+ let s = a + b;
61
+ let t = fma(1.0, s, -a);
62
+ return vec2<f32>(s, fma(1.0, b, -t));
63
+ }
64
+
65
+ fn two_prod(a: f32, b: f32) -> vec2<f32> {
66
+ let p = a * b;
67
+ let A = split12(a);
68
+ let B = split12(b);
69
+ let err = ((A.x * B.x - p) + A.x * B.y + A.y * B.x) + A.y * B.y;
70
+ return vec2<f32>(p, err);
71
+ }
72
+
73
+ fn df_add(a: vec2<f32>, b: vec2<f32>) -> vec2<f32> {
74
+ let s = two_sum(a.x, b.x);
75
+ let t = two_sum(a.y, b.y);
76
+ let s3 = quick_two_sum(s.x, s.y + t.x);
77
+ return quick_two_sum(s3.x, s3.y + t.y);
78
+ }
79
+
80
+ fn df_mul(a: vec2<f32>, b: vec2<f32>) -> vec2<f32> {
81
+ let p = two_prod(a.x, b.x);
82
+ let cross1 = fma(a.x, b.y, p.y);
83
+ let cross = fma(a.y, b.x, cross1);
84
+ return quick_two_sum(p.x, cross);
85
+ }
86
+
87
+ // ─── Constituents access ──────────────────────────────────────────
88
+ //
89
+ // One slot = 16 vec2<f32> = one df32 mat4 in row-major order
90
+ // (matching Aardvark M44d convention). Element (row, col) of slot k
91
+ // lives at vec2 index k*16 + row*4 + col.
92
+
93
+ fn read_entry(slot: u32, row: u32, col: u32) -> vec2<f32> {
94
+ return Constituents[slot * 16u + row * 4u + col];
95
+ }
96
+
97
+ // (A · B) entry (r, c) in df32, both A and B in constituents.
98
+ fn df_mul_entry(a_slot: u32, b_slot: u32, r: u32, c: u32) -> vec2<f32> {
99
+ var acc = vec2<f32>(0.0, 0.0);
100
+ for (var k: u32 = 0u; k < 4u; k = k + 1u) {
101
+ acc = df_add(acc, df_mul(read_entry(a_slot, r, k), read_entry(b_slot, k, c)));
102
+ }
103
+ return acc;
104
+ }
105
+
106
+ // Compute one full row of (A · B), returns 4 df32 entries.
107
+ fn df_mul_row(a_slot: u32, b_slot: u32, r: u32) -> array<vec2<f32>, 4> {
108
+ var out: array<vec2<f32>, 4>;
109
+ for (var c: u32 = 0u; c < 4u; c = c + 1u) {
110
+ out[c] = df_mul_entry(a_slot, b_slot, r, c);
111
+ }
112
+ return out;
113
+ }
114
+
115
+ // Triple product (A · B · C) entry (r, c). Uses 4 df_muls per entry
116
+ // — recomputes the inner row each call. Acceptable: at most one
117
+ // such recipe per RO and only on dirty frames.
118
+ fn df_mul3_entry(a_slot: u32, b_slot: u32, c_slot: u32, r: u32, c: u32) -> vec2<f32> {
119
+ // (A·B·C)[r,c] = sum_k (A·B)[r,k] · C[k,c]
120
+ var acc = vec2<f32>(0.0, 0.0);
121
+ for (var k: u32 = 0u; k < 4u; k = k + 1u) {
122
+ let ab_rk = df_mul_entry(a_slot, b_slot, r, k);
123
+ acc = df_add(acc, df_mul(ab_rk, read_entry(c_slot, k, c)));
124
+ }
125
+ return acc;
126
+ }
127
+
128
+ // ─── Writers ──────────────────────────────────────────────────────
129
+ //
130
+ // Mat4: 16 contiguous f32s, row-major.
131
+ // Mat3: 3 rows × 4-stride (std140 mat3<f32>), 12 f32s; last column
132
+ // per row left untouched.
133
+
134
+ fn write_mat4_entry(out_byte: u32, row: u32, col: u32, val: f32) {
135
+ MainHeap[(out_byte >> 2u) + row * 4u + col] = val;
136
+ }
137
+
138
+ fn write_mat3_entry(out_byte: u32, row: u32, col: u32, val: f32) {
139
+ MainHeap[(out_byte >> 2u) + row * 4u + col] = val;
140
+ }
141
+
142
+ // ─── Recipe arms ──────────────────────────────────────────────────
143
+
144
+ fn run_collapse_mat4(in0: u32, out_byte: u32) {
145
+ for (var r: u32 = 0u; r < 4u; r = r + 1u) {
146
+ for (var c: u32 = 0u; c < 4u; c = c + 1u) {
147
+ let e = read_entry(in0, r, c);
148
+ write_mat4_entry(out_byte, r, c, e.x + e.y);
149
+ }
150
+ }
151
+ }
152
+
153
+ // NormalMatrix: (M⁻¹)ᵀ upper-3×3.
154
+ // NM[i, j] = MInv[j, i]
155
+ fn run_collapse_mat3_normal(in0: u32, out_byte: u32) {
156
+ for (var i: u32 = 0u; i < 3u; i = i + 1u) {
157
+ for (var j: u32 = 0u; j < 3u; j = j + 1u) {
158
+ let e = read_entry(in0, j, i);
159
+ write_mat3_entry(out_byte, i, j, e.x + e.y);
160
+ }
161
+ }
162
+ }
163
+
164
+ fn run_dfmul2_collapse(in0: u32, in1: u32, out_byte: u32) {
165
+ for (var r: u32 = 0u; r < 4u; r = r + 1u) {
166
+ for (var c: u32 = 0u; c < 4u; c = c + 1u) {
167
+ let e = df_mul_entry(in0, in1, r, c);
168
+ write_mat4_entry(out_byte, r, c, e.x + e.y);
169
+ }
170
+ }
171
+ }
172
+
173
+ fn run_dfmul3_collapse(in0: u32, in1: u32, in2: u32, out_byte: u32) {
174
+ for (var r: u32 = 0u; r < 4u; r = r + 1u) {
175
+ for (var c: u32 = 0u; c < 4u; c = c + 1u) {
176
+ let e = df_mul3_entry(in0, in1, in2, r, c);
177
+ write_mat4_entry(out_byte, r, c, e.x + e.y);
178
+ }
179
+ }
180
+ }
181
+
182
+ // ─── Entry ────────────────────────────────────────────────────────
183
+
184
+ @compute @workgroup_size(64)
185
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
186
+ if (gid.x >= Count.count) { return; }
187
+ let r = Records[gid.x];
188
+ switch r.recipe_id {
189
+ case 0u: { run_collapse_mat4(r.in0, r.out_byte); } // ModelTrafo
190
+ case 1u: { run_collapse_mat4(r.in0, r.out_byte); } // ModelTrafoInv
191
+ case 2u: { run_collapse_mat3_normal(r.in0, r.out_byte); } // NormalMatrix
192
+ case 3u: { run_dfmul2_collapse(r.in0, r.in1, r.out_byte); } // ModelViewTrafo
193
+ case 4u: { run_dfmul2_collapse(r.in0, r.in1, r.out_byte); } // ModelViewTrafoInv
194
+ case 5u: { run_dfmul3_collapse(r.in0, r.in1, r.in2, r.out_byte); } // ModelViewProjTrafo
195
+ case 6u: { run_dfmul3_collapse(r.in0, r.in1, r.in2, r.out_byte); } // ModelViewProjTrafoInv
196
+ case 7u: { run_collapse_mat4(r.in0, r.out_byte); } // ViewTrafo
197
+ case 8u: { run_collapse_mat4(r.in0, r.out_byte); } // ViewTrafoInv
198
+ case 9u: { run_dfmul2_collapse(r.in0, r.in1, r.out_byte); } // ViewProjTrafo
199
+ case 10u:{ run_dfmul2_collapse(r.in0, r.in1, r.out_byte); } // ViewProjTrafoInv
200
+ case 11u:{ run_collapse_mat4(r.in0, r.out_byte); } // ProjTrafo
201
+ case 12u:{ run_collapse_mat4(r.in0, r.out_byte); } // ProjTrafoInv
202
+ default: { return; }
203
+ }
204
+ }
205
+
206
+ `;
207
+ /** Records are 5× u32 = 20 bytes. WGSL storage struct alignment of
208
+ * 4 means the array stride is 20 bytes. */
209
+ export const RECORD_STRIDE_BYTES = 24;
210
+ export const RECORD_STRIDE_U32 = 6;
211
+ export const RECORD_FIELD = {
212
+ recipe_id: 0,
213
+ in0: 1,
214
+ in1: 2,
215
+ in2: 3,
216
+ out_byte: 4,
217
+ };
218
+ //# sourceMappingURL=uberKernel.wgsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uberKernel.wgsl.js","sourceRoot":"","sources":["../../../src/runtime/derivedUniforms/uberKernel.wgsl.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,qEAAqE;AACrE,wBAAwB;AACxB,yDAAyD;AACzD,sEAAsE;AACtE,8CAA8C;AAC9C,EAAE;AACF,mEAAmE;AACnE,sEAAsE;AACtE,uEAAuE;AACvE,2BAA2B;AAC3B,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2BAA2B;AAC3B,oDAAoD;AAEpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LlD,CAAC;AAEF;4CAC4C;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,CAAC;IACZ,GAAG,EAAQ,CAAC;IACZ,GAAG,EAAQ,CAAC;IACZ,GAAG,EAAQ,CAAC;IACZ,QAAQ,EAAG,CAAC;CACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type aset } from "@aardworx/wombat.adaptive";
2
+ import type { RenderObject } from "../core/renderObject.js";
3
+ import type { RenderTree } from "../core/renderTree.js";
4
+ export declare function flattenRenderTree(tree: RenderTree): aset<RenderObject>;
5
+ //# sourceMappingURL=flattenTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenTree.d.ts","sourceRoot":"","sources":["../../src/runtime/flattenTree.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,CAwBtE"}
@@ -0,0 +1,45 @@
1
+ // flattenTree — reactive `RenderTree → aset<RenderObject>`.
2
+ //
3
+ // Inside a single Render command, draw order is not load-bearing
4
+ // (formal contract: an `aset` of objects, not a sequence). The two
5
+ // node-kinds `Ordered` and `Unordered` collapse to the same flat
6
+ // set — anything ordering-sensitive belongs at the Command level
7
+ // (separate Render passes, in the Command list's declared order).
8
+ //
9
+ // Reactive variants (`Adaptive`, `OrderedFromList`, `UnorderedFromSet`)
10
+ // stay reactive: marks propagate through `bind` / `collect`, and the
11
+ // resulting aset reflects current tree state without a manual rebuild.
12
+ //
13
+ // `OrderedFromList`'s `alist<RenderTree>` is converted via
14
+ // `AListBridges.toASet` — this drops index/order info, which we
15
+ // wouldn't honor anyway.
16
+ import { ASet } from "@aardworx/wombat.adaptive";
17
+ import { AListBridges } from "@aardworx/wombat.adaptive";
18
+ export function flattenRenderTree(tree) {
19
+ switch (tree.kind) {
20
+ case "Empty":
21
+ return ASet.empty();
22
+ case "Leaf":
23
+ return ASet.single(tree.object);
24
+ case "Ordered":
25
+ case "Unordered": {
26
+ // N-ary union via `unionMany(aset<aset<T>>)`. The naïve
27
+ // `children.reduce(ASet.union)` builds a 2N-deep nested-union
28
+ // tree; the reader's traversal recurses through it and blows
29
+ // the stack at ~2K leaves. `unionMany` is O(1)-deep regardless.
30
+ const children = tree.children.map(flattenRenderTree);
31
+ if (children.length === 0)
32
+ return ASet.empty();
33
+ if (children.length === 1)
34
+ return children[0];
35
+ return ASet.unionMany(ASet.ofArray(children));
36
+ }
37
+ case "Adaptive":
38
+ return ASet.bind(flattenRenderTree, tree.tree);
39
+ case "OrderedFromList":
40
+ return ASet.collect(flattenRenderTree, AListBridges.toASet(tree.children));
41
+ case "UnorderedFromSet":
42
+ return ASet.collect(flattenRenderTree, tree.children);
43
+ }
44
+ }
45
+ //# sourceMappingURL=flattenTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenTree.js","sourceRoot":"","sources":["../../src/runtime/flattenT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I,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7E,KAAK,kBAAkB;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type AdaptiveToken } from "@aardworx/wombat.adaptive";
2
+ import type { RenderObject } from "../core/renderObject.js";
3
+ import type { HeapDrawSpec } from "./heapScene.js";
4
+ import { AtlasPool } from "./textureAtlas/atlasPool.js";
5
+ /**
6
+ * Convert a heap-eligible `RenderObject` into a `HeapDrawSpec`. The
7
+ * caller (hybrid render task) is responsible for ensuring eligibility
8
+ * before calling — this adapter throws on any disagreement.
9
+ *
10
+ * The `token` is used once to read `drawCall` and the (single) texture
11
+ * + sampler avals at addDraw time. Per-frame data updates flow
12
+ * through the heap path's pool/repack machinery via the returned
13
+ * spec's avals — this function does not subscribe to anything.
14
+ */
15
+ export declare function renderObjectToHeapSpec(ro: RenderObject, token: AdaptiveToken, pool?: AtlasPool): HeapDrawSpec;
16
+ //# sourceMappingURL=heapAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heapAdapter.d.ts","sourceRoot":"","sources":["../../src/runtime/heapAdapter.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AA0HxD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,aAAa,EACpB,IAAI,CAAC,EAAE,SAAS,GACf,YAAY,CA8Id"}
@@ -0,0 +1,263 @@
1
+ // heapAdapter — `RenderObject → HeapDrawSpec`.
2
+ //
3
+ // Reactive: returns the same `HeapDrawSpec` shape the heap path
4
+ // already accepts. Per-input wiring:
5
+ //
6
+ // - vertexAttributes → spec.inputs[name] = BufferView (heap path
7
+ // handles BufferView ingest natively, pivots
8
+ // the pool aval-key onto the underlying
9
+ // `aval<IBuffer>` for share-by-identity).
10
+ // - uniforms → spec.inputs[name] = aval<unknown>.
11
+ // - textures/samplers → folded into a HeapTextureSet (single pair
12
+ // v1; the eligibility classifier already
13
+ // rejects multi-binding ROs).
14
+ // - indices → BufferView's `aval<IBuffer>` mapped to
15
+ // `aval<Uint32Array>` for the heap path's
16
+ // IndexPool.
17
+ // - effect → passed through.
18
+ // - pipelineState → passed through (heap path bucket-keys it).
19
+ //
20
+ // Drawcall wedges (instanceCount > 1, baseVertex/firstIndex/
21
+ // firstInstance != 0, non-indexed) are screened out by
22
+ // `isHeapEligible`; this adapter is the partner that converts the
23
+ // heap-eligible subset. If we see something we can't handle, throw —
24
+ // that's a classifier/adapter mismatch, a bug.
25
+ //
26
+ // No multi-binding texture API yet: `ro.textures.count <= 1` and
27
+ // `ro.samplers.count <= 1` are classifier invariants.
28
+ import {} from "@aardworx/wombat.adaptive";
29
+ import { ITexture } from "../core/texture.js";
30
+ import { ISampler } from "../core/sampler.js";
31
+ import { AtlasPool } from "./textureAtlas/atlasPool.js";
32
+ /**
33
+ * View `HostBufferSource` as `Uint32Array`. Index buffers are u32 in
34
+ * the heap path; non-u32 indices would have to be transcoded (out
35
+ * of scope — eligibility doesn't currently inspect index format).
36
+ */
37
+ function asUint32(data) {
38
+ if (data instanceof Uint32Array)
39
+ return data;
40
+ if (ArrayBuffer.isView(data)) {
41
+ return new Uint32Array(data.buffer, data.byteOffset, data.byteLength / 4);
42
+ }
43
+ return new Uint32Array(data);
44
+ }
45
+ // IndexPool keys on aval identity → ROs sharing the same
46
+ // `ro.indices.buffer` must produce the SAME downstream
47
+ // `aval<Uint32Array>`. A fresh `.map(…)` per RO would defeat the
48
+ // pool's identity-based sharing and balloon GPU memory (e.g. 11K
49
+ // spheres each allocating their own copy of the 6144-index buffer
50
+ // → 270 MB).
51
+ const indicesAvalCache = new WeakMap();
52
+ // Per-aval shared "current pool ref" cell. ROs that share an
53
+ // `aval<ITexture>` (and therefore one AtlasPool entry) all read
54
+ // through the same cell; `repack` updates `cell.ref` so every
55
+ // `release` closure frees the latest sub-rect after a swap.
56
+ const currentRefCellCache = new WeakMap();
57
+ function currentRefCellFor(av, initial) {
58
+ let c = currentRefCellCache.get(av);
59
+ if (c === undefined) {
60
+ c = { ref: initial };
61
+ currentRefCellCache.set(av, c);
62
+ }
63
+ return c;
64
+ }
65
+ function indicesAvalFor(ibAval) {
66
+ let av = indicesAvalCache.get(ibAval);
67
+ if (av === undefined) {
68
+ av = ibAval.map((ib) => {
69
+ if (ib.kind !== "host") {
70
+ throw new Error("heapAdapter: index buffer flipped to native GPUBuffer; classifier should have caught this");
71
+ }
72
+ return asUint32(ib.data);
73
+ });
74
+ indicesAvalCache.set(ibAval, av);
75
+ }
76
+ return av;
77
+ }
78
+ function describeTexture(t) {
79
+ if (t.kind === "gpu") {
80
+ const tex = t.texture;
81
+ return {
82
+ format: tex.format,
83
+ width: tex.width,
84
+ height: tex.height,
85
+ mipLevelCount: tex.mipLevelCount,
86
+ };
87
+ }
88
+ const src = t.source;
89
+ if (src.kind === "raw") {
90
+ return {
91
+ format: src.format,
92
+ width: src.width,
93
+ height: src.height,
94
+ mipLevelCount: src.mipLevelCount ?? 1,
95
+ host: src,
96
+ };
97
+ }
98
+ // external — read width/height off the source. Most types have it,
99
+ // HTMLVideoElement uses `videoWidth/videoHeight`.
100
+ const ext = src.source;
101
+ let w = 0, h = 0;
102
+ if (typeof HTMLVideoElement !== "undefined" && ext instanceof HTMLVideoElement) {
103
+ w = ext.videoWidth;
104
+ h = ext.videoHeight;
105
+ }
106
+ else if (typeof ImageData !== "undefined" && ext instanceof ImageData) {
107
+ w = ext.width;
108
+ h = ext.height;
109
+ }
110
+ else {
111
+ const any = ext;
112
+ w = any.width ?? 0;
113
+ h = any.height ?? 0;
114
+ }
115
+ if (w <= 0 || h <= 0)
116
+ return null;
117
+ return {
118
+ format: src.format ?? "rgba8unorm",
119
+ width: w,
120
+ height: h,
121
+ mipLevelCount: src.generateMips ? Math.floor(Math.log2(Math.max(w, h))) + 1 : 1,
122
+ host: src,
123
+ };
124
+ }
125
+ /**
126
+ * Convert a heap-eligible `RenderObject` into a `HeapDrawSpec`. The
127
+ * caller (hybrid render task) is responsible for ensuring eligibility
128
+ * before calling — this adapter throws on any disagreement.
129
+ *
130
+ * The `token` is used once to read `drawCall` and the (single) texture
131
+ * + sampler avals at addDraw time. Per-frame data updates flow
132
+ * through the heap path's pool/repack machinery via the returned
133
+ * spec's avals — this function does not subscribe to anything.
134
+ */
135
+ export function renderObjectToHeapSpec(ro, token, pool) {
136
+ // 1. Inputs map: vertex attributes (BufferView) + uniforms.
137
+ const inputs = {};
138
+ ro.vertexAttributes.iter((name, bv) => { inputs[name] = bv; });
139
+ ro.uniforms.iter((name, av) => { inputs[name] = av; });
140
+ // 1b. Instance attributes — same shape, threaded via the heap path's
141
+ // per-RO instancing fast path (one record / one drawIndirect for
142
+ // `instanceCount > 1`, with per-instance attribute reads indexed
143
+ // by the in-RO instance idx).
144
+ let instanceAttributes;
145
+ if (ro.instanceAttributes !== undefined && ro.instanceAttributes.count > 0) {
146
+ instanceAttributes = {};
147
+ ro.instanceAttributes.iter((name, bv) => {
148
+ instanceAttributes[name] = bv;
149
+ });
150
+ }
151
+ // 2. Indices: BufferView → aval<Uint32Array>. Map the underlying
152
+ // IBuffer aval; the heap path's IndexPool will key on this aval.
153
+ if (ro.indices === undefined) {
154
+ throw new Error("heapAdapter: RenderObject without indices not supported (heap is indexed-only)");
155
+ }
156
+ const indices = indicesAvalFor(ro.indices.buffer);
157
+ // 3. Texture/sampler: single-pair v1. Classifier already capped
158
+ // counts at 1 each.
159
+ let textures;
160
+ if (ro.textures.count === 1 && ro.samplers.count === 1) {
161
+ let texAval;
162
+ let texVal;
163
+ let samplerAval;
164
+ let samplerVal;
165
+ ro.textures.iter((_n, av) => {
166
+ texAval = av;
167
+ texVal = av.getValue(token);
168
+ });
169
+ ro.samplers.iter((_n, av) => {
170
+ samplerAval = av;
171
+ samplerVal = av.getValue(token);
172
+ });
173
+ void samplerAval;
174
+ if (texVal === undefined || samplerVal === undefined) {
175
+ throw new Error("heapAdapter: missing texture/sampler value");
176
+ }
177
+ // Inspect format/dimensions/mipLevels from ITexture. Both
178
+ // variants expose enough to classify:
179
+ // - kind: "host" → carries width/height/format on the source
180
+ // descriptor (raw) or implicit (external; default rgba8unorm).
181
+ // - kind: "gpu" → resolved GPUTexture exposes .format/.width/
182
+ // .height/.mipLevelCount.
183
+ const dims = describeTexture(texVal);
184
+ // Tier-S routing: pool present, format eligible, dims ≤ cap. Mips
185
+ // are honoured if the source advertises them.
186
+ const atlasFormat = dims === null ? null : AtlasPool.eligibleFormat(dims.format);
187
+ if (pool !== undefined &&
188
+ dims !== null &&
189
+ atlasFormat !== null &&
190
+ AtlasPool.eligibleSize(dims.width, dims.height)) {
191
+ const wantsMips = dims.mipLevelCount > 1;
192
+ const acq = pool.acquire(atlasFormat, texAval, dims.width, dims.height, {
193
+ wantsMips,
194
+ ...(dims.host !== undefined ? { source: { width: dims.width, height: dims.height, host: dims.host } } : {}),
195
+ });
196
+ const texAvalTyped = texAval;
197
+ // Per-aval shared current-ref cell so all ROs sharing a single
198
+ // `aval<ITexture>` see the same "live" pool ref. After a repack
199
+ // every release closure reads the cell and frees the LATEST
200
+ // sub-rect — no leaks even when multiple ROs are bucket-shared.
201
+ const cell = currentRefCellFor(texAvalTyped, acq.ref);
202
+ textures = {
203
+ kind: "atlas",
204
+ format: atlasFormat,
205
+ pageId: acq.pageId,
206
+ origin: acq.origin,
207
+ size: acq.size,
208
+ numMips: acq.numMips,
209
+ sampler: samplerVal,
210
+ page: acq.page,
211
+ poolRef: acq.ref,
212
+ release: () => pool.release(cell.ref),
213
+ // Reactivity hooks: heapScene subscribes to `sourceAval`; on
214
+ // mark, drains via `repack(newTex)` — the pool frees the old
215
+ // sub-rect, acquires a new one, and the heap path rewrites
216
+ // the drawHeader fields. Mirrors UniformPool.repack(av, val).
217
+ sourceAval: texAvalTyped,
218
+ repack: (newTex) => {
219
+ const next = pool.repack(texAvalTyped, newTex, {
220
+ wantsMips: dims.mipLevelCount > 1,
221
+ });
222
+ cell.ref = next.ref;
223
+ return next;
224
+ },
225
+ };
226
+ }
227
+ else {
228
+ // Tier-L fallback: keep the existing standalone path, which
229
+ // requires a resolved GPUTexture/GPUSampler.
230
+ if (texVal.kind !== "gpu") {
231
+ throw new Error("heapAdapter: standalone path requires ITexture.kind === 'gpu'");
232
+ }
233
+ if (samplerVal.kind !== "gpu") {
234
+ throw new Error("heapAdapter: standalone path requires ISampler.kind === 'gpu'");
235
+ }
236
+ textures = {
237
+ kind: "standalone",
238
+ texture: ITexture.fromGPU(texVal.texture),
239
+ sampler: ISampler.fromGPU(samplerVal.sampler),
240
+ };
241
+ }
242
+ }
243
+ else if (ro.textures.count > 0 || ro.samplers.count > 0) {
244
+ throw new Error(`heapAdapter: RO has ${ro.textures.count} texture(s) and ${ro.samplers.count} sampler(s); ` +
245
+ `single-pair only in v1 (classifier should have caught this)`);
246
+ }
247
+ // 4. DrawCall: read once. Classifier validates fields are heap-
248
+ // compatible (indexed, instanceCount=1, zero offsets).
249
+ const dc = ro.drawCall.getValue(token);
250
+ if (dc.kind !== "indexed") {
251
+ throw new Error("heapAdapter: non-indexed drawCall; classifier should have caught this");
252
+ }
253
+ return {
254
+ effect: ro.effect,
255
+ pipelineState: ro.pipelineState,
256
+ inputs,
257
+ ...(instanceAttributes !== undefined ? { instanceAttributes } : {}),
258
+ ...(dc.instanceCount > 1 ? { instanceCount: dc.instanceCount } : {}),
259
+ indices,
260
+ ...(textures !== undefined ? { textures } : {}),
261
+ };
262
+ }
263
+ //# sourceMappingURL=heapAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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