@flighthq/render-gl 0.3.0-next.906.07cea63 → 0.3.1-next.209.43ef1bc

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 (112) hide show
  1. package/dist/contract.d.ts +5 -0
  2. package/dist/contract.d.ts.map +1 -1
  3. package/dist/contract.js +5 -0
  4. package/dist/contract.js.map +1 -1
  5. package/dist/enableGlRenderStateGuards.d.ts +4 -0
  6. package/dist/enableGlRenderStateGuards.d.ts.map +1 -0
  7. package/dist/enableGlRenderStateGuards.js +52 -0
  8. package/dist/enableGlRenderStateGuards.js.map +1 -0
  9. package/dist/enableGlRenderTextureGuards.d.ts.map +1 -1
  10. package/dist/enableGlRenderTextureGuards.js +2 -2
  11. package/dist/enableGlRenderTextureGuards.js.map +1 -1
  12. package/dist/enableGlTextureResolverGuards.d.ts +4 -0
  13. package/dist/enableGlTextureResolverGuards.d.ts.map +1 -0
  14. package/dist/enableGlTextureResolverGuards.js +8 -0
  15. package/dist/enableGlTextureResolverGuards.js.map +1 -0
  16. package/dist/explainGlTextureResolution.d.ts +3 -0
  17. package/dist/explainGlTextureResolution.d.ts.map +1 -0
  18. package/dist/explainGlTextureResolution.js +12 -0
  19. package/dist/explainGlTextureResolution.js.map +1 -0
  20. package/dist/glBackground.d.ts.map +1 -1
  21. package/dist/glBackground.js +5 -3
  22. package/dist/glBackground.js.map +1 -1
  23. package/dist/glCompressedTexture.d.ts +2 -2
  24. package/dist/glCompressedTexture.d.ts.map +1 -1
  25. package/dist/glCompressedTexture.js +46 -17
  26. package/dist/glCompressedTexture.js.map +1 -1
  27. package/dist/glDraw.d.ts +4 -2
  28. package/dist/glDraw.d.ts.map +1 -1
  29. package/dist/glDraw.js +100 -65
  30. package/dist/glDraw.js.map +1 -1
  31. package/dist/glExternalTexture.d.ts +4 -0
  32. package/dist/glExternalTexture.d.ts.map +1 -0
  33. package/dist/glExternalTexture.js +46 -0
  34. package/dist/glExternalTexture.js.map +1 -0
  35. package/dist/glFullscreenPass.js +5 -6
  36. package/dist/glFullscreenPass.js.map +1 -1
  37. package/dist/glLinearToSrgbPass.js +3 -3
  38. package/dist/glLinearToSrgbPass.js.map +1 -1
  39. package/dist/glMaterialRegistry.d.ts.map +1 -1
  40. package/dist/glMaterialRegistry.js +12 -10
  41. package/dist/glMaterialRegistry.js.map +1 -1
  42. package/dist/glPresentRenderTarget.js +3 -3
  43. package/dist/glPresentRenderTarget.js.map +1 -1
  44. package/dist/glRenderPass.d.ts +2 -2
  45. package/dist/glRenderPass.d.ts.map +1 -1
  46. package/dist/glRenderPass.js +193 -33
  47. package/dist/glRenderPass.js.map +1 -1
  48. package/dist/glRenderState.d.ts +11 -1
  49. package/dist/glRenderState.d.ts.map +1 -1
  50. package/dist/glRenderState.js +206 -22
  51. package/dist/glRenderState.js.map +1 -1
  52. package/dist/glRenderStateBracket.d.ts.map +1 -1
  53. package/dist/glRenderStateBracket.js +16 -4
  54. package/dist/glRenderStateBracket.js.map +1 -1
  55. package/dist/glRenderTarget.d.ts +10 -1
  56. package/dist/glRenderTarget.d.ts.map +1 -1
  57. package/dist/glRenderTarget.js +154 -69
  58. package/dist/glRenderTarget.js.map +1 -1
  59. package/dist/glRenderTargetPool.d.ts +4 -1
  60. package/dist/glRenderTargetPool.d.ts.map +1 -1
  61. package/dist/glRenderTargetPool.js +32 -23
  62. package/dist/glRenderTargetPool.js.map +1 -1
  63. package/dist/glRenderTexture.d.ts +13 -8
  64. package/dist/glRenderTexture.d.ts.map +1 -1
  65. package/dist/glRenderTexture.js +94 -37
  66. package/dist/glRenderTexture.js.map +1 -1
  67. package/dist/glRenderTexturePool.d.ts +7 -0
  68. package/dist/glRenderTexturePool.d.ts.map +1 -0
  69. package/dist/glRenderTexturePool.js +88 -0
  70. package/dist/glRenderTexturePool.js.map +1 -0
  71. package/dist/glTestHelper.d.ts.map +1 -1
  72. package/dist/glTestHelper.js +12 -8
  73. package/dist/glTestHelper.js.map +1 -1
  74. package/dist/glTextureResolver.d.ts +7 -8
  75. package/dist/glTextureResolver.d.ts.map +1 -1
  76. package/dist/glTextureResolver.js +57 -55
  77. package/dist/glTextureResolver.js.map +1 -1
  78. package/dist/glTextureUpload.d.ts +4 -4
  79. package/dist/glTextureUpload.d.ts.map +1 -1
  80. package/dist/glTextureUpload.js +8 -14
  81. package/dist/glTextureUpload.js.map +1 -1
  82. package/dist/glTextureVideoUpload.d.ts +2 -2
  83. package/dist/glTextureVideoUpload.d.ts.map +1 -1
  84. package/dist/glTextureVideoUpload.js +5 -5
  85. package/dist/glTextureVideoUpload.js.map +1 -1
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +1 -1
  89. package/dist/index.js.map +1 -1
  90. package/package.json +12 -6
  91. package/src/enableGlRenderStateGuards.test.ts +70 -0
  92. package/src/enableGlTextureResolverGuards.test.ts +58 -0
  93. package/src/explainGlTextureResolution.test.ts +32 -0
  94. package/src/glBackground.test.ts +24 -0
  95. package/src/glCompressedTexture.test.ts +7 -17
  96. package/src/glDraw.test.ts +172 -80
  97. package/src/glExternalTexture.test.ts +30 -0
  98. package/src/glFullscreenPass.test.ts +15 -2
  99. package/src/glLinearToSrgbPass.test.ts +13 -0
  100. package/src/glMaterialRegistry.test.ts +42 -1
  101. package/src/glPresentRenderTarget.test.ts +15 -1
  102. package/src/glReadback.test.ts +13 -0
  103. package/src/glRenderPass.test.ts +257 -5
  104. package/src/glRenderState.test.ts +136 -1
  105. package/src/glRenderStateBracket.test.ts +31 -1
  106. package/src/glRenderTarget.test.ts +244 -3
  107. package/src/glRenderTargetPool.test.ts +110 -5
  108. package/src/glRenderTexture.test.ts +88 -14
  109. package/src/glRenderTexturePool.test.ts +137 -0
  110. package/src/glTextureResolver.test.ts +151 -72
  111. package/src/glTextureUpload.test.ts +2 -10
  112. package/src/glTextureVideoUpload.test.ts +20 -5
