@babylonjs/lite-gl 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -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/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|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AC;IACjC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACrE,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport type { GLEffectOptions } from \"./family.js\";\nimport { compileShader, getLinkError, isLinkComplete, linkProgram } from \"./shader.js\";\nimport { bindTextureRaw, type GLTexture } from \"./texture.js\";\n\n/** A compiled + linked shader program with cached uniform, sampler and\n * attribute locations. Created by `createEffect`; most fields are managed\n * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`\n * setters rather than mutating it directly. */\nexport interface GLEffect {\n /** The `name` from the originating `GLEffectOptions`. */\n readonly name: string;\n /** The options this effect was created from (retained for context-restore). */\n readonly options: GLEffectOptions;\n /** The live `WebGLProgram`. Swapped for a fresh handle after context-restore. */\n program: WebGLProgram;\n /** @internal */\n _vs: WebGLShader;\n /** @internal */\n _fs: WebGLShader;\n /** Resolved during readiness finalization. Missing names map to `null` —\n * setters with a `null` location are silent no-ops (matches Babylon). */\n uniformLocations: { [name: string]: WebGLUniformLocation | null };\n /** Fixed unit assignment for declared samplers, index into\n * `_state.boundTextures`. */\n samplerUnits: { [name: string]: number };\n /**\n * True once `gl.uniform1i(samplerLoc, unit)` has been issued for every\n * declared sampler. Cleared on context-lost so finalization re-runs.\n * @internal\n */\n _samplersAssigned: boolean;\n /** Resolved attribute locations, keyed by attribute name. */\n attributeLocations: { [name: string]: number };\n /**\n * Last-UPLOADED scalar floats. A setter that skips the upload must NOT\n * update this — otherwise a later real set with the same value would\n * incorrectly elide and the GPU would keep stale data.\n * @internal\n */\n readonly _lastF1: { [name: string]: number };\n /**\n * Last-UPLOADED vector floats (vec2/vec3/vec4). Plain `number[]` (NOT\n * `Float32Array`) so values like `0.1` compare equal across frames.\n * @internal\n */\n readonly _lastVec: { [name: string]: number[] };\n /** @internal */\n readonly _lastI1: { [name: string]: number };\n /** True once the program has linked and finalization has run; the\n * `setEffect*` setters are no-ops until then. Poll `isEffectReady` to advance it. */\n isReady: boolean;\n /** The engine that created (and owns) this effect. Effect operations derive\n * their engine from it, so they take the effect alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _compileError: string | null;\n /** @internal */\n _disposed: boolean;\n /**\n * Number of live `createEffect` callers sharing this effect (and its one\n * `WebGLProgram`). `createEffect` returns the cached effect and bumps this\n * when an identical descriptor is requested; `disposeEffect` decrements it\n * and only tears the program down when it reaches 0.\n * @internal\n */\n _refCount: number;\n /**\n * The `_effectCache` key this effect was stored under (the source\n * descriptor). Used by `disposeEffect` to evict the cache entry at refcount\n * 0.\n * @internal\n */\n _cacheKey: string;\n /**\n * Callbacks fired exactly once on the first transition to ready.\n * @internal\n */\n readonly _onCompiled: ((effect: GLEffect) => void)[];\n /**\n * Replay closure for context-restore. Re-compiles + relinks into a fresh\n * `program` field. Finalization happens lazily on the next `isEffectReady`\n * poll.\n * @internal\n */\n _restore: (engine: GLEngineContext) => void;\n}\n\n/** Submit compilation + linking without querying their results. `isReady`\n * starts false; poll `isEffectReady` or opt into `waitForEffect` to finalize.\n * Allocation failures throw synchronously. Shader syntax/link errors are\n * recorded during polling and exposed by `getEffectCompilationError`. */\nexport function createEffect(engine: GLEngineContext, options: GLEffectOptions): GLEffect {\n const attribs = options.attributeNames ?? [\"position\"];\n const gl = engine.gl;\n\n // Per-engine cache keyed by the source descriptor. Identical descriptors\n // share ONE GLEffect (and thus one WebGLProgram), so `useEffect`'s\n // current-program cache can elide redundant `gl.useProgram` across the\n // consumers. The key covers every input that affects the program or its\n // readiness finalization, joined by a NUL separator (cannot appear in GLSL).\n const cacheKey = [options.vertexSource, options.fragmentSource, options.defines ?? \"\", attribs.join(\",\"), options.uniformNames.join(\",\"), options.samplerNames.join(\",\")].join(\n \"\\u0000\"\n );\n const cached = engine._effectCache.get(cacheKey);\n if (cached !== undefined && !cached._disposed) {\n cached._refCount++;\n return cached;\n }\n\n const compiled = compileEffectProgram(gl, options, attribs);\n if (typeof compiled === \"string\") {\n throw new Error(`lite-gl: ${options.name} ${compiled}`);\n }\n const { vs, fs, program } = compiled;\n\n const effect: GLEffect = {\n name: options.name,\n options,\n program,\n _vs: vs,\n _fs: fs,\n uniformLocations: {},\n samplerUnits: {},\n _samplersAssigned: false,\n attributeLocations: {},\n _lastF1: {},\n _lastVec: {},\n _lastI1: {},\n isReady: false,\n _engine: engine,\n _compileError: null,\n _disposed: false,\n _refCount: 1,\n _cacheKey: cacheKey,\n _onCompiled: [],\n _restore: () => {},\n };\n\n effect._restore = (target: GLEngineContext): void => {\n const restored = compileEffectProgram(target.gl, options, attribs);\n if (typeof restored === \"string\") {\n recordCompilationError(effect, `context-restore: ${restored}`);\n return;\n }\n effect.program = restored.program;\n effect._vs = restored.vs;\n effect._fs = restored.fs;\n effect.isReady = false;\n effect._samplersAssigned = false;\n effect.uniformLocations = {};\n effect.attributeLocations = {};\n effect._compileError = null;\n };\n\n engine._effects.push(effect);\n engine._effectCache.set(cacheKey, effect);\n return effect;\n}\n\n/** Shader/program handles allocated as one unit on creation and restoration. */\ninterface EffectProgram {\n vs: WebGLShader;\n fs: WebGLShader;\n program: WebGLProgram;\n}\n\n/** Share allocation and partial-failure cleanup between initial creation and\n * context restoration. Returns a diagnostic on allocation failure; compile\n * and link results are deliberately left to readiness polling. */\nfunction compileEffectProgram(gl: WebGL2RenderingContext, options: GLEffectOptions, attribs: readonly string[]): EffectProgram | string {\n const vs = compileShader(gl, applyDefines(options.vertexSource, options.defines), gl.VERTEX_SHADER);\n if (vs === null) {\n return \"vertex shader allocation failed\";\n }\n const fs = compileShader(gl, applyDefines(options.fragmentSource, options.defines), gl.FRAGMENT_SHADER);\n if (fs === null) {\n gl.deleteShader(vs);\n return \"fragment shader allocation failed\";\n }\n const program = linkProgram(gl, vs, fs, attribs);\n if (program === null) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n return \"program allocation failed\";\n }\n return { vs, fs, program };\n}\n\n/** Poll the link state and, on first success, run finalization (uniform-\n * location resolution + one-shot sampler-unit `uniform1i` assignment +\n * `_onCompiled` callbacks). Returns `true` once the effect is usable. */\nexport function isEffectReady(effect: GLEffect): boolean {\n const engine = effect._engine;\n if (\n !effect.isReady &&\n !effect._disposed &&\n !engine._isLost &&\n !engine._disposed &&\n effect._compileError === null &&\n isLinkComplete(engine.gl, effect.program, engine.caps.parallelShaderCompile)\n ) {\n const linkErr = getLinkError(engine.gl, effect.program, effect._vs, effect._fs);\n if (linkErr !== null) {\n recordCompilationError(effect, linkErr);\n } else {\n finalizeEffect(engine, effect);\n }\n }\n // Read back rather than returning `true` after finalization: a ready\n // callback may have disposed the effect or engine (or lost the context).\n return effect.isReady;\n}\n\n/** Poll readiness once and return the recorded compile/link/restore diagnostic.\n * Returns null while pending or when no failure has been recorded; this is\n * not a readiness guarantee. Does not schedule polling. A successful restore\n * allocation clears the previous diagnostic before the new link is checked. */\nexport function getEffectCompilationError(effect: GLEffect): string | null {\n isEffectReady(effect);\n return effect._compileError;\n}\n\nfunction recordCompilationError(effect: GLEffect, error: string): void {\n effect._compileError = error;\n effect.isReady = false;\n console.error(`lite-gl: ${effect.name} ${error}`);\n}\n\n/** Resolves uniform/attribute locations, binds the program (cached), and\n * issues the one-time `gl.uniform1i(samplerLoc, unit)` per declared sampler. */\nfunction finalizeEffect(engine: GLEngineContext, effect: GLEffect): void {\n const gl = engine.gl;\n const program = effect.program;\n for (const name of effect.options.uniformNames) {\n effect.uniformLocations[name] = gl.getUniformLocation(program, name);\n }\n const attribs = effect.options.attributeNames ?? [\"position\"];\n for (const name of attribs) {\n effect.attributeLocations[name] = gl.getAttribLocation(program, name);\n }\n // Switch to this program via the cached helper so _state.currentProgram\n // stays consistent — no raw gl.useProgram outside useEffect.\n useEffect(effect);\n let unit = 0;\n for (const name of effect.options.samplerNames) {\n const loc = gl.getUniformLocation(program, name);\n if (loc !== null) {\n gl.uniform1i(loc, unit);\n }\n effect.samplerUnits[name] = unit;\n unit++;\n }\n effect._samplersAssigned = true;\n effect.isReady = true;\n // Fire and clear the one-shot ready callbacks.\n const cbs = effect._onCompiled.slice();\n effect._onCompiled.length = 0;\n for (const cb of cbs) {\n try {\n cb(effect);\n } catch (err) {\n console.error(`lite-gl: ${effect.name} onCompiled callback threw`, err);\n }\n }\n}\n\n/** Fires `cb` synchronously if the effect is already ready; otherwise queues\n * it for the next finalization. Does not start polling: call `isEffectReady`\n * from the render loop or opt into `waitForEffect`. */\nexport function executeWhenCompiled(effect: GLEffect, cb: (e: GLEffect) => void): void {\n if (isEffectReady(effect)) {\n cb(effect);\n return;\n }\n effect._onCompiled.push(cb);\n}\n\n/** Decrement the share count and, on the last release, delete the effect's\n * program + shaders, unregister it from the context + cache, and clear the\n * cached current-program if it pointed at this effect. A shared effect (still\n * referenced by another `createEffect` caller) is kept alive. Call exactly ONCE\n * per `createEffect` (each call decrements the ref count); safe (no-op) once the\n * effect is fully torn down. */\nexport function disposeEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (effect._disposed) {\n return;\n }\n if (--effect._refCount > 0) {\n return;\n }\n effect._disposed = true;\n effect.isReady = false;\n const i = engine._effects.indexOf(effect);\n if (i !== -1) {\n engine._effects.splice(i, 1);\n }\n engine._effectCache.delete(effect._cacheKey);\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteProgram(effect.program);\n engine.gl.deleteShader(effect._vs);\n engine.gl.deleteShader(effect._fs);\n }\n if (engine._state.currentProgram === effect.program) {\n engine._state.currentProgram = null;\n }\n effect._onCompiled.length = 0;\n}\n\n/** Cached `gl.useProgram`. Low-level: it does NOT check readiness, so poll\n * {@link isEffectReady} first (binding a still-linking program can stall, and\n * a failed one fails the next draw). `applyEffectWrapper` does that poll for\n * wrappers. No-op when the effect is already current, disposed, or the\n * context is lost/disposed. */\nexport function useEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || effect._disposed) {\n return;\n }\n if (engine._state.currentProgram === effect.program) {\n return;\n }\n engine.gl.useProgram(effect.program);\n engine._state.currentProgram = effect.program;\n}\n\n/* ──────────────────────────── cached setters ────────────────────────────\n *\n * Each setter has the shape:\n * 1. bail when context lost / effect not ready (no cache write)\n * 2. lookup uniform location; bail on null (no cache write)\n * 3. compare against last-UPLOADED value; bail on equality\n * 4. write to cache, issue gl.uniform*\n *\n * Step 3's comparison is intentionally bit-equal (===) — NaN inputs re-upload\n * every frame because `NaN !== NaN`, which is the correct safety net for\n * caller bugs.\n */\n\n/** Cached `gl.uniform1f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastF1[name] === x) {\n return;\n }\n effect._lastF1[name] = x;\n engine.gl.uniform1f(loc, x);\n}\n\n/** Cached `gl.uniform2f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat2(effect: GLEffect, name: string, x: number, y: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y) {\n return;\n }\n if (v === undefined) {\n v = [x, y];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n }\n engine.gl.uniform2f(loc, x, y);\n}\n\n/** Cached `gl.uniform3f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat3(effect: GLEffect, name: string, x: number, y: number, z: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n engine.gl.uniform3f(loc, x, y, z);\n}\n\n/** Cached `gl.uniform4f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat4(effect: GLEffect, name: string, x: number, y: number, z: number, w: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z && v[3] === w) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z, w];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n v[3] = w;\n }\n engine.gl.uniform4f(loc, x, y, z, w);\n}\n\n/** Cached `gl.uniform3f` from an r/g/b color object. Delegates to `setEffectFloat3`. */\nexport function setEffectColor3(effect: GLEffect, name: string, c: { r: number; g: number; b: number }): void {\n setEffectFloat3(effect, name, c.r, c.g, c.b);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color object. Delegates to `setEffectFloat4`. */\nexport function setEffectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform2f` from an `{x,y}` vector object — the lite-gl equivalent\n * of Babylon's `Effect.setVector2`. Delegates to `setEffectFloat2`. */\nexport function setEffectVector2(effect: GLEffect, name: string, v: { x: number; y: number }): void {\n setEffectFloat2(effect, name, v.x, v.y);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the\n * lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to\n * `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so\n * this matches `setEffectColor4`; the distinct name eases the ShapeBuilder\n * port). */\nexport function setEffectDirectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform1i`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectInt(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastI1[name] === x) {\n return;\n }\n effect._lastI1[name] = x;\n engine.gl.uniform1i(loc, x);\n}\n\n/* ── Matrix / array setters (uploaded every call — not value-cached) ──────────\n *\n * Matrices and arrays usually change every frame; element-wise caching would\n * cost more than the upload it saves, so these always issue the GL call (the\n * location lookup + ready guards still apply). They cover the ShapeBuilder\n * surface (`setMatrix3x3`, `setFloatArray`, `setFloatArray4`) plus a general\n * 4×4 matrix setter for any future mesh consumer. */\n\n/** `gl.uniformMatrix4fv` from a column-major 4×4 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix`. Not value-cached. */\nexport function setEffectMatrix(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix4fv(loc, false, matrix);\n}\n\n/** `gl.uniformMatrix3fv` from a column-major 3×3 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix3x3`. Not value-cached. */\nexport function setEffectMatrix3x3(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix3fv(loc, false, matrix);\n}\n\n/** `gl.uniform1fv` — a flat float array (`Effect.setFloatArray` / `setArray`).\n * Not value-cached. */\nexport function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1fv(loc, array);\n}\n\n/** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */\nexport function setEffectFloatArray2(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const location = effect.uniformLocations[name];\n if (location !== null && location !== undefined) {\n engine.gl.uniform2fv(location, array);\n }\n}\n\n/** `gl.uniform3fv` — an array of `vec3`s. Not value-cached. */\nexport function setEffectFloatArray3(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const location = effect.uniformLocations[name];\n if (location !== null && location !== undefined) {\n engine.gl.uniform3fv(location, array);\n }\n}\n\n/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).\n * Not value-cached. */\nexport function setEffectFloatArray4(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform4fv(loc, array);\n}\n\n/** `gl.uniform1iv` — a flat int array (`Effect.setIntArray`). Not value-cached. */\nexport function setEffectIntArray(effect: GLEffect, name: string, array: Int32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1iv(loc, array);\n}\n\n/** Bind a texture to the sampler's pre-assigned unit, or pass `null` to unbind\n * that unit (§4.4). NO `gl.uniform1i` is issued — that was done exactly once per program lifetime during\n * finalization. This is the key win over Babylon's `Effect.setTexture` which\n * re-issues the sampler binding on every call. */\nexport function setEffectTexture(effect: GLEffect, samplerName: string, tex: GLTexture | null): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || !effect.isReady) {\n return;\n }\n const unit = effect.samplerUnits[samplerName];\n if (unit === undefined || tex?._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex === null ? null : tex.handle);\n}\n\n/** Resolve (and cache) a vertex-attribute location by name — the lite-gl\n * equivalent of Babylon's `Effect.getAttributeLocationByName`. Locations for\n * declared `attributeNames` are resolved during finalization; this also serves\n * the mesh / instancing path, where attribute names are not declared up-front.\n * Returns `-1` when the attribute is absent (matching `gl.getAttribLocation`).\n * @internal */\nexport function getEffectAttributeLocation(effect: GLEffect, name: string): number {\n const engine = effect._engine;\n const cached = effect.attributeLocations[name];\n if (cached !== undefined) {\n return cached;\n }\n const loc = engine.gl.getAttribLocation(effect.program, name);\n effect.attributeLocations[name] = loc;\n return loc;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Inject `options.defines` between the `#version`/precision header and the\n * user shader body. Supports a `// __DEFINES__` marker (preferred — keeps the\n * runtime regex-free, per spec §6.2) OR auto-detects the end of the leading\n * preprocessor / precision lines. */\nfunction applyDefines(source: string, defines: string | undefined): string {\n if (defines === undefined || defines.length === 0) {\n return source;\n }\n const marker = \"// __DEFINES__\";\n const idx = source.indexOf(marker);\n if (idx !== -1) {\n return source.slice(0, idx) + defines + source.slice(idx + marker.length);\n }\n // Fallback: insert after the last `precision` line (or after `#version`).\n const lines = source.split(\"\\n\");\n let insertAt = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === undefined) {\n continue;\n }\n const trimmed = line.trim();\n if (trimmed.startsWith(\"#version\") || trimmed.startsWith(\"precision \")) {\n insertAt = i + 1;\n }\n }\n lines.splice(insertAt, 0, defines);\n return lines.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,cAAc,EAAkB,MAAM,cAAc,CAAC;AAqF9D;;;0EAG0E;AAC1E,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,OAAwB;IAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IAErB,yEAAyE;IACzE,mEAAmE;IACnE,uEAAuE;IACvE,wEAAwE;IACxE,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAC1K,QAAQ,CACX,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ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AS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QACb,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;IACD,0EAA0E;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACrE,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\nimport type { GLEffectOptions } from \"./family.js\";\nimport { compileShader, getLinkError, isLinkComplete, linkProgram } from \"./shader.js\";\nimport { bindTextureRaw, type GLTexture } from \"./texture.js\";\n\n/** A compiled + linked shader program with cached uniform, sampler and\n * attribute locations. Created by `createEffect`; most fields are managed\n * internally — drive it via `isEffectReady` / `useEffect` / the `setEffect*`\n * setters rather than mutating it directly. */\nexport interface GLEffect {\n /** The `name` from the originating `GLEffectOptions`. */\n readonly name: string;\n /** The options this effect was created from (retained for context-restore). */\n readonly options: GLEffectOptions;\n /** The live `WebGLProgram`. Swapped for a fresh handle after context-restore. */\n program: WebGLProgram;\n /** @internal */\n _vs: WebGLShader;\n /** @internal */\n _fs: WebGLShader;\n /** Resolved during readiness finalization. Missing names map to `null` —\n * setters with a `null` location are silent no-ops (matches Babylon). */\n uniformLocations: { [name: string]: WebGLUniformLocation | null };\n /** Fixed unit assignment for declared samplers, index into\n * `_state.boundTextures`. */\n samplerUnits: { [name: string]: number };\n /**\n * True once `gl.uniform1i(samplerLoc, unit)` has been issued for every\n * declared sampler. Cleared on context-lost so finalization re-runs.\n * @internal\n */\n _samplersAssigned: boolean;\n /** Resolved attribute locations, keyed by attribute name. */\n attributeLocations: { [name: string]: number };\n /**\n * Last-UPLOADED scalar floats. A setter that skips the upload must NOT\n * update this — otherwise a later real set with the same value would\n * incorrectly elide and the GPU would keep stale data.\n * @internal\n */\n readonly _lastF1: { [name: string]: number };\n /**\n * Last-UPLOADED vector floats (vec2/vec3/vec4). Plain `number[]` (NOT\n * `Float32Array`) so values like `0.1` compare equal across frames.\n * @internal\n */\n readonly _lastVec: { [name: string]: number[] };\n /** @internal */\n readonly _lastI1: { [name: string]: number };\n /** True once the program has linked and finalization has run; the\n * `setEffect*` setters are no-ops until then. Poll `isEffectReady` to advance it. */\n isReady: boolean;\n /** The engine that created (and owns) this effect. Effect operations derive\n * their engine from it, so they take the effect alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _compileError: string | null;\n /** @internal */\n _disposed: boolean;\n /**\n * Number of live `createEffect` callers sharing this effect (and its one\n * `WebGLProgram`). `createEffect` returns the cached effect and bumps this\n * when an identical descriptor is requested; `disposeEffect` decrements it\n * and only tears the program down when it reaches 0.\n * @internal\n */\n _refCount: number;\n /**\n * The `_effectCache` key this effect was stored under (the source\n * descriptor). Used by `disposeEffect` to evict the cache entry at refcount\n * 0.\n * @internal\n */\n _cacheKey: string;\n /**\n * Callbacks fired exactly once on the first transition to ready.\n * @internal\n */\n readonly _onCompiled: ((effect: GLEffect) => void)[];\n /**\n * Replay closure for context-restore. Re-compiles + relinks into a fresh\n * `program` field. Finalization happens lazily on the next `isEffectReady`\n * poll.\n * @internal\n */\n _restore?: (engine: GLEngineContext) => void;\n}\n\n/** Submit compilation + linking without querying their results. `isReady`\n * starts false; poll `isEffectReady` or opt into `waitForEffect` to finalize.\n * Allocation failures throw synchronously. Shader syntax/link errors are\n * recorded during polling and exposed by `getEffectCompilationError`. */\nexport function createEffect(engine: GLEngineContext, options: GLEffectOptions): GLEffect {\n const attribs = options.attributeNames ?? [\"position\"];\n const gl = engine.gl;\n\n // Per-engine cache keyed by the source descriptor. Identical descriptors\n // share ONE GLEffect (and thus one WebGLProgram), so `useEffect`'s\n // current-program cache can elide redundant `gl.useProgram` across the\n // consumers. The key covers every input that affects the program or its\n // readiness finalization, joined by a NUL separator (cannot appear in GLSL).\n const cacheKey = [options.vertexSource, options.fragmentSource, options.defines ?? \"\", attribs.join(\",\"), options.uniformNames.join(\",\"), options.samplerNames.join(\",\")].join(\n \"\\u0000\"\n );\n const cached = engine._effectCache.get(cacheKey);\n if (cached !== undefined && !cached._disposed) {\n cached._refCount++;\n return cached;\n }\n\n const compiled = compileEffectProgram(gl, options, attribs);\n if (typeof compiled === \"string\") {\n throw new Error(`lite-gl: ${options.name} ${compiled}`);\n }\n const { vs, fs, program } = compiled;\n\n const effect: GLEffect = {\n name: options.name,\n options,\n program,\n _vs: vs,\n _fs: fs,\n uniformLocations: {},\n samplerUnits: {},\n _samplersAssigned: false,\n attributeLocations: {},\n _lastF1: {},\n _lastVec: {},\n _lastI1: {},\n isReady: false,\n _engine: engine,\n _compileError: null,\n _disposed: false,\n _refCount: 1,\n _cacheKey: cacheKey,\n _onCompiled: [],\n };\n\n if (!engine._noRestore) {\n effect._restore = (target: GLEngineContext): void => {\n const restored = compileEffectProgram(target.gl, options, attribs);\n if (typeof restored === \"string\") {\n recordCompilationError(effect, `context-restore: ${restored}`);\n return;\n }\n effect.program = restored.program;\n effect._vs = restored.vs;\n effect._fs = restored.fs;\n effect.isReady = false;\n effect._samplersAssigned = false;\n effect.uniformLocations = {};\n effect.attributeLocations = {};\n effect._compileError = null;\n };\n }\n\n engine._effects.push(effect);\n engine._effectCache.set(cacheKey, effect);\n return effect;\n}\n\n/** Shader/program handles allocated as one unit on creation and restoration. */\ninterface EffectProgram {\n vs: WebGLShader;\n fs: WebGLShader;\n program: WebGLProgram;\n}\n\n/** Share allocation and partial-failure cleanup between initial creation and\n * context restoration. Returns a diagnostic on allocation failure; compile\n * and link results are deliberately left to readiness polling. */\nfunction compileEffectProgram(gl: WebGL2RenderingContext, options: GLEffectOptions, attribs: readonly string[]): EffectProgram | string {\n const vs = compileShader(gl, applyDefines(options.vertexSource, options.defines), gl.VERTEX_SHADER);\n if (vs === null) {\n return \"vertex shader allocation failed\";\n }\n const fs = compileShader(gl, applyDefines(options.fragmentSource, options.defines), gl.FRAGMENT_SHADER);\n if (fs === null) {\n gl.deleteShader(vs);\n return \"fragment shader allocation failed\";\n }\n const program = linkProgram(gl, vs, fs, attribs);\n if (program === null) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n return \"program allocation failed\";\n }\n return { vs, fs, program };\n}\n\n/** Poll the link state and, on first success, run finalization (uniform-\n * location resolution + one-shot sampler-unit `uniform1i` assignment +\n * `_onCompiled` callbacks). Returns `true` once the effect is usable. */\nexport function isEffectReady(effect: GLEffect): boolean {\n const engine = effect._engine;\n if (\n !effect.isReady &&\n !effect._disposed &&\n !engine._isLost &&\n !engine._disposed &&\n effect._compileError === null &&\n isLinkComplete(engine.gl, effect.program, engine.caps.parallelShaderCompile)\n ) {\n const linkErr = getLinkError(engine.gl, effect.program, effect._vs, effect._fs);\n if (linkErr !== null) {\n recordCompilationError(effect, linkErr);\n } else {\n finalizeEffect(engine, effect);\n }\n }\n // Read back rather than returning `true` after finalization: a ready\n // callback may have disposed the effect or engine (or lost the context).\n return effect.isReady;\n}\n\n/** Poll readiness once and return the recorded compile/link/restore diagnostic.\n * Returns null while pending or when no failure has been recorded; this is\n * not a readiness guarantee. Does not schedule polling. A successful restore\n * allocation clears the previous diagnostic before the new link is checked. */\nexport function getEffectCompilationError(effect: GLEffect): string | null {\n isEffectReady(effect);\n return effect._compileError;\n}\n\nfunction recordCompilationError(effect: GLEffect, error: string): void {\n effect._compileError = error;\n effect.isReady = false;\n console.error(`lite-gl: ${effect.name} ${error}`);\n}\n\n/** Resolves uniform/attribute locations, binds the program (cached), and\n * issues the one-time `gl.uniform1i(samplerLoc, unit)` per declared sampler. */\nfunction finalizeEffect(engine: GLEngineContext, effect: GLEffect): void {\n const gl = engine.gl;\n const program = effect.program;\n for (const name of effect.options.uniformNames) {\n effect.uniformLocations[name] = gl.getUniformLocation(program, name);\n }\n const attribs = effect.options.attributeNames ?? [\"position\"];\n for (const name of attribs) {\n effect.attributeLocations[name] = gl.getAttribLocation(program, name);\n }\n // Switch to this program via the cached helper so _state.currentProgram\n // stays consistent — no raw gl.useProgram outside useEffect.\n useEffect(effect);\n let unit = 0;\n for (const name of effect.options.samplerNames) {\n const loc = gl.getUniformLocation(program, name);\n if (loc !== null) {\n gl.uniform1i(loc, unit);\n }\n effect.samplerUnits[name] = unit;\n unit++;\n }\n effect._samplersAssigned = true;\n effect.isReady = true;\n // Fire and clear the one-shot ready callbacks.\n const cbs = effect._onCompiled.slice();\n effect._onCompiled.length = 0;\n for (const cb of cbs) {\n try {\n cb(effect);\n } catch (err) {\n console.error(`lite-gl: ${effect.name} onCompiled callback threw`, err);\n }\n }\n}\n\n/** Fires `cb` synchronously if the effect is already ready; otherwise queues\n * it for the next finalization. Does not start polling: call `isEffectReady`\n * from the render loop or opt into `waitForEffect`. */\nexport function executeWhenCompiled(effect: GLEffect, cb: (e: GLEffect) => void): void {\n if (isEffectReady(effect)) {\n cb(effect);\n return;\n }\n effect._onCompiled.push(cb);\n}\n\n/** Decrement the share count and, on the last release, delete the effect's\n * program + shaders, unregister it from the context + cache, and clear the\n * cached current-program if it pointed at this effect. A shared effect (still\n * referenced by another `createEffect` caller) is kept alive. Call exactly ONCE\n * per `createEffect` (each call decrements the ref count); safe (no-op) once the\n * effect is fully torn down. */\nexport function disposeEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (effect._disposed) {\n return;\n }\n if (--effect._refCount > 0) {\n return;\n }\n effect._disposed = true;\n effect.isReady = false;\n const i = engine._effects.indexOf(effect);\n if (i !== -1) {\n engine._effects.splice(i, 1);\n }\n engine._effectCache.delete(effect._cacheKey);\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteProgram(effect.program);\n engine.gl.deleteShader(effect._vs);\n engine.gl.deleteShader(effect._fs);\n }\n if (engine._state.currentProgram === effect.program) {\n engine._state.currentProgram = null;\n }\n effect._onCompiled.length = 0;\n}\n\n/** Cached `gl.useProgram`. Low-level: it does NOT check readiness, so poll\n * {@link isEffectReady} first (binding a still-linking program can stall, and\n * a failed one fails the next draw). `applyEffectWrapper` does that poll for\n * wrappers. No-op when the effect is already current, disposed, or the\n * context is lost/disposed. */\nexport function useEffect(effect: GLEffect): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || effect._disposed) {\n return;\n }\n if (engine._state.currentProgram === effect.program) {\n return;\n }\n engine.gl.useProgram(effect.program);\n engine._state.currentProgram = effect.program;\n}\n\n/* ──────────────────────────── cached setters ────────────────────────────\n *\n * Each setter has the shape:\n * 1. bail when context lost / effect not ready (no cache write)\n * 2. lookup uniform location; bail on null (no cache write)\n * 3. compare against last-UPLOADED value; bail on equality\n * 4. write to cache, issue gl.uniform*\n *\n * Step 3's comparison is intentionally bit-equal (===) — NaN inputs re-upload\n * every frame because `NaN !== NaN`, which is the correct safety net for\n * caller bugs.\n */\n\n/** Cached `gl.uniform1f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastF1[name] === x) {\n return;\n }\n effect._lastF1[name] = x;\n engine.gl.uniform1f(loc, x);\n}\n\n/** Cached `gl.uniform2f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat2(effect: GLEffect, name: string, x: number, y: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y) {\n return;\n }\n if (v === undefined) {\n v = [x, y];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n }\n engine.gl.uniform2f(loc, x, y);\n}\n\n/** Cached `gl.uniform3f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat3(effect: GLEffect, name: string, x: number, y: number, z: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n engine.gl.uniform3f(loc, x, y, z);\n}\n\n/** Cached `gl.uniform4f`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectFloat4(effect: GLEffect, name: string, x: number, y: number, z: number, w: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n let v = effect._lastVec[name];\n if (v !== undefined && v[0] === x && v[1] === y && v[2] === z && v[3] === w) {\n return;\n }\n if (v === undefined) {\n v = [x, y, z, w];\n effect._lastVec[name] = v;\n } else {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n v[3] = w;\n }\n engine.gl.uniform4f(loc, x, y, z, w);\n}\n\n/** Cached `gl.uniform3f` from an r/g/b color object. Delegates to `setEffectFloat3`. */\nexport function setEffectColor3(effect: GLEffect, name: string, c: { r: number; g: number; b: number }): void {\n setEffectFloat3(effect, name, c.r, c.g, c.b);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color object. Delegates to `setEffectFloat4`. */\nexport function setEffectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform2f` from an `{x,y}` vector object — the lite-gl equivalent\n * of Babylon's `Effect.setVector2`. Delegates to `setEffectFloat2`. */\nexport function setEffectVector2(effect: GLEffect, name: string, v: { x: number; y: number }): void {\n setEffectFloat2(effect, name, v.x, v.y);\n}\n\n/** Cached `gl.uniform4f` from an r/g/b/a color WITHOUT premultiplication — the\n * lite-gl equivalent of Babylon's `Effect.setDirectColor4`. Delegates to\n * `setEffectFloat4` (lite-gl never premultiplies in the uniform setters, so\n * this matches `setEffectColor4`; the distinct name eases `ThinEngine`\n * ports). */\nexport function setEffectDirectColor4(effect: GLEffect, name: string, c: { r: number; g: number; b: number; a: number }): void {\n setEffectFloat4(effect, name, c.r, c.g, c.b, c.a);\n}\n\n/** Cached `gl.uniform1i`. No-op when context-lost, the effect isn't ready, the\n * uniform is absent, or the value is unchanged since last upload. */\nexport function setEffectInt(effect: GLEffect, name: string, x: number): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n if (effect._lastI1[name] === x) {\n return;\n }\n effect._lastI1[name] = x;\n engine.gl.uniform1i(loc, x);\n}\n\n/* ── Matrix / array setters (uploaded every call — not value-cached) ──────────\n *\n * Matrices and arrays usually change every frame; element-wise caching would\n * cost more than the upload it saves, so these always issue the GL call (the\n * location lookup + ready guards still apply). They cover Babylon's `Effect`\n * surface (`setMatrix3x3`, `setFloatArray`, `setFloatArray4`) plus a general\n * 4×4 matrix setter for any future mesh consumer. */\n\n/** `gl.uniformMatrix4fv` from a column-major 4×4 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix`. Not value-cached. */\nexport function setEffectMatrix(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix4fv(loc, false, matrix);\n}\n\n/** `gl.uniformMatrix3fv` from a column-major 3×3 matrix — the lite-gl\n * equivalent of Babylon's `Effect.setMatrix3x3`. Not value-cached. */\nexport function setEffectMatrix3x3(effect: GLEffect, name: string, matrix: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniformMatrix3fv(loc, false, matrix);\n}\n\n/** `gl.uniform1fv` — a flat float array (`Effect.setFloatArray` / `setArray`).\n * Not value-cached. */\nexport function setEffectFloatArray(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1fv(loc, array);\n}\n\n/** `gl.uniform2fv` — an array of `vec2`s. Not value-cached. */\nexport function setEffectFloatArray2(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const location = effect.uniformLocations[name];\n if (location !== null && location !== undefined) {\n engine.gl.uniform2fv(location, array);\n }\n}\n\n/**\n * Upload packed XYZ triples with `gl.uniform3fv` (`Effect.setFloatArray3` /\n * `setArray3`). Not value-cached; in-place edits are uploaded on every call.\n * Bind the effect first. No-op on a lost/disposed engine, a disposed/unready\n * effect, or a missing uniform. After restore, finalize/bind the effect again.\n *\n * @param effect - The effect receiving the uniform.\n * @param name - The uniform name.\n * @param array - Packed triples; its length must be a multiple of three.\n */\nexport function setEffectFloatArray3(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || !effect.isReady || effect._disposed) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform3fv(loc, array);\n}\n\n/** `gl.uniform4fv` — an array of `vec4`s (`Effect.setFloatArray4` / `setArray4`).\n * Not value-cached. */\nexport function setEffectFloatArray4(effect: GLEffect, name: string, array: Float32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform4fv(loc, array);\n}\n\n/** `gl.uniform1iv` — a flat int array (`Effect.setIntArray`). Not value-cached. */\nexport function setEffectIntArray(effect: GLEffect, name: string, array: Int32Array | number[]): void {\n const engine = effect._engine;\n if (engine._isLost || !effect.isReady) {\n return;\n }\n const loc = effect.uniformLocations[name];\n if (loc === null || loc === undefined) {\n return;\n }\n engine.gl.uniform1iv(loc, array);\n}\n\n/** Bind a texture to the sampler's pre-assigned unit, or pass `null` to unbind\n * that unit (§4.4). NO `gl.uniform1i` is issued — that was done exactly once per program lifetime during\n * finalization. This is the key win over Babylon's `Effect.setTexture` which\n * re-issues the sampler binding on every call. */\nexport function setEffectTexture(effect: GLEffect, samplerName: string, tex: GLTexture | null): void {\n const engine = effect._engine;\n if (engine._isLost || engine._disposed || !effect.isReady) {\n return;\n }\n const unit = effect.samplerUnits[samplerName];\n if (unit === undefined || tex?._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex === null ? null : tex.handle);\n}\n\n/** Resolve (and cache) a vertex-attribute location by name — the lite-gl\n * equivalent of Babylon's `Effect.getAttributeLocationByName`. Locations for\n * declared `attributeNames` are resolved during finalization; this also serves\n * the mesh / instancing path, where attribute names are not declared up-front.\n * Returns `-1` when the attribute is absent (matching `gl.getAttribLocation`).\n * @internal */\nexport function getEffectAttributeLocation(effect: GLEffect, name: string): number {\n const engine = effect._engine;\n const cached = effect.attributeLocations[name];\n if (cached !== undefined) {\n return cached;\n }\n const loc = engine.gl.getAttribLocation(effect.program, name);\n effect.attributeLocations[name] = loc;\n return loc;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Inject `options.defines` between the `#version`/precision header and the\n * user shader body. Supports a `// __DEFINES__` marker (preferred — keeps the\n * runtime regex-free, per spec §6.2) OR auto-detects the end of the leading\n * preprocessor / precision lines. */\nfunction applyDefines(source: string, defines: string | undefined): string {\n if (defines === undefined || defines.length === 0) {\n return source;\n }\n const marker = \"// __DEFINES__\";\n const idx = source.indexOf(marker);\n if (idx !== -1) {\n return source.slice(0, idx) + defines + source.slice(idx + marker.length);\n }\n // Fallback: insert after the last `precision` line (or after `#version`).\n const lines = source.split(\"\\n\");\n let insertAt = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === undefined) {\n continue;\n }\n const trimmed = line.trim();\n if (trimmed.startsWith(\"#version\") || trimmed.startsWith(\"precision \")) {\n insertAt = i + 1;\n }\n }\n lines.splice(insertAt, 0, defines);\n return lines.join(\"\\n\");\n}\n"]}
|
package/family.d.ts
CHANGED
|
@@ -302,7 +302,7 @@ export type GLRenderTargetOf<F extends GLFamily> = [F] extends [{
|
|
|
302
302
|
export interface GLOps<F extends GLFamily> {
|
|
303
303
|
readonly resizeGLEngine: (engine: F["engine"]) => void;
|
|
304
304
|
readonly setGLEngineSize: (engine: F["engine"], width: number, height: number) => void;
|
|
305
|
-
readonly wipeGLStateCache: (engine: F["engine"]) => void;
|
|
305
|
+
readonly wipeGLStateCache: (engine: F["engine"], bruteForce?: boolean) => void;
|
|
306
306
|
readonly getRenderWidth: (engine: F["engine"]) => number;
|
|
307
307
|
readonly getRenderHeight: (engine: F["engine"]) => number;
|
|
308
308
|
readonly getTextureCount: (engine: F["engine"]) => number;
|
|
@@ -322,6 +322,7 @@ export interface GLOps<F extends GLFamily> {
|
|
|
322
322
|
readonly endFrame: (engine: F["engine"]) => void;
|
|
323
323
|
readonly captureGPUFrameTime: (engine: F["engine"], enabled: boolean) => void;
|
|
324
324
|
readonly getGPUFrameTimeCounter: (engine: F["engine"]) => F["perfCounter"];
|
|
325
|
+
readonly setFramebufferValidation: (engine: F["engine"], enabled: boolean) => void;
|
|
325
326
|
readonly createEffect: (engine: F["engine"], options: GLEffectOptions) => F["effect"];
|
|
326
327
|
readonly useEffect: (effect: F["effect"]) => void;
|
|
327
328
|
readonly isEffectReady: (effect: F["effect"]) => boolean;
|
|
@@ -409,6 +410,9 @@ export interface GLOps<F extends GLFamily> {
|
|
|
409
410
|
readonly disposeBuffer: (buffer: F["vertexBuffer"] | F["indexBuffer"]) => void;
|
|
410
411
|
readonly bindIndexBuffer: (ib: F["indexBuffer"]) => void;
|
|
411
412
|
readonly bindAttributes: (vb: F["vertexBuffer"], descriptors: readonly F["attributeDescriptor"][], effect: F["effect"], computeStride?: boolean) => void;
|
|
413
|
+
readonly bindAttributesCached: (vb: F["vertexBuffer"], descriptors: readonly F["attributeDescriptor"][], effect: F["effect"], computeStride?: boolean) => void;
|
|
414
|
+
readonly disableAttributeByIndex: (engine: F["engine"], location: number) => void;
|
|
415
|
+
readonly unbindAllAttributes: (engine: F["engine"]) => void;
|
|
412
416
|
readonly unbindInstanceAttributes: (engine: F["engine"]) => void;
|
|
413
417
|
readonly drawIndexed: (ib: F["indexBuffer"], indexCount: number, indexStart?: number, instanceCount?: F["instanceCount"]) => void;
|
|
414
418
|
readonly createMeshVao: (engine: F["engine"], vertexBuffers: readonly GLFamilyMeshVertexBuffer<F["vertexBuffer"], F["attributeDescriptor"]>[], indexBuffer: F["indexBuffer"], effect: F["effect"]) => F["meshVao"];
|
package/family.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"family.js","sourceRoot":"","sources":["../src/family.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG","sourcesContent":["/**\n * Backend-neutral contract for the Lite GL backends.\n *\n * A {@link GLFamily} names the resource and data types of one backend, and\n * {@link GLOps} describes every backend-neutral operation over a family. A\n * consumer selects the operations it uses with {@link GLKit}, fills the kit with\n * a backend entry's exported functions in its composition root, and writes\n * shared code against the kit. The contract is types only and references no\n * browser or native host type.\n *\n * @packageDocumentation\n */\n\n/** Inputs to `createEffect`: shader sources plus the uniform, sampler and\n * attribute names the effect resolves. */\nexport interface GLEffectOptions {\n /** Human-readable label, surfaced in compile/link error messages. */\n name: string;\n /** GLSL ES 3.00 vertex source. */\n vertexSource: string;\n /** GLSL ES 3.00 fragment source. */\n fragmentSource: string;\n /** Declared uniform names. Portable code sets only these; native ignores\n * undeclared names, and only some web setters resolve them lazily. */\n uniformNames: readonly string[];\n /** Declared sampler names, in texture-unit assignment order. */\n samplerNames: readonly string[];\n /** Default `[\"position\"]`. The first attribute is bound to location 0, so\n * shared quad geometry always feeds the same location. */\n attributeNames?: readonly string[];\n /** Optional `#define` block placed ahead of both sources. Each distinct\n * block needs its own `createEffect` call. */\n defines?: string;\n}\n\n/** Pixel-space viewport rectangle passed to `setViewport`. */\nexport interface GLViewport {\n /** Lower-left X origin in physical pixels. */\n x: number;\n /** Lower-left Y origin in physical pixels. */\n y: number;\n /** Width in physical pixels. */\n w: number;\n /** Height in physical pixels. */\n h: number;\n}\n\n/** Options for `clearEngine`. */\nexport interface GLClearOptions {\n /** When set, clears the color buffer to this RGBA color (alpha default 1). */\n color?: { r: number; g: number; b: number; a?: number };\n /** Clear the depth buffer. */\n depth?: boolean;\n /** Clear the stencil buffer. */\n stencil?: boolean;\n}\n\n/** What backend-neutral code may read from any backend's texture. */\nexport interface GLFamilyTexture {\n /** Texture width in texels. */\n readonly width: number;\n /** Texture height in texels. */\n readonly height: number;\n /** Whether the texture holds its final content and is safe to sample. */\n readonly isReady: boolean;\n}\n\n/** What backend-neutral code may read from any backend's render target. */\nexport interface GLFamilyRenderTarget<Texture> {\n /** Color attachment width in texels. */\n readonly width: number;\n /** Color attachment height in texels. */\n readonly height: number;\n /** The color attachment, sampleable like any other texture of the family. */\n readonly texture: Texture;\n}\n\n/** The vertex attribute fields backend-neutral code may read. */\nexport interface GLFamilyAttributeDescriptor {\n /** Shader attribute name. */\n readonly name?: string;\n /** Number of float components, 1–4. */\n readonly size: number;\n /** Byte offset of the attribute's first element within its buffer. */\n readonly offset?: number;\n /** Per-instance divisor; `0` marks a per-vertex attribute and is listed so\n * shared code's per-vertex literals keep that type. */\n readonly divisor?: 0 | (number & {});\n}\n\n/** A per-vertex attribute every backend accepts from backend-neutral code. */\nexport interface GLPortableAttributeDescriptor {\n /** Shader attribute name. */\n readonly name: string;\n /** Number of float components, 1–4. */\n readonly size: number;\n /** Byte offset of the attribute's first element within its buffer. */\n readonly offset?: number;\n /** Per-vertex. */\n readonly divisor: 0;\n}\n\n/** A vertex buffer and the attributes a mesh reads from it. */\nexport interface GLFamilyMeshVertexBuffer<VertexBuffer, AttributeDescriptor> {\n /** The buffer supplying the attributes. */\n buffer: VertexBuffer;\n /** The attributes read from `buffer`. */\n attributes: readonly AttributeDescriptor[];\n /** Whether the attributes are interleaved with a computed stride. */\n computeStride?: boolean;\n}\n\n/**\n * Values backend-neutral code may supply for the {@link GLFamily} slots that\n * have them. Every backend that implements a slot accepts its value here.\n */\nexport interface GLFamilyPortableValues {\n /** Non-instanced draws. */\n readonly instanceCount: 0;\n /** Vertex buffers created from their data alone. */\n readonly vertexBufferArgs: [];\n /** Float matrix and array uniform inputs. */\n readonly floatArray: Float32Array | number[];\n /** RGBA8 pixel data. */\n readonly rawTextureData: Uint8Array;\n /** Per-vertex attributes. */\n readonly attributeDescriptor: GLPortableAttributeDescriptor;\n /** Blend presets, numbered as Babylon's `ALPHA_DISABLE`, `ALPHA_ADD`, `ALPHA_COMBINE` and `ALPHA_PREMULTIPLIED`. */\n readonly blendMode: 0 | 1 | 2 | 7;\n}\n\n/**\n * The resource and data types of one Lite GL backend.\n *\n * A slot's getter type is the bound every backend's type must satisfy and all\n * that backend-neutral code may read from it. Its setter type is what\n * backend-neutral code may supply for it: the slot's\n * {@link GLFamilyPortableValues} member, or `never` when its values come only\n * from the backend's operations or from a composition root that knows the\n * backend. A backend maps the slots it does not implement to `never`.\n */\nexport interface GLFamily {\n /** Engine context created by the backend's host operations. */\n get engine(): object;\n set engine(value: never);\n /** Compiled shader program. */\n get effect(): object;\n set effect(value: never);\n /** Fullscreen-quad effect wrapper. */\n get effectWrapper(): object;\n set effectWrapper(value: never);\n /** Sampled 2D texture. */\n get texture(): GLFamilyTexture;\n set texture(value: never);\n /** Sampled 3D texture. */\n get texture3D(): object;\n set texture3D(value: never);\n /** Offscreen color target; backend-neutral code names it {@link GLRenderTargetOf}. */\n get renderTarget(): GLFamilyRenderTarget<GLFamilyTexture>;\n set renderTarget(value: never);\n /** Float vertex storage. */\n get vertexBuffer(): object;\n set vertexBuffer(value: never);\n /** Index storage. */\n get indexBuffer(): object;\n set indexBuffer(value: never);\n /** Recorded mesh geometry. */\n get meshVao(): object;\n set meshVao(value: never);\n /** Batched sprite renderer. */\n get spriteRenderer(): object;\n set spriteRenderer(value: never);\n /** Parsed font. */\n get font(): object;\n set font(value: never);\n /** Glyph outlines and their atlases. */\n get glyphStorage(): object;\n set glyphStorage(value: never);\n /** Positioned glyph runs. */\n get textData(): object;\n set textData(value: never);\n /** Single-font text data with default layout. */\n get defaultTextData(): object;\n set defaultTextData(value: never);\n /** Positioned instance of text data. */\n get textLayer(): object;\n set textLayer(value: never);\n /** Text layer renderer. */\n get textRenderer(): object;\n set textRenderer(value: never);\n /** GPU frame-time statistics. */\n get perfCounter(): object;\n set perfCounter(value: never);\n /** Value that unbinds a sampler, or `never` when samplers cannot be unbound. */\n get noTexture(): null;\n set noTexture(value: never);\n /** Instance counts the backend's draws accept. */\n get instanceCount(): number;\n set instanceCount(value: GLFamilyPortableValues[\"instanceCount\"]);\n /** Trailing `createVertexBuffer` arguments after the data. */\n get vertexBufferArgs(): readonly unknown[];\n set vertexBufferArgs(value: GLFamilyPortableValues[\"vertexBufferArgs\"]);\n /** Float matrix and array uniform inputs. */\n get floatArray(): ArrayLike<number>;\n set floatArray(value: GLFamilyPortableValues[\"floatArray\"]);\n /** Pixel data for raw texture uploads. */\n get rawTextureData(): ArrayBufferView | null;\n set rawTextureData(value: GLFamilyPortableValues[\"rawTextureData\"]);\n /** `createRawTexture` options. */\n get rawTextureOptions(): unknown;\n set rawTextureOptions(value: never);\n /** Options shared by texture factories. */\n get textureOptions(): unknown;\n set textureOptions(value: never);\n /** `createRenderTarget` options. */\n get renderTargetOptions(): unknown;\n set renderTargetOptions(value: never);\n /** One vertex attribute read by a mesh or attribute binding. */\n get attributeDescriptor(): GLFamilyAttributeDescriptor;\n set attributeDescriptor(value: GLFamilyPortableValues[\"attributeDescriptor\"]);\n /** Blend preset value. */\n get blendMode(): number;\n set blendMode(value: GLFamilyPortableValues[\"blendMode\"]);\n /** `waitForEffect` options. */\n get effectWaitOptions(): unknown;\n set effectWaitOptions(value: never);\n /** `createEffectWrapper` options. */\n get effectWrapperOptions(): unknown;\n set effectWrapperOptions(value: never);\n /** Per-update texture options. */\n get textureUpdateOptions(): unknown;\n set textureUpdateOptions(value: never);\n /** `createFloatTexture` options. */\n get floatTextureOptions(): unknown;\n set floatTextureOptions(value: never);\n /** Sampling preset value. */\n get samplingMode(): number;\n set samplingMode(value: never);\n /** Filters resolved from a sampling preset. */\n get samplingFilters(): unknown;\n set samplingFilters(value: never);\n /** `createTexture3DFromPixels` options. */\n get texture3DOptions(): unknown;\n set texture3DOptions(value: never);\n /** `createFloatRenderTarget` options. */\n get floatRenderTargetOptions(): unknown;\n set floatRenderTargetOptions(value: never);\n /** `readRenderTargetPixels` options. */\n get readPixelsOptions(): unknown;\n set readPixelsOptions(value: never);\n /** Explicit blend state. */\n get blendState(): unknown;\n set blendState(value: never);\n /** Depth state. */\n get depthState(): unknown;\n set depthState(value: never);\n /** Stencil state. */\n get stencilState(): unknown;\n set stencilState(value: never);\n /** One face's stencil operations. */\n get stencilOpState(): unknown;\n set stencilOpState(value: never);\n /** `createSpriteRenderer` options. */\n get spriteRendererOptions(): unknown;\n set spriteRendererOptions(value: never);\n /** One sprite instance. */\n get sprite(): unknown;\n set sprite(value: never);\n /** One glyph's outline curves. */\n get glyphCurves(): unknown;\n set glyphCurves(value: never);\n /** One quadratic curve segment. */\n get quadCurve(): unknown;\n set quadCurve(value: never);\n /** One run of glyphs sharing a curve set. */\n get glyphRun(): unknown;\n set glyphRun(value: never);\n /** Partial update applied to text data. */\n get textDataUpdate(): unknown;\n set textDataUpdate(value: never);\n /** Text layout options. */\n get textLayoutOptions(): unknown;\n set textLayoutOptions(value: never);\n /** `createTextLayer` options. */\n get textLayerOptions(): unknown;\n set textLayerOptions(value: never);\n /** `createTextRenderer` options. */\n get textRendererOptions(): unknown;\n set textRendererOptions(value: never);\n}\n\n/**\n * Family `F`'s render target, whose color attachment is `F`'s texture.\n * Backend-neutral code names render targets with this type rather than\n * `F[\"renderTarget\"]`, so a target's texture can be sampled through the same\n * family.\n */\nexport type GLRenderTargetOf<F extends GLFamily> = [F] extends [{ readonly renderTarget: infer R extends GLFamilyRenderTarget<F[\"texture\"]> }] ? R : never;\n\n/**\n * Every backend-neutral Lite GL operation over the family `F`.\n *\n * Each member has the semantics of the identically named export of the\n * backend entries. Instantiated with a backend's family, every member that\n * backend exports matches its exported signature exactly.\n */\nexport interface GLOps<F extends GLFamily> {\n // Engine, render loop and frame timing\n readonly resizeGLEngine: (engine: F[\"engine\"]) => void;\n readonly setGLEngineSize: (engine: F[\"engine\"], width: number, height: number) => void;\n readonly wipeGLStateCache: (engine: F[\"engine\"]) => void;\n readonly getRenderWidth: (engine: F[\"engine\"]) => number;\n readonly getRenderHeight: (engine: F[\"engine\"]) => number;\n readonly getTextureCount: (engine: F[\"engine\"]) => number;\n readonly getCurrentRenderTarget: (engine: F[\"engine\"]) => GLRenderTargetOf<F> | null;\n readonly getHardwareScalingLevel: (engine: F[\"engine\"]) => number;\n readonly setHardwareScalingLevel: (engine: F[\"engine\"], level: number) => void;\n readonly onContextLost: (engine: F[\"engine\"], cb: () => void) => void;\n readonly offContextLost: (engine: F[\"engine\"], cb: () => void) => void;\n readonly onContextRestored: (engine: F[\"engine\"], cb: () => void) => void;\n readonly offContextRestored: (engine: F[\"engine\"], cb: () => void) => void;\n readonly getAlphaToCoverage: (engine: F[\"engine\"]) => boolean;\n readonly getCurrentSampleCount: (engine: F[\"engine\"]) => number;\n readonly setAlphaToCoverage: (engine: F[\"engine\"], enabled: boolean) => void;\n readonly runRenderLoop: (engine: F[\"engine\"], fn: (dt: number) => void) => void;\n readonly stopRenderLoop: (engine: F[\"engine\"], fn?: (dt: number) => void) => void;\n readonly beginFrame: (engine: F[\"engine\"]) => void;\n readonly endFrame: (engine: F[\"engine\"]) => void;\n readonly captureGPUFrameTime: (engine: F[\"engine\"], enabled: boolean) => void;\n readonly getGPUFrameTimeCounter: (engine: F[\"engine\"]) => F[\"perfCounter\"];\n\n // Effects and the fullscreen effect renderer\n readonly createEffect: (engine: F[\"engine\"], options: GLEffectOptions) => F[\"effect\"];\n readonly useEffect: (effect: F[\"effect\"]) => void;\n readonly isEffectReady: (effect: F[\"effect\"]) => boolean;\n readonly getEffectCompilationError: (effect: F[\"effect\"]) => string | null;\n readonly executeWhenCompiled: (effect: F[\"effect\"], cb: (e: F[\"effect\"]) => void) => void;\n readonly disposeEffect: (effect: F[\"effect\"]) => void;\n readonly setEffectFloat: (effect: F[\"effect\"], name: string, x: number) => void;\n readonly setEffectFloat2: (effect: F[\"effect\"], name: string, x: number, y: number) => void;\n readonly setEffectFloat3: (effect: F[\"effect\"], name: string, x: number, y: number, z: number) => void;\n readonly setEffectFloat4: (effect: F[\"effect\"], name: string, x: number, y: number, z: number, w: number) => void;\n readonly setEffectColor3: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number }) => void;\n readonly setEffectColor4: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number; a: number }) => void;\n readonly setEffectVector2: (effect: F[\"effect\"], name: string, v: { x: number; y: number }) => void;\n readonly setEffectDirectColor4: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number; a: number }) => void;\n readonly setEffectInt: (effect: F[\"effect\"], name: string, x: number) => void;\n readonly setEffectTexture: (effect: F[\"effect\"], samplerName: string, tex: F[\"texture\"] | F[\"noTexture\"]) => void;\n readonly setEffectMatrix: (effect: F[\"effect\"], name: string, matrix: F[\"floatArray\"]) => void;\n readonly setEffectMatrix3x3: (effect: F[\"effect\"], name: string, matrix: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray2: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray3: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray4: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectIntArray: (effect: F[\"effect\"], name: string, array: number[] | Int32Array) => void;\n readonly waitForEffect: (effect: F[\"effect\"], options?: F[\"effectWaitOptions\"]) => Promise<F[\"effect\"]>;\n readonly createEffectWrapper: (engine: F[\"engine\"], options: F[\"effectWrapperOptions\"]) => F[\"effectWrapper\"];\n readonly applyEffectWrapper: (wrapper: F[\"effectWrapper\"]) => boolean;\n readonly drawEffect: (engine: F[\"engine\"]) => void;\n readonly setViewport: (engine: F[\"engine\"], viewport?: GLViewport) => void;\n readonly disposeEffectWrapper: (wrapper: F[\"effectWrapper\"]) => void;\n\n // Textures\n readonly createRawTexture: (engine: F[\"engine\"], data: F[\"rawTextureData\"], width: number, height: number, options?: F[\"rawTextureOptions\"]) => F[\"texture\"];\n readonly createFloatTexture: (engine: F[\"engine\"], data: ArrayBufferView | null, width: number, height: number, options?: F[\"floatTextureOptions\"]) => F[\"texture\"];\n readonly generateTextureMipMaps: (tex: F[\"texture\"]) => void;\n readonly loadTexture2D: (engine: F[\"engine\"], url: string, options?: F[\"textureOptions\"], onLoad?: (tex: F[\"texture\"]) => void, onError?: (err: Error) => void) => F[\"texture\"];\n readonly bindTexture: (tex: F[\"texture\"], unit: number) => void;\n readonly unbindTexture: (engine: F[\"engine\"], unit: number) => void;\n readonly disposeTexture: (tex: F[\"texture\"]) => void;\n readonly updateRawTexture: (\n tex: F[\"texture\"],\n data: F[\"rawTextureData\"],\n options?: F[\"textureUpdateOptions\"] & { width?: number; height?: number; unpackAlignment?: number }\n ) => void;\n readonly updateTextureSamplingMode: (tex: F[\"texture\"], minFilter: number, magFilter: number) => void;\n readonly updateTextureSamplingPreset: (tex: F[\"texture\"], samplingMode: F[\"samplingMode\"], generateMipMaps?: boolean) => void;\n readonly updateTextureWrapMode: (tex: F[\"texture\"], wrapS: number, wrapT: number) => void;\n readonly getSamplingModeFilters: (samplingMode: F[\"samplingMode\"], useMipMaps?: boolean) => F[\"samplingFilters\"];\n readonly isTextureReady: (tex: F[\"texture\"]) => boolean;\n readonly createTexture3DFromPixels: (engine: F[\"engine\"], data: Uint8Array, width: number, height: number, depth: number, options?: F[\"texture3DOptions\"]) => F[\"texture3D\"];\n readonly bindTexture3D: (tex: F[\"texture3D\"], unit: number) => void;\n readonly unbindTexture3D: (engine: F[\"engine\"], unit: number) => void;\n readonly setEffectTexture3D: (effect: F[\"effect\"], samplerName: string, tex: F[\"texture3D\"] | F[\"noTexture\"]) => void;\n readonly generateTexture3DMipMaps: (tex: F[\"texture3D\"]) => void;\n readonly updateTexture3DSamplingMode: (tex: F[\"texture3D\"], minFilter: number, magFilter: number) => void;\n readonly updateTexture3DWrapMode: (tex: F[\"texture3D\"], wrapS: number, wrapT: number, wrapR: number) => void;\n readonly disposeTexture3D: (tex: F[\"texture3D\"]) => void;\n readonly createDynamicTexture: (engine: F[\"engine\"], width: number, height: number, options?: F[\"textureOptions\"]) => F[\"texture\"];\n\n // Render targets\n readonly createRenderTarget: (engine: F[\"engine\"], width: number, height: number, options?: F[\"renderTargetOptions\"]) => GLRenderTargetOf<F>;\n readonly createFloatRenderTarget: (engine: F[\"engine\"], width: number, height: number, options?: F[\"floatRenderTargetOptions\"]) => GLRenderTargetOf<F>;\n readonly bindRenderTarget: (rt: GLRenderTargetOf<F>) => void;\n readonly restoreDefaultFramebuffer: (engine: F[\"engine\"]) => void;\n readonly presentRenderTarget: (target: GLRenderTargetOf<F>) => void;\n readonly generateRenderTargetMipMaps: (rt: GLRenderTargetOf<F>) => void;\n readonly resizeRenderTarget: (rt: GLRenderTargetOf<F>, width: number, height: number) => void;\n readonly readRenderTargetPixels: (rt: GLRenderTargetOf<F>, options?: F[\"readPixelsOptions\"]) => ArrayBufferView;\n readonly disposeRenderTarget: (rt: GLRenderTargetOf<F> | null | undefined) => void;\n\n // Meshes, buffers and instancing\n readonly createVertexBuffer: (engine: F[\"engine\"], data: Float32Array, ...args: F[\"vertexBufferArgs\"]) => F[\"vertexBuffer\"];\n readonly updateVertexBuffer: (vb: F[\"vertexBuffer\"], data: Float32Array, dstByteOffset?: number) => void;\n readonly createIndexBuffer: (engine: F[\"engine\"], data: Uint16Array | Uint32Array) => F[\"indexBuffer\"];\n readonly disposeBuffer: (buffer: F[\"vertexBuffer\"] | F[\"indexBuffer\"]) => void;\n readonly bindIndexBuffer: (ib: F[\"indexBuffer\"]) => void;\n readonly bindAttributes: (vb: F[\"vertexBuffer\"], descriptors: readonly F[\"attributeDescriptor\"][], effect: F[\"effect\"], computeStride?: boolean) => void;\n readonly unbindInstanceAttributes: (engine: F[\"engine\"]) => void;\n readonly drawIndexed: (ib: F[\"indexBuffer\"], indexCount: number, indexStart?: number, instanceCount?: F[\"instanceCount\"]) => void;\n readonly createMeshVao: (\n engine: F[\"engine\"],\n vertexBuffers: readonly GLFamilyMeshVertexBuffer<F[\"vertexBuffer\"], F[\"attributeDescriptor\"]>[],\n indexBuffer: F[\"indexBuffer\"],\n effect: F[\"effect\"]\n ) => F[\"meshVao\"];\n readonly bindMeshVao: (vao: F[\"meshVao\"]) => void;\n readonly drawMesh: (vao: F[\"meshVao\"], instanceCount?: F[\"instanceCount\"], indexStart?: number, indexCount?: number) => void;\n readonly disposeMeshVao: (vao: F[\"meshVao\"]) => void;\n\n // Blend, depth, stencil, color mask, clear and scissor state\n readonly setBlendMode: (engine: F[\"engine\"], mode: F[\"blendMode\"]) => void;\n readonly setBlendState: (engine: F[\"engine\"], state: F[\"blendState\"]) => void;\n readonly disableBlend: (engine: F[\"engine\"]) => void;\n readonly setDepthState: (engine: F[\"engine\"], state: F[\"depthState\"]) => void;\n readonly setCullState: (engine: F[\"engine\"], enabled: boolean, face?: number) => void;\n readonly setStencilState: (engine: F[\"engine\"], state: F[\"stencilState\"]) => void;\n readonly setStencilOpSeparate: (engine: F[\"engine\"], face: number, state: F[\"stencilOpState\"]) => void;\n readonly setColorMask: (engine: F[\"engine\"], r: boolean, g: boolean, b: boolean, a: boolean) => void;\n readonly clearEngine: (engine: F[\"engine\"], options: GLClearOptions) => void;\n readonly generateRenderTargetStencil: (rt: GLRenderTargetOf<F>, options?: { depth?: boolean }) => void;\n /** Portable dimensions are nonnegative integers; a rectangle without area clips everything. */\n readonly setScissor: (engine: F[\"engine\"], x: number, y: number, width: number, height: number) => void;\n readonly disableScissor: (engine: F[\"engine\"]) => void;\n\n // Sprites\n readonly createSpriteRenderer: (engine: F[\"engine\"], options: F[\"spriteRendererOptions\"]) => F[\"spriteRenderer\"];\n readonly renderSprites: (\n renderer: F[\"spriteRenderer\"],\n sprites: readonly F[\"sprite\"][],\n deltaTime: number,\n viewMatrix: F[\"floatArray\"],\n projectionMatrix: F[\"floatArray\"]\n ) => void;\n readonly setSpriteRendererTexture: (renderer: F[\"spriteRenderer\"], texture: F[\"texture\"]) => void;\n readonly disposeSpriteRenderer: (renderer: F[\"spriteRenderer\"]) => void;\n\n // Text\n readonly loadFont: (url: string) => Promise<F[\"font\"]>;\n readonly createFontFromBuffer: (data: ArrayBuffer) => F[\"font\"];\n readonly extractGlyphCurves: (font: F[\"font\"], glyphIds: ReadonlySet<number>, target: Map<number, F[\"glyphCurves\"]>) => void;\n readonly cubicToQuadratics: (p0x: number, p0y: number, c1x: number, c1y: number, c2x: number, c2y: number, p1x: number, p1y: number) => [F[\"quadCurve\"], F[\"quadCurve\"]];\n readonly createGlyphStorage: (initial?: Map<string, Map<number, F[\"glyphCurves\"]>>) => F[\"glyphStorage\"];\n readonly updateGlyphStorage: (storage: F[\"glyphStorage\"], curveSetId: string, curves: ReadonlyMap<number, F[\"glyphCurves\"]>) => void;\n readonly disposeGlyphStorage: (storage: F[\"glyphStorage\"]) => void;\n readonly createTextData: (storage: F[\"glyphStorage\"], runs?: readonly F[\"glyphRun\"][]) => F[\"textData\"];\n readonly updateTextData: (data: F[\"textData\"], update: F[\"textDataUpdate\"]) => void;\n readonly disposeTextData: (data: F[\"textData\"]) => void;\n readonly createDefaultTextData: (\n font: F[\"font\"],\n fontSizePx: number,\n text: string,\n textColor?: readonly [number, number, number, number],\n options?: F[\"textLayoutOptions\"]\n ) => F[\"defaultTextData\"];\n readonly updateDefaultTextData: (data: F[\"defaultTextData\"], text: string, textColor?: readonly [number, number, number, number]) => void;\n readonly disposeDefaultTextData: (data: F[\"defaultTextData\"]) => void;\n readonly createTextLayer: (data: F[\"textData\"], options?: F[\"textLayerOptions\"]) => F[\"textLayer\"];\n readonly setTextLayerPosition: (layer: F[\"textLayer\"], x: number, y: number) => void;\n readonly createTextRenderer: (engine: F[\"engine\"], options: F[\"textRendererOptions\"]) => F[\"textRenderer\"];\n readonly renderText: (renderer: F[\"textRenderer\"]) => number;\n readonly isTextRendererReady: (renderer: F[\"textRenderer\"]) => boolean;\n readonly addTextRendererLayer: (renderer: F[\"textRenderer\"], layer: F[\"textLayer\"]) => void;\n readonly removeTextRendererLayer: (renderer: F[\"textRenderer\"], layer: F[\"textLayer\"]) => boolean;\n readonly registerTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly unregisterTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly disposeTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly setFontWeightOffset: (data: F[\"textData\"], run: number | F[\"glyphRun\"], offset: number) => void;\n}\n\n/** Name of a backend-neutral operation. */\nexport type GLOpName = keyof GLOps<GLFamily>;\n\n/** Type-only witness that lets TypeScript infer a kit's family. It is never set at runtime. */\nexport interface GLFamilyMarker<F extends GLFamily> {\n /** Never present at runtime. */\n readonly glFamily?: F;\n}\n\n/** The operations `K` of family `F`, as selected by a consumer and filled with a backend's exported functions. */\nexport type GLKit<F extends GLFamily, K extends GLOpName> = Pick<GLOps<F>, K> & GLFamilyMarker<F>;\n"]}
|
|
1
|
+
{"version":3,"file":"family.js","sourceRoot":"","sources":["../src/family.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG","sourcesContent":["/**\n * Backend-neutral contract for the Lite GL backends.\n *\n * A {@link GLFamily} names the resource and data types of one backend, and\n * {@link GLOps} describes every backend-neutral operation over a family. A\n * consumer selects the operations it uses with {@link GLKit}, fills the kit with\n * a backend entry's exported functions in its composition root, and writes\n * shared code against the kit. The contract is types only and references no\n * browser or native host type.\n *\n * @packageDocumentation\n */\n\n/** Inputs to `createEffect`: shader sources plus the uniform, sampler and\n * attribute names the effect resolves. */\nexport interface GLEffectOptions {\n /** Human-readable label, surfaced in compile/link error messages. */\n name: string;\n /** GLSL ES 3.00 vertex source. */\n vertexSource: string;\n /** GLSL ES 3.00 fragment source. */\n fragmentSource: string;\n /** Declared uniform names. Portable code sets only these; native ignores\n * undeclared names, and only some web setters resolve them lazily. */\n uniformNames: readonly string[];\n /** Declared sampler names, in texture-unit assignment order. */\n samplerNames: readonly string[];\n /** Default `[\"position\"]`. The first attribute is bound to location 0, so\n * shared quad geometry always feeds the same location. */\n attributeNames?: readonly string[];\n /** Optional `#define` block placed ahead of both sources. Each distinct\n * block needs its own `createEffect` call. */\n defines?: string;\n}\n\n/** Pixel-space viewport rectangle passed to `setViewport`. */\nexport interface GLViewport {\n /** Lower-left X origin in physical pixels. */\n x: number;\n /** Lower-left Y origin in physical pixels. */\n y: number;\n /** Width in physical pixels. */\n w: number;\n /** Height in physical pixels. */\n h: number;\n}\n\n/** Options for `clearEngine`. */\nexport interface GLClearOptions {\n /** When set, clears the color buffer to this RGBA color (alpha default 1). */\n color?: { r: number; g: number; b: number; a?: number };\n /** Clear the depth buffer. */\n depth?: boolean;\n /** Clear the stencil buffer. */\n stencil?: boolean;\n}\n\n/** What backend-neutral code may read from any backend's texture. */\nexport interface GLFamilyTexture {\n /** Texture width in texels. */\n readonly width: number;\n /** Texture height in texels. */\n readonly height: number;\n /** Whether the texture holds its final content and is safe to sample. */\n readonly isReady: boolean;\n}\n\n/** What backend-neutral code may read from any backend's render target. */\nexport interface GLFamilyRenderTarget<Texture> {\n /** Color attachment width in texels. */\n readonly width: number;\n /** Color attachment height in texels. */\n readonly height: number;\n /** The color attachment, sampleable like any other texture of the family. */\n readonly texture: Texture;\n}\n\n/** The vertex attribute fields backend-neutral code may read. */\nexport interface GLFamilyAttributeDescriptor {\n /** Shader attribute name. */\n readonly name?: string;\n /** Number of float components, 1–4. */\n readonly size: number;\n /** Byte offset of the attribute's first element within its buffer. */\n readonly offset?: number;\n /** Per-instance divisor; `0` marks a per-vertex attribute and is listed so\n * shared code's per-vertex literals keep that type. */\n readonly divisor?: 0 | (number & {});\n}\n\n/** A per-vertex attribute every backend accepts from backend-neutral code. */\nexport interface GLPortableAttributeDescriptor {\n /** Shader attribute name. */\n readonly name: string;\n /** Number of float components, 1–4. */\n readonly size: number;\n /** Byte offset of the attribute's first element within its buffer. */\n readonly offset?: number;\n /** Per-vertex. */\n readonly divisor: 0;\n}\n\n/** A vertex buffer and the attributes a mesh reads from it. */\nexport interface GLFamilyMeshVertexBuffer<VertexBuffer, AttributeDescriptor> {\n /** The buffer supplying the attributes. */\n buffer: VertexBuffer;\n /** The attributes read from `buffer`. */\n attributes: readonly AttributeDescriptor[];\n /** Whether the attributes are interleaved with a computed stride. */\n computeStride?: boolean;\n}\n\n/**\n * Values backend-neutral code may supply for the {@link GLFamily} slots that\n * have them. Every backend that implements a slot accepts its value here.\n */\nexport interface GLFamilyPortableValues {\n /** Non-instanced draws. */\n readonly instanceCount: 0;\n /** Vertex buffers created from their data alone. */\n readonly vertexBufferArgs: [];\n /** Float matrix and array uniform inputs. */\n readonly floatArray: Float32Array | number[];\n /** RGBA8 pixel data. */\n readonly rawTextureData: Uint8Array;\n /** Per-vertex attributes. */\n readonly attributeDescriptor: GLPortableAttributeDescriptor;\n /** Blend presets, numbered as Babylon's `ALPHA_DISABLE`, `ALPHA_ADD`, `ALPHA_COMBINE` and `ALPHA_PREMULTIPLIED`. */\n readonly blendMode: 0 | 1 | 2 | 7;\n}\n\n/**\n * The resource and data types of one Lite GL backend.\n *\n * A slot's getter type is the bound every backend's type must satisfy and all\n * that backend-neutral code may read from it. Its setter type is what\n * backend-neutral code may supply for it: the slot's\n * {@link GLFamilyPortableValues} member, or `never` when its values come only\n * from the backend's operations or from a composition root that knows the\n * backend. A backend maps the slots it does not implement to `never`.\n */\nexport interface GLFamily {\n /** Engine context created by the backend's host operations. */\n get engine(): object;\n set engine(value: never);\n /** Compiled shader program. */\n get effect(): object;\n set effect(value: never);\n /** Fullscreen-quad effect wrapper. */\n get effectWrapper(): object;\n set effectWrapper(value: never);\n /** Sampled 2D texture. */\n get texture(): GLFamilyTexture;\n set texture(value: never);\n /** Sampled 3D texture. */\n get texture3D(): object;\n set texture3D(value: never);\n /** Offscreen color target; backend-neutral code names it {@link GLRenderTargetOf}. */\n get renderTarget(): GLFamilyRenderTarget<GLFamilyTexture>;\n set renderTarget(value: never);\n /** Float vertex storage. */\n get vertexBuffer(): object;\n set vertexBuffer(value: never);\n /** Index storage. */\n get indexBuffer(): object;\n set indexBuffer(value: never);\n /** Recorded mesh geometry. */\n get meshVao(): object;\n set meshVao(value: never);\n /** Batched sprite renderer. */\n get spriteRenderer(): object;\n set spriteRenderer(value: never);\n /** Parsed font. */\n get font(): object;\n set font(value: never);\n /** Glyph outlines and their atlases. */\n get glyphStorage(): object;\n set glyphStorage(value: never);\n /** Positioned glyph runs. */\n get textData(): object;\n set textData(value: never);\n /** Single-font text data with default layout. */\n get defaultTextData(): object;\n set defaultTextData(value: never);\n /** Positioned instance of text data. */\n get textLayer(): object;\n set textLayer(value: never);\n /** Text layer renderer. */\n get textRenderer(): object;\n set textRenderer(value: never);\n /** GPU frame-time statistics. */\n get perfCounter(): object;\n set perfCounter(value: never);\n /** Value that unbinds a sampler, or `never` when samplers cannot be unbound. */\n get noTexture(): null;\n set noTexture(value: never);\n /** Instance counts the backend's draws accept. */\n get instanceCount(): number;\n set instanceCount(value: GLFamilyPortableValues[\"instanceCount\"]);\n /** Trailing `createVertexBuffer` arguments after the data. */\n get vertexBufferArgs(): readonly unknown[];\n set vertexBufferArgs(value: GLFamilyPortableValues[\"vertexBufferArgs\"]);\n /** Float matrix and array uniform inputs. */\n get floatArray(): ArrayLike<number>;\n set floatArray(value: GLFamilyPortableValues[\"floatArray\"]);\n /** Pixel data for raw texture uploads. */\n get rawTextureData(): ArrayBufferView | null;\n set rawTextureData(value: GLFamilyPortableValues[\"rawTextureData\"]);\n /** `createRawTexture` options. */\n get rawTextureOptions(): unknown;\n set rawTextureOptions(value: never);\n /** Options shared by texture factories. */\n get textureOptions(): unknown;\n set textureOptions(value: never);\n /** `createRenderTarget` options. */\n get renderTargetOptions(): unknown;\n set renderTargetOptions(value: never);\n /** One vertex attribute read by a mesh or attribute binding. */\n get attributeDescriptor(): GLFamilyAttributeDescriptor;\n set attributeDescriptor(value: GLFamilyPortableValues[\"attributeDescriptor\"]);\n /** Blend preset value. */\n get blendMode(): number;\n set blendMode(value: GLFamilyPortableValues[\"blendMode\"]);\n /** `waitForEffect` options. */\n get effectWaitOptions(): unknown;\n set effectWaitOptions(value: never);\n /** `createEffectWrapper` options. */\n get effectWrapperOptions(): unknown;\n set effectWrapperOptions(value: never);\n /** Per-update texture options. */\n get textureUpdateOptions(): unknown;\n set textureUpdateOptions(value: never);\n /** `createFloatTexture` options. */\n get floatTextureOptions(): unknown;\n set floatTextureOptions(value: never);\n /** Sampling preset value. */\n get samplingMode(): number;\n set samplingMode(value: never);\n /** Filters resolved from a sampling preset. */\n get samplingFilters(): unknown;\n set samplingFilters(value: never);\n /** `createTexture3DFromPixels` options. */\n get texture3DOptions(): unknown;\n set texture3DOptions(value: never);\n /** `createFloatRenderTarget` options. */\n get floatRenderTargetOptions(): unknown;\n set floatRenderTargetOptions(value: never);\n /** `readRenderTargetPixels` options. */\n get readPixelsOptions(): unknown;\n set readPixelsOptions(value: never);\n /** Explicit blend state. */\n get blendState(): unknown;\n set blendState(value: never);\n /** Depth state. */\n get depthState(): unknown;\n set depthState(value: never);\n /** Stencil state. */\n get stencilState(): unknown;\n set stencilState(value: never);\n /** One face's stencil operations. */\n get stencilOpState(): unknown;\n set stencilOpState(value: never);\n /** `createSpriteRenderer` options. */\n get spriteRendererOptions(): unknown;\n set spriteRendererOptions(value: never);\n /** One sprite instance. */\n get sprite(): unknown;\n set sprite(value: never);\n /** One glyph's outline curves. */\n get glyphCurves(): unknown;\n set glyphCurves(value: never);\n /** One quadratic curve segment. */\n get quadCurve(): unknown;\n set quadCurve(value: never);\n /** One run of glyphs sharing a curve set. */\n get glyphRun(): unknown;\n set glyphRun(value: never);\n /** Partial update applied to text data. */\n get textDataUpdate(): unknown;\n set textDataUpdate(value: never);\n /** Text layout options. */\n get textLayoutOptions(): unknown;\n set textLayoutOptions(value: never);\n /** `createTextLayer` options. */\n get textLayerOptions(): unknown;\n set textLayerOptions(value: never);\n /** `createTextRenderer` options. */\n get textRendererOptions(): unknown;\n set textRendererOptions(value: never);\n}\n\n/**\n * Family `F`'s render target, whose color attachment is `F`'s texture.\n * Backend-neutral code names render targets with this type rather than\n * `F[\"renderTarget\"]`, so a target's texture can be sampled through the same\n * family.\n */\nexport type GLRenderTargetOf<F extends GLFamily> = [F] extends [{ readonly renderTarget: infer R extends GLFamilyRenderTarget<F[\"texture\"]> }] ? R : never;\n\n/**\n * Every backend-neutral Lite GL operation over the family `F`.\n *\n * Each member has the semantics of the identically named export of the\n * backend entries. Instantiated with a backend's family, every member that\n * backend exports matches its exported signature exactly.\n */\nexport interface GLOps<F extends GLFamily> {\n // Engine, render loop and frame timing\n readonly resizeGLEngine: (engine: F[\"engine\"]) => void;\n readonly setGLEngineSize: (engine: F[\"engine\"], width: number, height: number) => void;\n readonly wipeGLStateCache: (engine: F[\"engine\"], bruteForce?: boolean) => void;\n readonly getRenderWidth: (engine: F[\"engine\"]) => number;\n readonly getRenderHeight: (engine: F[\"engine\"]) => number;\n readonly getTextureCount: (engine: F[\"engine\"]) => number;\n readonly getCurrentRenderTarget: (engine: F[\"engine\"]) => GLRenderTargetOf<F> | null;\n readonly getHardwareScalingLevel: (engine: F[\"engine\"]) => number;\n readonly setHardwareScalingLevel: (engine: F[\"engine\"], level: number) => void;\n readonly onContextLost: (engine: F[\"engine\"], cb: () => void) => void;\n readonly offContextLost: (engine: F[\"engine\"], cb: () => void) => void;\n readonly onContextRestored: (engine: F[\"engine\"], cb: () => void) => void;\n readonly offContextRestored: (engine: F[\"engine\"], cb: () => void) => void;\n readonly getAlphaToCoverage: (engine: F[\"engine\"]) => boolean;\n readonly getCurrentSampleCount: (engine: F[\"engine\"]) => number;\n readonly setAlphaToCoverage: (engine: F[\"engine\"], enabled: boolean) => void;\n readonly runRenderLoop: (engine: F[\"engine\"], fn: (dt: number) => void) => void;\n readonly stopRenderLoop: (engine: F[\"engine\"], fn?: (dt: number) => void) => void;\n readonly beginFrame: (engine: F[\"engine\"]) => void;\n readonly endFrame: (engine: F[\"engine\"]) => void;\n readonly captureGPUFrameTime: (engine: F[\"engine\"], enabled: boolean) => void;\n readonly getGPUFrameTimeCounter: (engine: F[\"engine\"]) => F[\"perfCounter\"];\n readonly setFramebufferValidation: (engine: F[\"engine\"], enabled: boolean) => void;\n\n // Effects and the fullscreen effect renderer\n readonly createEffect: (engine: F[\"engine\"], options: GLEffectOptions) => F[\"effect\"];\n readonly useEffect: (effect: F[\"effect\"]) => void;\n readonly isEffectReady: (effect: F[\"effect\"]) => boolean;\n readonly getEffectCompilationError: (effect: F[\"effect\"]) => string | null;\n readonly executeWhenCompiled: (effect: F[\"effect\"], cb: (e: F[\"effect\"]) => void) => void;\n readonly disposeEffect: (effect: F[\"effect\"]) => void;\n readonly setEffectFloat: (effect: F[\"effect\"], name: string, x: number) => void;\n readonly setEffectFloat2: (effect: F[\"effect\"], name: string, x: number, y: number) => void;\n readonly setEffectFloat3: (effect: F[\"effect\"], name: string, x: number, y: number, z: number) => void;\n readonly setEffectFloat4: (effect: F[\"effect\"], name: string, x: number, y: number, z: number, w: number) => void;\n readonly setEffectColor3: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number }) => void;\n readonly setEffectColor4: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number; a: number }) => void;\n readonly setEffectVector2: (effect: F[\"effect\"], name: string, v: { x: number; y: number }) => void;\n readonly setEffectDirectColor4: (effect: F[\"effect\"], name: string, c: { r: number; g: number; b: number; a: number }) => void;\n readonly setEffectInt: (effect: F[\"effect\"], name: string, x: number) => void;\n readonly setEffectTexture: (effect: F[\"effect\"], samplerName: string, tex: F[\"texture\"] | F[\"noTexture\"]) => void;\n readonly setEffectMatrix: (effect: F[\"effect\"], name: string, matrix: F[\"floatArray\"]) => void;\n readonly setEffectMatrix3x3: (effect: F[\"effect\"], name: string, matrix: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray2: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray3: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectFloatArray4: (effect: F[\"effect\"], name: string, array: F[\"floatArray\"]) => void;\n readonly setEffectIntArray: (effect: F[\"effect\"], name: string, array: number[] | Int32Array) => void;\n readonly waitForEffect: (effect: F[\"effect\"], options?: F[\"effectWaitOptions\"]) => Promise<F[\"effect\"]>;\n readonly createEffectWrapper: (engine: F[\"engine\"], options: F[\"effectWrapperOptions\"]) => F[\"effectWrapper\"];\n readonly applyEffectWrapper: (wrapper: F[\"effectWrapper\"]) => boolean;\n readonly drawEffect: (engine: F[\"engine\"]) => void;\n readonly setViewport: (engine: F[\"engine\"], viewport?: GLViewport) => void;\n readonly disposeEffectWrapper: (wrapper: F[\"effectWrapper\"]) => void;\n\n // Textures\n readonly createRawTexture: (engine: F[\"engine\"], data: F[\"rawTextureData\"], width: number, height: number, options?: F[\"rawTextureOptions\"]) => F[\"texture\"];\n readonly createFloatTexture: (engine: F[\"engine\"], data: ArrayBufferView | null, width: number, height: number, options?: F[\"floatTextureOptions\"]) => F[\"texture\"];\n readonly generateTextureMipMaps: (tex: F[\"texture\"]) => void;\n readonly loadTexture2D: (engine: F[\"engine\"], url: string, options?: F[\"textureOptions\"], onLoad?: (tex: F[\"texture\"]) => void, onError?: (err: Error) => void) => F[\"texture\"];\n readonly bindTexture: (tex: F[\"texture\"], unit: number) => void;\n readonly unbindTexture: (engine: F[\"engine\"], unit: number) => void;\n readonly disposeTexture: (tex: F[\"texture\"]) => void;\n readonly updateRawTexture: (\n tex: F[\"texture\"],\n data: F[\"rawTextureData\"],\n options?: F[\"textureUpdateOptions\"] & { width?: number; height?: number; unpackAlignment?: number }\n ) => void;\n readonly updateTextureSamplingMode: (tex: F[\"texture\"], minFilter: number, magFilter: number) => void;\n readonly updateTextureSamplingPreset: (tex: F[\"texture\"], samplingMode: F[\"samplingMode\"], generateMipMaps?: boolean) => void;\n readonly updateTextureWrapMode: (tex: F[\"texture\"], wrapS: number, wrapT: number) => void;\n readonly getSamplingModeFilters: (samplingMode: F[\"samplingMode\"], useMipMaps?: boolean) => F[\"samplingFilters\"];\n readonly isTextureReady: (tex: F[\"texture\"]) => boolean;\n readonly createTexture3DFromPixels: (engine: F[\"engine\"], data: Uint8Array, width: number, height: number, depth: number, options?: F[\"texture3DOptions\"]) => F[\"texture3D\"];\n readonly bindTexture3D: (tex: F[\"texture3D\"], unit: number) => void;\n readonly unbindTexture3D: (engine: F[\"engine\"], unit: number) => void;\n readonly setEffectTexture3D: (effect: F[\"effect\"], samplerName: string, tex: F[\"texture3D\"] | F[\"noTexture\"]) => void;\n readonly generateTexture3DMipMaps: (tex: F[\"texture3D\"]) => void;\n readonly updateTexture3DSamplingMode: (tex: F[\"texture3D\"], minFilter: number, magFilter: number) => void;\n readonly updateTexture3DWrapMode: (tex: F[\"texture3D\"], wrapS: number, wrapT: number, wrapR: number) => void;\n readonly disposeTexture3D: (tex: F[\"texture3D\"]) => void;\n readonly createDynamicTexture: (engine: F[\"engine\"], width: number, height: number, options?: F[\"textureOptions\"]) => F[\"texture\"];\n\n // Render targets\n readonly createRenderTarget: (engine: F[\"engine\"], width: number, height: number, options?: F[\"renderTargetOptions\"]) => GLRenderTargetOf<F>;\n readonly createFloatRenderTarget: (engine: F[\"engine\"], width: number, height: number, options?: F[\"floatRenderTargetOptions\"]) => GLRenderTargetOf<F>;\n readonly bindRenderTarget: (rt: GLRenderTargetOf<F>) => void;\n readonly restoreDefaultFramebuffer: (engine: F[\"engine\"]) => void;\n readonly presentRenderTarget: (target: GLRenderTargetOf<F>) => void;\n readonly generateRenderTargetMipMaps: (rt: GLRenderTargetOf<F>) => void;\n readonly resizeRenderTarget: (rt: GLRenderTargetOf<F>, width: number, height: number) => void;\n readonly readRenderTargetPixels: (rt: GLRenderTargetOf<F>, options?: F[\"readPixelsOptions\"]) => ArrayBufferView;\n readonly disposeRenderTarget: (rt: GLRenderTargetOf<F> | null | undefined) => void;\n\n // Meshes, buffers and instancing\n readonly createVertexBuffer: (engine: F[\"engine\"], data: Float32Array, ...args: F[\"vertexBufferArgs\"]) => F[\"vertexBuffer\"];\n readonly updateVertexBuffer: (vb: F[\"vertexBuffer\"], data: Float32Array, dstByteOffset?: number) => void;\n readonly createIndexBuffer: (engine: F[\"engine\"], data: Uint16Array | Uint32Array) => F[\"indexBuffer\"];\n readonly disposeBuffer: (buffer: F[\"vertexBuffer\"] | F[\"indexBuffer\"]) => void;\n readonly bindIndexBuffer: (ib: F[\"indexBuffer\"]) => void;\n readonly bindAttributes: (vb: F[\"vertexBuffer\"], descriptors: readonly F[\"attributeDescriptor\"][], effect: F[\"effect\"], computeStride?: boolean) => void;\n readonly bindAttributesCached: (vb: F[\"vertexBuffer\"], descriptors: readonly F[\"attributeDescriptor\"][], effect: F[\"effect\"], computeStride?: boolean) => void;\n readonly disableAttributeByIndex: (engine: F[\"engine\"], location: number) => void;\n readonly unbindAllAttributes: (engine: F[\"engine\"]) => void;\n readonly unbindInstanceAttributes: (engine: F[\"engine\"]) => void;\n readonly drawIndexed: (ib: F[\"indexBuffer\"], indexCount: number, indexStart?: number, instanceCount?: F[\"instanceCount\"]) => void;\n readonly createMeshVao: (\n engine: F[\"engine\"],\n vertexBuffers: readonly GLFamilyMeshVertexBuffer<F[\"vertexBuffer\"], F[\"attributeDescriptor\"]>[],\n indexBuffer: F[\"indexBuffer\"],\n effect: F[\"effect\"]\n ) => F[\"meshVao\"];\n readonly bindMeshVao: (vao: F[\"meshVao\"]) => void;\n readonly drawMesh: (vao: F[\"meshVao\"], instanceCount?: F[\"instanceCount\"], indexStart?: number, indexCount?: number) => void;\n readonly disposeMeshVao: (vao: F[\"meshVao\"]) => void;\n\n // Blend, depth, stencil, color mask, clear and scissor state\n readonly setBlendMode: (engine: F[\"engine\"], mode: F[\"blendMode\"]) => void;\n readonly setBlendState: (engine: F[\"engine\"], state: F[\"blendState\"]) => void;\n readonly disableBlend: (engine: F[\"engine\"]) => void;\n readonly setDepthState: (engine: F[\"engine\"], state: F[\"depthState\"]) => void;\n readonly setCullState: (engine: F[\"engine\"], enabled: boolean, face?: number) => void;\n readonly setStencilState: (engine: F[\"engine\"], state: F[\"stencilState\"]) => void;\n readonly setStencilOpSeparate: (engine: F[\"engine\"], face: number, state: F[\"stencilOpState\"]) => void;\n readonly setColorMask: (engine: F[\"engine\"], r: boolean, g: boolean, b: boolean, a: boolean) => void;\n readonly clearEngine: (engine: F[\"engine\"], options: GLClearOptions) => void;\n readonly generateRenderTargetStencil: (rt: GLRenderTargetOf<F>, options?: { depth?: boolean }) => void;\n /** Portable dimensions are nonnegative integers; a rectangle without area clips everything. */\n readonly setScissor: (engine: F[\"engine\"], x: number, y: number, width: number, height: number) => void;\n readonly disableScissor: (engine: F[\"engine\"]) => void;\n\n // Sprites\n readonly createSpriteRenderer: (engine: F[\"engine\"], options: F[\"spriteRendererOptions\"]) => F[\"spriteRenderer\"];\n readonly renderSprites: (\n renderer: F[\"spriteRenderer\"],\n sprites: readonly F[\"sprite\"][],\n deltaTime: number,\n viewMatrix: F[\"floatArray\"],\n projectionMatrix: F[\"floatArray\"]\n ) => void;\n readonly setSpriteRendererTexture: (renderer: F[\"spriteRenderer\"], texture: F[\"texture\"]) => void;\n readonly disposeSpriteRenderer: (renderer: F[\"spriteRenderer\"]) => void;\n\n // Text\n readonly loadFont: (url: string) => Promise<F[\"font\"]>;\n readonly createFontFromBuffer: (data: ArrayBuffer) => F[\"font\"];\n readonly extractGlyphCurves: (font: F[\"font\"], glyphIds: ReadonlySet<number>, target: Map<number, F[\"glyphCurves\"]>) => void;\n readonly cubicToQuadratics: (p0x: number, p0y: number, c1x: number, c1y: number, c2x: number, c2y: number, p1x: number, p1y: number) => [F[\"quadCurve\"], F[\"quadCurve\"]];\n readonly createGlyphStorage: (initial?: Map<string, Map<number, F[\"glyphCurves\"]>>) => F[\"glyphStorage\"];\n readonly updateGlyphStorage: (storage: F[\"glyphStorage\"], curveSetId: string, curves: ReadonlyMap<number, F[\"glyphCurves\"]>) => void;\n readonly disposeGlyphStorage: (storage: F[\"glyphStorage\"]) => void;\n readonly createTextData: (storage: F[\"glyphStorage\"], runs?: readonly F[\"glyphRun\"][]) => F[\"textData\"];\n readonly updateTextData: (data: F[\"textData\"], update: F[\"textDataUpdate\"]) => void;\n readonly disposeTextData: (data: F[\"textData\"]) => void;\n readonly createDefaultTextData: (\n font: F[\"font\"],\n fontSizePx: number,\n text: string,\n textColor?: readonly [number, number, number, number],\n options?: F[\"textLayoutOptions\"]\n ) => F[\"defaultTextData\"];\n readonly updateDefaultTextData: (data: F[\"defaultTextData\"], text: string, textColor?: readonly [number, number, number, number]) => void;\n readonly disposeDefaultTextData: (data: F[\"defaultTextData\"]) => void;\n readonly createTextLayer: (data: F[\"textData\"], options?: F[\"textLayerOptions\"]) => F[\"textLayer\"];\n readonly setTextLayerPosition: (layer: F[\"textLayer\"], x: number, y: number) => void;\n readonly createTextRenderer: (engine: F[\"engine\"], options: F[\"textRendererOptions\"]) => F[\"textRenderer\"];\n readonly renderText: (renderer: F[\"textRenderer\"]) => number;\n readonly isTextRendererReady: (renderer: F[\"textRenderer\"]) => boolean;\n readonly addTextRendererLayer: (renderer: F[\"textRenderer\"], layer: F[\"textLayer\"]) => void;\n readonly removeTextRendererLayer: (renderer: F[\"textRenderer\"], layer: F[\"textLayer\"]) => boolean;\n readonly registerTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly unregisterTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly disposeTextRenderer: (renderer: F[\"textRenderer\"]) => void;\n readonly setFontWeightOffset: (data: F[\"textData\"], run: number | F[\"glyphRun\"], offset: number) => void;\n}\n\n/** Name of a backend-neutral operation. */\nexport type GLOpName = keyof GLOps<GLFamily>;\n\n/** Type-only witness that lets TypeScript infer a kit's family. It is never set at runtime. */\nexport interface GLFamilyMarker<F extends GLFamily> {\n /** Never present at runtime. */\n readonly glFamily?: F;\n}\n\n/** The operations `K` of family `F`, as selected by a consumer and filled with a backend's exported functions. */\nexport type GLKit<F extends GLFamily, K extends GLOpName> = Pick<GLOps<F>, K> & GLFamilyMarker<F>;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GLEngineContext } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* Enable or disable synchronous framebuffer completeness checks. Enabled by
|
|
4
|
+
* default, so render-target creation, stencil attachment, resize and restore
|
|
5
|
+
* fail fast (and roll back) on an incomplete framebuffer — e.g. a missing or
|
|
6
|
+
* unsupported attachment that WebGL reports only through the status query.
|
|
7
|
+
* Sizes above `caps.maxTextureSize` are rejected separately, regardless of this
|
|
8
|
+
* setting. Each check is a
|
|
9
|
+
* `checkFramebufferStatus` GPU-process round trip; pass `false` to skip them
|
|
10
|
+
* (matching ThinEngine's render-target creation path) when the host already
|
|
11
|
+
* guarantees valid attachments. Affects subsequent framebuffer builds, not
|
|
12
|
+
* existing targets or per-frame draws.
|
|
13
|
+
*
|
|
14
|
+
* The setting survives cache wipes and context restoration. No-op on a
|
|
15
|
+
* lost/disposed engine.
|
|
16
|
+
*
|
|
17
|
+
* @param engine - The engine whose future framebuffer builds are validated.
|
|
18
|
+
* @param enabled - Whether to validate framebuffer completeness.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setFramebufferValidation(engine: GLEngineContext, enabled: boolean): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enable or disable synchronous framebuffer completeness checks. Enabled by
|
|
3
|
+
* default, so render-target creation, stencil attachment, resize and restore
|
|
4
|
+
* fail fast (and roll back) on an incomplete framebuffer — e.g. a missing or
|
|
5
|
+
* unsupported attachment that WebGL reports only through the status query.
|
|
6
|
+
* Sizes above `caps.maxTextureSize` are rejected separately, regardless of this
|
|
7
|
+
* setting. Each check is a
|
|
8
|
+
* `checkFramebufferStatus` GPU-process round trip; pass `false` to skip them
|
|
9
|
+
* (matching ThinEngine's render-target creation path) when the host already
|
|
10
|
+
* guarantees valid attachments. Affects subsequent framebuffer builds, not
|
|
11
|
+
* existing targets or per-frame draws.
|
|
12
|
+
*
|
|
13
|
+
* The setting survives cache wipes and context restoration. No-op on a
|
|
14
|
+
* lost/disposed engine.
|
|
15
|
+
*
|
|
16
|
+
* @param engine - The engine whose future framebuffer builds are validated.
|
|
17
|
+
* @param enabled - Whether to validate framebuffer completeness.
|
|
18
|
+
*/
|
|
19
|
+
export function setFramebufferValidation(engine, enabled) {
|
|
20
|
+
if (engine._isLost || engine._disposed) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
engine._skipFramebufferValidation = !enabled;
|
|
24
|
+
}
|
|
25
|
+
/** Throw if the currently bound framebuffer is incomplete, unless the engine
|
|
26
|
+
* opted out via {@link setFramebufferValidation}. @internal */
|
|
27
|
+
export function validateFramebuffer(engine, stencil) {
|
|
28
|
+
if (engine._skipFramebufferValidation) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const gl = engine.gl;
|
|
32
|
+
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
33
|
+
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
34
|
+
throw new Error(`lite-gl: render target framebuffer incomplete${stencil ? " after stencil attach" : ""} (status 0x${status.toString(16)})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=framebuffer-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framebuffer-validation.js","sourceRoot":"","sources":["../src/framebuffer-validation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAuB,EAAE,OAAgB;IAC9E,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrC,OAAO;IACX,CAAC;IACD,MAAM,CAAC,0BAA0B,GAAG,CAAC,OAAO,CAAC;AACjD,CAAC;AAED;gEACgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,MAAuB,EAAE,OAAgB;IACzE,IAAI,MAAM,CAAC,0BAA0B,EAAE,CAAC;QACpC,OAAO;IACX,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACzD,IAAI,MAAM,KAAK,EAAE,CAAC,oBAAoB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,gDAAgD,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,cAAc,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAChJ,CAAC;AACL,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\n\n/**\n * Enable or disable synchronous framebuffer completeness checks. Enabled by\n * default, so render-target creation, stencil attachment, resize and restore\n * fail fast (and roll back) on an incomplete framebuffer — e.g. a missing or\n * unsupported attachment that WebGL reports only through the status query.\n * Sizes above `caps.maxTextureSize` are rejected separately, regardless of this\n * setting. Each check is a\n * `checkFramebufferStatus` GPU-process round trip; pass `false` to skip them\n * (matching ThinEngine's render-target creation path) when the host already\n * guarantees valid attachments. Affects subsequent framebuffer builds, not\n * existing targets or per-frame draws.\n *\n * The setting survives cache wipes and context restoration. No-op on a\n * lost/disposed engine.\n *\n * @param engine - The engine whose future framebuffer builds are validated.\n * @param enabled - Whether to validate framebuffer completeness.\n */\nexport function setFramebufferValidation(engine: GLEngineContext, enabled: boolean): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n engine._skipFramebufferValidation = !enabled;\n}\n\n/** Throw if the currently bound framebuffer is incomplete, unless the engine\n * opted out via {@link setFramebufferValidation}. @internal */\nexport function validateFramebuffer(engine: GLEngineContext, stencil: boolean): void {\n if (engine._skipFramebufferValidation) {\n return;\n }\n const gl = engine.gl;\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`lite-gl: render target framebuffer incomplete${stencil ? \" after stencil attach\" : \"\"} (status 0x${status.toString(16)})`);\n }\n}\n"]}
|
package/html-texture.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* HTML element textures.
|
|
3
3
|
*
|
|
4
4
|
* Part of the public API via the `@babylonjs/lite-gl` barrel. The package is
|
|
5
|
-
* `sideEffects: false`, so consumers that don't
|
|
6
|
-
*
|
|
5
|
+
* `sideEffects: false`, so consumers that don't sample HTML elements
|
|
6
|
+
* tree-shake it out.
|
|
7
7
|
*/
|
|
8
8
|
import type { GLEngineContext } from "./context.js";
|
|
9
9
|
import { type GLTexture, type GLTextureOptions, type GLTextureUpdateOptions } from "./texture.js";
|
package/html-texture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-texture.js","sourceRoot":"","sources":["../src/html-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GAIjB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;0CAW0C;AAC1C,MAAM,UAAU,wBAAwB,CAAC,MAAuB,EAAE,OAAgE,EAAE,OAA0B;IAC1J,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,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,SA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E,KAAK;QAChB,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,qBAAqB,EAAE,oBAAoB;QAC3C,SAAS,EAAE,IAAI;KAClB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,CAAC;IACf,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;iFAWiF;AACjF,MAAM,UAAU,wBAAwB,CAAC,GAAc,EAAE,OAAgC;IACrF,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,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","sourcesContent":["/**\n * HTML element textures.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that don't
|
|
1
|
+
{"version":3,"file":"html-texture.js","sourceRoot":"","sources":["../src/html-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GAIjB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;0CAW0C;AAC1C,MAAM,UAAU,wBAAwB,CAAC,MAAuB,EAAE,OAAgE,EAAE,OAA0B;IAC1J,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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E,CAAC,UAAU;QACrB,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,qBAAqB,EAAE,oBAAoB;QAC3C,SAAS,EAAE,IAAI;KAClB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,CAAC;IACf,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;iFAWiF;AACjF,MAAM,UAAU,wBAAwB,CAAC,GAAc,EAAE,OAAgC;IACrF,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,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","sourcesContent":["/**\n * HTML element textures.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that don't sample HTML elements\n * tree-shake it out.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport {\n bindTextureForUpload,\n setTexImageSourceSize,\n setBoundTextureParams,\n setUnpackState,\n type GLTexture,\n type GLTextureOptions,\n type GLTextureUpdateOptions,\n} from \"./texture.js\";\n\n/** Create a texture backed by an `<canvas>` / `<img>` / `<video>` element.\n * The initial upload is performed immediately; call `updateHtmlElementTexture`\n * to re-upload after the source has changed.\n *\n * @param engine - The engine to create GL resources on.\n * @param element - The source element.\n * @param options - The shared {@link GLTextureOptions} (including `invertY`\n * and `premultiplyAlpha`), applied on creation, on every\n * `updateHtmlElementTexture` that omits them and on `webglcontextrestored`.\n * For Babylon-style presets spread `getSamplingModeFilters(...)`; for mipmaps\n * call `generateTextureMipMaps` once and every later update rebuilds the chain.\n * @returns The new {@link GLTexture}. */\nexport function createHtmlElementTexture(engine: GLEngineContext, element: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement, 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 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 const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiplyAlpha);\n bindTextureForUpload(target, tex.handle);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA8, g.RGBA, g.UNSIGNED_BYTE, element);\n setTexImageSourceSize(tex, element);\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: 1,\n height: 1,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _initializeParameters: initializeParameters,\n _wasReady: true,\n };\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Re-upload the texture from its source element — the counterpart of\n * Babylon's `HtmlElementTexture.update(invertY)`. Only valid for textures\n * created by {@link createHtmlElementTexture}. No-op when the context is\n * lost/disposed or the texture is disposed.\n *\n * `invertY` is always the raw `UNPACK_FLIP_Y_WEBGL` value. Babylon flips\n * video elements with `!invertY`, so port `videoTexture.update(invertY)` as\n * `{ invertY: !invertY }` (canvas / image calls map directly).\n *\n * @param tex - A texture created by {@link createHtmlElementTexture}.\n * @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to\n * the texture's creation value. Retained for `webglcontextrestored` replay. */\nexport function updateHtmlElementTexture(tex: GLTexture, options?: GLTextureUpdateOptions): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n tex._invertY = options?.invertY;\n tex._premultiplyAlpha = options?.premultiplyAlpha;\n tex._upload(engine);\n}\n"]}
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type { GLEffectOptions, GLViewport, GLClearOptions } from "./family.js";
|
|
2
2
|
export type { WebGLFamily, WebGLHostOps } from "./web-family.js";
|
|
3
|
-
export { createGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeGLStateCache, getRenderWidth, getRenderHeight, getTextureCount, getCurrentRenderTarget, getHardwareScalingLevel, setHardwareScalingLevel, getRenderingCanvas, onContextLost, offContextLost, onContextRestored, offContextRestored, } from "./context.js";
|
|
3
|
+
export { createGLEngine, createHostOwnedGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeGLStateCache, getRenderWidth, getRenderHeight, getTextureCount, getCurrentRenderTarget, getHardwareScalingLevel, setHardwareScalingLevel, getRenderingCanvas, onContextLost, offContextLost, onContextRestored, offContextRestored, } from "./context.js";
|
|
4
4
|
export type { GLEngineOptions, GLEngineCaps, GLEngineContext } from "./context.js";
|
|
5
|
+
export { setFramebufferValidation } from "./framebuffer-validation.js";
|
|
5
6
|
export { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from "./alpha-to-coverage.js";
|
|
6
7
|
export { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from "./render-loop.js";
|
|
7
8
|
export { captureGPUFrameTime, getGPUFrameTimeCounter } from "./gpu-frame-time.js";
|
|
@@ -21,7 +22,7 @@ export type { GLPixelsTexture3DOptions, GLTexture3D } from "./texture-3d.js";
|
|
|
21
22
|
export { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from "./dynamic-texture.js";
|
|
22
23
|
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, restoreDefaultFramebuffer, presentRenderTarget, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, readRenderTargetPixelsToBuffer, disposeRenderTarget, } from "./render-target.js";
|
|
23
24
|
export type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions, GLReadPixelsRegionOptions, GLReadPixelsOptions, GLReadPixelsToBufferOptions, } from "./render-target.js";
|
|
24
|
-
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
25
|
+
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, bindAttributesCached, disableAttributeByIndex, unbindAllAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
25
26
|
export type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from "./mesh.js";
|
|
26
27
|
export { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from "./blend.js";
|
|
27
28
|
export type { GLBlendState } from "./blend.js";
|
package/index.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// so a consumer that imports only the symbols it needs tree-shakes everything
|
|
12
12
|
// else (sprites, html-texture, …) away.
|
|
13
13
|
// ─── Engine / context ────────────────────────────────────────────────
|
|
14
|
-
export { createGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeGLStateCache, getRenderWidth, getRenderHeight, getTextureCount, getCurrentRenderTarget, getHardwareScalingLevel, setHardwareScalingLevel, getRenderingCanvas, onContextLost, offContextLost, onContextRestored, offContextRestored, } from "./context.js";
|
|
14
|
+
export { createGLEngine, createHostOwnedGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeGLStateCache, getRenderWidth, getRenderHeight, getTextureCount, getCurrentRenderTarget, getHardwareScalingLevel, setHardwareScalingLevel, getRenderingCanvas, onContextLost, offContextLost, onContextRestored, offContextRestored, } from "./context.js";
|
|
15
|
+
export { setFramebufferValidation } from "./framebuffer-validation.js";
|
|
15
16
|
// ─── Alpha-to-coverage (optional) ───────────────────────────────────
|
|
16
17
|
export { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from "./alpha-to-coverage.js";
|
|
17
18
|
// ─── Render loop ─────────────────────────────────────────────────────
|
|
@@ -34,7 +35,7 @@ export { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource }
|
|
|
34
35
|
// ─── Render targets ──────────────────────────────────────────────────
|
|
35
36
|
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, restoreDefaultFramebuffer, presentRenderTarget, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, readRenderTargetPixelsToBuffer, disposeRenderTarget, } from "./render-target.js";
|
|
36
37
|
// ─── Meshes / buffers / instancing ───────────────────────────────────
|
|
37
|
-
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
38
|
+
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, bindAttributesCached, disableAttributeByIndex, unbindAllAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
38
39
|
// ─── Blend modes ─────────────────────────────────────────────────────
|
|
39
40
|
// GLBlendMode / GLBlendEquation are const + same-name type; one value
|
|
40
41
|
// re-export carries both.
|