@babylonjs/lite-gl 1.24.0 → 1.25.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/CHANGELOG.md +26 -0
- package/README.md +5 -4
- package/blend.d.ts +1 -1
- package/blend.js +1 -1
- package/blend.js.map +1 -1
- package/context.d.ts +47 -4
- package/context.js +100 -11
- package/context.js.map +1 -1
- package/depth-stencil.d.ts +3 -2
- package/depth-stencil.js +10 -11
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +6 -3
- package/dynamic-texture.js +16 -4
- package/dynamic-texture.js.map +1 -1
- package/effect.d.ts +12 -3
- package/effect.js +35 -24
- package/effect.js.map +1 -1
- package/family.d.ts +5 -1
- package/family.js.map +1 -1
- package/framebuffer-validation.d.ts +20 -0
- package/framebuffer-validation.js +37 -0
- package/framebuffer-validation.js.map +1 -0
- package/html-texture.d.ts +2 -2
- package/html-texture.js.map +1 -1
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/mesh.d.ts +68 -14
- package/mesh.js +211 -61
- package/mesh.js.map +1 -1
- package/package.json +3 -3
- package/render-target.d.ts +11 -9
- package/render-target.js +50 -35
- package/render-target.js.map +1 -1
- package/scissor.d.ts +1 -1
- package/scissor.js.map +1 -1
- package/sprites.d.ts +5 -3
- package/sprites.js +24 -23
- package/sprites.js.map +1 -1
- package/state.d.ts +25 -13
- package/state.js +13 -10
- package/state.js.map +1 -1
- package/text/_gpu/text-instances.js +1 -1
- package/text/_gpu/text-instances.js.map +1 -1
- package/texture-3d.d.ts +2 -1
- package/texture-3d.js +7 -2
- package/texture-3d.js.map +1 -1
- package/texture-source.d.ts +4 -2
- package/texture-source.js +3 -2
- package/texture-source.js.map +1 -1
- package/texture.d.ts +18 -8
- package/texture.js +61 -35
- package/texture.js.map +1 -1
- package/web-family.d.ts +2 -1
- package/web-family.js.map +1 -1
package/depth-stencil.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateFramebuffer } from "./framebuffer-validation.js";
|
|
1
2
|
import { applyGLStates } from "./apply-states.js";
|
|
2
3
|
import { RS_CLEAR_A, RS_CLEAR_B, RS_CLEAR_G, RS_CLEAR_R, RS_COLOR_MASK, RS_CULL_ENABLED, RS_CULL_FACE, RS_DEPTH_FUNC, RS_DEPTH_MASK, RS_DEPTH_TEST, RS_DESIRED, RS_STENCIL_FUNC_FUNC, RS_STENCIL_FUNC_MASK, RS_STENCIL_FUNC_REF, RS_STENCIL_MASK, RS_STENCIL_OP_FAIL, RS_STENCIL_OP_ZFAIL, RS_STENCIL_OP_ZPASS, RS_STENCIL_TEST, } from "./state.js";
|
|
3
4
|
// ── Clear bits (used by `clearEngine`).
|
|
@@ -45,8 +46,6 @@ const STENCIL_ATTACHMENT = 0x8d20;
|
|
|
45
46
|
/** GL `gl.DEPTH_ATTACHMENT` — where the render-target core attaches its depth-only
|
|
46
47
|
* renderbuffer (re-established when rolling back a failed stencil attach). */
|
|
47
48
|
const DEPTH_ATTACHMENT = 0x8d00;
|
|
48
|
-
/** GL `gl.FRAMEBUFFER_COMPLETE`. */
|
|
49
|
-
const FRAMEBUFFER_COMPLETE = 0x8cd5;
|
|
50
49
|
/** Seed the shared desired op tuple with WebGL's KEEP defaults. */
|
|
51
50
|
function ensureStencilOpCacheInitialized(rs) {
|
|
52
51
|
if (rs[RS_STENCIL_OP_FAIL + RS_DESIRED] !== -1) {
|
|
@@ -474,8 +473,9 @@ function flushColorMask(engine) {
|
|
|
474
473
|
* — the common case, and the correct choice when the target was created with
|
|
475
474
|
* `generateDepthBuffer: true`. When `false` the attachment is stencil-only
|
|
476
475
|
* (`STENCIL_INDEX8` on `STENCIL_ATTACHMENT`).
|
|
477
|
-
* @throws If a renderbuffer handle could not be allocated or the framebuffer is
|
|
478
|
-
* incomplete after attaching
|
|
476
|
+
* @throws If a renderbuffer handle could not be allocated, or the framebuffer is
|
|
477
|
+
* incomplete after attaching (unless `setFramebufferValidation(engine, false)`
|
|
478
|
+
* opted out of completeness checks).
|
|
479
479
|
*/
|
|
480
480
|
export function generateRenderTargetStencil(rt, options) {
|
|
481
481
|
const engine = rt._engine;
|
|
@@ -489,8 +489,10 @@ export function generateRenderTargetStencil(rt, options) {
|
|
|
489
489
|
const gl = e.gl;
|
|
490
490
|
// Capture the caller's draw target so this helper is STATE-NEUTRAL: it must
|
|
491
491
|
// not silently redirect subsequent draws to `rt` (during an internal
|
|
492
|
-
// rebuild `prevFb` is `rt._framebuffer`, which the core re-checks next
|
|
493
|
-
|
|
492
|
+
// rebuild `prevFb` is `rt._framebuffer`, which the core re-checks next
|
|
493
|
+
// unless validation was opted out).
|
|
494
|
+
// An unknown (wiped) binding is restored as the canvas.
|
|
495
|
+
const prevFb = e._state.boundFramebuffer ?? null;
|
|
494
496
|
const newRb = gl.createRenderbuffer();
|
|
495
497
|
if (newRb === null) {
|
|
496
498
|
throw new Error("lite-gl: gl.createRenderbuffer returned null (render target stencil)");
|
|
@@ -503,10 +505,7 @@ export function generateRenderTargetStencil(rt, options) {
|
|
|
503
505
|
gl.renderbufferStorage(RENDERBUFFER, format, rt.width, rt.height);
|
|
504
506
|
gl.framebufferRenderbuffer(FRAMEBUFFER, attachment, RENDERBUFFER, newRb);
|
|
505
507
|
gl.bindRenderbuffer(RENDERBUFFER, null);
|
|
506
|
-
|
|
507
|
-
if (status !== FRAMEBUFFER_COMPLETE) {
|
|
508
|
-
throw new Error(`lite-gl: render target framebuffer incomplete after stencil attach (status 0x${status.toString(16)})`);
|
|
509
|
-
}
|
|
508
|
+
validateFramebuffer(e, true);
|
|
510
509
|
// Commit only after a complete attachment: release the buffer we
|
|
511
510
|
// replaced (the core depth-only one, or our own from a prior rebuild).
|
|
512
511
|
if (rt._depthStencil !== null) {
|
|
@@ -567,7 +566,7 @@ export function generateRenderTargetStencil(rt, options) {
|
|
|
567
566
|
*/
|
|
568
567
|
function reattachCoreDepthBuffer(engine, rt, depthBuffer) {
|
|
569
568
|
const gl = engine.gl;
|
|
570
|
-
const prevFb = engine._state.boundFramebuffer;
|
|
569
|
+
const prevFb = engine._state.boundFramebuffer ?? null;
|
|
571
570
|
gl.bindFramebuffer(FRAMEBUFFER, rt._framebuffer);
|
|
572
571
|
engine._state.boundFramebuffer = rt._framebuffer;
|
|
573
572
|
gl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, depthBuffer);
|
package/depth-stencil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth-stencil.js","sourceRoot":"","sources":["../src/depth-stencil.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAClB,MAAM,YAAY,CAAC;AAEpB,yCAAyC;AACzC,qBAAqB;AACrB,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,+DAA+D;AAC/D,0BAA0B;AAC1B,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,yBAAyB;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,oBAAoB;AACpB,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,qBAAqB;AACrB,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,oBAAoB;AACpB,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,8BAA8B;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AA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C,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC,YAAY,CAAC;IACjD,EAAE,CAAC,uBAAuB,CAAC,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IACrF,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAC5C,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC;IAC5C,CAAC;AACL,CAAC","sourcesContent":["/**\n * Depth, stencil, color-mask and clear state — the lite-gl counterpart of\n * Babylon's `_depthCullingState` / `_stencilState` / `setColorWrite` / `clear`.\n *\n * Like Babylon, these setters are DEFERRED: they buffer the requested values\n * into the DESIRED (`d*`) mirror fields of `GLState` and raise `statesDirty`,\n * issuing NO `gl.*` calls themselves. `applyGLStates` (apply-states.ts) flushes\n * the diff to GL right before each draw (and before `clearEngine`'s `gl.clear`,\n * since a clear respects the current write masks). Every field is reconciled\n * independently, so a flush that changes only one sub-state (e.g. just the\n * stencil op triple) issues only that GL call. Omitted setter fields leave the\n * corresponding desired value untouched (merge-from-desired).\n *\n * All setters are no-ops on a lost/disposed context.\n *\n * This module also hosts {@link generateRenderTargetStencil} — the tree-shakeable\n * opt-in that gives a `/render-target` {@link GLRenderTarget} a stencil (or packed\n * depth+stencil) attachment. Keeping the STENCIL_INDEX8 / DEPTH24_STENCIL8\n * renderbuffer code here (rather than in the render-target core) means a consumer\n * that only needs a depth buffer never ships it. The one-way type import below\n * (`depth-stencil` importing `render-target`) introduces NO cycle: render-target\n * must not import this module.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport type { GLClearOptions } from \"./family.js\";\nimport type { GLRenderTarget } from \"./render-target.js\";\nimport { applyGLStates } from \"./apply-states.js\";\nimport {\n RS_CLEAR_A,\n RS_CLEAR_B,\n RS_CLEAR_G,\n RS_CLEAR_R,\n RS_COLOR_MASK,\n RS_CULL_ENABLED,\n RS_CULL_FACE,\n RS_DEPTH_FUNC,\n RS_DEPTH_MASK,\n RS_DEPTH_TEST,\n RS_DESIRED,\n RS_STENCIL_FUNC_FUNC,\n RS_STENCIL_FUNC_MASK,\n RS_STENCIL_FUNC_REF,\n RS_STENCIL_MASK,\n RS_STENCIL_OP_FAIL,\n RS_STENCIL_OP_ZFAIL,\n RS_STENCIL_OP_ZPASS,\n RS_STENCIL_TEST,\n} from \"./state.js\";\n\n// ── Clear bits (used by `clearEngine`).\n/** GL clear bits. */\nconst COLOR_BUFFER_BIT = 0x4000;\nconst DEPTH_BUFFER_BIT = 0x0100;\nconst STENCIL_BUFFER_BIT = 0x0400;\n\n// ── Test-enable enums for the per-category reconcilers below.\n/** GL `gl.DEPTH_TEST`. */\nconst DEPTH_TEST = 0x0b71;\n/** GL `gl.CULL_FACE`. */\nconst CULL_FACE = 0x0b44;\n/** GL `gl.STENCIL_TEST`. */\nconst STENCIL_TEST = 0x0b90;\n/** GL `gl.KEEP`. */\nconst KEEP = 0x1e00;\n/** GL `gl.FRONT`. */\nconst FRONT = 0x0404;\n/** GL `gl.BACK`. */\nconst BACK = 0x0405;\n/** GL `gl.FRONT_AND_BACK`. */\nconst FRONT_AND_BACK = 0x0408;\n// Two-sided mode appends actual slots 46..48 and desired slots 49..51 to the\n// compact 46-slot state array. Base indices remain unchanged.\nconst BACK_OP_FAIL = 46;\nconst BACK_OP_ZFAIL = 47;\nconst BACK_OP_ZPASS = 48;\nconst BACK_DESIRED = 3;\n\n// ── Framebuffer / renderbuffer enums (used only by generateRenderTargetStencil).\n// Module-local consts mirror render-target.ts's constant style. Because the\n// render-target core no longer references the stencil/packed enums, they live\n// here and tree-shake away for consumers that never opt into a stencil buffer.\n/** GL `gl.FRAMEBUFFER`. */\nconst FRAMEBUFFER = 0x8d40;\n/** GL `gl.RENDERBUFFER`. */\nconst RENDERBUFFER = 0x8d41;\n/** GL `gl.DEPTH24_STENCIL8` — packed depth+stencil sized format. */\nconst DEPTH24_STENCIL8 = 0x88f0;\n/** GL `gl.STENCIL_INDEX8` — stencil-only sized format. */\nconst STENCIL_INDEX8 = 0x8d48;\n/** GL `gl.DEPTH_STENCIL_ATTACHMENT`. */\nconst DEPTH_STENCIL_ATTACHMENT = 0x821a;\n/** GL `gl.STENCIL_ATTACHMENT`. */\nconst STENCIL_ATTACHMENT = 0x8d20;\n/** GL `gl.DEPTH_ATTACHMENT` — where the render-target core attaches its depth-only\n * renderbuffer (re-established when rolling back a failed stencil attach). */\nconst DEPTH_ATTACHMENT = 0x8d00;\n/** GL `gl.FRAMEBUFFER_COMPLETE`. */\nconst FRAMEBUFFER_COMPLETE = 0x8cd5;\n\n/** Depth-buffer configuration for {@link setDepthState}. Omitted fields are\n * left unchanged. */\nexport interface GLDepthState {\n /** Enable/disable the depth test (`gl.enable/disable(DEPTH_TEST)`). */\n test?: boolean;\n /** Enable/disable depth writes (`gl.depthMask`). */\n write?: boolean;\n /** Depth comparison function (`gl.depthFunc`), e.g. `gl.LESS`. */\n func?: GLenum;\n}\n\n/** Stencil configuration for {@link setStencilState}. Omitted fields are left\n * unchanged. Operation fields update both front and back faces; use\n * {@link setStencilOpSeparate} for per-face values. */\nexport interface GLStencilState {\n /** Enable/disable the stencil test (`gl.enable/disable(STENCIL_TEST)`). */\n test?: boolean;\n /** Comparison function (`gl.stencilFunc` arg 1), e.g. `gl.ALWAYS`. */\n func?: GLenum;\n /** Reference value (`gl.stencilFunc` arg 2). */\n ref?: number;\n /** Comparison mask (`gl.stencilFunc` arg 3). */\n funcMask?: number;\n /** Stencil write mask (`gl.stencilMask`). */\n mask?: number;\n /** Op when the stencil test fails (`gl.stencilOp` arg 1). */\n opFail?: GLenum;\n /** Op when the stencil test passes but depth fails (`gl.stencilOp` arg 2). */\n opZFail?: GLenum;\n /** Op when both stencil and depth pass (`gl.stencilOp` arg 3). */\n opZPass?: GLenum;\n}\n\n/** Per-face stencil operations for {@link setStencilOpSeparate}. Omitted fields\n * retain that face's desired value. */\nexport interface GLStencilOpState {\n /** Op when the stencil test fails (`gl.stencilOpSeparate` arg 2). */\n opFail?: GLenum;\n /** Op when the stencil test passes but depth fails (`gl.stencilOpSeparate` arg 3). */\n opZFail?: GLenum;\n /** Op when both stencil and depth pass (`gl.stencilOpSeparate` arg 4). */\n opZPass?: GLenum;\n}\n\n/** Seed the shared desired op tuple with WebGL's KEEP defaults. */\nfunction ensureStencilOpCacheInitialized(rs: Float64Array): void {\n if (rs[RS_STENCIL_OP_FAIL + RS_DESIRED] !== -1) {\n return;\n }\n rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = KEEP;\n rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = KEEP;\n rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = KEEP;\n}\n\nfunction setDesiredStencilOps(rs: Float64Array, state: GLStencilOpState): void {\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n ensureStencilOpCacheInitialized(rs);\n if (state.opFail !== undefined) {\n rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = state.opZPass;\n }\n}\n\n/** Store one complete GL operation tuple starting at `opIndex`. */\nfunction setStencilOps(rs: Float64Array, opIndex: number, fail: GLenum, zfail: GLenum, zpass: GLenum): void {\n rs[opIndex] = fail;\n rs[opIndex + 1] = zfail;\n rs[opIndex + 2] = zpass;\n}\n\nfunction resetStencilBack(rs: Float64Array): void {\n ensureStencilOpCacheInitialized(rs);\n setStencilOps(rs, BACK_OP_FAIL, rs[RS_STENCIL_OP_FAIL]!, rs[RS_STENCIL_OP_ZFAIL]!, rs[RS_STENCIL_OP_ZPASS]!);\n setStencilOps(rs, BACK_OP_FAIL + BACK_DESIRED, rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!, rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!, rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!);\n}\n\nfunction ensureStencilBackCacheInitialized(rs: Float64Array): void {\n if (rs[RS_STENCIL_OP_FAIL + RS_DESIRED] === -1) {\n resetStencilBack(rs);\n }\n}\n\nfunction setDesiredStencilBackOps(rs: Float64Array, state: GLStencilOpState): void {\n if (state.opFail !== undefined) {\n rs[BACK_OP_FAIL + BACK_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n rs[BACK_OP_ZFAIL + BACK_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n rs[BACK_OP_ZPASS + BACK_DESIRED] = state.opZPass;\n }\n}\n\n/** Mirror a shared stencil-op update to the lazily allocated back-face cache. */\nfunction mirrorSharedStencilOpsToBack(s: GLEngineContext[\"_state\"], state: GLStencilOpState): void {\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n ensureStencilBackCacheInitialized(s.rs);\n setDesiredStencilBackOps(s.rs, state);\n}\n\n/** Lazily install back-face storage and the two-sided reconciler. */\nfunction enableSeparateStencil(s: GLEngineContext[\"_state\"]): void {\n if (s._setStencilBack !== undefined) {\n return;\n }\n const rs = new Float64Array(52);\n rs.set(s.rs);\n s.rs = rs;\n resetStencilBack(rs);\n s._setStencilBack = mirrorSharedStencilOpsToBack;\n s._flushStencil = flushStencilSeparate;\n}\n\n/**\n * Buffer depth-buffer state (test enable, write mask, comparison function) into\n * the DESIRED state — the lite-gl equivalent of mutating Babylon's\n * `engine.depthCullingState.{depthTest,depthMask,depthFunc}`. Flushed to GL by\n * `applyGLStates` before the next draw / clear; omitted fields are untouched.\n *\n * @param engine - The engine.\n * @param state - The depth fields to change. Omitted fields are untouched.\n */\nexport function setDepthState(engine: GLEngineContext, state: GLDepthState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (state.test !== undefined) {\n s.rs[RS_DEPTH_TEST + RS_DESIRED] = state.test ? 1 : 0;\n }\n if (state.write !== undefined) {\n s.rs[RS_DEPTH_MASK + RS_DESIRED] = state.write ? 1 : 0;\n }\n if (state.func !== undefined) {\n s.rs[RS_DEPTH_FUNC + RS_DESIRED] = state.func;\n }\n s._flushDepthCull = flushDepthCull;\n s.statesDirty = true;\n}\n\n/**\n * Enable/disable face culling and (optionally) set the cull face — the lite-gl\n * equivalent of `engine.depthCullingState.cull` + `cullFace`.\n *\n * @param engine - The engine.\n * @param enabled - Enable (`true`) or disable (`false`) `gl.CULL_FACE`.\n * @param face - Optional cull face (`gl.BACK` / `gl.FRONT` / `gl.FRONT_AND_BACK`).\n */\nexport function setCullState(engine: GLEngineContext, enabled: boolean, face?: GLenum): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n s.rs[RS_CULL_ENABLED + RS_DESIRED] = enabled ? 1 : 0;\n if (face !== undefined) {\n s.rs[RS_CULL_FACE + RS_DESIRED] = face;\n }\n s._flushDepthCull = flushDepthCull;\n s.statesDirty = true;\n}\n\n/**\n * Buffer stencil state (test enable, write mask, comparison func triple, op\n * triple) into the DESIRED state — the lite-gl equivalent of mutating Babylon's\n * `engine.stencilState.*`. Flushed by `applyGLStates` before the next draw /\n * clear; omitted fields are untouched (merge-from-desired).\n *\n * @param engine - The engine.\n * @param state - The stencil fields to change. Omitted fields are untouched.\n */\nexport function setStencilState(engine: GLEngineContext, state: GLStencilState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (state.test !== undefined) {\n s.rs[RS_STENCIL_TEST + RS_DESIRED] = state.test ? 1 : 0;\n }\n if (state.func !== undefined) {\n s.rs[RS_STENCIL_FUNC_FUNC + RS_DESIRED] = state.func;\n }\n if (state.ref !== undefined) {\n s.rs[RS_STENCIL_FUNC_REF + RS_DESIRED] = state.ref;\n }\n if (state.funcMask !== undefined) {\n s.rs[RS_STENCIL_FUNC_MASK + RS_DESIRED] = state.funcMask;\n }\n if (state.mask !== undefined) {\n s.rs[RS_STENCIL_MASK + RS_DESIRED] = state.mask;\n }\n s._setStencilBack?.(s, state);\n if ((state.opFail ?? state.opZFail ?? state.opZPass) !== undefined) {\n ensureStencilOpCacheInitialized(s.rs);\n if (state.opFail !== undefined) {\n s.rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n s.rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n s.rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = state.opZPass;\n }\n }\n s._flushStencil ??= flushStencil;\n s.statesDirty = true;\n}\n\n/**\n * Buffer stencil operations for one face into the DESIRED state. This is the\n * deferred lite-gl counterpart of `gl.stencilOpSeparate`; use it to apply\n * different winding operations to front and back faces in one draw. A\n * `FRONT_AND_BACK` update applies each provided operation to both faces while\n * leaving omitted operations unchanged on each face.\n *\n * @param engine - The engine.\n * @param face - `gl.FRONT`, `gl.BACK`, or `gl.FRONT_AND_BACK`.\n * @param state - The operation fields to change for the selected face(s).\n * @throws If `face` is not `gl.FRONT`, `gl.BACK`, or `gl.FRONT_AND_BACK`.\n */\nexport function setStencilOpSeparate(engine: GLEngineContext, face: GLenum, state: GLStencilOpState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (face !== FRONT && face !== BACK && face !== FRONT_AND_BACK) {\n throw new Error(\"lite-gl: invalid face\");\n }\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n enableSeparateStencil(s);\n ensureStencilBackCacheInitialized(s.rs);\n if (face !== BACK) {\n setDesiredStencilOps(s.rs, state);\n }\n if (face !== FRONT) {\n setDesiredStencilBackOps(s.rs, state);\n }\n s.statesDirty = true;\n}\n\n/**\n * Buffer the color write mask into the DESIRED state — the lite-gl equivalent of\n * Babylon's `setColorWrite` (which passes the same flag to all four channels).\n * Flushed to GL (`gl.colorMask`) by `applyGLStates` before the next draw /\n * clear.\n *\n * @param engine - The engine.\n * @param r - Write red.\n * @param g - Write green.\n * @param b - Write blue.\n * @param a - Write alpha.\n */\nexport function setColorMask(engine: GLEngineContext, r: boolean, g: boolean, b: boolean, a: boolean): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const packed = (r ? 8 : 0) | (g ? 4 : 0) | (b ? 2 : 0) | (a ? 1 : 0);\n const s = engine._state;\n s.rs[RS_COLOR_MASK + RS_DESIRED] = packed;\n s._flushColorMask = flushColorMask;\n s.statesDirty = true;\n}\n\n/**\n * Clear the currently-bound framebuffer's color / depth / stencil buffers — the\n * lite-gl equivalent of Babylon's `clear(color, backBuffer, depth, stencil)`.\n * Depth/stencil clears respect the current write masks (set them first via\n * {@link setDepthState} / {@link setStencilState}). No-op when nothing is\n * requested or the context is lost/disposed.\n *\n * @param engine - The engine.\n * @param options - Which buffers to clear (and the color value).\n */\nexport function clearEngine(engine: GLEngineContext, options: GLClearOptions): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n let mask = 0;\n if (options.color !== undefined) {\n const c = options.color;\n const a = c.a ?? 1;\n const rs = engine._state.rs;\n // Cached: gl.clearColor is per-context state GL retains, so only re-issue\n // it when the requested color actually changes (Babylon re-sets it every\n // clear; this elides the redundant JS↔native call for constant backgrounds).\n if (rs[RS_CLEAR_R] !== c.r || rs[RS_CLEAR_G] !== c.g || rs[RS_CLEAR_B] !== c.b || rs[RS_CLEAR_A] !== a) {\n gl.clearColor(c.r, c.g, c.b, a);\n rs[RS_CLEAR_R] = c.r;\n rs[RS_CLEAR_G] = c.g;\n rs[RS_CLEAR_B] = c.b;\n rs[RS_CLEAR_A] = a;\n }\n mask |= COLOR_BUFFER_BIT;\n }\n if (options.depth === true) {\n mask |= DEPTH_BUFFER_BIT;\n }\n if (options.stencil === true) {\n mask |= STENCIL_BUFFER_BIT;\n }\n if (mask !== 0) {\n // Babylon parity: a clear respects the current depth/stencil/color write\n // masks, so flush any deferred state before clearing.\n applyGLStates(engine);\n gl.clear(mask);\n }\n}\n\n/* ─────────────────── deferred render-state reconcilers ──────────────────────\n * The per-category half of `applyGLStates`. Each setter above installs the\n * matching reconciler onto its `_state._flush*` slot; `applyGLStates`\n * (apply-states.ts) dispatches ONLY through those slots. Co-locating them with\n * their setters makes each one reachable solely when its setter is in the bundle,\n * so a scene that never touches depth/cull, stencil, or color-mask tree-shakes\n * the corresponding reconciler — and its GL code — away entirely. Each reconciles\n * its DESIRED (`rs[RS_X + RS_DESIRED]`) slots against the ACTUAL twins (`rs[RS_X]`)\n * and issues only the `gl.*` calls that changed, in the same order and with the\n * same elision rules as the former monolithic flush. */\n\n/** Reconcile depth + cull (Babylon's `_depthCullingState.apply`). @internal */\nfunction flushDepthCull(engine: GLEngineContext): void {\n const gl = engine.gl;\n const rs = engine._state.rs;\n const dTest = rs[RS_DEPTH_TEST + RS_DESIRED]!;\n if (dTest !== rs[RS_DEPTH_TEST]) {\n rs[RS_DEPTH_TEST] = dTest;\n if (dTest === 1) {\n gl.enable(DEPTH_TEST);\n } else {\n gl.disable(DEPTH_TEST);\n }\n }\n const dMask = rs[RS_DEPTH_MASK + RS_DESIRED]!;\n if (dMask !== rs[RS_DEPTH_MASK]) {\n rs[RS_DEPTH_MASK] = dMask;\n gl.depthMask(dMask === 1);\n }\n const dFunc = rs[RS_DEPTH_FUNC + RS_DESIRED]!;\n if (dFunc !== rs[RS_DEPTH_FUNC]) {\n rs[RS_DEPTH_FUNC] = dFunc;\n gl.depthFunc(dFunc);\n }\n const dCull = rs[RS_CULL_ENABLED + RS_DESIRED]!;\n if (dCull !== rs[RS_CULL_ENABLED]) {\n rs[RS_CULL_ENABLED] = dCull;\n if (dCull === 1) {\n gl.enable(CULL_FACE);\n } else {\n gl.disable(CULL_FACE);\n }\n }\n const dCullFace = rs[RS_CULL_FACE + RS_DESIRED]!;\n if (dCullFace !== rs[RS_CULL_FACE]) {\n rs[RS_CULL_FACE] = dCullFace;\n gl.cullFace(dCullFace);\n }\n}\n\nfunction flushStencilCommon(engine: GLEngineContext): void {\n const gl = engine.gl;\n const rs = engine._state.rs;\n const dTest = rs[RS_STENCIL_TEST + RS_DESIRED]!;\n if (dTest !== rs[RS_STENCIL_TEST]) {\n rs[RS_STENCIL_TEST] = dTest;\n if (dTest === 1) {\n gl.enable(STENCIL_TEST);\n } else {\n gl.disable(STENCIL_TEST);\n }\n }\n const dMask = rs[RS_STENCIL_MASK + RS_DESIRED]!;\n if (dMask !== rs[RS_STENCIL_MASK]) {\n rs[RS_STENCIL_MASK] = dMask;\n gl.stencilMask(dMask);\n }\n const dFuncFunc = rs[RS_STENCIL_FUNC_FUNC + RS_DESIRED]!;\n const dFuncRef = rs[RS_STENCIL_FUNC_REF + RS_DESIRED]!;\n const dFuncMask = rs[RS_STENCIL_FUNC_MASK + RS_DESIRED]!;\n if (dFuncFunc !== rs[RS_STENCIL_FUNC_FUNC] || dFuncRef !== rs[RS_STENCIL_FUNC_REF] || dFuncMask !== rs[RS_STENCIL_FUNC_MASK]) {\n rs[RS_STENCIL_FUNC_FUNC] = dFuncFunc;\n rs[RS_STENCIL_FUNC_REF] = dFuncRef;\n rs[RS_STENCIL_FUNC_MASK] = dFuncMask;\n gl.stencilFunc(dFuncFunc, dFuncRef, dFuncMask);\n }\n}\n\n/** Reconcile the compact shared stencil state. @internal */\nfunction flushStencil(engine: GLEngineContext): void {\n flushStencilCommon(engine);\n const gl = engine.gl;\n const rs = engine._state.rs;\n const frontOpFail = rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!;\n if (frontOpFail === -1) {\n return;\n }\n const frontOpZFail = rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!;\n const frontOpZPass = rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!;\n const frontChanged = frontOpFail !== rs[RS_STENCIL_OP_FAIL] || frontOpZFail !== rs[RS_STENCIL_OP_ZFAIL] || frontOpZPass !== rs[RS_STENCIL_OP_ZPASS];\n if (frontChanged) {\n rs[RS_STENCIL_OP_FAIL] = frontOpFail;\n rs[RS_STENCIL_OP_ZFAIL] = frontOpZFail;\n rs[RS_STENCIL_OP_ZPASS] = frontOpZPass;\n gl.stencilOp(frontOpFail, frontOpZFail, frontOpZPass);\n }\n}\n\n/** Reconcile independently cached front/back stencil operation tuples. */\nfunction flushStencilSeparate(engine: GLEngineContext): void {\n flushStencilCommon(engine);\n const gl = engine.gl;\n const rs = engine._state.rs;\n const frontOpFail = rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!;\n if (frontOpFail === -1) {\n return;\n }\n const frontOpZFail = rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!;\n const frontOpZPass = rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!;\n const backOpFail = rs[BACK_OP_FAIL + BACK_DESIRED]!;\n const backOpZFail = rs[BACK_OP_ZFAIL + BACK_DESIRED]!;\n const backOpZPass = rs[BACK_OP_ZPASS + BACK_DESIRED]!;\n const frontChanged = frontOpFail !== rs[RS_STENCIL_OP_FAIL] || frontOpZFail !== rs[RS_STENCIL_OP_ZFAIL] || frontOpZPass !== rs[RS_STENCIL_OP_ZPASS];\n const backChanged = backOpFail !== rs[BACK_OP_FAIL] || backOpZFail !== rs[BACK_OP_ZFAIL] || backOpZPass !== rs[BACK_OP_ZPASS];\n if (!frontChanged && !backChanged) {\n return;\n }\n const facesMatch = frontOpFail === backOpFail && frontOpZFail === backOpZFail && frontOpZPass === backOpZPass;\n if (facesMatch) {\n setStencilOps(rs, RS_STENCIL_OP_FAIL, frontOpFail, frontOpZFail, frontOpZPass);\n setStencilOps(rs, BACK_OP_FAIL, backOpFail, backOpZFail, backOpZPass);\n gl.stencilOp(frontOpFail, frontOpZFail, frontOpZPass);\n return;\n }\n if (frontChanged) {\n setStencilOps(rs, RS_STENCIL_OP_FAIL, frontOpFail, frontOpZFail, frontOpZPass);\n gl.stencilOpSeparate(FRONT, frontOpFail, frontOpZFail, frontOpZPass);\n }\n if (backChanged) {\n setStencilOps(rs, BACK_OP_FAIL, backOpFail, backOpZFail, backOpZPass);\n gl.stencilOpSeparate(BACK, backOpFail, backOpZFail, backOpZPass);\n }\n}\n\n/** Reconcile the packed color-write mask (Babylon's `setColorWrite`). @internal */\nfunction flushColorMask(engine: GLEngineContext): void {\n const rs = engine._state.rs;\n const dColorMask = rs[RS_COLOR_MASK + RS_DESIRED]!;\n if (dColorMask !== rs[RS_COLOR_MASK]) {\n rs[RS_COLOR_MASK] = dColorMask;\n engine.gl.colorMask((dColorMask & 8) !== 0, (dColorMask & 4) !== 0, (dColorMask & 2) !== 0, (dColorMask & 1) !== 0);\n }\n}\n\n/**\n * Opt-in: give a `/render-target` {@link GLRenderTarget} a stencil attachment,\n * replacing the core's depth-only `DEPTH_COMPONENT16` renderbuffer with either a\n * packed **`DEPTH24_STENCIL8`** buffer (default — depth *and* stencil) or a\n * stencil-only **`STENCIL_INDEX8`** buffer.\n *\n * Stencil is intentionally NOT a {@link createRenderTarget} option: keeping this\n * helper in the depth-stencil module means the stencil/packed renderbuffer\n * code tree-shakes out of every bundle that only needs a color (and optional\n * depth) target.\n *\n * The attachment is **restore-correct**: it is rebuilt automatically — at the new\n * size on {@link resizeRenderTarget}, and into the fresh framebuffer after a\n * `webglcontextrestored` event — so the stencil survives for the life of the\n * target, and {@link disposeRenderTarget} releases it along with the target.\n *\n * No-op on a lost/disposed context or a disposed target.\n *\n * @param rt - The render target to attach the stencil buffer to.\n * @param options - `depth` (default `true`): when `true` the attachment is a\n * packed depth+stencil buffer (`DEPTH24_STENCIL8` on `DEPTH_STENCIL_ATTACHMENT`)\n * — the common case, and the correct choice when the target was created with\n * `generateDepthBuffer: true`. When `false` the attachment is stencil-only\n * (`STENCIL_INDEX8` on `STENCIL_ATTACHMENT`).\n * @throws If a renderbuffer handle could not be allocated or the framebuffer is\n * incomplete after attaching.\n */\nexport function generateRenderTargetStencil(rt: GLRenderTarget, options?: { depth?: boolean }): void {\n const engine = rt._engine;\n if (engine._isLost || engine._disposed || rt._disposed) {\n return;\n }\n const packDepth = options?.depth ?? true;\n const attachment = packDepth ? DEPTH_STENCIL_ATTACHMENT : STENCIL_ATTACHMENT;\n const format = packDepth ? DEPTH24_STENCIL8 : STENCIL_INDEX8;\n\n const build = (e: GLEngineContext): void => {\n const gl = e.gl;\n // Capture the caller's draw target so this helper is STATE-NEUTRAL: it must\n // not silently redirect subsequent draws to `rt` (during an internal\n // rebuild `prevFb` is `rt._framebuffer`, which the core re-checks next).\n const prevFb = e._state.boundFramebuffer;\n const newRb = gl.createRenderbuffer();\n if (newRb === null) {\n throw new Error(\"lite-gl: gl.createRenderbuffer returned null (render target stencil)\");\n }\n let committed = false;\n try {\n gl.bindFramebuffer(FRAMEBUFFER, rt._framebuffer);\n e._state.boundFramebuffer = rt._framebuffer;\n gl.bindRenderbuffer(RENDERBUFFER, newRb);\n gl.renderbufferStorage(RENDERBUFFER, format, rt.width, rt.height);\n gl.framebufferRenderbuffer(FRAMEBUFFER, attachment, RENDERBUFFER, newRb);\n gl.bindRenderbuffer(RENDERBUFFER, null);\n const status = gl.checkFramebufferStatus(FRAMEBUFFER);\n if (status !== FRAMEBUFFER_COMPLETE) {\n throw new Error(`lite-gl: render target framebuffer incomplete after stencil attach (status 0x${status.toString(16)})`);\n }\n // Commit only after a complete attachment: release the buffer we\n // replaced (the core depth-only one, or our own from a prior rebuild).\n if (rt._depthStencil !== null) {\n gl.deleteRenderbuffer(rt._depthStencil);\n }\n rt._depthStencil = newRb;\n committed = true;\n } finally {\n if (!committed) {\n // Any non-committed exit (incomplete framebuffer OR an unexpected\n // GL throw): detach + delete the buffer we couldn't adopt so it\n // never leaks, leaving the attachment point empty for the\n // caller-level rollback to re-establish the prior buffer.\n gl.framebufferRenderbuffer(FRAMEBUFFER, attachment, RENDERBUFFER, null);\n gl.deleteRenderbuffer(newRb);\n }\n // Restore the caller's draw target + the bound-framebuffer cache.\n if (e._state.boundFramebuffer !== prevFb) {\n gl.bindFramebuffer(FRAMEBUFFER, prevFb);\n e._state.boundFramebuffer = prevFb;\n }\n }\n };\n\n // Build once now, but COMMIT the resize/restore hook only if it succeeds — a\n // failed opt-in must leave the target exactly as it was. The packed attach\n // above can clear the core `DEPTH_ATTACHMENT`, so on failure restore the prior\n // hook AND re-establish the prior depth/stencil attachment (the prior hook's,\n // or the core depth-only buffer).\n const prevHook = rt._rebuildDepthStencil;\n const prevDepthStencil = rt._depthStencil;\n try {\n build(engine);\n } catch (err) {\n rt._rebuildDepthStencil = prevHook;\n try {\n if (prevHook !== undefined) {\n prevHook(engine);\n } else if (prevDepthStencil !== null) {\n reattachCoreDepthBuffer(engine, rt, prevDepthStencil);\n }\n } catch {\n // Best-effort restore; surface the original failure below.\n }\n throw err;\n }\n rt._rebuildDepthStencil = build;\n}\n\n/**\n * Re-attach a core depth-only renderbuffer at `DEPTH_ATTACHMENT` — used to roll a\n * render target back when a packed {@link generateRenderTargetStencil} attach\n * fails completeness (attaching at `DEPTH_STENCIL_ATTACHMENT` clears the core\n * `DEPTH_ATTACHMENT`). State-neutral: restores the caller's bound framebuffer.\n * @internal\n */\nfunction reattachCoreDepthBuffer(engine: GLEngineContext, rt: GLRenderTarget, depthBuffer: WebGLRenderbuffer): void {\n const gl = engine.gl;\n const prevFb = engine._state.boundFramebuffer;\n gl.bindFramebuffer(FRAMEBUFFER, rt._framebuffer);\n engine._state.boundFramebuffer = rt._framebuffer;\n gl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, depthBuffer);\n if (engine._state.boundFramebuffer !== prevFb) {\n gl.bindFramebuffer(FRAMEBUFFER, prevFb);\n engine._state.boundFramebuffer = prevFb;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"depth-stencil.js","sourceRoot":"","sources":["../src/depth-stencil.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAA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AC;QACX,EAAE,CAAC,oBAAoB,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC;YACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzB,QAAQ,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;iBAAM,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;gBACnC,uBAAuB,CAAC,MAAM,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC;YAC1D,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,2DAA2D;QAC/D,CAAC;QACD,MAAM,GAAG,CAAC;IACd,CAAC;IACD,EAAE,CAAC,oBAAoB,GAAG,KAAK,CAAC;AACpC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,MAAuB,EAAE,EAAkB,EAAE,WAA8B;IACxG,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC;IACtD,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC,YAAY,CAAC;IACjD,EAAE,CAAC,uBAAuB,CAAC,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IACrF,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAC5C,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC;IAC5C,CAAC;AACL,CAAC","sourcesContent":["/**\n * Depth, stencil, color-mask and clear state — the lite-gl counterpart of\n * Babylon's `_depthCullingState` / `_stencilState` / `setColorWrite` / `clear`.\n *\n * Like Babylon, these setters are DEFERRED: they buffer the requested values\n * into the DESIRED (`d*`) mirror fields of `GLState` and raise `statesDirty`,\n * issuing NO `gl.*` calls themselves. `applyGLStates` (apply-states.ts) flushes\n * the diff to GL right before each draw (and before `clearEngine`'s `gl.clear`,\n * since a clear respects the current write masks). Every field is reconciled\n * independently, so a flush that changes only one sub-state (e.g. just the\n * stencil op triple) issues only that GL call. Omitted setter fields leave the\n * corresponding desired value untouched (merge-from-desired).\n *\n * All setters are no-ops on a lost/disposed context.\n *\n * This module also hosts {@link generateRenderTargetStencil} — the tree-shakeable\n * opt-in that gives a `/render-target` {@link GLRenderTarget} a stencil (or packed\n * depth+stencil) attachment. Keeping the STENCIL_INDEX8 / DEPTH24_STENCIL8\n * renderbuffer code here (rather than in the render-target core) means a consumer\n * that only needs a depth buffer never ships it. The one-way type import below\n * (`depth-stencil` importing `render-target`) introduces NO cycle: render-target\n * must not import this module.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport type { GLClearOptions } from \"./family.js\";\nimport type { GLRenderTarget } from \"./render-target.js\";\nimport { validateFramebuffer } from \"./framebuffer-validation.js\";\nimport { applyGLStates } from \"./apply-states.js\";\nimport {\n RS_CLEAR_A,\n RS_CLEAR_B,\n RS_CLEAR_G,\n RS_CLEAR_R,\n RS_COLOR_MASK,\n RS_CULL_ENABLED,\n RS_CULL_FACE,\n RS_DEPTH_FUNC,\n RS_DEPTH_MASK,\n RS_DEPTH_TEST,\n RS_DESIRED,\n RS_STENCIL_FUNC_FUNC,\n RS_STENCIL_FUNC_MASK,\n RS_STENCIL_FUNC_REF,\n RS_STENCIL_MASK,\n RS_STENCIL_OP_FAIL,\n RS_STENCIL_OP_ZFAIL,\n RS_STENCIL_OP_ZPASS,\n RS_STENCIL_TEST,\n} from \"./state.js\";\n\n// ── Clear bits (used by `clearEngine`).\n/** GL clear bits. */\nconst COLOR_BUFFER_BIT = 0x4000;\nconst DEPTH_BUFFER_BIT = 0x0100;\nconst STENCIL_BUFFER_BIT = 0x0400;\n\n// ── Test-enable enums for the per-category reconcilers below.\n/** GL `gl.DEPTH_TEST`. */\nconst DEPTH_TEST = 0x0b71;\n/** GL `gl.CULL_FACE`. */\nconst CULL_FACE = 0x0b44;\n/** GL `gl.STENCIL_TEST`. */\nconst STENCIL_TEST = 0x0b90;\n/** GL `gl.KEEP`. */\nconst KEEP = 0x1e00;\n/** GL `gl.FRONT`. */\nconst FRONT = 0x0404;\n/** GL `gl.BACK`. */\nconst BACK = 0x0405;\n/** GL `gl.FRONT_AND_BACK`. */\nconst FRONT_AND_BACK = 0x0408;\n// Two-sided mode appends actual slots 46..48 and desired slots 49..51 to the\n// compact 46-slot state array. Base indices remain unchanged.\nconst BACK_OP_FAIL = 46;\nconst BACK_OP_ZFAIL = 47;\nconst BACK_OP_ZPASS = 48;\nconst BACK_DESIRED = 3;\n\n// ── Framebuffer / renderbuffer enums (used only by generateRenderTargetStencil).\n// Module-local consts mirror render-target.ts's constant style. Because the\n// render-target core no longer references the stencil/packed enums, they live\n// here and tree-shake away for consumers that never opt into a stencil buffer.\n/** GL `gl.FRAMEBUFFER`. */\nconst FRAMEBUFFER = 0x8d40;\n/** GL `gl.RENDERBUFFER`. */\nconst RENDERBUFFER = 0x8d41;\n/** GL `gl.DEPTH24_STENCIL8` — packed depth+stencil sized format. */\nconst DEPTH24_STENCIL8 = 0x88f0;\n/** GL `gl.STENCIL_INDEX8` — stencil-only sized format. */\nconst STENCIL_INDEX8 = 0x8d48;\n/** GL `gl.DEPTH_STENCIL_ATTACHMENT`. */\nconst DEPTH_STENCIL_ATTACHMENT = 0x821a;\n/** GL `gl.STENCIL_ATTACHMENT`. */\nconst STENCIL_ATTACHMENT = 0x8d20;\n/** GL `gl.DEPTH_ATTACHMENT` — where the render-target core attaches its depth-only\n * renderbuffer (re-established when rolling back a failed stencil attach). */\nconst DEPTH_ATTACHMENT = 0x8d00;\n\n/** Depth-buffer configuration for {@link setDepthState}. Omitted fields are\n * left unchanged. */\nexport interface GLDepthState {\n /** Enable/disable the depth test (`gl.enable/disable(DEPTH_TEST)`). */\n test?: boolean;\n /** Enable/disable depth writes (`gl.depthMask`). */\n write?: boolean;\n /** Depth comparison function (`gl.depthFunc`), e.g. `gl.LESS`. */\n func?: GLenum;\n}\n\n/** Stencil configuration for {@link setStencilState}. Omitted fields are left\n * unchanged. Operation fields update both front and back faces; use\n * {@link setStencilOpSeparate} for per-face values. */\nexport interface GLStencilState {\n /** Enable/disable the stencil test (`gl.enable/disable(STENCIL_TEST)`). */\n test?: boolean;\n /** Comparison function (`gl.stencilFunc` arg 1), e.g. `gl.ALWAYS`. */\n func?: GLenum;\n /** Reference value (`gl.stencilFunc` arg 2). */\n ref?: number;\n /** Comparison mask (`gl.stencilFunc` arg 3). */\n funcMask?: number;\n /** Stencil write mask (`gl.stencilMask`). */\n mask?: number;\n /** Op when the stencil test fails (`gl.stencilOp` arg 1). */\n opFail?: GLenum;\n /** Op when the stencil test passes but depth fails (`gl.stencilOp` arg 2). */\n opZFail?: GLenum;\n /** Op when both stencil and depth pass (`gl.stencilOp` arg 3). */\n opZPass?: GLenum;\n}\n\n/** Per-face stencil operations for {@link setStencilOpSeparate}. Omitted fields\n * retain that face's desired value. */\nexport interface GLStencilOpState {\n /** Op when the stencil test fails (`gl.stencilOpSeparate` arg 2). */\n opFail?: GLenum;\n /** Op when the stencil test passes but depth fails (`gl.stencilOpSeparate` arg 3). */\n opZFail?: GLenum;\n /** Op when both stencil and depth pass (`gl.stencilOpSeparate` arg 4). */\n opZPass?: GLenum;\n}\n\n/** Seed the shared desired op tuple with WebGL's KEEP defaults. */\nfunction ensureStencilOpCacheInitialized(rs: Float64Array): void {\n if (rs[RS_STENCIL_OP_FAIL + RS_DESIRED] !== -1) {\n return;\n }\n rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = KEEP;\n rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = KEEP;\n rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = KEEP;\n}\n\nfunction setDesiredStencilOps(rs: Float64Array, state: GLStencilOpState): void {\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n ensureStencilOpCacheInitialized(rs);\n if (state.opFail !== undefined) {\n rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = state.opZPass;\n }\n}\n\n/** Store one complete GL operation tuple starting at `opIndex`. */\nfunction setStencilOps(rs: Float64Array, opIndex: number, fail: GLenum, zfail: GLenum, zpass: GLenum): void {\n rs[opIndex] = fail;\n rs[opIndex + 1] = zfail;\n rs[opIndex + 2] = zpass;\n}\n\nfunction resetStencilBack(rs: Float64Array): void {\n ensureStencilOpCacheInitialized(rs);\n setStencilOps(rs, BACK_OP_FAIL, rs[RS_STENCIL_OP_FAIL]!, rs[RS_STENCIL_OP_ZFAIL]!, rs[RS_STENCIL_OP_ZPASS]!);\n setStencilOps(rs, BACK_OP_FAIL + BACK_DESIRED, rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!, rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!, rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!);\n}\n\nfunction ensureStencilBackCacheInitialized(rs: Float64Array): void {\n if (rs[RS_STENCIL_OP_FAIL + RS_DESIRED] === -1) {\n resetStencilBack(rs);\n }\n}\n\nfunction setDesiredStencilBackOps(rs: Float64Array, state: GLStencilOpState): void {\n if (state.opFail !== undefined) {\n rs[BACK_OP_FAIL + BACK_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n rs[BACK_OP_ZFAIL + BACK_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n rs[BACK_OP_ZPASS + BACK_DESIRED] = state.opZPass;\n }\n}\n\n/** Mirror a shared stencil-op update to the lazily allocated back-face cache. */\nfunction mirrorSharedStencilOpsToBack(s: GLEngineContext[\"_state\"], state: GLStencilOpState): void {\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n ensureStencilBackCacheInitialized(s.rs);\n setDesiredStencilBackOps(s.rs, state);\n}\n\n/** Lazily install back-face storage and the two-sided reconciler. */\nfunction enableSeparateStencil(s: GLEngineContext[\"_state\"]): void {\n if (s._setStencilBack !== undefined) {\n return;\n }\n const rs = new Float64Array(52);\n rs.set(s.rs);\n s.rs = rs;\n resetStencilBack(rs);\n s._setStencilBack = mirrorSharedStencilOpsToBack;\n s._flushStencil = flushStencilSeparate;\n}\n\n/**\n * Buffer depth-buffer state (test enable, write mask, comparison function) into\n * the DESIRED state — the lite-gl equivalent of mutating Babylon's\n * `engine.depthCullingState.{depthTest,depthMask,depthFunc}`. Flushed to GL by\n * `applyGLStates` before the next draw / clear; omitted fields are untouched.\n *\n * @param engine - The engine.\n * @param state - The depth fields to change. Omitted fields are untouched.\n */\nexport function setDepthState(engine: GLEngineContext, state: GLDepthState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (state.test !== undefined) {\n s.rs[RS_DEPTH_TEST + RS_DESIRED] = state.test ? 1 : 0;\n }\n if (state.write !== undefined) {\n s.rs[RS_DEPTH_MASK + RS_DESIRED] = state.write ? 1 : 0;\n }\n if (state.func !== undefined) {\n s.rs[RS_DEPTH_FUNC + RS_DESIRED] = state.func;\n }\n s._flushDepthCull = flushDepthCull;\n s.statesDirty = true;\n}\n\n/**\n * Enable/disable face culling and (optionally) set the cull face — the lite-gl\n * equivalent of `engine.depthCullingState.cull` + `cullFace`.\n *\n * @param engine - The engine.\n * @param enabled - Enable (`true`) or disable (`false`) `gl.CULL_FACE`.\n * @param face - Optional cull face (`gl.BACK` / `gl.FRONT` / `gl.FRONT_AND_BACK`).\n */\nexport function setCullState(engine: GLEngineContext, enabled: boolean, face?: GLenum): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n s.rs[RS_CULL_ENABLED + RS_DESIRED] = enabled ? 1 : 0;\n if (face !== undefined) {\n s.rs[RS_CULL_FACE + RS_DESIRED] = face;\n }\n s._flushDepthCull = flushDepthCull;\n s.statesDirty = true;\n}\n\n/**\n * Buffer stencil state (test enable, write mask, comparison func triple, op\n * triple) into the DESIRED state — the lite-gl equivalent of mutating Babylon's\n * `engine.stencilState.*`. Flushed by `applyGLStates` before the next draw /\n * clear; omitted fields are untouched (merge-from-desired).\n *\n * @param engine - The engine.\n * @param state - The stencil fields to change. Omitted fields are untouched.\n */\nexport function setStencilState(engine: GLEngineContext, state: GLStencilState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (state.test !== undefined) {\n s.rs[RS_STENCIL_TEST + RS_DESIRED] = state.test ? 1 : 0;\n }\n if (state.func !== undefined) {\n s.rs[RS_STENCIL_FUNC_FUNC + RS_DESIRED] = state.func;\n }\n if (state.ref !== undefined) {\n s.rs[RS_STENCIL_FUNC_REF + RS_DESIRED] = state.ref;\n }\n if (state.funcMask !== undefined) {\n s.rs[RS_STENCIL_FUNC_MASK + RS_DESIRED] = state.funcMask;\n }\n if (state.mask !== undefined) {\n s.rs[RS_STENCIL_MASK + RS_DESIRED] = state.mask;\n }\n s._setStencilBack?.(s, state);\n if ((state.opFail ?? state.opZFail ?? state.opZPass) !== undefined) {\n ensureStencilOpCacheInitialized(s.rs);\n if (state.opFail !== undefined) {\n s.rs[RS_STENCIL_OP_FAIL + RS_DESIRED] = state.opFail;\n }\n if (state.opZFail !== undefined) {\n s.rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED] = state.opZFail;\n }\n if (state.opZPass !== undefined) {\n s.rs[RS_STENCIL_OP_ZPASS + RS_DESIRED] = state.opZPass;\n }\n }\n s._flushStencil ??= flushStencil;\n s.statesDirty = true;\n}\n\n/**\n * Buffer stencil operations for one face into the DESIRED state. This is the\n * deferred lite-gl counterpart of `gl.stencilOpSeparate`; use it to apply\n * different winding operations to front and back faces in one draw. A\n * `FRONT_AND_BACK` update applies each provided operation to both faces while\n * leaving omitted operations unchanged on each face.\n *\n * @param engine - The engine.\n * @param face - `gl.FRONT`, `gl.BACK`, or `gl.FRONT_AND_BACK`.\n * @param state - The operation fields to change for the selected face(s).\n * @throws If `face` is not `gl.FRONT`, `gl.BACK`, or `gl.FRONT_AND_BACK`.\n */\nexport function setStencilOpSeparate(engine: GLEngineContext, face: GLenum, state: GLStencilOpState): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n if (face !== FRONT && face !== BACK && face !== FRONT_AND_BACK) {\n throw new Error(\"lite-gl: invalid face\");\n }\n if ((state.opFail ?? state.opZFail ?? state.opZPass) === undefined) {\n return;\n }\n enableSeparateStencil(s);\n ensureStencilBackCacheInitialized(s.rs);\n if (face !== BACK) {\n setDesiredStencilOps(s.rs, state);\n }\n if (face !== FRONT) {\n setDesiredStencilBackOps(s.rs, state);\n }\n s.statesDirty = true;\n}\n\n/**\n * Buffer the color write mask into the DESIRED state — the lite-gl equivalent of\n * Babylon's `setColorWrite` (which passes the same flag to all four channels).\n * Flushed to GL (`gl.colorMask`) by `applyGLStates` before the next draw /\n * clear.\n *\n * @param engine - The engine.\n * @param r - Write red.\n * @param g - Write green.\n * @param b - Write blue.\n * @param a - Write alpha.\n */\nexport function setColorMask(engine: GLEngineContext, r: boolean, g: boolean, b: boolean, a: boolean): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const packed = (r ? 8 : 0) | (g ? 4 : 0) | (b ? 2 : 0) | (a ? 1 : 0);\n const s = engine._state;\n s.rs[RS_COLOR_MASK + RS_DESIRED] = packed;\n s._flushColorMask = flushColorMask;\n s.statesDirty = true;\n}\n\n/**\n * Clear the currently-bound framebuffer's color / depth / stencil buffers — the\n * lite-gl equivalent of Babylon's `clear(color, backBuffer, depth, stencil)`.\n * Depth/stencil clears respect the current write masks (set them first via\n * {@link setDepthState} / {@link setStencilState}). No-op when nothing is\n * requested or the context is lost/disposed.\n *\n * @param engine - The engine.\n * @param options - Which buffers to clear (and the color value).\n */\nexport function clearEngine(engine: GLEngineContext, options: GLClearOptions): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n let mask = 0;\n if (options.color !== undefined) {\n const c = options.color;\n const a = c.a ?? 1;\n const rs = engine._state.rs;\n // Cached: gl.clearColor is per-context state GL retains, so only re-issue\n // it when the requested color actually changes (Babylon re-sets it every\n // clear; this elides the redundant JS↔native call for constant backgrounds).\n if (rs[RS_CLEAR_R] !== c.r || rs[RS_CLEAR_G] !== c.g || rs[RS_CLEAR_B] !== c.b || rs[RS_CLEAR_A] !== a) {\n gl.clearColor(c.r, c.g, c.b, a);\n rs[RS_CLEAR_R] = c.r;\n rs[RS_CLEAR_G] = c.g;\n rs[RS_CLEAR_B] = c.b;\n rs[RS_CLEAR_A] = a;\n }\n mask |= COLOR_BUFFER_BIT;\n }\n if (options.depth === true) {\n mask |= DEPTH_BUFFER_BIT;\n }\n if (options.stencil === true) {\n mask |= STENCIL_BUFFER_BIT;\n }\n if (mask !== 0) {\n // Babylon parity: a clear respects the current depth/stencil/color write\n // masks, so flush any deferred state before clearing.\n applyGLStates(engine);\n gl.clear(mask);\n }\n}\n\n/* ─────────────────── deferred render-state reconcilers ──────────────────────\n * The per-category half of `applyGLStates`. Each setter above installs the\n * matching reconciler onto its `_state._flush*` slot; `applyGLStates`\n * (apply-states.ts) dispatches ONLY through those slots. Co-locating them with\n * their setters makes each one reachable solely when its setter is in the bundle,\n * so a scene that never touches depth/cull, stencil, or color-mask tree-shakes\n * the corresponding reconciler — and its GL code — away entirely. Each reconciles\n * its DESIRED (`rs[RS_X + RS_DESIRED]`) slots against the ACTUAL twins (`rs[RS_X]`)\n * and issues only the `gl.*` calls that changed, in the same order and with the\n * same elision rules as the former monolithic flush. */\n\n/** Reconcile depth + cull (Babylon's `_depthCullingState.apply`). @internal */\nfunction flushDepthCull(engine: GLEngineContext): void {\n const gl = engine.gl;\n const rs = engine._state.rs;\n const dTest = rs[RS_DEPTH_TEST + RS_DESIRED]!;\n if (dTest !== rs[RS_DEPTH_TEST]) {\n rs[RS_DEPTH_TEST] = dTest;\n if (dTest === 1) {\n gl.enable(DEPTH_TEST);\n } else {\n gl.disable(DEPTH_TEST);\n }\n }\n const dMask = rs[RS_DEPTH_MASK + RS_DESIRED]!;\n if (dMask !== rs[RS_DEPTH_MASK]) {\n rs[RS_DEPTH_MASK] = dMask;\n gl.depthMask(dMask === 1);\n }\n const dFunc = rs[RS_DEPTH_FUNC + RS_DESIRED]!;\n if (dFunc !== rs[RS_DEPTH_FUNC]) {\n rs[RS_DEPTH_FUNC] = dFunc;\n gl.depthFunc(dFunc);\n }\n const dCull = rs[RS_CULL_ENABLED + RS_DESIRED]!;\n if (dCull !== rs[RS_CULL_ENABLED]) {\n rs[RS_CULL_ENABLED] = dCull;\n if (dCull === 1) {\n gl.enable(CULL_FACE);\n } else {\n gl.disable(CULL_FACE);\n }\n }\n const dCullFace = rs[RS_CULL_FACE + RS_DESIRED]!;\n if (dCullFace !== rs[RS_CULL_FACE]) {\n rs[RS_CULL_FACE] = dCullFace;\n gl.cullFace(dCullFace);\n }\n}\n\nfunction flushStencilCommon(engine: GLEngineContext): void {\n const gl = engine.gl;\n const rs = engine._state.rs;\n const dTest = rs[RS_STENCIL_TEST + RS_DESIRED]!;\n if (dTest !== rs[RS_STENCIL_TEST]) {\n rs[RS_STENCIL_TEST] = dTest;\n if (dTest === 1) {\n gl.enable(STENCIL_TEST);\n } else {\n gl.disable(STENCIL_TEST);\n }\n }\n const dMask = rs[RS_STENCIL_MASK + RS_DESIRED]!;\n if (dMask !== rs[RS_STENCIL_MASK]) {\n rs[RS_STENCIL_MASK] = dMask;\n gl.stencilMask(dMask);\n }\n const dFuncFunc = rs[RS_STENCIL_FUNC_FUNC + RS_DESIRED]!;\n const dFuncRef = rs[RS_STENCIL_FUNC_REF + RS_DESIRED]!;\n const dFuncMask = rs[RS_STENCIL_FUNC_MASK + RS_DESIRED]!;\n if (dFuncFunc !== rs[RS_STENCIL_FUNC_FUNC] || dFuncRef !== rs[RS_STENCIL_FUNC_REF] || dFuncMask !== rs[RS_STENCIL_FUNC_MASK]) {\n rs[RS_STENCIL_FUNC_FUNC] = dFuncFunc;\n rs[RS_STENCIL_FUNC_REF] = dFuncRef;\n rs[RS_STENCIL_FUNC_MASK] = dFuncMask;\n gl.stencilFunc(dFuncFunc, dFuncRef, dFuncMask);\n }\n}\n\n/** Reconcile the compact shared stencil state. @internal */\nfunction flushStencil(engine: GLEngineContext): void {\n flushStencilCommon(engine);\n const gl = engine.gl;\n const rs = engine._state.rs;\n const frontOpFail = rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!;\n if (frontOpFail === -1) {\n return;\n }\n const frontOpZFail = rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!;\n const frontOpZPass = rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!;\n const frontChanged = frontOpFail !== rs[RS_STENCIL_OP_FAIL] || frontOpZFail !== rs[RS_STENCIL_OP_ZFAIL] || frontOpZPass !== rs[RS_STENCIL_OP_ZPASS];\n if (frontChanged) {\n rs[RS_STENCIL_OP_FAIL] = frontOpFail;\n rs[RS_STENCIL_OP_ZFAIL] = frontOpZFail;\n rs[RS_STENCIL_OP_ZPASS] = frontOpZPass;\n gl.stencilOp(frontOpFail, frontOpZFail, frontOpZPass);\n }\n}\n\n/** Reconcile independently cached front/back stencil operation tuples. */\nfunction flushStencilSeparate(engine: GLEngineContext): void {\n flushStencilCommon(engine);\n const gl = engine.gl;\n const rs = engine._state.rs;\n const frontOpFail = rs[RS_STENCIL_OP_FAIL + RS_DESIRED]!;\n if (frontOpFail === -1) {\n return;\n }\n const frontOpZFail = rs[RS_STENCIL_OP_ZFAIL + RS_DESIRED]!;\n const frontOpZPass = rs[RS_STENCIL_OP_ZPASS + RS_DESIRED]!;\n const backOpFail = rs[BACK_OP_FAIL + BACK_DESIRED]!;\n const backOpZFail = rs[BACK_OP_ZFAIL + BACK_DESIRED]!;\n const backOpZPass = rs[BACK_OP_ZPASS + BACK_DESIRED]!;\n const frontChanged = frontOpFail !== rs[RS_STENCIL_OP_FAIL] || frontOpZFail !== rs[RS_STENCIL_OP_ZFAIL] || frontOpZPass !== rs[RS_STENCIL_OP_ZPASS];\n const backChanged = backOpFail !== rs[BACK_OP_FAIL] || backOpZFail !== rs[BACK_OP_ZFAIL] || backOpZPass !== rs[BACK_OP_ZPASS];\n if (!frontChanged && !backChanged) {\n return;\n }\n const facesMatch = frontOpFail === backOpFail && frontOpZFail === backOpZFail && frontOpZPass === backOpZPass;\n if (facesMatch) {\n setStencilOps(rs, RS_STENCIL_OP_FAIL, frontOpFail, frontOpZFail, frontOpZPass);\n setStencilOps(rs, BACK_OP_FAIL, backOpFail, backOpZFail, backOpZPass);\n gl.stencilOp(frontOpFail, frontOpZFail, frontOpZPass);\n return;\n }\n if (frontChanged) {\n setStencilOps(rs, RS_STENCIL_OP_FAIL, frontOpFail, frontOpZFail, frontOpZPass);\n gl.stencilOpSeparate(FRONT, frontOpFail, frontOpZFail, frontOpZPass);\n }\n if (backChanged) {\n setStencilOps(rs, BACK_OP_FAIL, backOpFail, backOpZFail, backOpZPass);\n gl.stencilOpSeparate(BACK, backOpFail, backOpZFail, backOpZPass);\n }\n}\n\n/** Reconcile the packed color-write mask (Babylon's `setColorWrite`). @internal */\nfunction flushColorMask(engine: GLEngineContext): void {\n const rs = engine._state.rs;\n const dColorMask = rs[RS_COLOR_MASK + RS_DESIRED]!;\n if (dColorMask !== rs[RS_COLOR_MASK]) {\n rs[RS_COLOR_MASK] = dColorMask;\n engine.gl.colorMask((dColorMask & 8) !== 0, (dColorMask & 4) !== 0, (dColorMask & 2) !== 0, (dColorMask & 1) !== 0);\n }\n}\n\n/**\n * Opt-in: give a `/render-target` {@link GLRenderTarget} a stencil attachment,\n * replacing the core's depth-only `DEPTH_COMPONENT16` renderbuffer with either a\n * packed **`DEPTH24_STENCIL8`** buffer (default — depth *and* stencil) or a\n * stencil-only **`STENCIL_INDEX8`** buffer.\n *\n * Stencil is intentionally NOT a {@link createRenderTarget} option: keeping this\n * helper in the depth-stencil module means the stencil/packed renderbuffer\n * code tree-shakes out of every bundle that only needs a color (and optional\n * depth) target.\n *\n * The attachment is **restore-correct**: it is rebuilt automatically — at the new\n * size on {@link resizeRenderTarget}, and into the fresh framebuffer after a\n * `webglcontextrestored` event — so the stencil survives for the life of the\n * target, and {@link disposeRenderTarget} releases it along with the target.\n *\n * No-op on a lost/disposed context or a disposed target.\n *\n * @param rt - The render target to attach the stencil buffer to.\n * @param options - `depth` (default `true`): when `true` the attachment is a\n * packed depth+stencil buffer (`DEPTH24_STENCIL8` on `DEPTH_STENCIL_ATTACHMENT`)\n * — the common case, and the correct choice when the target was created with\n * `generateDepthBuffer: true`. When `false` the attachment is stencil-only\n * (`STENCIL_INDEX8` on `STENCIL_ATTACHMENT`).\n * @throws If a renderbuffer handle could not be allocated, or the framebuffer is\n * incomplete after attaching (unless `setFramebufferValidation(engine, false)`\n * opted out of completeness checks).\n */\nexport function generateRenderTargetStencil(rt: GLRenderTarget, options?: { depth?: boolean }): void {\n const engine = rt._engine;\n if (engine._isLost || engine._disposed || rt._disposed) {\n return;\n }\n const packDepth = options?.depth ?? true;\n const attachment = packDepth ? DEPTH_STENCIL_ATTACHMENT : STENCIL_ATTACHMENT;\n const format = packDepth ? DEPTH24_STENCIL8 : STENCIL_INDEX8;\n\n const build = (e: GLEngineContext): void => {\n const gl = e.gl;\n // Capture the caller's draw target so this helper is STATE-NEUTRAL: it must\n // not silently redirect subsequent draws to `rt` (during an internal\n // rebuild `prevFb` is `rt._framebuffer`, which the core re-checks next\n // unless validation was opted out).\n // An unknown (wiped) binding is restored as the canvas.\n const prevFb = e._state.boundFramebuffer ?? null;\n const newRb = gl.createRenderbuffer();\n if (newRb === null) {\n throw new Error(\"lite-gl: gl.createRenderbuffer returned null (render target stencil)\");\n }\n let committed = false;\n try {\n gl.bindFramebuffer(FRAMEBUFFER, rt._framebuffer);\n e._state.boundFramebuffer = rt._framebuffer;\n gl.bindRenderbuffer(RENDERBUFFER, newRb);\n gl.renderbufferStorage(RENDERBUFFER, format, rt.width, rt.height);\n gl.framebufferRenderbuffer(FRAMEBUFFER, attachment, RENDERBUFFER, newRb);\n gl.bindRenderbuffer(RENDERBUFFER, null);\n validateFramebuffer(e, true);\n // Commit only after a complete attachment: release the buffer we\n // replaced (the core depth-only one, or our own from a prior rebuild).\n if (rt._depthStencil !== null) {\n gl.deleteRenderbuffer(rt._depthStencil);\n }\n rt._depthStencil = newRb;\n committed = true;\n } finally {\n if (!committed) {\n // Any non-committed exit (incomplete framebuffer OR an unexpected\n // GL throw): detach + delete the buffer we couldn't adopt so it\n // never leaks, leaving the attachment point empty for the\n // caller-level rollback to re-establish the prior buffer.\n gl.framebufferRenderbuffer(FRAMEBUFFER, attachment, RENDERBUFFER, null);\n gl.deleteRenderbuffer(newRb);\n }\n // Restore the caller's draw target + the bound-framebuffer cache.\n if (e._state.boundFramebuffer !== prevFb) {\n gl.bindFramebuffer(FRAMEBUFFER, prevFb);\n e._state.boundFramebuffer = prevFb;\n }\n }\n };\n\n // Build once now, but COMMIT the resize/restore hook only if it succeeds — a\n // failed opt-in must leave the target exactly as it was. The packed attach\n // above can clear the core `DEPTH_ATTACHMENT`, so on failure restore the prior\n // hook AND re-establish the prior depth/stencil attachment (the prior hook's,\n // or the core depth-only buffer).\n const prevHook = rt._rebuildDepthStencil;\n const prevDepthStencil = rt._depthStencil;\n try {\n build(engine);\n } catch (err) {\n rt._rebuildDepthStencil = prevHook;\n try {\n if (prevHook !== undefined) {\n prevHook(engine);\n } else if (prevDepthStencil !== null) {\n reattachCoreDepthBuffer(engine, rt, prevDepthStencil);\n }\n } catch {\n // Best-effort restore; surface the original failure below.\n }\n throw err;\n }\n rt._rebuildDepthStencil = build;\n}\n\n/**\n * Re-attach a core depth-only renderbuffer at `DEPTH_ATTACHMENT` — used to roll a\n * render target back when a packed {@link generateRenderTargetStencil} attach\n * fails completeness (attaching at `DEPTH_STENCIL_ATTACHMENT` clears the core\n * `DEPTH_ATTACHMENT`). State-neutral: restores the caller's bound framebuffer.\n * @internal\n */\nfunction reattachCoreDepthBuffer(engine: GLEngineContext, rt: GLRenderTarget, depthBuffer: WebGLRenderbuffer): void {\n const gl = engine.gl;\n const prevFb = engine._state.boundFramebuffer ?? null;\n gl.bindFramebuffer(FRAMEBUFFER, rt._framebuffer);\n engine._state.boundFramebuffer = rt._framebuffer;\n gl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, depthBuffer);\n if (engine._state.boundFramebuffer !== prevFb) {\n gl.bindFramebuffer(FRAMEBUFFER, prevFb);\n engine._state.boundFramebuffer = prevFb;\n }\n}\n"]}
|
package/dynamic-texture.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* pixels are pushed on demand from a canvas / `OffscreenCanvas` / image / video
|
|
11
11
|
* / `ImageBitmap` / `ImageData` source. The most recent source is retained
|
|
12
12
|
* internally and replayed into the fresh handle on `webglcontextrestored` by the
|
|
13
|
-
* engine's standard context-restore protocol
|
|
13
|
+
* engine's standard context-restore protocol unless the engine is host-owned
|
|
14
|
+
* (`createHostOwnedGLEngine`); that mode drops the source reference after each upload.
|
|
14
15
|
*/
|
|
15
16
|
import { type GLTexture, type GLTextureOptions, type GLTextureUpdateOptions } from "./texture.js";
|
|
16
17
|
import type { GLEngineContext } from "./context.js";
|
|
@@ -22,7 +23,8 @@ import type { GLEngineContext } from "./context.js";
|
|
|
22
23
|
* The texture is immediately sampleable (reads as transparent black until the
|
|
23
24
|
* first update). It is context-restore-safe: the most recent source pushed via
|
|
24
25
|
* {@link updateDynamicTexture} is replayed into the fresh handle on
|
|
25
|
-
* `webglcontextrestored` (and re-blanked if no update happened yet)
|
|
26
|
+
* `webglcontextrestored` (and re-blanked if no update happened yet), unless
|
|
27
|
+
* the engine is host-owned (`createHostOwnedGLEngine`).
|
|
26
28
|
*
|
|
27
29
|
* @param engine - The engine to create GL resources on.
|
|
28
30
|
* @param width - Texture width in texels (clamped to ≥ 1).
|
|
@@ -36,7 +38,8 @@ export declare function createDynamicTexture(engine: GLEngineContext, width: num
|
|
|
36
38
|
/** Push 2D pixels into a {@link createDynamicTexture} texture from a canvas /
|
|
37
39
|
* `OffscreenCanvas` / image / video / `ImageBitmap` / `ImageData` source — the
|
|
38
40
|
* WebGL counterpart of Babylon's `ThinEngine.updateDynamicTexture`. The source
|
|
39
|
-
* is retained on the texture
|
|
41
|
+
* is retained on the texture for `webglcontextrestored` unless the engine is
|
|
42
|
+
* host-owned (`createHostOwnedGLEngine`), and
|
|
40
43
|
* `tex.width` / `tex.height` follow the source's size (`texImage2D` resizes
|
|
41
44
|
* the storage). No-op when the context is lost/disposed or the texture is
|
|
42
45
|
* disposed.
|
package/dynamic-texture.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* pixels are pushed on demand from a canvas / `OffscreenCanvas` / image / video
|
|
11
11
|
* / `ImageBitmap` / `ImageData` source. The most recent source is retained
|
|
12
12
|
* internally and replayed into the fresh handle on `webglcontextrestored` by the
|
|
13
|
-
* engine's standard context-restore protocol
|
|
13
|
+
* engine's standard context-restore protocol unless the engine is host-owned
|
|
14
|
+
* (`createHostOwnedGLEngine`); that mode drops the source reference after each upload.
|
|
14
15
|
*/
|
|
15
16
|
import { bindTextureForUpload, setTexImageSourceSize, setBoundTextureParams, setUnpackState, } from "./texture.js";
|
|
16
17
|
/** Create a texture backed by an empty (blank) `width × height` RGBA8
|
|
@@ -21,7 +22,8 @@ import { bindTextureForUpload, setTexImageSourceSize, setBoundTextureParams, set
|
|
|
21
22
|
* The texture is immediately sampleable (reads as transparent black until the
|
|
22
23
|
* first update). It is context-restore-safe: the most recent source pushed via
|
|
23
24
|
* {@link updateDynamicTexture} is replayed into the fresh handle on
|
|
24
|
-
* `webglcontextrestored` (and re-blanked if no update happened yet)
|
|
25
|
+
* `webglcontextrestored` (and re-blanked if no update happened yet), unless
|
|
26
|
+
* the engine is host-owned (`createHostOwnedGLEngine`).
|
|
25
27
|
*
|
|
26
28
|
* @param engine - The engine to create GL resources on.
|
|
27
29
|
* @param width - Texture width in texels (clamped to ≥ 1).
|
|
@@ -93,7 +95,8 @@ export function createDynamicTexture(engine, width, height, options) {
|
|
|
93
95
|
/** Push 2D pixels into a {@link createDynamicTexture} texture from a canvas /
|
|
94
96
|
* `OffscreenCanvas` / image / video / `ImageBitmap` / `ImageData` source — the
|
|
95
97
|
* WebGL counterpart of Babylon's `ThinEngine.updateDynamicTexture`. The source
|
|
96
|
-
* is retained on the texture
|
|
98
|
+
* is retained on the texture for `webglcontextrestored` unless the engine is
|
|
99
|
+
* host-owned (`createHostOwnedGLEngine`), and
|
|
97
100
|
* `tex.width` / `tex.height` follow the source's size (`texImage2D` resizes
|
|
98
101
|
* the storage). No-op when the context is lost/disposed or the texture is
|
|
99
102
|
* disposed.
|
|
@@ -111,7 +114,16 @@ export function updateDynamicTexture(tex, source, options) {
|
|
|
111
114
|
tex._dynSource = source;
|
|
112
115
|
tex._invertY = options?.invertY;
|
|
113
116
|
tex._premultiplyAlpha = options?.premultiplyAlpha;
|
|
114
|
-
|
|
117
|
+
try {
|
|
118
|
+
tex._upload(engine);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
// Also on a throwing upload (e.g. a cross-origin source): a host-owned
|
|
122
|
+
// engine never replays, so it must not keep the source alive.
|
|
123
|
+
if (engine._noRestore) {
|
|
124
|
+
tex._dynSource = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
115
127
|
}
|
|
116
128
|
/** Forget the source a dynamic texture retained for context-restore replay.
|
|
117
129
|
* The current GPU pixels are kept (no re-upload), but the source reference is
|
package/dynamic-texture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-texture.js","sourceRoot":"","sources":["../src/dynamic-texture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACH,oBAAoB,EAC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,CAAC;QACT,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;KACnB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,CAAC;IACf,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;kCAYkC;AAClC,MAAM,UAAU,oBAAoB,CAAC,GAAc,EAAE,MAAsB,EAAE,OAAgC;IACzG,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC3B,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QACtD,OAAO;IACX,CAAC;IACD,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC;IACxB,GAAG,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,CAAC;IAChC,GAAG,CAAC,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,CAAC;IAClD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;sEAQsE;AACtE,MAAM,UAAU,yBAAyB,CAAC,GAAc;IACpD,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Dynamic (canvas-/bitmap-backed) textures.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that never push 2D pixel sources into a\n * texture tree-shake this code out.\n *\n * The WebGL counterpart of Babylon's `ThinEngine.createDynamicTexture` +\n * `updateDynamicTexture`. A dynamic texture is a blank RGBA8 allocation whose\n * pixels are pushed on demand from a canvas / `OffscreenCanvas` / image / video\n * / `ImageBitmap` / `ImageData` source. The most recent source is retained\n * internally and replayed into the fresh handle on `webglcontextrestored` by the\n * engine's standard context-restore protocol.\n */\nimport {\n bindTextureForUpload,\n setTexImageSourceSize,\n setBoundTextureParams,\n setUnpackState,\n type GLTexture,\n type GLTextureOptions,\n type GLTextureUpdateOptions,\n} from \"./texture.js\";\nimport type { GLEngineContext } from \"./context.js\";\n\n/** Create a texture backed by an empty (blank) `width × height` RGBA8\n * allocation, whose pixels are pushed on demand with\n * {@link updateDynamicTexture} — the WebGL counterpart of Babylon's\n * `ThinEngine.createDynamicTexture` + `ThinTexture` wrapper.\n *\n * The texture is immediately sampleable (reads as transparent black until the\n * first update). It is context-restore-safe: the most recent source pushed via\n * {@link updateDynamicTexture} is replayed into the fresh handle on\n * `webglcontextrestored` (and re-blanked if no update happened yet).\n *\n * @param engine - The engine to create GL resources on.\n * @param width - Texture width in texels (clamped to ≥ 1).\n * @param height - Texture height in texels (clamped to ≥ 1).\n * @param options - The shared {@link GLTextureOptions}. `invertY` /\n * `premultiplyAlpha` become the defaults of every {@link updateDynamicTexture}\n * call that omits them. For mipmaps, call `generateTextureMipMaps` once; every\n * later update rebuilds the chain.\n * @returns The new {@link GLTexture}. */\nexport function createDynamicTexture(engine: GLEngineContext, width: number, height: number, options?: GLTextureOptions): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const w = Math.max(1, width | 0);\n const h = Math.max(1, height | 0);\n const opts = options ?? {};\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiplyAlpha = opts.premultiplyAlpha ?? false;\n\n // Single `_upload` closure used for both the initial allocation AND every\n // `webglcontextrestored` replay AND every `updateDynamicTexture`. The pixel\n // upload runs every time; the four `texParameteri` calls run ONLY when the\n // handle changed (initial create + restore install a fresh, GL-default\n // handle) — a per-frame pixel update keeps the same handle, whose filter/wrap\n // GL retains, so re-applying them would be a pure redundant cost.\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n bindTextureForUpload(target, tex.handle);\n const src = tex._dynSource;\n if (src !== null && src !== undefined) {\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiplyAlpha);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, src);\n // `texImage2D(source)` resizes the GL storage to the source size.\n setTexImageSourceSize(tex, src);\n } else {\n setUnpackState(target, false, false);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA8, w, h, 0, g.RGBA, g.UNSIGNED_BYTE, null);\n tex.width = w;\n tex.height = h;\n }\n if (tex._dynParamsHandle !== tex.handle) {\n setBoundTextureParams(g, minFilter, magFilter, wrapS, wrapT);\n tex._dynParamsHandle = tex.handle;\n }\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: w,\n height: h,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _wasReady: true,\n _dynSource: null,\n };\n upload(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Push 2D pixels into a {@link createDynamicTexture} texture from a canvas /\n * `OffscreenCanvas` / image / video / `ImageBitmap` / `ImageData` source — the\n * WebGL counterpart of Babylon's `ThinEngine.updateDynamicTexture`. The source\n * is retained on the texture so it is replayed on `webglcontextrestored`, and\n * `tex.width` / `tex.height` follow the source's size (`texImage2D` resizes\n * the storage). No-op when the context is lost/disposed or the texture is\n * disposed.\n *\n * @param tex - A texture created by {@link createDynamicTexture}.\n * @param source - The 2D pixel source to upload.\n * @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to\n * the texture's creation value (like Babylon's `texture.invertY` fallback),\n * itself `false` by default. */\nexport function updateDynamicTexture(tex: GLTexture, source: TexImageSource, options?: GLTextureUpdateOptions): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n tex._dynSource = source;\n tex._invertY = options?.invertY;\n tex._premultiplyAlpha = options?.premultiplyAlpha;\n tex._upload(engine);\n}\n\n/** Forget the source a dynamic texture retained for context-restore replay.\n * The current GPU pixels are kept (no re-upload), but the source reference is\n * dropped so it can be garbage-collected — and a subsequent\n * `webglcontextrestored` will re-blank the texture instead of replaying. Use\n * after the final {@link updateDynamicTexture} once the source (e.g. a large\n * atlas canvas) is no longer needed. No-op on a non-dynamic texture. No GL\n * call is made.\n *\n * @param tex - A texture created by {@link createDynamicTexture}. */\nexport function clearDynamicTextureSource(tex: GLTexture): void {\n tex._dynSource = null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-texture.js","sourceRoot":"","sources":["../src/dynamic-texture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GAIjB,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;0CAkB0C;AAC1C,MAAM,UAAU,oBAAoB,CAAC,MAAuB,EAAE,KAAa,EAAE,MAAc,EAAE,OAA0B;IACnH,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC;IAClC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,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AAC,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,CAAC;IAClD,IAAI,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;YAAS,CAAC;QACP,uEAAuE;QACvE,8DAA8D;QAC9D,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACpB,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1B,CAAC;IACL,CAAC;AACL,CAAC;AAED;;;;;;;;sEAQsE;AACtE,MAAM,UAAU,yBAAyB,CAAC,GAAc;IACpD,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Dynamic (canvas-/bitmap-backed) textures.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that never push 2D pixel sources into a\n * texture tree-shake this code out.\n *\n * The WebGL counterpart of Babylon's `ThinEngine.createDynamicTexture` +\n * `updateDynamicTexture`. A dynamic texture is a blank RGBA8 allocation whose\n * pixels are pushed on demand from a canvas / `OffscreenCanvas` / image / video\n * / `ImageBitmap` / `ImageData` source. The most recent source is retained\n * internally and replayed into the fresh handle on `webglcontextrestored` by the\n * engine's standard context-restore protocol unless the engine is host-owned\n * (`createHostOwnedGLEngine`); that mode drops the source reference after each upload.\n */\nimport {\n bindTextureForUpload,\n setTexImageSourceSize,\n setBoundTextureParams,\n setUnpackState,\n type GLTexture,\n type GLTextureOptions,\n type GLTextureUpdateOptions,\n} from \"./texture.js\";\nimport type { GLEngineContext } from \"./context.js\";\n\n/** Create a texture backed by an empty (blank) `width × height` RGBA8\n * allocation, whose pixels are pushed on demand with\n * {@link updateDynamicTexture} — the WebGL counterpart of Babylon's\n * `ThinEngine.createDynamicTexture` + `ThinTexture` wrapper.\n *\n * The texture is immediately sampleable (reads as transparent black until the\n * first update). It is context-restore-safe: the most recent source pushed via\n * {@link updateDynamicTexture} is replayed into the fresh handle on\n * `webglcontextrestored` (and re-blanked if no update happened yet), unless\n * the engine is host-owned (`createHostOwnedGLEngine`).\n *\n * @param engine - The engine to create GL resources on.\n * @param width - Texture width in texels (clamped to ≥ 1).\n * @param height - Texture height in texels (clamped to ≥ 1).\n * @param options - The shared {@link GLTextureOptions}. `invertY` /\n * `premultiplyAlpha` become the defaults of every {@link updateDynamicTexture}\n * call that omits them. For mipmaps, call `generateTextureMipMaps` once; every\n * later update rebuilds the chain.\n * @returns The new {@link GLTexture}. */\nexport function createDynamicTexture(engine: GLEngineContext, width: number, height: number, options?: GLTextureOptions): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const w = Math.max(1, width | 0);\n const h = Math.max(1, height | 0);\n const opts = options ?? {};\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiplyAlpha = opts.premultiplyAlpha ?? false;\n\n // Single `_upload` closure used for both the initial allocation AND every\n // `webglcontextrestored` replay AND every `updateDynamicTexture`. The pixel\n // upload runs every time; the four `texParameteri` calls run ONLY when the\n // handle changed (initial create + restore install a fresh, GL-default\n // handle) — a per-frame pixel update keeps the same handle, whose filter/wrap\n // GL retains, so re-applying them would be a pure redundant cost.\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n bindTextureForUpload(target, tex.handle);\n const src = tex._dynSource;\n if (src !== null && src !== undefined) {\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiplyAlpha);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, src);\n // `texImage2D(source)` resizes the GL storage to the source size.\n setTexImageSourceSize(tex, src);\n } else {\n setUnpackState(target, false, false);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA8, w, h, 0, g.RGBA, g.UNSIGNED_BYTE, null);\n tex.width = w;\n tex.height = h;\n }\n if (tex._dynParamsHandle !== tex.handle) {\n setBoundTextureParams(g, minFilter, magFilter, wrapS, wrapT);\n tex._dynParamsHandle = tex.handle;\n }\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: w,\n height: h,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _wasReady: true,\n _dynSource: null,\n };\n upload(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Push 2D pixels into a {@link createDynamicTexture} texture from a canvas /\n * `OffscreenCanvas` / image / video / `ImageBitmap` / `ImageData` source — the\n * WebGL counterpart of Babylon's `ThinEngine.updateDynamicTexture`. The source\n * is retained on the texture for `webglcontextrestored` unless the engine is\n * host-owned (`createHostOwnedGLEngine`), and\n * `tex.width` / `tex.height` follow the source's size (`texImage2D` resizes\n * the storage). No-op when the context is lost/disposed or the texture is\n * disposed.\n *\n * @param tex - A texture created by {@link createDynamicTexture}.\n * @param source - The 2D pixel source to upload.\n * @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to\n * the texture's creation value (like Babylon's `texture.invertY` fallback),\n * itself `false` by default. */\nexport function updateDynamicTexture(tex: GLTexture, source: TexImageSource, options?: GLTextureUpdateOptions): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n tex._dynSource = source;\n tex._invertY = options?.invertY;\n tex._premultiplyAlpha = options?.premultiplyAlpha;\n try {\n tex._upload(engine);\n } finally {\n // Also on a throwing upload (e.g. a cross-origin source): a host-owned\n // engine never replays, so it must not keep the source alive.\n if (engine._noRestore) {\n tex._dynSource = null;\n }\n }\n}\n\n/** Forget the source a dynamic texture retained for context-restore replay.\n * The current GPU pixels are kept (no re-upload), but the source reference is\n * dropped so it can be garbage-collected — and a subsequent\n * `webglcontextrestored` will re-blank the texture instead of replaying. Use\n * after the final {@link updateDynamicTexture} once the source (e.g. a large\n * atlas canvas) is no longer needed. No-op on a non-dynamic texture. No GL\n * call is made.\n *\n * @param tex - A texture created by {@link createDynamicTexture}. */\nexport function clearDynamicTextureSource(tex: GLTexture): void {\n tex._dynSource = null;\n}\n"]}
|
package/effect.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export declare function setEffectVector2(effect: GLEffect, name: string, v: {
|
|
|
95
95
|
/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the
|
|
96
96
|
* lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to
|
|
97
97
|
* `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so
|
|
98
|
-
* this matches `setEffectColor4`; the distinct name eases
|
|
99
|
-
*
|
|
98
|
+
* this matches `setEffectColor4`; the distinct name eases `ThinEngine`
|
|
99
|
+
* ports). */
|
|
100
100
|
export declare function setEffectDirectColor4(effect: GLEffect, name: string, c: {
|
|
101
101
|
r: number;
|
|
102
102
|
g: number;
|
|
@@ -117,7 +117,16 @@ export declare function setEffectMatrix3x3(effect: GLEffect, name: string, matri
|
|
|
117
117
|
export declare function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void;
|
|
118
118
|
/** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */
|
|
119
119
|
export declare function setEffectFloatArray2(effect: GLEffect, name: string, array: Float32Array | number[]): void;
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Upload packed XYZ triples with `gl.uniform3fv` (`Effect.setFloatArray3` /
|
|
122
|
+
* `setArray3`). Not value-cached; in-place edits are uploaded on every call.
|
|
123
|
+
* Bind the effect first. No-op on a lost/disposed engine, a disposed/unready
|
|
124
|
+
* effect, or a missing uniform. After restore, finalize/bind the effect again.
|
|
125
|
+
*
|
|
126
|
+
* @param effect - The effect receiving the uniform.
|
|
127
|
+
* @param name - The uniform name.
|
|
128
|
+
* @param array - Packed triples; its length must be a multiple of three.
|
|
129
|
+
*/
|
|
121
130
|
export declare function setEffectFloatArray3(effect: GLEffect, name: string, array: Float32Array | number[]): void;
|
|
122
131
|
/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).
|
|
123
132
|
* Not value-cached. */
|
package/effect.js
CHANGED
|
@@ -43,23 +43,24 @@ export function createEffect(engine, options) {
|
|
|
43
43
|
_refCount: 1,
|
|
44
44
|
_cacheKey: cacheKey,
|
|
45
45
|
_onCompiled: [],
|
|
46
|
-
_restore: () => { },
|
|
47
|
-
};
|
|
48
|
-
effect._restore = (target) => {
|
|
49
|
-
const restored = compileEffectProgram(target.gl, options, attribs);
|
|
50
|
-
if (typeof restored === "string") {
|
|
51
|
-
recordCompilationError(effect, `context-restore: ${restored}`);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
effect.program = restored.program;
|
|
55
|
-
effect._vs = restored.vs;
|
|
56
|
-
effect._fs = restored.fs;
|
|
57
|
-
effect.isReady = false;
|
|
58
|
-
effect._samplersAssigned = false;
|
|
59
|
-
effect.uniformLocations = {};
|
|
60
|
-
effect.attributeLocations = {};
|
|
61
|
-
effect._compileError = null;
|
|
62
46
|
};
|
|
47
|
+
if (!engine._noRestore) {
|
|
48
|
+
effect._restore = (target) => {
|
|
49
|
+
const restored = compileEffectProgram(target.gl, options, attribs);
|
|
50
|
+
if (typeof restored === "string") {
|
|
51
|
+
recordCompilationError(effect, `context-restore: ${restored}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
effect.program = restored.program;
|
|
55
|
+
effect._vs = restored.vs;
|
|
56
|
+
effect._fs = restored.fs;
|
|
57
|
+
effect.isReady = false;
|
|
58
|
+
effect._samplersAssigned = false;
|
|
59
|
+
effect.uniformLocations = {};
|
|
60
|
+
effect.attributeLocations = {};
|
|
61
|
+
effect._compileError = null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
63
64
|
engine._effects.push(effect);
|
|
64
65
|
engine._effectCache.set(cacheKey, effect);
|
|
65
66
|
return effect;
|
|
@@ -339,8 +340,8 @@ export function setEffectVector2(effect, name, v) {
|
|
|
339
340
|
/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the
|
|
340
341
|
* lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to
|
|
341
342
|
* `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so
|
|
342
|
-
* this matches `setEffectColor4`; the distinct name eases
|
|
343
|
-
*
|
|
343
|
+
* this matches `setEffectColor4`; the distinct name eases `ThinEngine`
|
|
344
|
+
* ports). */
|
|
344
345
|
export function setEffectDirectColor4(effect, name, c) {
|
|
345
346
|
setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);
|
|
346
347
|
}
|
|
@@ -365,7 +366,7 @@ export function setEffectInt(effect, name, x) {
|
|
|
365
366
|
*
|
|
366
367
|
* Matrices and arrays usually change every frame; element-wise caching would
|
|
367
368
|
* cost more than the upload it saves, so these always issue the GL call (the
|
|
368
|
-
* location lookup + ready guards still apply). They cover
|
|
369
|
+
* location lookup + ready guards still apply). They cover Babylon's `Effect`
|
|
369
370
|
* surface (`setMatrix3x3`, `setFloatArray`, `setFloatArray4`) plus a general
|
|
370
371
|
* 4×4 matrix setter for any future mesh consumer. */
|
|
371
372
|
/** `gl.uniformMatrix4fv` from a column-major 4×4 matrix — the lite-gl
|
|
@@ -418,16 +419,26 @@ export function setEffectFloatArray2(effect, name, array) {
|
|
|
418
419
|
engine.gl.uniform2fv(location, array);
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
|
-
/**
|
|
422
|
+
/**
|
|
423
|
+
* Upload packed XYZ triples with `gl.uniform3fv` (`Effect.setFloatArray3` /
|
|
424
|
+
* `setArray3`). Not value-cached; in-place edits are uploaded on every call.
|
|
425
|
+
* Bind the effect first. No-op on a lost/disposed engine, a disposed/unready
|
|
426
|
+
* effect, or a missing uniform. After restore, finalize/bind the effect again.
|
|
427
|
+
*
|
|
428
|
+
* @param effect - The effect receiving the uniform.
|
|
429
|
+
* @param name - The uniform name.
|
|
430
|
+
* @param array - Packed triples; its length must be a multiple of three.
|
|
431
|
+
*/
|
|
422
432
|
export function setEffectFloatArray3(effect, name, array) {
|
|
423
433
|
const engine = effect._engine;
|
|
424
|
-
if (engine._isLost || !effect.isReady) {
|
|
434
|
+
if (engine._isLost || engine._disposed || !effect.isReady || effect._disposed) {
|
|
425
435
|
return;
|
|
426
436
|
}
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
429
|
-
|
|
437
|
+
const loc = effect.uniformLocations[name];
|
|
438
|
+
if (loc === null || loc === undefined) {
|
|
439
|
+
return;
|
|
430
440
|
}
|
|
441
|
+
engine.gl.uniform3fv(loc, array);
|
|
431
442
|
}
|
|
432
443
|
/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).
|
|
433
444
|
* Not value-cached. */
|