@@ -7,6 +7,10 @@ import { resolveGlRenderTarget } from './glRenderTarget';
7
7
  // with endGlRenderPass. This is the clear/preserve model, not GL/Vulkan load ops: omit `preserve` and
8
8
  // everything starts fresh; name what to keep.
9
9
  //
10
+ // `viewport` is a device-pixel, top-left-origin region of `target`. It is intersected with target
11
+ // storage, realized as both viewport and scissor, and therefore constrains drawing plus color/depth
12
+ // clears without allocating another target. Nested passes cannot escape an enclosing pass scissor.
13
+ //
10
14
  // A render pass carries NO 2D transform — that is a display-object DRAW concern, not a pass concern, so
11
15
  // a 3D pass (drawGlScene3D, which uses the camera) is unaffected. A 2D pass that needs a specific root
12
16
  // device transform sets it explicitly with setGlRenderTransform2D after begin; the value is saved and
@@ -15,61 +19,109 @@ import { resolveGlRenderTarget } from './glRenderTarget';
15
19
  // Single-attachment (the common no-effects scene / 2D-offscreen path):
16
20
  // beginGlRenderPass(state, target) // clear color + depth
17
21
  // drawGlScene3D(state, scene, camera, lights)
18
- // endGlRenderPass(state, target) // restore binding + resolve MSAA
22
+ // endGlRenderPass(state) // restore binding + resolve MSAA
19
23
  // presentGlRenderTarget(state, target) // colorSpace-aware encode to the canvas
20
24
  //
21
25
  // MRT / G-buffer (three color attachments, keep depth for a later lighting pass over the same target):
22
26
  // beginGlRenderPass(state, gbuffer, { preserveColor: [false, false, false], preserveDepth: false })
23
27
  // drawGlScene3D(state, scene, camera, lights) // fragment shader writes location 0,1,2
24
- // endGlRenderPass(state, gbuffer)
28
+ // endGlRenderPass(state)
25
29
  // // ...lighting pass samples gbuffer.textures[0..2], preserving depth: { preserveDepth: true }
