@aardworx/wombat.rendering 0.8.1 → 0.9.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.
Files changed (141) 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 +529 -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 -1
  73. package/dist/runtime/index.d.ts.map +1 -1
  74. package/dist/runtime/index.js +9 -1
  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 +6 -5
  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 +728 -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 +45 -1
  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
  137. package/dist/runtime/heapShader.d.ts +0 -12
  138. package/dist/runtime/heapShader.d.ts.map +0 -1
  139. package/dist/runtime/heapShader.js +0 -157
  140. package/dist/runtime/heapShader.js.map +0 -1
  141. package/src/runtime/heapShader.ts +0 -185
@@ -0,0 +1,529 @@
1
+ // heapEffect — effect introspection + bucket-layout generation.
2
+ //
3
+ // Two stages:
4
+ //
5
+ // 1. `compileHeapEffect(effect)` — runs `effect.compile({target:"wgsl"})`
6
+ // and returns the raw stage WGSL (untouched) plus a `schema`
7
+ // describing the effect's surviving inputs / uniforms / outputs
8
+ // (post link + DCE). No name hardcoding; everything is read off
9
+ // `CompiledEffect.interface`.
10
+ //
11
+ // 2. `buildBucketLayout(schema, hasTextures, opts)` — turns a schema
12
+ // into a concrete per-bucket WGSL prelude + a JS-side layout
13
+ // object that knows where each named uniform / attribute lives
14
+ // (struct field offset for packing). The IR rewriter in
15
+ // `heapEffectIR.ts` consumes this layout to substitute uniform /
16
+ // attribute reads with heap loads at the IR level.
17
+ export function compileHeapEffect(effect, fragmentOutputLayout) {
18
+ const compiled = effect.compile(fragmentOutputLayout !== undefined
19
+ ? { target: "wgsl", fragmentOutputLayout }
20
+ : { target: "wgsl" });
21
+ const vsStage = compiled.stages.find(s => s.stage === "vertex");
22
+ const fsStage = compiled.stages.find(s => s.stage === "fragment");
23
+ return {
24
+ rawVs: vsStage?.source ?? "",
25
+ rawFs: fsStage?.source ?? "",
26
+ schema: buildSchema(compiled.interface),
27
+ };
28
+ }
29
+ function buildSchema(iface) {
30
+ const attributes = iface.attributes.map(a => ({
31
+ name: a.name,
32
+ wgslType: irTypeToWgsl(a.type),
33
+ byteSize: a.byteSize,
34
+ location: a.location,
35
+ }));
36
+ // When `instanceUniforms` (or any other rewrite) converts a uniform
37
+ // read into a vertex-input fetch, the source module still carries the
38
+ // original Uniform declaration. The interface extractor surfaces it
39
+ // here, but the field is now satisfied by the per-instance attribute —
40
+ // collecting it as a uniform too would double-book the name in the
41
+ // drawHeader. Drop uniforms shadowed by an attribute of the same name.
42
+ const attributeNames = new Set(attributes.map(a => a.name));
43
+ const uniforms = [];
44
+ for (const block of iface.uniformBlocks) {
45
+ for (const f of block.fields) {
46
+ if (attributeNames.has(f.name))
47
+ continue;
48
+ uniforms.push({
49
+ name: f.name,
50
+ wgslType: irTypeToWgsl(f.type),
51
+ byteSize: irTypePackedSize(f.type),
52
+ });
53
+ }
54
+ }
55
+ // GLSL-style "loose" uniforms (no enclosing buffer name). On WGSL these
56
+ // emit as individual `var<uniform>` decls; the heap IR rewrite substitutes
57
+ // each `ReadInput("Uniform", name, ...)` with a per-draw heap load before
58
+ // WGSL emit, so the loose decls never reach the final shader.
59
+ for (const u of iface.uniforms) {
60
+ if (attributeNames.has(u.name))
61
+ continue;
62
+ uniforms.push({
63
+ name: u.name,
64
+ wgslType: irTypeToWgsl(u.type),
65
+ byteSize: irTypePackedSize(u.type),
66
+ });
67
+ }
68
+ // Inter-stage varyings: VS outputs (post link + DCE). The FS inputs
69
+ // mirror these — `linkCrossStage` aligns them by semantic, so we
70
+ // can use VS outputs as the single source of truth for VsOut.
71
+ const vsStage = iface.stages.find(s => s.stage === "vertex");
72
+ const varyings = vsStage === undefined
73
+ ? []
74
+ : vsStage.outputs.map(o => {
75
+ const v = { name: o.name, wgslType: irTypeToWgsl(o.type) };
76
+ if (o.location !== undefined)
77
+ v.location = o.location;
78
+ if (o.builtin !== undefined)
79
+ v.builtin = o.builtin;
80
+ if (o.interpolation !== undefined)
81
+ v.interpolation = o.interpolation;
82
+ return v;
83
+ });
84
+ const fragmentOutputs = iface.fragmentOutputs.map(o => ({
85
+ name: o.name, location: o.location, wgslType: irTypeToWgsl(o.type),
86
+ }));
87
+ // Texture/sampler bindings post-DCE. The IR Type for textures is a
88
+ // structured kind we don't fully model here yet — for v1 every
89
+ // texture maps to "texture_2d<f32>" and every sampler to plain
90
+ // "sampler". Specialise as multi-kind support lands in the DSL.
91
+ const textures = iface.textures.map(t => ({
92
+ name: t.name, wgslType: "texture_2d<f32>",
93
+ }));
94
+ const samplers = iface.samplers.map(s => ({
95
+ name: s.name, wgslType: "sampler",
96
+ }));
97
+ return { attributes, uniforms, varyings, fragmentOutputs, textures, samplers };
98
+ }
99
+ function irTypeToWgsl(t) {
100
+ switch (t.kind) {
101
+ case "Float": return "f32";
102
+ case "Int": return t.signed ? "i32" : "u32";
103
+ case "Bool": return "bool";
104
+ case "Vector": return `vec${t.dim}<${irTypeToWgsl(t.element)}>`;
105
+ case "Matrix": return `mat${t.cols}x${t.rows}<${irTypeToWgsl(t.element)}>`;
106
+ case "Array": {
107
+ const inner = irTypeToWgsl(t.element);
108
+ return t.length === "runtime" ? `array<${inner}>` : `array<${inner}, ${t.length}>`;
109
+ }
110
+ default:
111
+ throw new Error(`compileHeapEffect: cannot map IR Type kind '${t.kind}' to WGSL`);
112
+ }
113
+ }
114
+ function irTypePackedSize(t) {
115
+ switch (t.kind) {
116
+ case "Float": return 4;
117
+ case "Int": return 4;
118
+ case "Bool": return 4;
119
+ case "Vector": return t.dim * irTypePackedSize(t.element);
120
+ case "Matrix": return t.cols * t.rows * irTypePackedSize(t.element);
121
+ case "Array": {
122
+ if (t.length === "runtime") {
123
+ throw new Error("compileHeapEffect: runtime-sized arrays have no fixed packed size");
124
+ }
125
+ return t.length * irTypePackedSize(t.element);
126
+ }
127
+ default:
128
+ throw new Error(`compileHeapEffect: cannot size IR Type kind '${t.kind}'`);
129
+ }
130
+ }
131
+ /**
132
+ * First texture binding number; samplers come after the textures.
133
+ * Bindings 0–3 are the four heap arena views, 4–6 are megacall
134
+ * (drawTable, indexStorage, firstDrawInTile).
135
+ */
136
+ export const HEAP_TEX_BINDING_START = 7;
137
+ /**
138
+ * Number of independent pages per format. Drives both the BGL slot
139
+ * count (N consecutive linear bindings + N consecutive srgb bindings
140
+ * + 1 sampler) and the shader's `switch pageRef` ladder. Must match
141
+ * `ATLAS_MAX_PAGES_PER_FORMAT` in `textureAtlas/atlasPool.ts`.
142
+ */
143
+ export const ATLAS_ARRAY_SIZE = 8;
144
+ /** First atlas binding (linear texture for page 0). */
145
+ export const ATLAS_LINEAR_BINDING_BASE = 11;
146
+ /** First srgb atlas binding (= linear base + N). */
147
+ export const ATLAS_SRGB_BINDING_BASE = ATLAS_LINEAR_BINDING_BASE + ATLAS_ARRAY_SIZE;
148
+ /** Atlas sampler binding (= linear base + 2N). */
149
+ export const ATLAS_SAMPLER_BINDING = ATLAS_LINEAR_BINDING_BASE + 2 * ATLAS_ARRAY_SIZE;
150
+ export function buildBucketLayout(schema, _hasTextures, opts = {}) {
151
+ const perInstanceUniforms = opts.perInstanceUniforms ?? new Set();
152
+ const perInstanceAttributes = opts.perInstanceAttributes ?? new Set();
153
+ const atlasTextureBindings = opts.atlasTextureBindings ?? new Set();
154
+ const drawHeaderFields = [];
155
+ // Per-draw uniforms → u32 ref slots in the DrawHeader. The runtime
156
+ // (UniformPool) keeps one arena allocation per unique aval; sharing
157
+ // across draws → shared ref → shared upload.
158
+ let dhOff = 0;
159
+ for (const u of schema.uniforms) {
160
+ dhOff = roundUp(dhOff, 4);
161
+ drawHeaderFields.push({
162
+ name: u.name, wgslName: lowerFirst(u.name) + "Ref", wgslType: "u32",
163
+ byteOffset: dhOff, byteSize: 4, kind: "uniform-ref",
164
+ uniformWgslType: u.wgslType,
165
+ });
166
+ dhOff += 4;
167
+ }
168
+ // Attribute refs — same shape as uniform refs, also routed through the pool.
169
+ for (const a of schema.attributes) {
170
+ dhOff = roundUp(dhOff, 4);
171
+ drawHeaderFields.push({
172
+ name: a.name, wgslName: lowerFirst(a.name) + "Ref", wgslType: "u32",
173
+ byteOffset: dhOff, byteSize: 4, kind: "attribute-ref",
174
+ attributeWgslType: a.wgslType,
175
+ });
176
+ dhOff += 4;
177
+ }
178
+ // Atlas-routed texture bindings: 24 bytes / binding split into
179
+ // pageRef (u32) + formatBits (u32) + origin (vec2<f32>) + size
180
+ // (vec2<f32>). Inline values, not pool refs — the runtime packs
181
+ // them at addDraw time from the atlas acquisition + ISampler.
182
+ for (const t of schema.textures) {
183
+ if (!atlasTextureBindings.has(t.name))
184
+ continue;
185
+ const base = lowerFirst(t.name);
186
+ dhOff = roundUp(dhOff, 4);
187
+ drawHeaderFields.push({
188
+ name: `${t.name}.pageRef`, wgslName: `${base}PageRef`, wgslType: "u32",
189
+ byteOffset: dhOff, byteSize: 4, kind: "texture-ref",
190
+ textureSub: "pageRef", textureBindingName: t.name,
191
+ });
192
+ dhOff += 4;
193
+ drawHeaderFields.push({
194
+ name: `${t.name}.formatBits`, wgslName: `${base}FormatBits`, wgslType: "u32",
195
+ byteOffset: dhOff, byteSize: 4, kind: "texture-ref",
196
+ textureSub: "formatBits", textureBindingName: t.name,
197
+ });
198
+ dhOff += 4;
199
+ dhOff = roundUp(dhOff, 8);
200
+ drawHeaderFields.push({
201
+ name: `${t.name}.origin`, wgslName: `${base}Origin`, wgslType: "vec2<f32>",
202
+ byteOffset: dhOff, byteSize: 8, kind: "texture-ref",
203
+ textureSub: "origin", textureBindingName: t.name,
204
+ });
205
+ dhOff += 8;
206
+ drawHeaderFields.push({
207
+ name: `${t.name}.size`, wgslName: `${base}Size`, wgslType: "vec2<f32>",
208
+ byteOffset: dhOff, byteSize: 8, kind: "texture-ref",
209
+ textureSub: "size", textureBindingName: t.name,
210
+ });
211
+ dhOff += 8;
212
+ }
213
+ const drawHeaderBytes = roundUp(dhOff, 16);
214
+ const strideU32 = drawHeaderBytes / 4;
215
+ // Allocate texture + sampler bindings starting at HEAP_TEX_BINDING_START.
216
+ // Order: all textures, then all samplers — matches the prelude
217
+ // layout below and the runtime's BGL/bind-group construction.
218
+ // Atlas-routed bindings drop out — their data flows through the
219
+ // drawHeader instead of through individual texture/sampler slots.
220
+ let nextBinding = HEAP_TEX_BINDING_START;
221
+ const textureBindings = schema.textures
222
+ .filter(t => !atlasTextureBindings.has(t.name))
223
+ .map(t => ({ name: t.name, wgslType: t.wgslType, binding: nextBinding++ }));
224
+ // Samplers: drop the matching one when its texture is atlas-routed.
225
+ // Heuristic: assume position-aligned (nth sampler pairs with nth
226
+ // texture). Heap path's v1 surface only ever has 0..1 of each, so
227
+ // this collapses to "if the lone texture is atlas, drop the lone
228
+ // sampler too".
229
+ const atlasSamplerNames = new Set();
230
+ for (let i = 0; i < schema.textures.length; i++) {
231
+ const t = schema.textures[i];
232
+ if (atlasTextureBindings.has(t.name)) {
233
+ const s = schema.samplers[i];
234
+ if (s !== undefined)
235
+ atlasSamplerNames.add(s.name);
236
+ }
237
+ }
238
+ const samplerBindings = schema.samplers
239
+ .filter(s => !atlasSamplerNames.has(s.name))
240
+ .map(s => ({ name: s.name, wgslType: s.wgslType, binding: nextBinding++ }));
241
+ const isAtlasBucket = atlasTextureBindings.size > 0;
242
+ // Extend the schema's varyings with flat-interpolated atlas threading
243
+ // slots when atlas is in use — the prelude generator emits these into
244
+ // VsOut so user VS code can write them and FS can read them. The
245
+ // location numbers are picked after the existing varyings.
246
+ const schemaForPrelude = isAtlasBucket
247
+ ? extendSchemaWithAtlasVaryings(schema, atlasTextureBindings)
248
+ : schema;
249
+ const preludeWgsl = generatePrelude(schemaForPrelude, textureBindings, samplerBindings, isAtlasBucket);
250
+ return {
251
+ drawHeaderFields, drawHeaderBytes, preludeWgsl, strideU32,
252
+ perInstanceUniforms,
253
+ perInstanceAttributes,
254
+ textureBindings, samplerBindings,
255
+ atlasTextureBindings,
256
+ };
257
+ }
258
+ /**
259
+ * Append flat-interpolated atlas threading varyings to a schema.
260
+ * Locations follow the highest existing `@location(N)` so we don't
261
+ * collide with effect-declared varyings.
262
+ */
263
+ function extendSchemaWithAtlasVaryings(schema, atlasNames) {
264
+ let nextLoc = 0;
265
+ for (const v of schema.varyings) {
266
+ if (v.location !== undefined)
267
+ nextLoc = Math.max(nextLoc, v.location + 1);
268
+ }
269
+ const extras = [];
270
+ for (const name of atlasNames) {
271
+ const v = atlasVaryingNames(name);
272
+ extras.push({ name: v.pageRef, wgslType: "u32", location: nextLoc++, interpolation: "flat" });
273
+ extras.push({ name: v.formatBits, wgslType: "u32", location: nextLoc++, interpolation: "flat" });
274
+ extras.push({ name: v.origin, wgslType: "vec2<f32>", location: nextLoc++, interpolation: "flat" });
275
+ extras.push({ name: v.size, wgslType: "vec2<f32>", location: nextLoc++, interpolation: "flat" });
276
+ }
277
+ return { ...schema, varyings: [...schema.varyings, ...extras] };
278
+ }
279
+ function lowerFirst(s) {
280
+ return s.length === 0 ? s : s[0].toLowerCase() + s.slice(1);
281
+ }
282
+ function roundUp(value, mult) {
283
+ return Math.ceil(value / mult) * mult;
284
+ }
285
+ // ─── Prelude generation ─────────────────────────────────────────────
286
+ function generatePrelude(schema, textureBindings, samplerBindings, isAtlasBucket) {
287
+ // VsOut is generated from the schema's surviving VS outputs (post
288
+ // link + DCE). No hardcoded fields — what the effect declared is
289
+ // what ends up here.
290
+ const vsOutBody = schema.varyings.map(v => ` ${vsOutFieldDecl(v)}: ${v.wgslType},`).join("\n");
291
+ // Textures + samplers — one binding per surviving entry, starting
292
+ // at HEAP_TEX_BINDING_START. The user's WGSL must reference them
293
+ // by their schema name; the rewriter drops any DSL-emitted decls
294
+ // that conflict.
295
+ const texDecls = textureBindings.map(t => `@group(0) @binding(${t.binding}) var ${t.name}: ${t.wgslType};`).join("\n");
296
+ const smpDecls = samplerBindings.map(s => `@group(0) @binding(${s.binding}) var ${s.name}: ${s.wgslType};`).join("\n");
297
+ const samplingBlock = (texDecls.length > 0 || smpDecls.length > 0)
298
+ ? `\n${texDecls}${texDecls && smpDecls ? "\n" : ""}${smpDecls}\n`
299
+ : "";
300
+ const megacallDecls = `\n@group(0) @binding(4) var<storage, read> drawTable: array<u32>;\n@group(0) @binding(5) var<storage, read> indexStorage: array<u32>;\n@group(0) @binding(6) var<storage, read> firstDrawInTile: array<u32>;`;
301
+ const atlasBlock = isAtlasBucket ? generateAtlasPrelude() : "";
302
+ return /* wgsl */ `
303
+ @group(0) @binding(0) var<storage, read> heapU32: array<u32>;
304
+ @group(0) @binding(1) var<storage, read> headersU32: array<u32>;
305
+ @group(0) @binding(2) var<storage, read> heapF32: array<f32>;
306
+ @group(0) @binding(3) var<storage, read> heapV4f: array<vec4<f32>>;${megacallDecls}
307
+ ${samplingBlock}${atlasBlock}
308
+ struct VsOut {
309
+ ${vsOutBody}
310
+ };
311
+ `;
312
+ }
313
+ /**
314
+ * Atlas prelude: declares N independent `texture_2d<f32>` bindings
315
+ * per format (linear + srgb), plus a shared atlas sampler. The N-way
316
+ * `switch pageRef` ladder picks the matching texture pair for each
317
+ * draw. Each atlas page is its own `GPUTexture` — adding pages to a
318
+ * format is just a fresh allocation slotted into the next BGL entry,
319
+ * no GPU-side `copyTextureToTexture` required.
320
+ *
321
+ * `binding_array<texture_2d<f32>, N>` would collapse the switch into
322
+ * a runtime index but requires Chrome's experimental bindless
323
+ * feature; the N-consecutive-bindings + switch pattern is native
324
+ * WebGPU 1.0.
325
+ *
326
+ * Mip filtering is software (the GPU's mip walk would walk the
327
+ * texture's mip chain, not our embedded Iliffe pyramid). LOD is
328
+ * computed from screen-space derivatives of `uv * size_px` in mip-0
329
+ * texels-per-screen-pixel.
330
+ *
331
+ * Sample math (verified by `tests-browser/atlas-sampling-conformance.test.ts`
332
+ * to match native hardware bilinear within 1 LSB across clamp/repeat/
333
+ * mirror at any uv):
334
+ * - Clamp: atlas_p = origin_px + clamp(uv, 0, 1) * size_px
335
+ * - Mirror: atlas_p = origin_px + mirrorUv(uv) * size_px
336
+ * - Repeat: atlas_p = origin_px + fract(uv) * size_px, then shift ∓1
337
+ * if within 0.5 atlas-pixel of the sub-rect edge, so
338
+ * hardware bilinear straddles the outer wrap-gutter ring.
339
+ * `origin_px` / `size_px` are atlas-pixel coordinates of mip-0, NOT
340
+ * normalized. Mip-k rect is computed by walking the integer floor-
341
+ * halving sequence that matches the CPU packer's pyramid layout.
342
+ * Each sub-rect (incl. every mip slot) carries a 2-px gutter (inner
343
+ * ring = clamp-replicate edge, outer ring = wrap = opposite edge)
344
+ * filled by the upload kernel; without it bilinear at the edges
345
+ * bleeds across sub-rect boundaries.
346
+ */
347
+ export function generateAtlasPrelude() {
348
+ return /* wgsl */ `
349
+ ${generateAtlasBindings()}
350
+
351
+ fn mirrorAtlasUv(u: f32) -> f32 {
352
+ let t = u - floor(u * 0.5) * 2.0;
353
+ return 1.0 - abs(t - 1.0);
354
+ }
355
+
356
+ // One axis: produce atlas-pixel coord from logical uv per wrap mode.
357
+ // mip_origin / mip_size are in atlas pixels for the target mip slot.
358
+ fn atlasAxisAt(uv: f32, mip_origin: f32, mip_size: f32, mode: u32) -> f32 {
359
+ if (mode == 0u) { // clamp
360
+ let c = clamp(uv, 0.0, 1.0);
361
+ return mip_origin + c * mip_size;
362
+ }
363
+ if (mode == 2u) { // mirror
364
+ let m = mirrorAtlasUv(uv);
365
+ return mip_origin + m * mip_size;
366
+ }
367
+ // repeat
368
+ let f = uv - floor(uv);
369
+ var p = mip_origin + f * mip_size;
370
+ let dL = p - mip_origin;
371
+ let dR = (mip_origin + mip_size) - p;
372
+ if (dL < 0.5) { p = p - 1.0; }
373
+ else if (dR < 0.5) { p = p + 1.0; }
374
+ return p;
375
+ }
376
+
377
+ // Mip-k rect within the Iliffe pyramid, in atlas pixels. Matches the
378
+ // CPU packer's integer floor-halving (so non-pow2 sources still hit
379
+ // the right texels). 2-px gutter between adjacent mip slots.
380
+ const ATLAS_MIP_GAP: f32 = 4.0;
381
+
382
+ fn atlasMipOriginPx(origin: vec2<f32>, size: vec2<f32>, k: u32) -> vec2<f32> {
383
+ if (k == 0u) { return origin; }
384
+ let x = origin.x + size.x + ATLAS_MIP_GAP;
385
+ var y = origin.y;
386
+ var j: u32 = 1u;
387
+ loop {
388
+ if (j >= k) { break; }
389
+ let mh = max(1.0, floor(size.y * exp2(-f32(j))));
390
+ y = y + mh + ATLAS_MIP_GAP;
391
+ j = j + 1u;
392
+ }
393
+ return vec2<f32>(x, y);
394
+ }
395
+
396
+ fn atlasMipSizePx(size: vec2<f32>, k: u32) -> vec2<f32> {
397
+ return vec2<f32>(
398
+ max(1.0, floor(size.x * exp2(-f32(k)))),
399
+ max(1.0, floor(size.y * exp2(-f32(k)))),
400
+ );
401
+ }
402
+
403
+ fn atlasSampleAtMip(
404
+ pageRef: u32, format: u32,
405
+ origin_px: vec2<f32>, size_px: vec2<f32>,
406
+ k: u32,
407
+ uv: vec2<f32>,
408
+ addrU: u32, addrV: u32,
409
+ ) -> vec4<f32> {
410
+ let mip_o = atlasMipOriginPx(origin_px, size_px, k);
411
+ let mip_s = atlasMipSizePx(size_px, k);
412
+ let px = atlasAxisAt(uv.x, mip_o.x, mip_s.x, addrU);
413
+ let py = atlasAxisAt(uv.y, mip_o.y, mip_s.y, addrV);
414
+ let atlasUv = vec2<f32>(px, py) / ${atlasPageSizeConst()}.0;
415
+ ${generateAtlasSwitch()}
416
+ return vec4<f32>(0.0);
417
+ }
418
+
419
+ fn atlasSample(
420
+ pageRef: u32, formatBits: u32,
421
+ origin_px: vec2<f32>, size_px: vec2<f32>,
422
+ uv: vec2<f32>,
423
+ ) -> vec4<f32> {
424
+ let format = formatBits & 0x1u;
425
+ let numMips = (formatBits >> 1u) & 0x7u;
426
+ let addrU = (formatBits >> 4u) & 0x3u;
427
+ let addrV = (formatBits >> 6u) & 0x3u;
428
+ // LOD on pre-wrap UV. dpdx/dpdy on the wrapped value spikes at the
429
+ // fract/mirror seam (discontinuity → bogus huge derivative → tiny
430
+ // mip selected → blurred band). Multiply by size_px to get
431
+ // texels-per-screen-pixel.
432
+ let dx = dpdx(uv) * size_px;
433
+ let dy = dpdy(uv) * size_px;
434
+ let rho = max(length(dx), length(dy));
435
+ let maxLod = f32(max(numMips, 1u) - 1u);
436
+ let lod = clamp(log2(max(rho, 1e-6)), 0.0, maxLod);
437
+ let lo = u32(floor(lod));
438
+ let hi = min(lo + 1u, max(numMips, 1u) - 1u);
439
+ let t = lod - f32(lo);
440
+ let a = atlasSampleAtMip(pageRef, format, origin_px, size_px, lo, uv, addrU, addrV);
441
+ if (numMips <= 1u) { return a; }
442
+ let b = atlasSampleAtMip(pageRef, format, origin_px, size_px, hi, uv, addrU, addrV);
443
+ return mix(a, b, t);
444
+ }
445
+ `;
446
+ }
447
+ function atlasPageSizeConst() {
448
+ // Embedded literal — divisor matches ATLAS_PAGE_SIZE in atlasPool.ts.
449
+ return "4096";
450
+ }
451
+ /**
452
+ * Emit `2 * ATLAS_ARRAY_SIZE + 1` binding declarations: N linear
453
+ * `texture_2d<f32>`, N srgb `texture_2d<f32>`, then the shared
454
+ * atlas sampler.
455
+ */
456
+ export function generateAtlasBindings() {
457
+ const lines = [];
458
+ for (let i = 0; i < ATLAS_ARRAY_SIZE; i++) {
459
+ lines.push(`@group(0) @binding(${ATLAS_LINEAR_BINDING_BASE + i}) var atlasLinear${i}: texture_2d<f32>;`);
460
+ }
461
+ for (let i = 0; i < ATLAS_ARRAY_SIZE; i++) {
462
+ lines.push(`@group(0) @binding(${ATLAS_SRGB_BINDING_BASE + i}) var atlasSrgb${i}: texture_2d<f32>;`);
463
+ }
464
+ lines.push(`@group(0) @binding(${ATLAS_SAMPLER_BINDING}) var atlasSampler: sampler;`);
465
+ return lines.join("\n");
466
+ }
467
+ /**
468
+ * Emit the `switch pageRef` ladder body for `atlasSampleAtMip`. Each
469
+ * case picks the matching `atlasLinear<i>` / `atlasSrgb<i>` decl and
470
+ * blends on `format == 1u`. The fallback (page out of range) is the
471
+ * function-level `vec4<f32>(0.0)` after the switch.
472
+ */
473
+ export function generateAtlasSwitch() {
474
+ const lines = [" switch pageRef {"];
475
+ for (let i = 0; i < ATLAS_ARRAY_SIZE; i++) {
476
+ lines.push(` case ${i}u: {`);
477
+ lines.push(` let lin = textureSampleLevel(atlasLinear${i}, atlasSampler, atlasUv, 0.0);`);
478
+ lines.push(` let sr = textureSampleLevel(atlasSrgb${i}, atlasSampler, atlasUv, 0.0);`);
479
+ lines.push(` return select(lin, sr, format == 1u);`);
480
+ lines.push(` }`);
481
+ }
482
+ lines.push(" default: {}");
483
+ lines.push(" }");
484
+ return lines.join("\n");
485
+ }
486
+ /** Render one varying as the WGSL field declaration: `[@builtin(...) | @location(N)] [@interpolate(...)] name`. */
487
+ function vsOutFieldDecl(v) {
488
+ if (v.builtin !== undefined)
489
+ return `@builtin(${v.builtin}) ${v.name}`;
490
+ const interp = v.interpolation !== undefined ? ` @interpolate(${v.interpolation})` : "";
491
+ if (v.location === undefined) {
492
+ throw new Error(`heapEffect: varying '${v.name}' has neither @builtin nor @location`);
493
+ }
494
+ return `@location(${v.location})${interp} ${v.name}`;
495
+ }
496
+ /** Atlas-texture varying names used by the VS→FS threading + FS preamble. */
497
+ export function atlasVaryingNames(name) {
498
+ return {
499
+ pageRef: `_h_${name}PageRef`,
500
+ formatBits: `_h_${name}FormatBits`,
501
+ origin: `_h_${name}Origin`,
502
+ size: `_h_${name}Size`,
503
+ };
504
+ }
505
+ /**
506
+ * Megacall VS prelude: binary-search `drawTable` (one record per slot,
507
+ * 5 u32s: firstEmit, drawIdx, indexStart, indexCount, instanceCount)
508
+ * for the slot owning the given `emitIdx`, then split the in-record
509
+ * offset into `(instId, vid)` so per-RO instancing collapses to one
510
+ * record + one drawIndirect. Defines:
511
+ * - `heap_drawIdx` — per-RO selector for header reads.
512
+ * - `instId` — instance index in [0, instanceCount-1].
513
+ * - `vid` — vertex index pulled from indexStorage.
514
+ *
515
+ * Layout: each record emits `indexCount * instanceCount` vertices.
516
+ * `local = emitIdx - firstEmit`, `instId = local / indexCount`,
517
+ * `vid = indices[indexStart + local % indexCount]`.
518
+ */
519
+ export function megacallSearchPrelude() {
520
+ // The shared megacall values (`heap_drawIdx`, `instId`, `vid`) are
521
+ // declared as `let` locals inside the @vertex fn body. Wombat.shader's
522
+ // composed-stage helper functions (extractFusedEntry) that reference
523
+ // these identifiers are post-processed in `applyMegacallToEmittedVs`
524
+ // to receive them as `u32` parameters — module-scope `var<private>`
525
+ // is rejected by some WGSL parsers (Safari/WebKit), so we thread the
526
+ // values through helper signatures instead.
527
+ return ` let _tileIdx = emitIdx >> 6u;\n var lo: u32 = firstDrawInTile[_tileIdx];\n var hi: u32 = firstDrawInTile[_tileIdx + 1u];\n loop {\n if (lo >= hi) { break; }\n let _mid = (lo + hi + 1u) >> 1u;\n if (drawTable[_mid * 5u] <= emitIdx) { lo = _mid; } else { hi = _mid - 1u; }\n }\n let _slot = lo;\n let _firstEmit = drawTable[_slot * 5u + 0u];\n let heap_drawIdx: u32 = drawTable[_slot * 5u + 1u];\n let _indexStart = drawTable[_slot * 5u + 2u];\n let _indexCount = drawTable[_slot * 5u + 3u];\n let _local = emitIdx - _firstEmit;\n let instId: u32 = _local / _indexCount;\n let vid: u32 = indexStorage[_indexStart + (_local % _indexCount)];\n`;
528
+ }
529
+ //# sourceMappingURL=heapEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heapEffect.js","sourceRoot":"","sources":["../../src/runtime/heapEffect.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,cAAc;AACd,EAAE;AACF,4EAA4E;AAC5E,kEAAkE;AAClE,qEAAqE;AACrE,qEAAqE;AACrE,mCAAmC;AACnC,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,oEAAoE;AACpE,6DAA6D;AAC7D,sEAAsE;AACtE,wDAAwD;AAkExD,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,oBAA2C;IAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAC7B,oBAAoB,KAAK,SAAS;QAChC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE;QAC1C,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CACvB,CAAC;IACF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,QAAQ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K,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,mHAAmH;AACnH,SAAS,cAAc,CAAC,CAAc;IACpC,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,MAAM,MAAM,GAAG,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxF,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,IAAI,sCAAsC,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,aAAa,CAAC,CAAC,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAG5C,OAAO;QACL,OAAO,EAAK,MAAM,IAAI,SAAS;QAC/B,UAAU,EAAE,MAAM,IAAI,YAAY;QAClC,MAAM,EAAM,MAAM,IAAI,QAAQ;QAC9B,IAAI,EAAQ,MAAM,IAAI,MAAM;KAC7B,CAAC;AACJ,CAAC;AAGD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB;IACnC,mEAAmE;IACnE,uEAAuE;IACvE,qEAAqE;IACrE,qEAAqE;IACrE,oEAAoE;IACpE,qEAAqE;IACrE,4CAA4C;IAC5C,OAAO,iqBAAiqB,CAAC;AAC3qB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { Effect, CompileOptions } from "@aardworx/wombat.shader";
2
+ import { type BucketLayout } from "./heapEffect.js";
3
+ /**
4
+ * Compile a wombat.shader Effect into heap-rendering WGSL via IR-level
5
+ * substitution.
6
+ *
7
+ * v1 scope:
8
+ * - Adds heap storage buffers + builtin VS params.
9
+ * - Substitutes VS attribute / VS uniform reads with heap loads.
10
+ * - FS uniform substitution still TBD — falls back to current
11
+ * regex rewriter for FS until the cross-stage threading is wired.
12
+ */
13
+ /**
14
+ * Emission mode for `compileHeapEffectIR`.
15
+ *
16
+ * - `"standalone"` (default): emit a self-contained pipeline. The VS
17
+ * entry takes `@builtin(vertex_index) emitIdx` and runs the megacall
18
+ * binary-search prelude inline; storage-buffer bindings 4..6 for
19
+ * drawTable / indexStorage / firstDrawInTile are appended.
20
+ * - `"family-member"`: emit a VS entry shaped to be invoked from a
21
+ * family wrapper. The wrapper performs the megacall search and
22
+ * passes `heap_drawIdx`, `instId`, `vid` down. The emitted entry
23
+ * becomes `@vertex fn vs(heap_drawIdx: u32, instId: u32, vid: u32)`;
24
+ * no megacall prelude or bindings 4..6 are emitted at this level.
25
+ */
26
+ export type HeapEffectEmitMode = "standalone" | "family-member";
27
+ export declare function compileHeapEffectIR(userEffect: Effect, layout: BucketLayout, compileOptions: CompileOptions, mode?: HeapEffectEmitMode): {
28
+ vs: string;
29
+ fs: string;
30
+ preludeWgsl: string;
31
+ vsEntry: string;
32
+ fsEntry: string;
33
+ };
34
+ //# sourceMappingURL=heapEffectIR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heapEffectIR.d.ts","sourceRoot":"","sources":["../../src/runtime/heapEffectIR.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOtE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAwuBzB;;;;;;;;;GASG;AACH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,eAAe,CAAC;AAEhE,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,cAAc,EAC9B,IAAI,GAAE,kBAAiC,GACtC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA2EnF"}