@flighthq/render-gl 0.1.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 (82) hide show
  1. package/dist/glBackground.d.ts +3 -0
  2. package/dist/glBackground.d.ts.map +1 -0
  3. package/dist/glBackground.js +17 -0
  4. package/dist/glBackground.js.map +1 -0
  5. package/dist/glDraw.d.ts +11 -0
  6. package/dist/glDraw.d.ts.map +1 -0
  7. package/dist/glDraw.js +132 -0
  8. package/dist/glDraw.js.map +1 -0
  9. package/dist/glElement.d.ts +2 -0
  10. package/dist/glElement.d.ts.map +1 -0
  11. package/dist/glElement.js +9 -0
  12. package/dist/glElement.js.map +1 -0
  13. package/dist/glFullscreenPass.d.ts +11 -0
  14. package/dist/glFullscreenPass.d.ts.map +1 -0
  15. package/dist/glFullscreenPass.js +114 -0
  16. package/dist/glFullscreenPass.js.map +1 -0
  17. package/dist/glMaterialRegistry.d.ts +5 -0
  18. package/dist/glMaterialRegistry.d.ts.map +1 -0
  19. package/dist/glMaterialRegistry.js +25 -0
  20. package/dist/glMaterialRegistry.js.map +1 -0
  21. package/dist/glProgram.d.ts +4 -0
  22. package/dist/glProgram.d.ts.map +1 -0
  23. package/dist/glProgram.js +37 -0
  24. package/dist/glProgram.js.map +1 -0
  25. package/dist/glReadback.d.ts +3 -0
  26. package/dist/glReadback.d.ts.map +1 -0
  27. package/dist/glReadback.js +33 -0
  28. package/dist/glReadback.js.map +1 -0
  29. package/dist/glRenderState.d.ts +7 -0
  30. package/dist/glRenderState.d.ts.map +1 -0
  31. package/dist/glRenderState.js +153 -0
  32. package/dist/glRenderState.js.map +1 -0
  33. package/dist/glRenderTarget.d.ts +41 -0
  34. package/dist/glRenderTarget.d.ts.map +1 -0
  35. package/dist/glRenderTarget.js +284 -0
  36. package/dist/glRenderTarget.js.map +1 -0
  37. package/dist/glRenderTargetPool.d.ts +6 -0
  38. package/dist/glRenderTargetPool.d.ts.map +1 -0
  39. package/dist/glRenderTargetPool.js +33 -0
  40. package/dist/glRenderTargetPool.js.map +1 -0
  41. package/dist/glShader.d.ts +39 -0
  42. package/dist/glShader.d.ts.map +1 -0
  43. package/dist/glShader.js +116 -0
  44. package/dist/glShader.js.map +1 -0
  45. package/dist/glShaderBinding.d.ts +21 -0
  46. package/dist/glShaderBinding.d.ts.map +1 -0
  47. package/dist/glShaderBinding.js +60 -0
  48. package/dist/glShaderBinding.js.map +1 -0
  49. package/dist/glShaderRegistry.d.ts +5 -0
  50. package/dist/glShaderRegistry.d.ts.map +1 -0
  51. package/dist/glShaderRegistry.js +6 -0
  52. package/dist/glShaderRegistry.js.map +1 -0
  53. package/dist/glShaderTypes.d.ts +2 -0
  54. package/dist/glShaderTypes.d.ts.map +1 -0
  55. package/dist/glShaderTypes.js +2 -0
  56. package/dist/glShaderTypes.js.map +1 -0
  57. package/dist/glTestHelper.d.ts +14 -0
  58. package/dist/glTestHelper.d.ts.map +1 -0
  59. package/dist/glTestHelper.js +69 -0
  60. package/dist/glTestHelper.js.map +1 -0
  61. package/dist/index.d.ts +14 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +13 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/internal.d.ts +2 -0
  66. package/dist/internal.d.ts.map +1 -0
  67. package/dist/internal.js +2 -0
  68. package/dist/internal.js.map +1 -0
  69. package/package.json +40 -0
  70. package/src/glBackground.test.ts +43 -0
  71. package/src/glDraw.test.ts +360 -0
  72. package/src/glElement.test.ts +38 -0
  73. package/src/glFullscreenPass.test.ts +185 -0
  74. package/src/glMaterialRegistry.test.ts +48 -0
  75. package/src/glProgram.test.ts +59 -0
  76. package/src/glReadback.test.ts +82 -0
  77. package/src/glRenderState.test.ts +186 -0
  78. package/src/glRenderTarget.test.ts +317 -0
  79. package/src/glRenderTargetPool.test.ts +97 -0
  80. package/src/glShader.test.ts +331 -0
  81. package/src/glShaderBinding.test.ts +149 -0
  82. package/src/glShaderRegistry.test.ts +19 -0