26
- export function beginGlRenderPass(state, target, preserve) {
27
- const runtime = getGlRenderStateRuntime(state);
30
+ //
31
+ // Partial target (clear only the sub-region, then restore the exact enclosing viewport/scissor):
32
+ // beginGlRenderPass(state, target, undefined, viewport)
33
+ // drawGlScene3D(state, scene, camera, lights)
34
+ // endGlRenderPass(state)
35
+ export function beginGlRenderPass(state, target, preserve, viewport) {
28
36
  const gl = state.gl;
29
- let stack = _passStack.get(state);
37
+ let stack = _passStack.get(gl);
38
+ // One WebGL context has one live framebuffer/stencil/scissor state even when several higher-level
39
+ // GlRenderStates share it (the render-cache path). The top context-owned pass is therefore the
40
+ // physical enclosing state; the incoming state's dormant runtime is only its local restore point.
41
+ const previousOwner = stack?.at(-1)?.owner ?? state;
42
+ const previousRuntime = getGlRenderStateRuntime(previousOwner);
43
+ const previousState = captureGlPassState(previousOwner);
44
+ const currentMaskDepth = previousState.currentMaskDepth;
45
+ if (currentMaskDepth > 0 && previousState.framebuffer === target.framebuffer) {
46
+ throw new Error('beginGlRenderPass: cannot nest the active framebuffer while a contour clip is live');
47
+ }
30
48
  if (stack === undefined) {
31
49
  stack = [];
32
- _passStack.set(state, stack);
50
+ _passStack.set(gl, stack);
33
51
  }
34
52
  stack.push({
35
- framebuffer: runtime.currentFramebuffer,
36
- renderTarget: runtime.currentRenderTarget ?? null,
37
- renderTargetViewport: runtime.renderTargetViewport,
38
- renderTransform2D: state.renderTransform2D,
53
+ depthMask: gl.getParameter(gl.DEPTH_WRITEMASK) !== false,
54
+ owner: state,
55
+ ownerState: previousOwner === state ? previousState : captureGlPassState(state),
56
+ previousOwner,
57
+ previousState,
58
+ stencil: currentMaskDepth > 0 ? captureGlStencil(gl) : null,
39
59
  });
60
+ const runtime = getGlRenderStateRuntime(state);
61
+ const activeViewport = resolveGlPassViewport(target, viewport);
62
+ const enclosingScissor = previousState.scissorRect;
63
+ const activeScissor = enclosingScissor === null
64
+ ? viewport === undefined
65
+ ? null
66
+ : activeViewport
67
+ : intersectGlRects(enclosingScissor, activeViewport);
40
68
  gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
41
- gl.viewport(0, 0, target.width, target.height);
69
+ gl.viewport(activeViewport.x, activeViewport.y, activeViewport.width, activeViewport.height);
42
70
  runtime.currentFramebuffer = target.framebuffer;
43
71
  runtime.currentRenderTarget = target;
44
- runtime.renderTargetViewport = { width: target.width, height: target.height };
72
+ runtime.renderTargetViewport = activeViewport;
73
+ runtime.currentScissorRect = activeScissor;
74
+ runtime.scissorStack = activeScissor === null ? [] : [activeScissor];
75
+ // A pass owns its logical 2D clip unwind state. Inheriting the enclosing entries would let
76
+ // renderGlScene2D.finalize pop clips it did not push, desynchronizing the logical and hardware
77
+ // stacks after the enclosing pass is restored.
78
+ runtime.clipForms = [];
79
+ runtime.currentMaskDepth = 0;
80
+ applyGlScissor(gl, activeScissor);
81
+ // Stencil clips belong to the framebuffer where they were rasterized. Disable the enclosing gate
82
+ // while the nested pass owns a different logical clip stack; end restores its exact steady state.
83
+ if (currentMaskDepth > 0)
84
+ gl.disable(gl.STENCIL_TEST);
45
85
  // Force rebind on next draw — the framebuffer switch invalidates GL state assumptions.
46
- runtime.currentTexture = null;
47
- runtime.currentBlendMode = null;
86
+ invalidateGlPassBindingCache(runtime);
87
+ if (previousOwner !== state)
88
+ invalidateGlPassBindingCache(previousRuntime);
48
89
  clearGlRenderPass(state, target, preserve);
49
90
  }
50
- // Ends the pass opened by beginGlRenderPass: restores the framebuffer binding, viewport, and 2D render
51
- // transform saved at begin, then resolves MSAA on the target that was active (a store-side property of
52
- // the pass). Afterward that target's textures hold the finished, single-sample result — ready for
53
- // present, effects, or sampling. A call with no matching begin is a no-op. The target is read from the
54
- // runtime rather than passed, so end mirrors endWgpuRenderPass / endCanvasRenderPass across backends.
91
+ // Ends the pass opened by beginGlRenderPass: restores the framebuffer binding, exact viewport/scissor,
92
+ // clip stack, and 2D render transform saved at begin, then resolves MSAA on the target that was active
93
+ // (a store-side property of the pass). Afterward that target's textures hold the finished,
94
+ // single-sample result — ready for present, effects, or sampling. A call with no matching begin throws:
95
+ // an unbalanced pass is a programmer error, and silently accepting it hides a leaked prior pass. The
96
+ // target is read from runtime rather than passed, so end mirrors the other backend brackets.
55
97
  export function endGlRenderPass(state) {
56
- const runtime = getGlRenderStateRuntime(state);
57
98
  const gl = state.gl;
99
+ const stack = _passStack.get(gl);
100
+ if (stack === undefined) {
101
+ throw new Error('endGlRenderPass called without a matching beginGlRenderPass');
102
+ }
103
+ const saved = stack.at(-1);
104
+ if (saved === undefined || saved.owner !== state) {
105
+ throw new Error('endGlRenderPass called without a matching beginGlRenderPass');
106
+ }
107
+ stack.pop();
108
+ if (stack.length === 0)
109
+ _passStack.delete(gl);
110
+ const runtime = getGlRenderStateRuntime(state);
58
111
  const ended = runtime.currentRenderTarget ?? null;
59
- const saved = _passStack.get(state)?.pop();
60
- if (saved !== undefined) {
61
- gl.bindFramebuffer(gl.FRAMEBUFFER, saved.framebuffer);
62
- const viewport = saved.renderTargetViewport ?? state.canvas;
63
- gl.viewport(0, 0, viewport.width, viewport.height);
64
- runtime.currentFramebuffer = saved.framebuffer;
65
- runtime.currentRenderTarget = saved.renderTarget;
66
- runtime.renderTargetViewport = saved.renderTargetViewport;
67
- state.renderTransform2D = saved.renderTransform2D;
68
- runtime.currentTexture = null;
69
- runtime.currentBlendMode = null;
112
+ restoreGlPassState(state, saved.ownerState);
113
+ gl.bindFramebuffer(gl.FRAMEBUFFER, saved.previousState.framebuffer);
114
+ const viewport = saved.previousState.renderTargetViewport;
115
+ gl.viewport(viewport?.x ?? 0, viewport?.y ?? 0, viewport?.width ?? saved.previousOwner.canvas.width, viewport?.height ?? saved.previousOwner.canvas.height);
116
+ applyGlScissor(gl, saved.previousState.scissorRect);
117
+ restoreGlStencil(gl, saved.stencil);
118
+ gl.depthMask(saved.depthMask);
119
+ invalidateGlPassBindingCache(runtime);
120
+ if (saved.previousOwner !== state) {
121
+ invalidateGlPassBindingCache(getGlRenderStateRuntime(saved.previousOwner));
70
122
  }
71
123
  if (ended !== null)
72
- resolveGlRenderTarget(state, ended);
124
+ resolveGlRenderTarget(saved.previousOwner, ended);
73
125
  }
74
126
  // Sets the 2D root device transform the display-object update pass (prepareScene2DRender) reads to
75
127
  // place nodes with no scene parent. Call after beginGlRenderPass when a 2D pass renders into a target
@@ -80,6 +132,15 @@ export function setGlRenderTransform2D(state, transform) {
80
132
  const next = createMatrix();
81
133
  copyMatrix(next, transform);
82
134
  state.renderTransform2D = next;
135
+ // The root device transform is an input to every prepared proxy transform, but it is state policy,
136
+ // not a node revision. Mark the state-local proxies stale so a repeated offscreen capture with new
137
+ // bounds/padding cannot reuse transforms prepared for the previous target dimensions.
138
+ const runtime = getGlRenderStateRuntime(state);
139
+ for (const source of runtime.renderProxySources) {
140
+ const proxy = runtime.renderProxyMap.get(source);
141
+ if (proxy !== undefined)
142
+ proxy.lastLocalTransformId = -1;
143
+ }
83
144
  }
84
145
  // Clears the bound target's aspects that `preserve` does not spare. Uses per-attachment clearBufferfv so
85
146
  // each color attachment can carry its own clear value (the G-buffer case) and preserved attachments are
@@ -124,7 +185,106 @@ function resolveGlClearColor(state, target, index, out) {
124
185
  out[2] = bg[2] ?? 0;
125
186
  out[3] = bg.length >= 4 ? bg[3] : 0;
126
187
  }
127
- // The pass bracket's save/restore stack, keyed off the render state so nested passes restore in order.
188
+ function captureGlPassState(state) {
189
+ const runtime = getGlRenderStateRuntime(state);
190
+ return {
191
+ clipForms: [...(runtime.clipForms ?? [])],
192
+ currentMaskDepth: runtime.currentMaskDepth ?? 0,
193
+ framebuffer: runtime.currentFramebuffer,
194
+ renderTarget: runtime.currentRenderTarget ?? null,
195
+ renderTargetViewport: runtime.renderTargetViewport,
196
+ renderTransform2D: state.renderTransform2D,
197
+ scissorRect: runtime.currentScissorRect ?? null,
198
+ scissorStack: [...(runtime.scissorStack ?? [])],
199
+ };
200
+ }
201
+ function invalidateGlPassBindingCache(runtime) {
202
+ runtime.currentBlendMode = null;
203
+ runtime.currentProgram = null;
204
+ runtime.currentTexture = null;
205
+ runtime.currentTextureStraightAlpha = false;
206
+ }
207
+ function restoreGlPassState(state, saved) {
208
+ const runtime = getGlRenderStateRuntime(state);
209
+ runtime.currentFramebuffer = saved.framebuffer;
210
+ runtime.currentRenderTarget = saved.renderTarget;
211
+ runtime.renderTargetViewport = saved.renderTargetViewport;
212
+ runtime.currentScissorRect = saved.scissorRect;
213
+ runtime.scissorStack = saved.scissorStack;
214
+ runtime.clipForms = saved.clipForms;
215
+ runtime.currentMaskDepth = saved.currentMaskDepth;
216
+ state.renderTransform2D = saved.renderTransform2D;
217
+ }
218
+ function applyGlScissor(gl, rect) {
219
+ if (rect === null) {
220
+ gl.disable(gl.SCISSOR_TEST);
221
+ return;
222
+ }
223
+ gl.enable(gl.SCISSOR_TEST);
224
+ gl.scissor(rect.x, rect.y, rect.width, rect.height);
225
+ }
226
+ function captureGlStencil(gl) {
227
+ return {
228
+ fail: gl.getParameter(gl.STENCIL_FAIL),
229
+ func: gl.getParameter(gl.STENCIL_FUNC),
230
+ passDepthFail: gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL),
231
+ passDepthPass: gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS),
232
+ ref: gl.getParameter(gl.STENCIL_REF),
233
+ valueMask: gl.getParameter(gl.STENCIL_VALUE_MASK),
234
+ writeMask: gl.getParameter(gl.STENCIL_WRITEMASK),
235
+ };
236
+ }
237
+ function restoreGlStencil(gl, saved) {
238
+ if (saved === null) {
239
+ gl.disable(gl.STENCIL_TEST);
240
+ return;
241
+ }
242
+ gl.enable(gl.STENCIL_TEST);
243
+ gl.stencilMask(saved.writeMask);
244
+ gl.stencilFunc(saved.func, saved.ref, saved.valueMask);
245
+ gl.stencilOp(saved.fail, saved.passDepthFail, saved.passDepthPass);
246
+ }
247
+ function intersectGlRects(a, b) {
248
+ const x = Math.max(a.x, b.x);
249
+ const y = Math.max(a.y, b.y);
250
+ const right = Math.min(a.x + a.width, b.x + b.width);
251
+ const top = Math.min(a.y + a.height, b.y + b.height);
252
+ return {
253
+ height: Math.max(0, top - y),
254
+ width: Math.max(0, right - x),
255
+ x,
256
+ y,
257
+ };
258
+ }
259
+ function resolveGlPassViewport(target, viewport) {
260
+ if (viewport === undefined)
261
+ return { height: target.height, width: target.width, x: 0, y: 0 };
262
+ // Compute both unbounded edges before clamping. Clamping x first and retaining width would turn
263
+ // {-10,width:20} into 20 visible pixels instead of the correct 10-pixel intersection.
264
+ const passWidth = Math.max(0, viewport.width);
265
+ const passHeight = Math.max(0, viewport.height);
266
+ const rawLeft = Math.floor(viewport.x);
267
+ const rawRight = passWidth === 0 ? rawLeft : Math.ceil(viewport.x + passWidth);
268
+ const rawTop = Math.floor(viewport.y);
269
+ const rawBottom = passHeight === 0 ? rawTop : Math.ceil(viewport.y + passHeight);
270
+ const left = clampGlPassEdge(rawLeft, target.width);
271
+ const right = clampGlPassEdge(rawRight, target.width);
272
+ const top = clampGlPassEdge(rawTop, target.height);
273
+ const bottom = clampGlPassEdge(rawBottom, target.height);
274
+ const width = Math.max(0, right - left);
275
+ const height = Math.max(0, bottom - top);
276
+ return {
277
+ height,
278
+ width,
279
+ x: left,
280
+ y: target.height - bottom,
281
+ };
282
+ }
283
+ function clampGlPassEdge(value, extent) {
284
+ return Math.min(extent, Math.max(0, value));
285
+ }
286
+ // A WebGL context has exactly one framebuffer binding and one live stencil gate. Keying the pass
287
+ // bracket by that physical owner keeps cache GlRenderStates sharing a context in the same LIFO scope.
128
288
  const _passStack = new WeakMap();
