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