@@ -0,0 +1,153 @@
1
+ import { createMatrix } from '@flighthq/geometry';
2
+ import { createRenderState as _createRenderState, createRenderStateRuntime, setRenderStateBackgroundColor, } from '@flighthq/render';
3
+ import { EntityRuntimeKey } from '@flighthq/types';
4
+ import { compileDefaultGlProgram, createDefaultGlBitmapShader } from './glShader';
5
+ export function createGlRenderState(canvas, options = {}) {
6
+ const contextAttribs = {
7
+ alpha: true,
8
+ antialias: options.antialias ?? true,
9
+ powerPreference: options.powerPreference ?? 'default',
10
+ stencil: true,
11
+ ...options.contextAttributes,
12
+ };
13
+ const gl = canvas.getContext('webgl2', contextAttribs);
14
+ if (!gl)
15
+ throw new Error('Failed to get WebGL2 context.');
16
+ const shaderLoc = compileDefaultGlProgram(gl);
17
+ const matrixArray = new Float32Array(9);
18
+ const defaultBitmapShader = createDefaultGlBitmapShader(shaderLoc, matrixArray);
19
+ // Static index buffer [0, 1, 2, 0, 2, 3]
20
+ const quadIndexBuffer = gl.createBuffer();
21
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, quadIndexBuffer);
22
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 0, 2, 3]), gl.STATIC_DRAW);
23
+ // Dynamic vertex buffer: 4 vertices × 4 floats (x, y, u, v) × 4 bytes = 64 bytes
24
+ const quadVertexBuffer = gl.createBuffer();
25
+ gl.bindBuffer(gl.ARRAY_BUFFER, quadVertexBuffer);
26
+ gl.bufferData(gl.ARRAY_BUFFER, 64, gl.DYNAMIC_DRAW);
27
+ const state = _createRenderState({
28
+ allowSmoothing: options.imageSmoothingEnabled ?? true,
29
+ pixelRatio: options.pixelRatio ?? 1,
30
+ renderTransform2D: createMatrix(),
31
+ roundPixels: options.roundPixels ?? false,
32
+ sceneGraphSyncPolicy: options.sceneGraphSyncPolicy,
33
+ });
34
+ state.applyBlendMode = null;
35
+ state.canvas = canvas;
36
+ state.gl = gl;
37
+ if (options.backgroundColor != null)
38
+ setRenderStateBackgroundColor(state, options.backgroundColor);
39
+ const runtime = createGlRenderStateRuntime();
40
+ state[EntityRuntimeKey] = runtime;
41
+ runtime.currentBlendMode = null;
42
+ runtime.currentFramebuffer = null;
43
+ runtime.currentMaskDepth = 0;
44
+ runtime.currentProgram = null;
45
+ runtime.currentScissorRect = null;
46
+ runtime.currentTexture = null;
47
+ runtime.renderTargetViewport = null;
48
+ runtime.defaultBitmapShader = defaultBitmapShader;
49
+ runtime.shaderLoc = shaderLoc;
50
+ runtime.spriteBatchBlendMode = null;
51
+ runtime.spriteBatchMaterial = null;
52
+ runtime.spriteBatchMaterialRenderer = null;
53
+ runtime.spriteBatchMaterialFloats = 0;
54
+ runtime.spriteBatchMaterialData = new Float32Array(8 * 256);
55
+ runtime.spriteBatchMaterialBuffer = null;
56
+ runtime.spriteBatchCount = 0;
57
+ runtime.spriteBatchInstanceBuffer = null;
58
+ runtime.spriteBatchInstanceData = new Float32Array(13 * 256);
59
+ runtime.spriteBatchTexture = null;
60
+ runtime.textureCache = new WeakMap();
61
+ runtime.quadVertexBuffer = quadVertexBuffer;
62
+ runtime.quadIndexBuffer = quadIndexBuffer;
63
+ runtime.quadVertexData = new Float32Array(16);
64
+ runtime.matrixArray = matrixArray;
65
+ runtime.scissorStack = [];
66
+ runtime.clipForms = [];
67
+ gl.enable(gl.BLEND);
68
+ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
69
+ gl.disable(gl.DEPTH_TEST);
70
+ return state;
71
+ }
72
+ // Allocates the package-private GPU runtime for a GlRenderState. createGlRenderState attaches
73
+ // one to each state under EntityRuntimeKey and populates its fields; getGlRenderStateRuntime reads
74
+ // it back. The render path writes the returned object every frame, so the return is intentionally
75
+ // mutable (not Readonly).
76
+ export function createGlRenderStateRuntime() {
77
+ return createRenderStateRuntime();
78
+ }
79
+ // Frees the GPU resources createGlRenderState and the lazy ensure* helpers allocated on the
80
+ // state's runtime: the compiled shader programs and the vertex/index/instance buffers. Call when the
81
+ // render state is no longer needed. Pass the state returned by createGlRenderState — render-cache
82
+ // states derived from it (createGlCacheState) alias these resources and become invalid too.
83
+ //
84
+ // Two things are intentionally NOT freed here:
85
+ // - User-registered material shaders (materialBitmapShaderMap and setGlShader bindings): their
86
+ // programs may be shared across states, so freeing them is the registrant's responsibility.
87
+ // - textureCache textures: textureCache is a WeakMap and cannot be enumerated. Those textures are
88
+ // freed per-node by the dispose* paths, or by the browser when the GL context is lost.
89
+ //
90
+ // Deleting an already-deleted Gl program or buffer is a silent no-op, so destroying a screen
91
+ // state whose resources a cache state still aliases is safe.
92
+ export function destroyGlRenderState(state) {
93
+ const runtime = getGlRenderStateRuntime(state);
94
+ const gl = state.gl;
95
+ // Dedupe: several shader wrappers (e.g. defaultBitmapShader) share shaderLoc.program.
96
+ const programs = new Set();
97
+ if (runtime.shaderLoc)
98
+ programs.add(runtime.shaderLoc.program);
99
+ if (runtime.defaultBitmapShader)
100
+ programs.add(runtime.defaultBitmapShader.program);
101
+ if (runtime.colorTransformBitmapShader)
102
+ programs.add(runtime.colorTransformBitmapShader.program);
103
+ if (runtime.particleShader)
104
+ programs.add(runtime.particleShader.program);
105
+ if (runtime.quadBatchShader)
106
+ programs.add(runtime.quadBatchShader.program);
107
+ if (runtime.colorTransformInstancedShader)
108
+ programs.add(runtime.colorTransformInstancedShader.program);
109
+ if (runtime.uniformColorTransformShader)
110
+ programs.add(runtime.uniformColorTransformShader.program);
111
+ for (const program of programs)
112
+ gl.deleteProgram(program);
113
+ gl.deleteBuffer(runtime.quadVertexBuffer);
114
+ gl.deleteBuffer(runtime.quadIndexBuffer);
115
+ if (runtime.particleCornerBuffer)
116
+ gl.deleteBuffer(runtime.particleCornerBuffer);
117
+ if (runtime.particleInstanceBuffer)
118
+ gl.deleteBuffer(runtime.particleInstanceBuffer);
119
+ if (runtime.quadBatchCornerBuffer)
120
+ gl.deleteBuffer(runtime.quadBatchCornerBuffer);
121
+ if (runtime.spriteBatchInstanceBuffer)
122
+ gl.deleteBuffer(runtime.spriteBatchInstanceBuffer);
123
+ if (runtime.spriteBatchMaterialBuffer)
124
+ gl.deleteBuffer(runtime.spriteBatchMaterialBuffer);
125
+ }
126
+ // Resolves the package-private GPU runtime attached to a GlRenderState. Mutable by design: the
127
+ // render path writes its fields every frame.
128
+ export function getGlRenderStateRuntime(state) {
129
+ return state[EntityRuntimeKey];
130
+ }
131
+ // Discards render-gl's cached GL binding state (bound program, texture, framebuffer, blend mode,
132
+ // scissor, viewport) so the next render-gl draw re-binds everything from scratch. render-gl's draw
133
+ // paths skip redundant `useProgram`/`bindTexture`/`bindFramebuffer` calls by trusting these cached
134
+ // slots, which is only sound while render-gl is the *sole* writer of GL state on the context.
135
+ //
136
+ // A sibling renderer that issues raw GL commands against the same context — scene-gl's mesh,
137
+ // skybox, shadow, and IBL passes all call `gl.useProgram`/`gl.blendFunc`/`gl.bindFramebuffer`
138
+ // directly — leaves those cached slots pointing at bindings that are no longer current. The next
139
+ // render-gl operation (a 2D draw or the effect-pipeline present pass) then skips a bind it needed,
140
+ // e.g. setting a uniform against a program that is not the one actually bound, which GL rejects with
141
+ // `INVALID_OPERATION: uniform...: location is not from the associated program`. Any such guest
142
+ // renderer must call this before returning control to render-gl.
143
+ export function invalidateGlRenderStateCache(state) {
144
+ const runtime = getGlRenderStateRuntime(state);
145
+ runtime.currentBlendMode = null;
146
+ runtime.currentFramebuffer = null;
147
+ runtime.currentMaskDepth = 0;
148
+ runtime.currentProgram = null;
149
+ runtime.currentScissorRect = null;
150
+ runtime.currentTexture = null;
151
+ runtime.renderTargetViewport = null;
152
+ }
153
+ //# sourceMappingURL=glRenderState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glRenderState.js","sourceRoot":"","sources":["../src/glRenderState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,IAAI,kBAAkB,EACvC,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAE1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@
1
+ import type { GlRenderState, GlRenderTarget, Matrix, RenderProxy2D, RenderTargetDescriptor } from '@flighthq/types';
2
+ /**
3
+ * Redirects subsequent Gl rendering into `target`'s framebuffer. Saves the current framebuffer
4
+ * binding, renderTargetViewport, and renderTransform2D so they can be fully restored by
5
+ * `endGlRenderTarget`. Supports nesting.
6
+ *
7
+ * The caller must set the desired `renderTransform` (via this function) before rendering into the
8
+ * target to ensure the render tree's transform2D values are correct.
9
+ */
10
+ export declare function beginGlRenderTarget(state: GlRenderState, target: GlRenderTarget, renderTransform: Readonly<Matrix>): void;
11
+ /**
12
+ * Allocates a render target realizing `descriptor`'s axes (format, MSAA sampleCount, MRT
13
+ * colorAttachments, depth). The framebuffer is bound during creation but the previous binding is
14
+ * restored before returning.
15
+ */
16
+ export declare function createGlRenderTarget(state: GlRenderState, descriptor: Readonly<RenderTargetDescriptor>): GlRenderTarget;
17
+ /** Deletes the GL resources owned by `target`. The target object must not be used after this call. */
18
+ export declare function destroyGlRenderTarget(state: GlRenderState, target: GlRenderTarget): void;
19
+ /**
20
+ * Composites `target`'s texture onto the current framebuffer as a positioned quad, using
21
+ * `renderProxy`'s world transform and alpha. `transform` maps the target's pixel space into the
22
+ * node's local space (as produced by `computeRenderCacheTransform`).
23
+ *
24
+ * Render-target textures are stored with GL's bottom-left origin, so the quad's V coordinates are
25
+ * flipped (`v0=1, v1=0`) so the result composites upright.
26
+ */
27
+ export declare function drawGlRenderTargetResult(state: GlRenderState, renderProxy: RenderProxy2D, target: Readonly<GlRenderTarget>, transform: Readonly<Matrix>): void;
28
+ /**
29
+ * Restores the framebuffer, viewport, renderTargetViewport, and renderTransform2D saved by the
30
+ * matching `beginGlRenderTarget` call.
31
+ */
32
+ export declare function endGlRenderTarget(state: GlRenderState): void;
33
+ /** Reallocates the storage backing `target` to the new pixel dimensions, preserving its axes. */
34
+ export declare function resizeGlRenderTarget(state: GlRenderState, target: GlRenderTarget, width: number, height: number): void;
35
+ /**
36
+ * Resolves an MSAA target's multisample framebuffer into its single-sample resolve texture(s) via
37
+ * blitFramebuffer. No-op when sampleCount === 1. Call after the scene is drawn into the target and
38
+ * before sampling `target.texture`/`target.textures`.
39
+ */
40
+ export declare function resolveGlRenderTarget(state: GlRenderState, target: GlRenderTarget): void;
41
+ //# sourceMappingURL=glRenderTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glRenderTarget.d.ts","sourceRoot":"","sources":["../src/glRenderTarget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,MAAM,EACN,aAAa,EACb,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,EACtB,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,IAAI,CA4BN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAC3C,cAAc,CAgChB;AAED,sGAAsG;AACtG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAQxF;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,aAAa,EAC1B,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,EAChC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC1B,IAAI,CAoBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAgB5D;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAoBN;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CA8BxF"}
@@ -0,0 +1,284 @@
1
+ import { acquireMatrix, copyMatrix, createMatrix, multiplyMatrix, releaseMatrix } from '@flighthq/geometry';
2
+ import { drawGlQuad, useGlProgram } from './glDraw';
3
+ import { getGlRenderStateRuntime } from './glRenderState';
4
+ import { setGlAttributes, setGlBaseUniforms, setGlMatrixFromTransform } from './glShader';
5
+ /**
6
+ * Redirects subsequent Gl rendering into `target`'s framebuffer. Saves the current framebuffer
7
+ * binding, renderTargetViewport, and renderTransform2D so they can be fully restored by
8
+ * `endGlRenderTarget`. Supports nesting.
9
+ *
10
+ * The caller must set the desired `renderTransform` (via this function) before rendering into the
11
+ * target to ensure the render tree's transform2D values are correct.
12
+ */
13
+ export function beginGlRenderTarget(state, target, renderTransform) {
14
+ const runtime = getGlRenderStateRuntime(state);
15
+ const gl = state.gl;
16
+ let stack = _targetStack.get(state);
17
+ if (stack === undefined) {
18
+ stack = [];
19
+ _targetStack.set(state, stack);
20
+ }
21
+ stack.push({
22
+ framebuffer: runtime.currentFramebuffer,
23
+ renderTargetViewport: runtime.renderTargetViewport,
24
+ renderTransform2D: state.renderTransform2D,
25
+ });
26
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
27
+ gl.viewport(0, 0, target.width, target.height);
28
+ runtime.currentFramebuffer = target.framebuffer;
29
+ runtime.renderTargetViewport = { width: target.width, height: target.height };
30
+ // Force rebind on next draw — the framebuffer switch invalidates GL state assumptions.
31
+ runtime.currentTexture = null;
32
+ runtime.currentBlendMode = null;
33
+ const newTransform = createMatrix();
34
+ copyMatrix(newTransform, renderTransform);
35
+ state.renderTransform2D = newTransform;
36
+ }
37
+ /**
38
+ * Allocates a render target realizing `descriptor`'s axes (format, MSAA sampleCount, MRT
39
+ * colorAttachments, depth). The framebuffer is bound during creation but the previous binding is
40
+ * restored before returning.
41
+ */
42
+ export function createGlRenderTarget(state, descriptor) {
43
+ const runtime = getGlRenderStateRuntime(state);
44
+ const gl = state.gl;
45
+ const w = Math.max(1, Math.ceil(descriptor.width));
46
+ const h = Math.max(1, Math.ceil(descriptor.height));
47
+ const format = descriptor.format ?? 'rgba8';
48
+ const attachments = Math.max(1, descriptor.colorAttachments ?? 1);
49
+ const sampleCount = Math.max(1, descriptor.sampleCount ?? 1);
50
+ const depth = descriptor.depth ?? 'none';
51
+ const maxSamples = sampleCount > 1 ? Math.min(sampleCount, gl.getParameter(gl.MAX_SAMPLES)) : 1;
52
+ const target = {
53
+ width: w,
54
+ height: h,
55
+ format,
56
+ sampleCount: maxSamples,
57
+ framebuffer: gl.createFramebuffer(),
58
+ resolveFramebuffer: null,
59
+ textures: [],
60
+ texture: null,
61
+ depthTexture: null,
62
+ colorRenderbuffers: [],
63
+ depthStencilRenderbuffer: null,
64
+ };
65
+ allocateGlRenderTargetStorage(state, target, descriptor.colorFormats, attachments, depth);
66
+ gl.bindFramebuffer(gl.FRAMEBUFFER, runtime.currentFramebuffer);
67
+ gl.bindTexture(gl.TEXTURE_2D, null);
68
+ runtime.currentTexture = null;
69
+ return target;
70
+ }
71
+ /** Deletes the GL resources owned by `target`. The target object must not be used after this call. */
72
+ export function destroyGlRenderTarget(state, target) {
73
+ const gl = state.gl;
74
+ gl.deleteFramebuffer(target.framebuffer);
75
+ if (target.resolveFramebuffer)
76
+ gl.deleteFramebuffer(target.resolveFramebuffer);
77
+ for (const texture of target.textures)
78
+ gl.deleteTexture(texture);
79
+ for (const rb of target.colorRenderbuffers)
80
+ gl.deleteRenderbuffer(rb);
81
+ if (target.depthTexture)
82
+ gl.deleteTexture(target.depthTexture);
83
+ if (target.depthStencilRenderbuffer)
84
+ gl.deleteRenderbuffer(target.depthStencilRenderbuffer);
85
+ }
86
+ /**
87
+ * Composites `target`'s texture onto the current framebuffer as a positioned quad, using
88
+ * `renderProxy`'s world transform and alpha. `transform` maps the target's pixel space into the
89
+ * node's local space (as produced by `computeRenderCacheTransform`).
90
+ *
91
+ * Render-target textures are stored with GL's bottom-left origin, so the quad's V coordinates are
92
+ * flipped (`v0=1, v1=0`) so the result composites upright.
93
+ */
94
+ export function drawGlRenderTargetResult(state, renderProxy, target, transform) {
95
+ if (target.width <= 0 || target.height <= 0)
96
+ return;
97
+ const runtime = getGlRenderStateRuntime(state);
98
+ useGlProgram(state);
99
+ state.applyBlendMode?.(state, renderProxy.blendMode);
100
+ const gl = state.gl;
101
+ const { shaderLoc, matrixArray } = runtime;
102
+ gl.bindTexture(gl.TEXTURE_2D, target.texture);
103
+ runtime.currentTexture = target.texture;
104
+ const quadTransform = acquireMatrix();
105
+ multiplyMatrix(quadTransform, renderProxy.transform2D, transform);
106
+ setGlAttributes(gl, shaderLoc);
107
+ setGlMatrixFromTransform(gl, shaderLoc, matrixArray, quadTransform, runtime.renderTargetViewport ?? state.canvas);
108
+ setGlBaseUniforms(gl, shaderLoc, renderProxy);
109
+ releaseMatrix(quadTransform);
110
+ drawGlQuad(state, 0, 0, target.width, target.height, 0, 1, 1, 0);
111
+ }
112
+ /**
113
+ * Restores the framebuffer, viewport, renderTargetViewport, and renderTransform2D saved by the
114
+ * matching `beginGlRenderTarget` call.
115
+ */
116
+ export function endGlRenderTarget(state) {
117
+ const runtime = getGlRenderStateRuntime(state);
118
+ const gl = state.gl;
119
+ const saved = _targetStack.get(state)?.pop();
120
+ if (saved === undefined)
121
+ return;
122
+ gl.bindFramebuffer(gl.FRAMEBUFFER, saved.framebuffer);
123
+ const viewport = saved.renderTargetViewport ?? state.canvas;
124
+ gl.viewport(0, 0, viewport.width, viewport.height);
125
+ runtime.currentFramebuffer = saved.framebuffer;
126
+ runtime.renderTargetViewport = saved.renderTargetViewport;
127
+ state.renderTransform2D = saved.renderTransform2D;
128
+ runtime.currentTexture = null;
129
+ runtime.currentBlendMode = null;
130
+ }
131
+ /** Reallocates the storage backing `target` to the new pixel dimensions, preserving its axes. */
132
+ export function resizeGlRenderTarget(state, target, width, height) {
133
+ const w = Math.max(1, Math.ceil(width));
134
+ const h = Math.max(1, Math.ceil(height));
135
+ if (w === target.width && h === target.height)
136
+ return;
137
+ const gl = state.gl;
138
+ for (const texture of target.textures)
139
+ gl.deleteTexture(texture);
140
+ for (const rb of target.colorRenderbuffers)
141
+ gl.deleteRenderbuffer(rb);
142
+ if (target.depthTexture)
143
+ gl.deleteTexture(target.depthTexture);
144
+ if (target.depthStencilRenderbuffer)
145
+ gl.deleteRenderbuffer(target.depthStencilRenderbuffer);
146
+ target.textures = [];
147
+ target.colorRenderbuffers = [];
148
+ target.depthTexture = null;
149
+ target.depthStencilRenderbuffer = null;
150
+ target.width = w;
151
+ target.height = h;
152
+ const depth = target.depthStencilRenderbuffer || target.depthTexture ? 'depth-stencil' : 'none';
153
+ allocateGlRenderTargetStorage(state, target, undefined, Math.max(1, target.textures.length || 1), depth);
154
+ getGlRenderStateRuntime(state).currentTexture = null;
155
+ }
156
+ /**
157
+ * Resolves an MSAA target's multisample framebuffer into its single-sample resolve texture(s) via
158
+ * blitFramebuffer. No-op when sampleCount === 1. Call after the scene is drawn into the target and
159
+ * before sampling `target.texture`/`target.textures`.
160
+ */
161
+ export function resolveGlRenderTarget(state, target) {
162
+ if (target.sampleCount <= 1 || target.resolveFramebuffer === null)
163
+ return;
164
+ const runtime = getGlRenderStateRuntime(state);
165
+ const gl = state.gl;
166
+ gl.bindFramebuffer(gl.READ_FRAMEBUFFER, target.framebuffer);
167
+ gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, target.resolveFramebuffer);
168
+ for (let i = 0; i < target.textures.length; i++) {
169
+ gl.readBuffer(gl.COLOR_ATTACHMENT0 + i);
170
+ gl.drawBuffers(buildSingleDrawBuffer(gl, i, target.textures.length));
171
+ gl.blitFramebuffer(0, 0, target.width, target.height, 0, 0, target.width, target.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
172
+ }
173
+ gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
174
+ gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, runtime.currentFramebuffer);
175
+ // Flush so the resolved texels are visible to the next sample of `target.texture`. The blit→sample
176
+ // dependency is implicit in conformant GL, but some drivers (notably headless SwiftShader) sample a
177
+ // stale resolve texture without this; the cost is one flush per frame, only when MSAA is enabled.
178
+ gl.flush();
179
+ runtime.currentTexture = null;
180
+ }
181
+ // Allocates color textures/renderbuffers (and the resolve FBO for MSAA) plus optional depth into the
182
+ // already-created `target.framebuffer`. Shared by create and resize.
183
+ function allocateGlRenderTargetStorage(state, target, colorFormats, attachments, depth) {
184
+ const gl = state.gl;
185
+ const { width: w, height: h, sampleCount } = target;
186
+ const multisampled = sampleCount > 1;
187
+ // Float color attachments (rgba16f/rgba32f) are not color-renderable in Gl2 until
188
+ // EXT_color_buffer_float is enabled; without it the framebuffer is incomplete and every draw/clear
189
+ // into an HDR target silently no-ops. getExtension is idempotent and cached, so enabling per-alloc is free.
190
+ let usesFloat = isFloatRenderTargetFormat(target.format);
191
+ if (colorFormats)
192
+ for (const f of colorFormats)
193
+ usesFloat = usesFloat || isFloatRenderTargetFormat(f);
194
+ if (usesFloat)
195
+ gl.getExtension('EXT_color_buffer_float');
196
+ // Resolve/sample textures (always single-sample).
197
+ const resolveFramebuffer = multisampled ? gl.createFramebuffer() : target.framebuffer;
198
+ gl.bindFramebuffer(gl.FRAMEBUFFER, resolveFramebuffer);
199
+ for (let i = 0; i < attachments; i++) {
200
+ const fmt = colorFormats?.[i] ?? target.format;
201
+ const gf = mapGlFormat(gl, fmt);
202
+ const texture = gl.createTexture();
203
+ gl.bindTexture(gl.TEXTURE_2D, texture);
204
+ gl.texImage2D(gl.TEXTURE_2D, 0, gf.internalFormat, w, h, 0, gf.format, gf.type, null);
205
+ const filter = state.allowSmoothing ? gl.LINEAR : gl.NEAREST;
206
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
207
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
208
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
209
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
210
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, texture, 0);
211
+ target.textures.push(texture);
212
+ }
213
+ target.texture = target.textures[0];
214
+ if (attachments > 1)
215
+ gl.drawBuffers(buildDrawBuffers(gl, attachments));
216
+ // MSAA color renderbuffers go on the draw framebuffer; resolve FBO holds the textures above.
217
+ if (multisampled) {
218
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
219
+ for (let i = 0; i < attachments; i++) {
220
+ const fmt = colorFormats?.[i] ?? target.format;
221
+ const rb = gl.createRenderbuffer();
222
+ gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
223
+ gl.renderbufferStorageMultisample(gl.RENDERBUFFER, sampleCount, mapGlFormat(gl, fmt).internalFormat, w, h);
224
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, rb);
225
+ target.colorRenderbuffers.push(rb);
226
+ }
227
+ if (attachments > 1)
228
+ gl.drawBuffers(buildDrawBuffers(gl, attachments));
229
+ target.resolveFramebuffer = resolveFramebuffer;
230
+ }
231
+ if (depth !== 'none') {
232
+ const sampled = depth === 'depth-stencil-sampled' && !multisampled;
233
+ if (sampled) {
234
+ const depthTexture = gl.createTexture();
235
+ gl.bindTexture(gl.TEXTURE_2D, depthTexture);
236
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, w, h, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
237
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
238
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
239
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
240
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthTexture, 0);
241
+ target.depthTexture = depthTexture;
242
+ }
243
+ else {
244
+ const rb = gl.createRenderbuffer();
245
+ gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
246
+ if (multisampled)
247
+ gl.renderbufferStorageMultisample(gl.RENDERBUFFER, sampleCount, gl.DEPTH24_STENCIL8, w, h);
248
+ else
249
+ gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, w, h);
250
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
251
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, rb);
252
+ target.depthStencilRenderbuffer = rb;
253
+ }
254
+ }
255
+ gl.bindRenderbuffer(gl.RENDERBUFFER, null);
256
+ gl.bindTexture(gl.TEXTURE_2D, null);
257
+ }
258
+ function buildDrawBuffers(gl, count) {
259
+ const buffers = [];
260
+ for (let i = 0; i < count; i++)
261
+ buffers.push(gl.COLOR_ATTACHMENT0 + i);
262
+ return buffers;
263
+ }
264
+ function buildSingleDrawBuffer(gl, index, count) {
265
+ const buffers = [];
266
+ for (let i = 0; i < count; i++)
267
+ buffers.push(i === index ? gl.COLOR_ATTACHMENT0 + i : gl.NONE);
268
+ return buffers;
269
+ }
270
+ function isFloatRenderTargetFormat(format) {
271
+ return format === 'rgba16f' || format === 'rgba32f';
272
+ }
273
+ function mapGlFormat(gl, format) {
274
+ switch (format) {
275
+ case 'rgba16f':
276
+ return { internalFormat: gl.RGBA16F, format: gl.RGBA, type: gl.HALF_FLOAT };
277
+ case 'rgba32f':
278
+ return { internalFormat: gl.RGBA32F, format: gl.RGBA, type: gl.FLOAT };
279
+ default:
280
+ return { internalFormat: gl.RGBA8, format: gl.RGBA, type: gl.UNSIGNED_BYTE };
281
+ }
282
+ }
283
+ const _targetStack = new WeakMap();
284
+ //# sourceMappingURL=glRenderTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glRenderTarget.js","sourceRoot":"","sources":["../src/glRenderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAU5G,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAQ1F;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAoB,EACpB,MAAsB,EACtB,eAAiC;IAEjC,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IAEpB,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,KAAK,GAAG,EAAE,CAAC;QACX,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC;QACT,WAAW,EAAE,OAAO,CAAC,kBAAkB;QACvC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACvD,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC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E,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;QACzE;YACE,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;IACjF,CAAC;AACH,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,OAAO,EAAiC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { GlRenderState, GlRenderTarget, GlRenderTargetPool, RenderTargetDescriptor } from '@flighthq/types';
2
+ export declare function acquireGlRenderTarget(state: GlRenderState, pool: GlRenderTargetPool, descriptor: Readonly<RenderTargetDescriptor>): GlRenderTarget;
3
+ export declare function createGlRenderTargetPool(): GlRenderTargetPool;
4
+ export declare function destroyGlRenderTargetPool(state: GlRenderState, pool: GlRenderTargetPool): void;
5
+ export declare function releaseGlRenderTarget(pool: GlRenderTargetPool, target: GlRenderTarget): void;
6
+ //# sourceMappingURL=glRenderTargetPool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glRenderTargetPool.d.ts","sourceRoot":"","sources":["../src/glRenderTargetPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAQjH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAC3C,cAAc,CAmBhB;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAG9F;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAE5F"}
@@ -0,0 +1,33 @@
1
+ import { createGlRenderTarget, destroyGlRenderTarget } from './glRenderTarget';
2
+ // Lends reusable intermediate targets to multi-pass effect recipes. acquire/release are paired
3
+ // brackets: every acquireGlRenderTarget must have a matching releaseGlRenderTarget. A released
4
+ // target returns to the free list (its GPU storage is kept) rather than being destroyed.
5
+ export function acquireGlRenderTarget(state, pool, descriptor) {
6
+ const w = Math.max(1, Math.ceil(descriptor.width));
7
+ const h = Math.max(1, Math.ceil(descriptor.height));
8
+ const format = descriptor.format ?? 'rgba8';
9
+ const sampleCount = Math.max(1, descriptor.sampleCount ?? 1);
10
+ for (let i = 0; i < pool.free.length; i++) {
11
+ const candidate = pool.free[i];
12
+ if (candidate.width === w &&
13
+ candidate.height === h &&
14
+ candidate.format === format &&
15
+ candidate.sampleCount === sampleCount) {
16
+ pool.free.splice(i, 1);
17
+ return candidate;
18
+ }
19
+ }
20
+ return createGlRenderTarget(state, descriptor);
21
+ }
22
+ export function createGlRenderTargetPool() {
23
+ return { free: [] };
24
+ }
25
+ export function destroyGlRenderTargetPool(state, pool) {
26
+ for (const target of pool.free)
27
+ destroyGlRenderTarget(state, target);
28
+ pool.free.length = 0;
29
+ }
30
+ export function releaseGlRenderTarget(pool, target) {
31
+ pool.free.push(target);
32
+ }
33
+ //# sourceMappingURL=glRenderTargetPool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glRenderTargetPool.js","sourceRoot":"","sources":["../src/glRenderTargetPool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,+FAA+F;AAC/F,+FAA+F;AAC/F,yFAAyF;AAEzF,MAAM,UAAU,qBAAqB,CACnC,KAAoB,EACpB,IAAwB,EACxB,UAA4C;IAE5C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CA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,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { RenderProxy, RenderProxy2D } from '@flighthq/types';
2
+ import type { GlBitmapShader, GlShaderLocations } from './glShaderTypes';
3
+ export type { GlBitmapShader, GlShaderLocations } from './glShaderTypes';
4
+ export declare function compileDefaultGlProgram(gl: WebGL2RenderingContext): GlShaderLocations;
5
+ /**
6
+ * Compiles a bitmap program, reusing the standard quad vertex shader. Pass a
7
+ * custom fragment source to build a custom shader; it must declare the interface
8
+ * the draw path drives — `in vec2 v_texCoord`, `uniform sampler2D u_texture`,
9
+ * `uniform float u_alpha` — and may add its own uniforms, resolved against the
10
+ * returned `program`.
11
+ */
12
+ export declare function compileGlBitmapProgram(gl: WebGL2RenderingContext, fragmentSrc?: string): GlShaderLocations;
13
+ export declare function createDefaultGlBitmapShader(shaderLoc: GlShaderLocations, matrixArray: Float32Array): GlBitmapShader;
14
+ /**
15
+ * Builds a custom bitmap shader from a fragment shader source, ready to pass to
16
+ * `setGlShader(state, node, shader)`. The standard quad vertex shader is
17
+ * reused, so the fragment shader must sample `u_texture` and respect `u_alpha`;
18
+ * any extra uniforms can be set per draw via `onBind` (resolve them against
19
+ * `locations.program`).
20
+ */
21
+ export declare function createGlBitmapShader(gl: WebGL2RenderingContext, fragmentSrc: string, onBind?: (gl: WebGL2RenderingContext, locations: GlShaderLocations, renderProxy: RenderProxy2D) => void): GlBitmapShader;
22
+ export declare function setGlAttributes(gl: WebGL2RenderingContext, loc: GlShaderLocations): void;
23
+ export declare function setGlBaseUniforms(gl: WebGL2RenderingContext, loc: GlShaderLocations, renderProxy: RenderProxy): void;
24
+ export declare function setGlMatrixFromTransform(gl: WebGL2RenderingContext, loc: GlShaderLocations, m: Float32Array, t: {
25
+ a: number;
26
+ b: number;
27
+ c: number;
28
+ d: number;
29
+ tx: number;
30
+ ty: number;
31
+ }, viewport: {
32
+ width: number;
33
+ height: number;
34
+ }): void;
35
+ export declare function setGlMatrixFromValues(gl: WebGL2RenderingContext, loc: GlShaderLocations, m: Float32Array, a: number, b: number, c: number, d: number, tx: number, ty: number, viewport: {
36
+ width: number;
37
+ height: number;
38
+ }): void;
39
+ //# sourceMappingURL=glShader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glShader.d.ts","sourceRoot":"","sources":["../src/glShader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIjF,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAyBzE,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,sBAAsB,GAAG,iBAAiB,CAErF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,sBAAsB,EAC1B,WAAW,GAAE,MAAqB,GACjC,iBAAiB,CAUnB;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,GAAG,cAAc,CAiBnH;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,sBAAsB,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,sBAAsB,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,KAAK,IAAI,GACtG,cAAc,CAmBhB;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAKxF;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAGpH;AAED,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,sBAAsB,EAC1B,GAAG,EAAE,iBAAiB,EACtB,CAAC,EAAE,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