129
289
  const _clearRgba = new Float32Array(4);
130
290
  //# sourceMappingURL=glRenderPass.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glRenderPass.js","sourceRoot":"","sources":["../src/glRenderPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AASzD,mGAAmG;AACnG,sGAAsG;AACtG,uGAAuG;AACvG,sGAAsG;AACtG,8CAA8C;AAC9C,EAAE;AACF,wGAAwG;AACxG,uGAAuG;AACvG,sGAAsG;AACtG,qEAAqE;AACrE,EAAE;AACF,uEAAuE;AACvE,kFAAkF;AAClF,gDAAgD;AAChD,6FAA6F;AAC7F,oGAAoG;AACpG,EAAE;AACF,uGAAuG;AACvG,sGAAsG;AACtG,sGAAsG;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,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC;IACzC,OAAO;QACL,MAAM;QACN,KAAK;QACL,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAa,EAAE,MAAc;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,iGAAiG;AACjG,sGAAsG;AACtG,MAAM,UAAU,GAAG,IAAI,OAAO,EAA8C,CAAC;AAC7E,MAAM,UAAU,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC"}
@@ -1,6 +1,16 @@
1
1
  import type { GlRenderOptions, GlRenderState, GlRenderStateRuntime } from '@flighthq/types/contract';
2
+ export declare function copyGlRenderStateRegistrations(target: GlRenderState, source: GlRenderState): void;
3
+ /**
4
+ * Creates a second render pipeline over `screenState`'s WebGL context.
5
+ *
6
+ * GPU objects and upload caches are aliases of one context tier. Pipeline policy is a creation-time
7
+ * snapshot: renderer/clip/material/effect/texture registrations start equal, then either state may
8
+ * override or omit them independently. Per-node proxies, adapters, frame counters, batch writers,
9
+ * render transforms, and renderer data are always fresh.
10
+ */
11
+ export declare function createGlOffscreenRenderState(screenState: GlRenderState): GlRenderState;
2
12
  export declare function createGlRenderState(canvas: HTMLCanvasElement, options?: GlRenderOptions): GlRenderState;
3
- export declare function createGlRenderStateRuntime(): GlRenderStateRuntime;
13
+ export declare function createGlRenderStateRuntime(sharedRuntime?: GlRenderStateRuntime): GlRenderStateRuntime;
4
14
  export declare function destroyGlRenderState(state: GlRenderState): void;
5
15
  export declare function getGlRenderStateRuntime(state: GlRenderState): GlRenderStateRuntime;
6
16
  export declare function invalidateGlRenderStateCache(state: GlRenderState): void;
@@ -1 +1 @@
1
- {"version":3,"file":"glRenderState.d.ts","sourceRoot":"","sources":["../src/glRenderState.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAKrG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,eAAoB,GAAG,aAAa,CAiF3G;AAMD,wBAAgB,0BAA0B,IAAI,oBAAoB,CAEjE;AAeD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAsB/D;AAID,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CAElF;AAcD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAUvE"}
1
+ {"version":3,"file":"glRenderState.d.ts","sourceRoot":"","sources":["../src/glRenderState.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAOrG,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAoBjG;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,aAAa,GAAG,aAAa,CAwBtF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,eAAoB,GAAG,aAAa,CAqF3G;AAMD,wBAAgB,0BAA0B,CAAC,aAAa,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,CAoBrG;AAeD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAgC/D;AAID,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CAElF;AAcD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAUvE"}
@@ -1,7 +1,62 @@
1
1
  import { createMatrix } from '@flighthq/geometry/contract';
2
- import { createRenderState as _createRenderState, createRenderStateRuntime, setRenderStateBackgroundColor, } from '@flighthq/render/contract';
2
+ import { copyAllRenderersFromRenderState, copyRenderStateRegistrations, createRenderState as _createRenderState, createRenderStateRuntime, destroyRenderState, setRenderStateBackgroundColor, } from '@flighthq/render/contract';
3
3
  import { EntityRuntimeKey } from '@flighthq/types/contract';
4
4
  import { compileDefaultGlProgram, createDefaultGlBitmapShader } from './glShader';
5
+ // Explicit snapshot re-copy. This never aliases registration maps: last-write-wins divergence is the
6
+ // point of a second render state, and a cache/effect state may intentionally omit screen policy.
7
+ export function copyGlRenderStateRegistrations(target, source) {
8
+ const targetRuntime = getGlRenderStateRuntime(target);
9
+ const sourceRuntime = getGlRenderStateRuntime(source);
10
+ target.applyBlendMode = source.applyBlendMode;
11
+ targetRuntime.defaultBitmapShader = sourceRuntime.defaultBitmapShader;
12
+ targetRuntime.glBlendModeRegistry = copyMap(sourceRuntime.glBlendModeRegistry);
13
+ targetRuntime.glColorAdjustmentMaterialFeature = sourceRuntime.glColorAdjustmentMaterialFeature;
14
+ targetRuntime.glColorAdjustmentMaterialFeatureGuard = sourceRuntime.glColorAdjustmentMaterialFeatureGuard;
15
+ targetRuntime.materialRendererMap =
16
+ sourceRuntime.materialRendererMap === undefined ? undefined : new Map(sourceRuntime.materialRendererMap);
17
+ targetRuntime.materialBitmapShaderMap =
18
+ sourceRuntime.materialBitmapShaderMap === undefined ? undefined : new Map(sourceRuntime.materialBitmapShaderMap);
19
+ targetRuntime.sceneMeshMaterialRegistry = copyMap(sourceRuntime.sceneMeshMaterialRegistry);
20
+ targetRuntime.webglShaderBindingResolver = sourceRuntime.webglShaderBindingResolver;
21
+ targetRuntime.glTextureResolverRegistry = copyRegistryMap(sourceRuntime.glTextureResolverRegistry);
22
+ targetRuntime.glRenderTextureGuard = sourceRuntime.glRenderTextureGuard;
23
+ targetRuntime.compressedTextureDecoder = sourceRuntime.compressedTextureDecoder;
24
+ targetRuntime.compressedTextureUpload = sourceRuntime.compressedTextureUpload;
25
+ targetRuntime.glRenderEffectRegistry = copyMap(sourceRuntime.glRenderEffectRegistry);
26
+ copyRenderStateRegistrations(target, source);
27
+ }
28
+ /**
29
+ * Creates a second render pipeline over `screenState`'s WebGL context.
30
+ *
31
+ * GPU objects and upload caches are aliases of one context tier. Pipeline policy is a creation-time
32
+ * snapshot: renderer/clip/material/effect/texture registrations start equal, then either state may
33
+ * override or omit them independently. Per-node proxies, adapters, frame counters, batch writers,
34
+ * render transforms, and renderer data are always fresh.
35
+ */
36
+ export function createGlOffscreenRenderState(screenState) {
37
+ const state = _createRenderState({
38
+ allowSmoothing: screenState.allowSmoothing,
39
+ backgroundColor: screenState.backgroundColor,
40
+ backgroundColorRgba: [...screenState.backgroundColorRgba],
41
+ backgroundColorString: screenState.backgroundColorString,
42
+ pixelRatio: screenState.pixelRatio,
43
+ renderAlpha: screenState.renderAlpha,
44
+ renderBlendMode: screenState.renderBlendMode,
45
+ renderTransform2D: createMatrix(),
46
+ roundPixels: screenState.roundPixels,
47
+ sceneGraphSyncPolicy: screenState.sceneGraphSyncPolicy,
48
+ });
49
+ state.applyBlendMode = screenState.applyBlendMode;
50
+ state.canvas = screenState.canvas;
51
+ state.gl = screenState.gl;
52
+ const screenRuntime = getGlRenderStateRuntime(screenState);
53
+ const runtime = createGlRenderStateRuntime(screenRuntime);
54
+ state[EntityRuntimeKey] = runtime;
55
+ initializeOffscreenGlRuntime(runtime, screenRuntime);
56
+ copyAllRenderersFromRenderState(state, screenState);
57
+ copyGlRenderStateRegistrations(state, screenState);
58
+ return state;
59
+ }
5
60
  export function createGlRenderState(canvas, options = {}) {
6
61
  const contextAttribs = {
7
62
  alpha: true,
@@ -49,22 +104,26 @@ export function createGlRenderState(canvas, options = {}) {
49
104
  runtime.renderTargetViewport = null;
50
105
  runtime.defaultBitmapShader = defaultBitmapShader;
51
106
  runtime.shaderLoc = shaderLoc;
52
- runtime.spriteBatchBlendMode = null;
53
- runtime.spriteBatchMaterial = null;
54
- runtime.spriteBatchMaterialRenderer = null;
55
- runtime.spriteBatchMaterialFloats = 0;
56
- runtime.spriteBatchMaterialData = new Float32Array(8 * 256);
57
- runtime.spriteBatchMaterialBuffer = null;
58
- runtime.spriteBatchCount = 0;
59
- runtime.spriteBatchInstanceBuffer = null;
60
- runtime.spriteBatchInstanceData = new Float32Array(13 * 256);
61
- runtime.spriteBatchTexture = null;
62
- runtime.spriteBatchSmoothing = null;
107
+ runtime.quadBatchWriterBlendMode = null;
108
+ runtime.quadBatchWriterMaterial = null;
109
+ runtime.quadBatchWriterMaterialRenderer = null;
110
+ runtime.quadBatchWriterMaterialFloats = 0;
111
+ runtime.quadBatchWriterMaterialData = new Float32Array(8 * 256);
112
+ runtime.quadBatchWriterMaterialBuffer = null;
113
+ runtime.quadBatchWriterCount = 0;
114
+ runtime.quadBatchWriterInstanceBuffer = null;
115
+ runtime.quadBatchWriterInstanceData = new Float32Array(13 * 256);
116
+ runtime.quadBatchWriterTexture = null;
117
+ runtime.quadBatchWriterSampler = null;
118
+ runtime.quadBatchWriterStraightAlpha = false;
119
+ runtime.quadBatchWriterSmoothing = null;
63
120
  // Color-adjustment fold state (mode/data/buffer + the compiled programs) is not allocated here: it
64
121
  // is owned by the opt-in registerGlColorAdjustmentMaterialFeature, so a state that never tints carries none of it.
65
122
  runtime.textureCache = new WeakMap();
66
- runtime.imageResourcePremultipliedTextureCache = new WeakMap();
67
- runtime.imageResourceStraightTextureCache = new WeakMap();
123
+ runtime.textureSourcePremultipliedTextureCache = new WeakMap();
124
+ runtime.textureSourcePremultipliedSrgbTextureCache = new WeakMap();
125
+ runtime.textureSourceStraightTextureCache = new WeakMap();
126
+ runtime.textureSourceStraightSrgbTextureCache = new WeakMap();
68
127
  runtime.quadVertexBuffer = quadVertexBuffer;
69
128
  runtime.quadIndexBuffer = quadIndexBuffer;
70
129
  runtime.quadVertexData = new Float32Array(16);
@@ -80,8 +139,25 @@ export function createGlRenderState(canvas, options = {}) {
80
139
  // one to each state under EntityRuntimeKey and populates its fields; getGlRenderStateRuntime reads
81
140
  // it back. The render path writes the returned object every frame, so the return is intentionally
82
141
  // mutable (not Readonly).
83
- export function createGlRenderStateRuntime() {
84
- return createRenderStateRuntime();
142
+ export function createGlRenderStateRuntime(sharedRuntime) {
143
+ const runtime = createRenderStateRuntime();
144
+ const contextRuntime = sharedRuntime === undefined ? { fields: {}, references: 0 } : getGlContextRuntime(sharedRuntime);
145
+ contextRuntime.references++;
146
+ _contextRuntimeByStateRuntime.set(runtime, contextRuntime);
147
+ for (const key of GL_CONTEXT_RUNTIME_KEYS) {
148
+ Object.defineProperty(runtime, key, {
149
+ configurable: true,
150
+ enumerable: true,
151
+ get: () => contextRuntime.fields[key],
152
+ set: (value) => {
153
+ contextRuntime.fields[key] = value;
154
+ },
155
+ });
156
+ }
157
+ runtime.currentRenderTarget = null;
158
+ // Per-state, not shared on the context tier: guards are installed per render state.
159
+ runtime.bindingCacheGuard = null;
160
+ return runtime;
85
161
  }
86
162
  // Frees the GPU resources createGlRenderState and the lazy ensure* helpers allocated on the
87
163
  // state's runtime: the compiled shader programs and the vertex/index/instance buffers. Call when the
@@ -97,7 +173,15 @@ export function createGlRenderStateRuntime() {
97
173
  // Deleting an already-deleted Gl program or buffer is a silent no-op, so destroying a screen
98
174
  // state whose resources a cache state still aliases is safe.
99
175
  export function destroyGlRenderState(state) {
176
+ if (_destroyedStates.has(state))
177
+ return;
178
+ _destroyedStates.add(state);
100
179
  const runtime = getGlRenderStateRuntime(state);
180
+ destroyRenderState(state);
181
+ const contextRuntime = getGlContextRuntime(runtime);
182
+ contextRuntime.references--;
183
+ if (contextRuntime.references !== 0)
184
+ return;
101
185
  const gl = state.gl;
102
186
  // Dedupe: several shader wrappers (e.g. defaultBitmapShader) share shaderLoc.program.
103
187
  const programs = new Set();
@@ -111,8 +195,16 @@ export function destroyGlRenderState(state) {
111
195
  programs.add(runtime.quadBatchShader.program);
112
196
  if (runtime.colorScaleBiasInstancedShader)
113
197
  programs.add(runtime.colorScaleBiasInstancedShader.program);
198
+ if (runtime.colorMatrixInstancedShader)
199
+ programs.add(runtime.colorMatrixInstancedShader.program);
200
+ if (runtime.colorTintInstancedShader)
201
+ programs.add(runtime.colorTintInstancedShader.program);
114
202
  if (runtime.uniformColorScaleBiasShader)
115
203
  programs.add(runtime.uniformColorScaleBiasShader.program);
204
+ if (runtime.shapeMeshColorScaleBiasShader)
205
+ programs.add(runtime.shapeMeshColorScaleBiasShader.program);
206
+ if (runtime.shapeMeshColorMatrixShader)
207
+ programs.add(runtime.shapeMeshColorMatrixShader.program);
116
208
  for (const program of programs)
117
209
  gl.deleteProgram(program);
118
210
  gl.deleteBuffer(runtime.quadVertexBuffer);
@@ -123,12 +215,12 @@ export function destroyGlRenderState(state) {
123
215
  gl.deleteBuffer(runtime.particleInstanceBuffer);
124
216
  if (runtime.quadBatchCornerBuffer)
125
217
  gl.deleteBuffer(runtime.quadBatchCornerBuffer);
126
- if (runtime.spriteBatchInstanceBuffer)
127
- gl.deleteBuffer(runtime.spriteBatchInstanceBuffer);
128
- if (runtime.spriteBatchMaterialBuffer)
129
- gl.deleteBuffer(runtime.spriteBatchMaterialBuffer);
130
- if (runtime.spriteBatchColorScaleBiasBuffer)
131
- gl.deleteBuffer(runtime.spriteBatchColorScaleBiasBuffer);
218
+ if (runtime.quadBatchWriterInstanceBuffer)
219
+ gl.deleteBuffer(runtime.quadBatchWriterInstanceBuffer);
220
+ if (runtime.quadBatchWriterMaterialBuffer)
221
+ gl.deleteBuffer(runtime.quadBatchWriterMaterialBuffer);
222
+ if (runtime.quadBatchWriterColorScaleBiasBuffer)
223
+ gl.deleteBuffer(runtime.quadBatchWriterColorScaleBiasBuffer);
132
224
  }
133
225
  // Resolves the package-private GPU runtime attached to a GlRenderState. Mutable by design: the
134
226
  // render path writes its fields every frame.
@@ -158,4 +250,96 @@ export function invalidateGlRenderStateCache(state) {
158
250
  runtime.currentTextureStraightAlpha = false;
159
251
  runtime.renderTargetViewport = null;
160
252
  }
253
+ function initializeOffscreenGlRuntime(runtime, screenRuntime) {
254
+ runtime.currentFramebuffer = null;
255
+ runtime.currentMaskDepth = 0;
256
+ runtime.currentScissorRect = null;
257
+ runtime.currentRenderTarget = null;
258
+ runtime.flushPendingDraws = null;
259
+ runtime.renderTargetViewport = null;
260
+ runtime.defaultBitmapShader = screenRuntime.defaultBitmapShader;
261
+ runtime.quadBatchWriterBlendMode = null;
262
+ runtime.quadBatchWriterMaterial = null;
263
+ runtime.quadBatchWriterMaterialRenderer = null;
264
+ runtime.quadBatchWriterMaterialFloats = 0;
265
+ runtime.quadBatchWriterMaterialData = new Float32Array(8 * 256);
266
+ runtime.quadBatchWriterCount = 0;
267
+ runtime.quadBatchWriterInstanceData = new Float32Array(13 * 256);
268
+ runtime.quadBatchWriterTexture = null;
269
+ runtime.quadBatchWriterSampler = null;
270
+ runtime.quadBatchWriterStraightAlpha = false;
271
+ runtime.quadBatchWriterSmoothing = null;
272
+ runtime.particleInstanceData = new Float32Array(0);
273
+ runtime.quadVertexData = new Float32Array(16);
274
+ runtime.matrixArray = new Float32Array(9);
275
+ runtime.scissorStack = [];
276
+ runtime.clipForms = [];
277
+ }
278
+ function copyMap(source) {
279
+ if (source === undefined)
280
+ return undefined;
281
+ if (source === null)
282
+ return null;
283
+ return new Map(source);
284
+ }
285
+ // Guard-enabled registries are Map subclasses. Constructing through the source registry preserves
286
+ // that diagnostic behavior while still producing an independent registration snapshot.
287
+ function copyRegistryMap(source) {
288
+ if (source === undefined)
289
+ return undefined;
290
+ if (source === null)
291
+ return null;
292
+ const Registry = source.constructor;
293
+ const result = new Registry();
294
+ source.forEach((value, key) => result.set(key, value));
295
+ return result;
296
+ }
297
+ function getGlContextRuntime(runtime) {
298
+ const contextRuntime = _contextRuntimeByStateRuntime.get(runtime);
299
+ if (contextRuntime === undefined)
300
+ throw new Error('GlRenderState runtime has no context tier');
301
+ return contextRuntime;
302
+ }
303
+ // Storage in these slots is a pure function of (WebGL context, source data). Accessors on each state
304
+ // preserve the established runtime surface while routing the actual value to one shared context tier.
305
+ // Pass-local framebuffer/viewport/clip fields stay state-local because glRenderPass owns their exact
306
+ // dormant restore points on its per-context stack.
307
+ const GL_CONTEXT_RUNTIME_KEYS = [
308
+ 'currentBlendMode',
309
+ 'currentProgram',
310
+ 'currentTexture',
311
+ 'currentTextureStraightAlpha',
312
+ 'particleShader',
313
+ 'particleCornerBuffer',
314
+ 'particleInstanceBuffer',
315
+ 'quadBatchShader',
316
+ 'quadBatchCornerBuffer',
317
+ 'colorScaleBiasInstancedShader',
318
+ 'colorMatrixInstancedShader',
319
+ 'colorTintInstancedShader',
320
+ 'uniformColorScaleBiasShader',
321
+ 'shapeMeshColorScaleBiasShader',
322
+ 'shapeMeshColorMatrixShader',
323
+ 'sceneMeshUploadCache',
324
+ 'shaderLoc',
325
+ 'textureCache',
326
+ 'textureSourcePremultipliedTextureCache',
327
+ 'textureSourcePremultipliedSrgbTextureCache',
328
+ 'textureSourceStraightTextureCache',
329
+ 'textureSourceStraightSrgbTextureCache',
330
+ 'glExternalTextureCache',
331
+ 'glRenderTextureCache',
332
+ 'videoTextureCache',
333
+ 'videoSrgbTextureCache',
334
+ 'mipmappedTextures',
335
+ 'anisotropyExt',
336
+ 'maxAnisotropy',
337
+ 'quadVertexBuffer',
338
+ 'quadIndexBuffer',
339
+ 'quadBatchWriterInstanceBuffer',
340
+ 'quadBatchWriterMaterialBuffer',
341
+ 'quadBatchWriterColorScaleBiasBuffer',
342
+ ];
343
+ const _contextRuntimeByStateRuntime = new WeakMap();
344
+ const _destroyedStates = new WeakSet();
161
345
  //# sourceMappingURL=glRenderState.js.map