@babylonjs/lite-gl 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +5 -4
- package/blend.d.ts +1 -1
- package/blend.js +1 -1
- package/blend.js.map +1 -1
- package/context.d.ts +47 -4
- package/context.js +100 -11
- package/context.js.map +1 -1
- package/depth-stencil.d.ts +3 -2
- package/depth-stencil.js +10 -11
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +6 -3
- package/dynamic-texture.js +16 -4
- package/dynamic-texture.js.map +1 -1
- package/effect.d.ts +12 -3
- package/effect.js +35 -24
- package/effect.js.map +1 -1
- package/family.d.ts +5 -1
- package/family.js.map +1 -1
- package/framebuffer-validation.d.ts +20 -0
- package/framebuffer-validation.js +37 -0
- package/framebuffer-validation.js.map +1 -0
- package/html-texture.d.ts +2 -2
- package/html-texture.js.map +1 -1
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/mesh.d.ts +68 -14
- package/mesh.js +211 -61
- package/mesh.js.map +1 -1
- package/package.json +3 -3
- package/render-target.d.ts +11 -9
- package/render-target.js +50 -35
- package/render-target.js.map +1 -1
- package/scissor.d.ts +1 -1
- package/scissor.js.map +1 -1
- package/sprites.d.ts +5 -3
- package/sprites.js +24 -23
- package/sprites.js.map +1 -1
- package/state.d.ts +25 -13
- package/state.js +13 -10
- package/state.js.map +1 -1
- package/text/_gpu/text-instances.js +1 -1
- package/text/_gpu/text-instances.js.map +1 -1
- package/texture-3d.d.ts +2 -1
- package/texture-3d.js +7 -2
- package/texture-3d.js.map +1 -1
- package/texture-source.d.ts +4 -2
- package/texture-source.js +3 -2
- package/texture-source.js.map +1 -1
- package/texture.d.ts +18 -8
- package/texture.js +61 -35
- package/texture.js.map +1 -1
- package/web-family.d.ts +2 -1
- package/web-family.js.map +1 -1
package/mesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
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iEACiE;AACjE,SAAS,kBAAkB,CAAC,MAAuB,EAAE,MAAmB;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO;IACX,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Indexed meshes, dynamic vertex/index buffers, and hardware instancing.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that only render the fullscreen quad /\n * sprites tree-shake the mesh code out.\n *\n * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /\n * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /\n * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The\n * attribute binder reproduces Babylon's instancing semantics EXACTLY, including\n * the `computeStride = false → stride 0` \"sliding window\" used by ShapeBuilder's\n * tape buffers (consecutive instances read overlapping vec4 windows) and the\n * `divisor === undefined → 1` default.\n *\n * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds\n * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.\n * Vertex and index buffers retain their CPU data and re-upload automatically on\n * `webglcontextrestored`.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport { onContextRestored, offContextRestored } from \"./context.js\";\nimport { getEffectAttributeLocation, type GLEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** GL `gl.ARRAY_BUFFER`. */\nconst ARRAY_BUFFER = 0x8892;\n/** GL `gl.ELEMENT_ARRAY_BUFFER`. */\nconst ELEMENT_ARRAY_BUFFER = 0x8893;\n/** GL `gl.STATIC_DRAW`. */\nconst STATIC_DRAW = 0x88e4;\n/** GL `gl.DYNAMIC_DRAW`. */\nconst DYNAMIC_DRAW = 0x88e8;\n/** GL `gl.FLOAT`. */\nconst FLOAT = 0x1406;\n/** GL `gl.TRIANGLES`. */\nconst TRIANGLES = 0x0004;\n/** GL `gl.UNSIGNED_SHORT`. */\nconst UNSIGNED_SHORT = 0x1403;\n/** GL `gl.UNSIGNED_INT`. */\nconst UNSIGNED_INT = 0x1405;\n\n/** A GPU vertex buffer holding interleaved float vertex data. The lite-gl\n * counterpart of Babylon's `DataBuffer` for vertex data. */\nexport interface GLVertexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Size of the GL buffer in bytes. */\n byteLength: number;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay (the creation /\n * last full-buffer upload). */\n _data: Float32Array;\n /** @internal `true` for `DYNAMIC_DRAW` (updated via `updateVertexBuffer`). */\n _dynamic: boolean;\n}\n\n/** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for\n * index data. */\nexport interface GLIndexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Number of indices. */\n count: number;\n /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */\n is32Bits: boolean;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay. */\n _data: Uint16Array | Uint32Array;\n}\n\n/**\n * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of\n * Babylon's `InstancingAttributeInfo`. Pass an array of these to\n * {@link bindAttributes}.\n */\nexport interface GLAttributeDescriptor {\n /** Attribute name; resolved to a location via the effect when `index` is\n * omitted (`Effect.getAttributeLocationByName`). */\n name?: string;\n /** Explicit attribute location. When set, overrides the `name` lookup. */\n index?: number;\n /** Number of components, 1–4. */\n size: number;\n /** Byte offset of this attribute's first element within the buffer. Default 0. */\n offset?: number;\n /**\n * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,\n * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a\n * per-vertex attribute (e.g. the base mesh position).\n */\n divisor?: number;\n /** GL component type. Default `gl.FLOAT`. */\n type?: GLenum;\n /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */\n normalized?: boolean;\n}\n\n/* ──────────────────────────────── buffers ──────────────────────────────── */\n\n/**\n * Create a GPU vertex buffer from interleaved float data.\n *\n * @param engine - The engine.\n * @param data - The vertex data. Retained by reference for context-restore — do\n * not mutate it in place; use {@link updateVertexBuffer} to change contents.\n * @param dynamic - Hint that the buffer will be updated frequently\n * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).\n * @returns The new {@link GLVertexBuffer}.\n */\nexport function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic = false): GLVertexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (vertex buffer)\");\n }\n const vb: GLVertexBuffer = {\n handle,\n byteLength: data.byteLength,\n _data: data,\n _dynamic: dynamic,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n vb._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(vb.handle);\n };\n vb._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n vb.handle = fresh;\n bindArrayBufferRaw(target, fresh);\n g.bufferData(ARRAY_BUFFER, vb._data, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n };\n bindArrayBufferRaw(engine, handle);\n gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n engine._buffers.push(vb);\n return vb;\n}\n\n/**\n * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A\n * full-buffer update from offset 0 also refreshes the retained CPU data used\n * for context-restore.\n *\n * @param vb - The vertex buffer to update.\n * @param data - The new float data.\n * @param dstByteOffset - Destination byte offset within the buffer. Default 0.\n */\nexport function updateVertexBuffer(vb: GLVertexBuffer, data: Float32Array, dstByteOffset = 0): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed) {\n return;\n }\n bindArrayBufferRaw(engine, vb.handle);\n engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);\n if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {\n vb._data = data;\n vb.byteLength = data.byteLength;\n }\n}\n\n/**\n * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →\n * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite\n * VAO element bindings.\n *\n * @param engine - The engine.\n * @param data - The index data. Retained by reference for context-restore.\n * @returns The new {@link GLIndexBuffer}.\n */\nexport function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (index buffer)\");\n }\n const is32 = data instanceof Uint32Array;\n const ib: GLIndexBuffer = {\n handle,\n count: data.length,\n is32Bits: is32,\n _data: data,\n _engine: engine,\n _disposed: false,\n _deleteGpu: () => {},\n _restore: () => {},\n };\n ib._deleteGpu = (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(ib.handle);\n };\n ib._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n ib.handle = fresh;\n bindDefaultVao(target);\n g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);\n target._state.boundElementBuffer = fresh;\n g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data, STATIC_DRAW);\n };\n bindDefaultVao(engine);\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);\n engine._state.boundElementBuffer = handle;\n gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);\n engine._buffers.push(ib);\n return ib;\n}\n\n/** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears\n * the array/element-buffer cache slot if it pointed at this buffer. Idempotent. */\nexport function disposeBuffer(buffer: GLVertexBuffer | GLIndexBuffer): void {\n const engine = buffer._engine;\n if (buffer._disposed) {\n return;\n }\n buffer._disposed = true;\n const i = engine._buffers.indexOf(buffer);\n if (i !== -1) {\n engine._buffers.splice(i, 1);\n }\n const s = engine._state;\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteBuffer(buffer.handle);\n }\n if (s.boundArrayBuffer === buffer.handle) {\n s.boundArrayBuffer = null;\n }\n if (s.boundElementBuffer === buffer.handle) {\n s.boundElementBuffer = null;\n }\n}\n\n/* ────────────────────────────── binding + draw ──────────────────────────── */\n\n/**\n * Bind an index buffer as the current element-array buffer (on the default\n * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.\n *\n * @param ib - The index buffer to bind.\n */\nexport function bindIndexBuffer(ib: GLIndexBuffer): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n bindDefaultVao(engine);\n const s = engine._state;\n if (s.boundElementBuffer === ib.handle) {\n return;\n }\n engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);\n s.boundElementBuffer = ib.handle;\n}\n\n/**\n * Configure vertex attributes from `vb`, reproducing Babylon's\n * `bindInstancesBuffer` exactly. For each descriptor: resolves the location\n * (explicit `index` or via the effect), enables the attribute array, issues\n * `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`). Each\n * instanced location (divisor ≠ 0) is tracked once so {@link unbindInstanceAttributes}\n * can reset its divisor afterwards; per-vertex locations already have divisor 0 and are\n * not tracked, so callers that never instance can rebind every frame without growth.\n *\n * `computeStride` controls the GL stride passed to `vertexAttribPointer`:\n * - `false` (default) → stride `0`: each attribute is independently tightly\n * packed. Combined with overlapping `offset`s this yields the \"sliding window\"\n * ShapeBuilder uses for distance-field tape buffers.\n * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.\n *\n * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.\n * No-op on a lost/disposed context or before the effect is ready.\n *\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See above. Default `false`.\n */\nexport function bindAttributes(vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n if (!s.enabledAttribs[loc]) {\n gl.enableVertexAttribArray(loc);\n s.enabledAttribs[loc] = true;\n }\n gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);\n const divisor = d.divisor ?? 1;\n gl.vertexAttribDivisor(loc, divisor);\n if (divisor !== 0 && !s.instanceLocations.includes(loc)) {\n s.instanceLocations.push(loc);\n }\n }\n}\n\n/**\n * Reset the vertex divisor of every attribute touched by {@link bindAttributes}\n * back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.\n * Call after an instanced draw so a following non-instanced draw is not skewed.\n * No-op on a lost/disposed context.\n *\n * @param engine - The engine.\n */\nexport function unbindInstanceAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n const locs = engine._state.instanceLocations;\n for (let i = 0; i < locs.length; i++) {\n gl.vertexAttribDivisor(locs[i] as number, 0);\n }\n locs.length = 0;\n}\n\n/**\n * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's\n * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues\n * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed\n * context or when no program is current.\n *\n * @param ib - The index buffer (also bound as a side-effect, cached).\n * @param indexCount - Number of indices to draw.\n * @param indexStart - First index offset (in indices, not bytes). Default 0.\n * @param instanceCount - Instance count for instanced draws. Default 0\n * (non-instanced).\n */\nexport function drawIndexed(ib: GLIndexBuffer, indexCount: number, indexStart = 0, instanceCount = 0): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindIndexBuffer(ib);\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);\n applyGLStates(engine);\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, byteOffset);\n }\n}\n\n/* ────────────────────────── static mesh VAO ─────────────────────────────\n * The VAO-cached counterpart of the manual `bindAttributes` path above — Babylon's\n * `recordVertexArrayObject` / `_cachedVertexArrayObject` for STATIC meshes. A\n * `GLMeshVao` records the whole attribute layout (enable + pointer + divisor for\n * every attribute, across one or more vertex buffers) AND the index binding into a\n * single VAO ONCE. The per-frame draw is then just `bindVertexArray` +\n * `drawElements[Instanced]` — zero per-draw `vertexAttribPointer`/`vertexAttribDivisor`,\n * and no `unbindInstanceAttributes` (the VAO isolates the divisors from the default\n * VAO). Use this for fixed-layout meshes; keep `bindAttributes` for dynamic layouts\n * (e.g. ShapeBuilder's per-draw sliding-window tape buffers). */\n\n/** One vertex buffer + its attribute layout, for {@link createMeshVao}. */\nexport interface GLMeshVertexBuffer {\n /** The buffer supplying this group's attributes. */\n buffer: GLVertexBuffer;\n /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */\n attributes: readonly GLAttributeDescriptor[];\n /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`\n * per attribute; `true` → interleaved stride = Σ(`size`·4). */\n computeStride?: boolean;\n}\n\n/** A recorded Vertex Array Object capturing a static mesh's attribute layout +\n * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU\n * replays the entire attribute setup from one `bindVertexArray`. Re-recorded\n * automatically on `webglcontextrestored`. */\nexport interface GLMeshVao {\n /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */\n handle: WebGLVertexArrayObject;\n /** The engine that created (and owns) this VAO. Operations on it derive\n * their engine from here, so they take the VAO alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal The index buffer recorded into the VAO. */\n _indexBuffer: GLIndexBuffer;\n /** @internal Resolved attribute bindings, reused to re-record on restore. */\n _bindings: _ResolvedBinding[];\n /** @internal `webglcontextrestored` re-record hook. */\n _restore: () => void;\n}\n\n/** @internal A single attribute with its location resolved once at record time\n * (locations are stable across re-link via `bindAttribLocation`, so the VAO can\n * re-record on context-restore without the effect). */\ninterface _ResolvedAttr {\n loc: number;\n size: number;\n type: number;\n normalized: boolean;\n stride: number;\n offset: number;\n divisor: number;\n}\n\n/** @internal A vertex buffer + its resolved attributes. */\ninterface _ResolvedBinding {\n buffer: GLVertexBuffer;\n attrs: _ResolvedAttr[];\n}\n\n/**\n * Record a static mesh's attribute layout + index binding into a new VAO. The\n * effect MUST be ready (its attribute locations are resolved here, once). Returns\n * a {@link GLMeshVao} to draw with {@link drawMesh}.\n *\n * @param engine - The engine.\n * @param vertexBuffers - One or more buffers + their attribute layouts.\n * @param indexBuffer - The index buffer recorded into the VAO.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @returns The recorded {@link GLMeshVao}.\n */\nexport function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao {\n const gl = engine.gl;\n // The effect's attribute locations are resolved (once) below; an unready effect\n // would resolve every name to -1 → a silently-empty VAO. Fail fast — callers\n // must gate on isEffectReady (see scene10's first-ready-frame creation).\n if (!effect.isReady) {\n throw new Error(\"lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)\");\n }\n const handle = gl.createVertexArray();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null (mesh VAO)\");\n }\n // Resolve every attribute location ONCE (stable across re-link), so a restore\n // re-record needs only the buffer handles, not the effect.\n const bindings: _ResolvedBinding[] = [];\n for (const vbb of vertexBuffers) {\n let stride = 0;\n if (vbb.computeStride) {\n for (let i = 0; i < vbb.attributes.length; i++) {\n stride += (vbb.attributes[i] as GLAttributeDescriptor).size * 4;\n }\n }\n const attrs: _ResolvedAttr[] = [];\n for (let i = 0; i < vbb.attributes.length; i++) {\n const d = vbb.attributes[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n attrs.push({\n loc,\n size: d.size,\n type: d.type ?? FLOAT,\n normalized: d.normalized ?? false,\n stride,\n offset: d.offset ?? 0,\n divisor: d.divisor === undefined ? 1 : d.divisor,\n });\n }\n bindings.push({ buffer: vbb.buffer, attrs });\n }\n const vao: GLMeshVao = { handle, _engine: engine, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings, _restore: () => {} };\n vao._restore = (): void => {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const fresh = engine.gl.createVertexArray();\n if (fresh === null) {\n return;\n }\n vao.handle = fresh;\n recordMeshVao(engine, vao);\n };\n recordMeshVao(engine, vao);\n onContextRestored(engine, vao._restore);\n return vao;\n}\n\n/**\n * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —\n * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element\n * binding, so the element-buffer cache is updated in lock-step.\n *\n * @param vao - The mesh VAO to bind.\n */\nexport function bindMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const s = engine._state;\n if (s.boundVao === vao.handle) {\n return;\n }\n engine.gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n s.boundElementBuffer = vao._indexBuffer.handle;\n}\n\n/**\n * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),\n * flushes deferred GL state, and issues ONE `drawElements` (or\n * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index\n * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a\n * disposed VAO, or when no program is current.\n *\n * @param vao - The mesh VAO to draw.\n * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).\n * @param indexStart - First index in the retained mesh.\n * @param indexCount - Number of indices; defaults to the indices from `indexStart` to the end of the mesh.\n * @throws RangeError when the range is not whole indices within the mesh.\n */\nexport function drawMesh(vao: GLMeshVao, instanceCount = 0, indexStart = 0, indexCount = vao._indexBuffer.count - indexStart): void {\n const total = vao._indexBuffer.count;\n if (!Number.isInteger(indexStart) || !Number.isInteger(indexCount) || indexStart < 0 || indexCount < 0 || indexStart + indexCount > total) {\n throw new RangeError(`lite-gl: drawMesh range (start ${indexStart}, count ${indexCount}) must be whole indices within the mesh's ${total}`);\n }\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindMeshVao(vao);\n applyGLStates(engine);\n const ib = vao._indexBuffer;\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2), instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2));\n }\n}\n\n/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.\n * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */\nexport function disposeMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (vao._disposed) {\n return;\n }\n vao._disposed = true;\n offContextRestored(engine, vao._restore);\n if (!engine._isLost && !engine._disposed) {\n const s = engine._state;\n engine.gl.deleteVertexArray(vao.handle);\n if (s.boundVao === vao.handle) {\n // Return to the default VAO so the cache stays coherent.\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n }\n}\n\n/** @internal Record `vao._bindings` + the index binding into `vao.handle`. Leaves\n * the default (null) VAO bound afterwards (so the mesh VAO is not left current),\n * forgetting the element-buffer cache. Touches neither `s.enabledAttribs` (those\n * track the DEFAULT VAO) nor the divisor reset — all of that lives in the VAO. */\nfunction recordMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n const gl = engine.gl;\n const s = engine._state;\n gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n for (const b of vao._bindings) {\n bindArrayBufferRaw(engine, b.buffer.handle);\n for (const a of b.attrs) {\n gl.enableVertexAttribArray(a.loc);\n gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);\n gl.vertexAttribDivisor(a.loc, a.divisor);\n }\n }\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);\n gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Bind the default (null) VAO if not already bound. The mesh path lives here so\n * it never disturbs the quad / sprite VAO state. Binding a VAO restores ITS\n * element-array binding, so the element-buffer cache is forgotten on the\n * switch (the next `bindIndexBuffer` re-binds). */\nfunction bindDefaultVao(engine: GLEngineContext): void {\n const s = engine._state;\n if (s.boundVao !== null) {\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n}\n\n/** Cached `gl.bindBuffer(ARRAY_BUFFER, …)`. ARRAY_BUFFER binding is global (not\n * VAO state), so this cache is coherent across VAO switches. */\nfunction bindArrayBufferRaw(engine: GLEngineContext, handle: WebGLBuffer): void {\n const s = engine._state;\n if (s.boundArrayBuffer === handle) {\n return;\n }\n engine.gl.bindBuffer(ARRAY_BUFFER, handle);\n s.boundArrayBuffer = handle;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mesh.js","sourceRoot":"","sources":["../src/mesh.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAiB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,oCAAoC;AACpC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,2BAA2B;AAC3B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,4BAA4B;AAC5B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,qBAAqB;AACrB,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,yBAAyB;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,8BAA8B;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,4BAA4B;AAC5B,MAAM,YAAY,GAAG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AC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;YAChF,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;IACD,EAAE,CAAC,UAAU,CAAC,oBAAoB,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7D,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC;AAChC,CAAC;AAED,kFAAkF;AAElF;;;oDAGoD;AACpD,SAAS,cAAc,CAAC,MAAuB;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAChC,CAAC;AACL,CAAC;AAED;iEACiE;AACjE,SAAS,kBAAkB,CAAC,MAAuB,EAAE,MAAmB;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO;IACX,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Indexed meshes, dynamic vertex/index buffers, and hardware instancing.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that only render the fullscreen quad /\n * sprites tree-shake the mesh code out.\n *\n * This is the lite-gl equivalent of Babylon's `ThinEngine.createVertexBuffer` /\n * `createIndexBuffer` / `_releaseBuffer` / `bindIndexBuffer` /\n * `bindInstancesBuffer` / `unbindInstanceAttributes` / `drawElementsType`. The\n * attribute binder reproduces Babylon's instancing semantics EXACTLY, including\n * the `computeStride = false → stride 0` \"sliding window\" used by distance-field\n * tape buffers (consecutive instances read overlapping vec4 windows) and the\n * `divisor === undefined → 1` default.\n *\n * The mesh path runs on the DEFAULT (null) VAO — every buffer/attribute op binds\n * `gl.bindVertexArray(null)` first, so it never corrupts the quad / sprite VAOs.\n * Unless the engine is host-owned (`createHostOwnedGLEngine`), vertex/index buffers retain their CPU\n * data and re-upload automatically on `webglcontextrestored`.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport { onContextRestored, offContextRestored } from \"./context.js\";\nimport { getEffectAttributeLocation, type GLEffect } from \"./effect.js\";\nimport { applyGLStates } from \"./apply-states.js\";\n\n/** GL `gl.ARRAY_BUFFER`. */\nconst ARRAY_BUFFER = 0x8892;\n/** GL `gl.ELEMENT_ARRAY_BUFFER`. */\nconst ELEMENT_ARRAY_BUFFER = 0x8893;\n/** GL `gl.STATIC_DRAW`. */\nconst STATIC_DRAW = 0x88e4;\n/** GL `gl.DYNAMIC_DRAW`. */\nconst DYNAMIC_DRAW = 0x88e8;\n/** GL `gl.FLOAT`. */\nconst FLOAT = 0x1406;\n/** GL `gl.TRIANGLES`. */\nconst TRIANGLES = 0x0004;\n/** GL `gl.UNSIGNED_SHORT`. */\nconst UNSIGNED_SHORT = 0x1403;\n/** GL `gl.UNSIGNED_INT`. */\nconst UNSIGNED_INT = 0x1405;\n\n/** A GPU vertex buffer holding interleaved float vertex data. The lite-gl\n * counterpart of Babylon's `DataBuffer` for vertex data. */\nexport interface GLVertexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Size of the GL buffer in bytes. */\n byteLength: number;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore?: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay (the creation /\n * last full-buffer upload). */\n _data?: Float32Array;\n /** @internal `true` for `DYNAMIC_DRAW` (updated via `updateVertexBuffer`). */\n _dynamic: boolean;\n}\n\n/** A GPU index buffer. The lite-gl counterpart of Babylon's `DataBuffer` for\n * index data. */\nexport interface GLIndexBuffer {\n /** The live `WebGLBuffer`. Swapped on `webglcontextrestored`. */\n handle: WebGLBuffer;\n /** Number of indices. */\n count: number;\n /** `true` for 32-bit (`Uint32Array`) indices, `false` for 16-bit. */\n is32Bits: boolean;\n /** The engine that created (and owns) this buffer. Operations on it derive\n * their engine from here, so they take the buffer alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal Delete the underlying GL buffer. */\n _deleteGpu: (gl: WebGL2RenderingContext) => void;\n /** @internal Re-create + re-upload the retained CPU data into a fresh handle. */\n _restore?: (engine: GLEngineContext) => void;\n /** @internal Retained CPU data for context-restore replay. */\n _data?: Uint16Array | Uint32Array;\n}\n\n/**\n * Describes one vertex attribute fed from a buffer — the lite-gl equivalent of\n * Babylon's `InstancingAttributeInfo`. Pass an array of these to\n * {@link bindAttributes}.\n */\nexport interface GLAttributeDescriptor {\n /** Attribute name; resolved to a location via the effect when `index` is\n * omitted (`Effect.getAttributeLocationByName`). */\n name?: string;\n /** Explicit attribute location. When set, overrides the `name` lookup. */\n index?: number;\n /** Number of components, 1–4. */\n size: number;\n /** Byte offset of this attribute's first element within the buffer. Default 0. */\n offset?: number;\n /**\n * Per-instance vertex divisor. **Omitted/`undefined` → `1` (instanced)**,\n * matching Babylon's `bindInstancesBuffer`. Pass `0` explicitly for a\n * per-vertex attribute (e.g. the base mesh position).\n */\n divisor?: number;\n /** GL component type. Default `gl.FLOAT`. */\n type?: GLenum;\n /** Normalize fixed-point integer data to `[0,1]`/`[-1,1]`. Default `false`. */\n normalized?: boolean;\n}\n\n/* ──────────────────────────────── buffers ──────────────────────────────── */\n\n/**\n * Create a GPU vertex buffer from interleaved float data.\n *\n * @param engine - The engine.\n * @param data - The vertex data. Retained by reference unless the engine opts out of context restoration — do\n * not mutate it in place; use {@link updateVertexBuffer} to change contents.\n * @param dynamic - Hint that the buffer will be updated frequently\n * (`DYNAMIC_DRAW`). Default `false` (`STATIC_DRAW`).\n * @returns The new {@link GLVertexBuffer}.\n */\nexport function createVertexBuffer(engine: GLEngineContext, data: Float32Array, dynamic = false): GLVertexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (vertex buffer)\");\n }\n const vb: GLVertexBuffer = {\n handle,\n byteLength: data.byteLength,\n _dynamic: dynamic,\n _engine: engine,\n _disposed: false,\n _deleteGpu: (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(vb.handle);\n },\n };\n if (!engine._noRestore) {\n vb._data = data;\n vb._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n vb.handle = fresh;\n bindArrayBufferRaw(target, fresh);\n g.bufferData(ARRAY_BUFFER, vb._data!, vb._dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n };\n }\n bindArrayBufferRaw(engine, handle);\n gl.bufferData(ARRAY_BUFFER, data, dynamic ? DYNAMIC_DRAW : STATIC_DRAW);\n engine._buffers.push(vb);\n return vb;\n}\n\n/**\n * Upload new contents into (part of) a vertex buffer via `bufferSubData`. A\n * full-buffer update from offset 0 also refreshes the retained CPU data used\n * for context-restore unless the engine opts out. Neither mode copies the input.\n *\n * @param vb - The vertex buffer to update.\n * @param data - The new float data.\n * @param dstByteOffset - Destination byte offset within the buffer. Default 0.\n */\nexport function updateVertexBuffer(vb: GLVertexBuffer, data: Float32Array, dstByteOffset = 0): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed) {\n return;\n }\n bindArrayBufferRaw(engine, vb.handle);\n engine.gl.bufferSubData(ARRAY_BUFFER, dstByteOffset, data);\n if (dstByteOffset === 0 && data.byteLength >= vb.byteLength) {\n if (!engine._noRestore) {\n vb._data = data;\n }\n vb.byteLength = data.byteLength;\n }\n}\n\n/**\n * Create a GPU index buffer. `Uint16Array` → 16-bit indices, `Uint32Array` →\n * 32-bit. Binds the default VAO first so it never corrupts the quad / sprite\n * VAO element bindings.\n *\n * @param engine - The engine.\n * @param data - The index data. Retained by reference unless the engine opts out of context restoration.\n * @returns The new {@link GLIndexBuffer}.\n */\nexport function createIndexBuffer(engine: GLEngineContext, data: Uint16Array | Uint32Array): GLIndexBuffer {\n const gl = engine.gl;\n const handle = gl.createBuffer();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createBuffer returned null (index buffer)\");\n }\n const is32 = data instanceof Uint32Array;\n const ib: GLIndexBuffer = {\n handle,\n count: data.length,\n is32Bits: is32,\n _engine: engine,\n _disposed: false,\n _deleteGpu: (g: WebGL2RenderingContext): void => {\n g.deleteBuffer(ib.handle);\n },\n };\n if (!engine._noRestore) {\n ib._data = data;\n ib._restore = (target: GLEngineContext): void => {\n const g = target.gl;\n const fresh = g.createBuffer();\n if (fresh === null) {\n return;\n }\n ib.handle = fresh;\n bindDefaultVao(target);\n g.bindBuffer(ELEMENT_ARRAY_BUFFER, fresh);\n target._state.boundElementBuffer = fresh;\n g.bufferData(ELEMENT_ARRAY_BUFFER, ib._data!, STATIC_DRAW);\n };\n }\n bindDefaultVao(engine);\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, handle);\n engine._state.boundElementBuffer = handle;\n gl.bufferData(ELEMENT_ARRAY_BUFFER, data, STATIC_DRAW);\n engine._buffers.push(ib);\n return ib;\n}\n\n/** Dispose a vertex or index buffer (delete the GL buffer + unregister). Clears\n * the array/element-buffer cache slot if it pointed at this buffer and releases\n * retained upload/restore references in both recovery modes. Idempotent. */\nexport function disposeBuffer(buffer: GLVertexBuffer | GLIndexBuffer): void {\n const engine = buffer._engine;\n if (buffer._disposed) {\n return;\n }\n buffer._disposed = true;\n buffer._data = buffer._restore = undefined;\n const i = engine._buffers.indexOf(buffer);\n if (i !== -1) {\n engine._buffers.splice(i, 1);\n }\n const s = engine._state;\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteBuffer(buffer.handle);\n }\n if (s.boundArrayBuffer === buffer.handle) {\n s.boundArrayBuffer = null;\n }\n if (s.boundElementBuffer === buffer.handle) {\n s.boundElementBuffer = null;\n }\n for (let location = 0; location < s.enabledAttribs.length; location++) {\n if (s.enabledAttribs[location] === buffer.handle) {\n s.enabledAttribs[location] = true;\n }\n }\n}\n\n/* ────────────────────────────── binding + draw ──────────────────────────── */\n\n/**\n * Bind an index buffer as the current element-array buffer (on the default\n * VAO). Cached. The lite-gl equivalent of Babylon's `_bindIndexBufferWithCache`.\n *\n * @param ib - The index buffer to bind.\n */\nexport function bindIndexBuffer(ib: GLIndexBuffer): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n bindDefaultVao(engine);\n const s = engine._state;\n if (s.boundElementBuffer === ib.handle) {\n return;\n }\n engine.gl.bindBuffer(ELEMENT_ARRAY_BUFFER, ib.handle);\n s.boundElementBuffer = ib.handle;\n}\n\n/**\n * Configure vertex attributes from `vb`, reproducing Babylon's\n * `bindInstancesBuffer` exactly. For each descriptor: resolves the location\n * (explicit `index` or via the effect), enables the attribute array (cached),\n * issues `vertexAttribPointer`, and sets the vertex divisor (`undefined → 1`).\n * Each instanced location (divisor ≠ 0) is tracked once so {@link unbindInstanceAttributes}\n * can reset its divisor afterwards; per-vertex locations already have divisor 0 and are\n * not tracked, so callers that never instance can rebind every frame without growth.\n *\n * `computeStride` controls the GL stride passed to `vertexAttribPointer`:\n * - `false` (default) → stride `0`: each attribute is independently tightly\n * packed. Combined with overlapping `offset`s this yields the \"sliding window\"\n * used by distance-field tape buffers.\n * - `true` → stride = Σ(`size`·4 bytes): interleaved per-vertex/per-instance.\n *\n * Every call re-issues `vertexAttribPointer`. Callers that rebind an equivalent\n * layout every draw (e.g. a 2D shape renderer) should use {@link bindAttributesCached},\n * which elides unchanged pointers; the two can be mixed freely.\n *\n * Runs on the default (null) VAO — never corrupts the quad / sprite VAOs.\n * No-op on a lost/disposed context or before the effect is ready.\n *\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See above. Default `false`.\n */\nexport function bindAttributes(vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n if (!s.enabledAttribs[loc]) {\n gl.enableVertexAttribArray(loc);\n }\n // Enabled, but with a pointer bindAttributesCached must not trust.\n s.enabledAttribs[loc] = true;\n gl.vertexAttribPointer(loc, d.size, d.type ?? FLOAT, d.normalized ?? false, stride, d.offset ?? 0);\n const divisor = d.divisor ?? 1;\n gl.vertexAttribDivisor(loc, divisor);\n if (divisor !== 0 && !s.instanceLocations.includes(loc)) {\n s.instanceLocations.push(loc);\n }\n }\n}\n\n/**\n * {@link bindAttributes} with a default-VAO attribute cache: `vertexAttribPointer`\n * is issued only when a location's (buffer handle, size, type, normalized,\n * stride, offset) tuple changes, and `vertexAttribDivisor` only when its divisor\n * changes, so rebinding an equivalent layout every draw (e.g. per-shape binds in a\n * 2D shape renderer) issues no attribute calls. Divisors are tracked through\n * `instanceLocations`, so {@link unbindInstanceAttributes} needs no cache code.\n * Semantics, parameters and no-op conditions are\n * otherwise identical to {@link bindAttributes}.\n *\n * The cache (4 numbers per `MAX_VERTEX_ATTRIBS` location) is allocated once on\n * the first effective call; later binds allocate nothing. Disabling an\n * attribute, {@link bindAttributes}, cache wipes/resets and context loss\n * invalidate the affected tuples, and a recreated buffer handle never matches\n * a stale one. Named VAOs keep independent state.\n *\n * @param vb - The buffer supplying the attribute data.\n * @param descriptors - The attribute layout.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @param computeStride - See {@link bindAttributes}. Default `false`.\n */\nexport function bindAttributesCached(vb: GLVertexBuffer, descriptors: readonly GLAttributeDescriptor[], effect: GLEffect, computeStride = false): void {\n const engine = vb._engine;\n if (engine._isLost || engine._disposed || vb._disposed || !effect.isReady) {\n return;\n }\n const gl = engine.gl;\n const s = engine._state;\n bindDefaultVao(engine);\n bindArrayBufferRaw(engine, vb.handle);\n const values = (s._attributePointers ??= new Float64Array((gl.getParameter(gl.MAX_VERTEX_ATTRIBS) as number) * 4));\n\n let stride = 0;\n if (computeStride) {\n for (let i = 0; i < descriptors.length; i++) {\n stride += (descriptors[i] as GLAttributeDescriptor).size * 4;\n }\n }\n\n for (let i = 0; i < descriptors.length; i++) {\n const d = descriptors[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n const enabled = s.enabledAttribs[loc];\n if (!enabled) {\n gl.enableVertexAttribArray(loc);\n }\n const type = d.type ?? FLOAT;\n const normalized = d.normalized ?? false;\n const offset = d.offset ?? 0;\n // A GLenum fits in 32 bits; packing the valid 1..4 size and normalize\n // flag leaves one exact (53-bit) number instead of three cache slots.\n const format = type * 16 + d.size * 2 + +normalized;\n const slot = loc * 4;\n if (enabled !== vb.handle || values[slot] !== format || values[slot + 1] !== stride || values[slot + 2] !== offset) {\n gl.vertexAttribPointer(loc, d.size, type, normalized, stride, offset);\n values[slot] = format;\n values[slot + 1] = stride;\n values[slot + 2] = offset;\n }\n const divisor = d.divisor ?? 1;\n // While this binder owns the location (a buffer handle, not `true`/null),\n // every non-zero divisor it sets is listed in instanceLocations, and only\n // unbindInstanceAttributes (which resets listed divisors to 0) or a cache\n // reset (which also drops ownership) clears that list. An owned, unlisted\n // location therefore has divisor 0; a listed one has the cached divisor.\n const listed = s.instanceLocations.includes(loc);\n if (!enabled || enabled === true || (listed ? values[slot + 3] : 0) !== divisor) {\n gl.vertexAttribDivisor(loc, divisor);\n values[slot + 3] = divisor;\n if (divisor !== 0 && !listed) {\n s.instanceLocations.push(loc);\n }\n }\n s.enabledAttribs[loc] = vb.handle;\n }\n}\n\n/**\n * Disable an enabled attribute on the default VAO, eliding redundant calls.\n * Leaves its divisor unchanged, like ThinEngine's `disableAttributeByIndex`;\n * use {@link unbindInstanceAttributes} for divisor cleanup. Named VAOs are\n * untouched. No-op on a lost/disposed engine. The enable cache is cleared on\n * context loss or cache reset, so subsequent binds replay their enables. After\n * a plain `wipeGLStateCache`, a location lite-gl has not confirmed\n * disabled is treated as unknown (the host may have enabled it) and is disabled.\n *\n * @param engine - The engine.\n * @param location - The attribute location to disable.\n */\nexport function disableAttributeByIndex(engine: GLEngineContext, location: number): void {\n const s = engine._state;\n const enabled = s.enabledAttribs[location];\n // `-1` is the \"optimized out\" sentinel from `getAttribLocation`: always a no-op.\n if (location < 0 || engine._isLost || engine._disposed || (s._unknownAttribs ? enabled === null : !enabled)) {\n return;\n }\n bindDefaultVao(engine);\n engine.gl.disableVertexAttribArray(location);\n s.enabledAttribs[location] = null;\n}\n\n/**\n * Disable all enabled default-VAO attributes in ascending location order.\n * Cached across frames and allocation-free; named VAOs and instance divisors\n * are unchanged (ThinEngine's `unbindAllAttributes` semantics). No-op on a\n * lost/disposed engine. Context loss/cache reset clears the enable cache;\n * subsequent {@link bindAttributes} calls replay their enables. The first call\n * after a plain `wipeGLStateCache` disables every location up to\n * `MAX_VERTEX_ATTRIBS` once, since the host may have enabled any of them.\n *\n * @param engine - The engine.\n */\nexport function unbindAllAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const s = engine._state;\n const count = s._unknownAttribs ? (engine.gl.getParameter(engine.gl.MAX_VERTEX_ATTRIBS) as number) : s.enabledAttribs.length;\n for (let location = 0; location < count; location++) {\n disableAttributeByIndex(engine, location);\n }\n s._unknownAttribs = false;\n}\n\n/**\n * Reset the vertex divisor of every attribute touched by {@link bindAttributes}\n * or {@link bindAttributesCached} back to 0 — the lite-gl equivalent of Babylon's `unbindInstanceAttributes`.\n * Call after an instanced draw so a following non-instanced draw is not skewed.\n * The divisors are reset on the default VAO (selected if a named VAO is bound),\n * where these binders set them. No-op on a lost/disposed context.\n *\n * @param engine - The engine.\n */\nexport function unbindInstanceAttributes(engine: GLEngineContext): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n const locs = engine._state.instanceLocations;\n if (locs.length === 0) {\n return;\n }\n // The listed divisors live on the default VAO; a named VAO bound since then\n // owns its own divisors and must not be reset.\n bindDefaultVao(engine);\n const gl = engine.gl;\n for (let i = 0; i < locs.length; i++) {\n gl.vertexAttribDivisor(locs[i] as number, 0);\n }\n locs.length = 0;\n}\n\n/**\n * Draw indexed triangles from `ib` — the lite-gl equivalent of Babylon's\n * `drawElementsType` (triangle fill mode). When `instanceCount > 0` issues\n * `drawElementsInstanced`, otherwise `drawElements`. No-op on a lost/disposed\n * context or when no program is current.\n *\n * @param ib - The index buffer (also bound as a side-effect, cached).\n * @param indexCount - Number of indices to draw.\n * @param indexStart - First index offset (in indices, not bytes). Default 0.\n * @param instanceCount - Instance count for instanced draws. Default 0\n * (non-instanced).\n */\nexport function drawIndexed(ib: GLIndexBuffer, indexCount: number, indexStart = 0, instanceCount = 0): void {\n const engine = ib._engine;\n if (engine._isLost || engine._disposed || ib._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindIndexBuffer(ib);\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n const byteOffset = indexStart * (ib.is32Bits ? 4 : 2);\n applyGLStates(engine);\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, byteOffset, instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, byteOffset);\n }\n}\n\n/* ────────────────────────── static mesh VAO ─────────────────────────────\n * The VAO-cached counterpart of the manual `bindAttributes` path above — Babylon's\n * `recordVertexArrayObject` / `_cachedVertexArrayObject` for STATIC meshes. A\n * `GLMeshVao` records the whole attribute layout (enable + pointer + divisor for\n * every attribute, across one or more vertex buffers) AND the index binding into a\n * single VAO ONCE. The per-frame draw is then just `bindVertexArray` +\n * `drawElements[Instanced]` — zero per-draw `vertexAttribPointer`/`vertexAttribDivisor`,\n * and no `unbindInstanceAttributes` (the VAO isolates the divisors from the default\n * VAO). Use this for fixed-layout meshes; keep `bindAttributes` for dynamic layouts\n * (e.g. per-draw sliding-window tape buffers). */\n\n/** One vertex buffer + its attribute layout, for {@link createMeshVao}. */\nexport interface GLMeshVertexBuffer {\n /** The buffer supplying this group's attributes. */\n buffer: GLVertexBuffer;\n /** The attributes read from `buffer` (same shape as {@link bindAttributes}). */\n attributes: readonly GLAttributeDescriptor[];\n /** Stride mode (see {@link bindAttributes}): `false` (default) → stride `0`\n * per attribute; `true` → interleaved stride = Σ(`size`·4). */\n computeStride?: boolean;\n}\n\n/** A recorded Vertex Array Object capturing a static mesh's attribute layout +\n * index binding. Bind + draw it with {@link drawMesh} each frame — the GPU\n * replays the entire attribute setup from one `bindVertexArray`. Re-recorded\n * automatically on `webglcontextrestored` unless the engine is host-owned\n * (`createHostOwnedGLEngine`). */\nexport interface GLMeshVao {\n /** The live `WebGLVertexArrayObject`. Swapped on `webglcontextrestored`. */\n handle: WebGLVertexArrayObject;\n /** The engine that created (and owns) this VAO. Operations on it derive\n * their engine from here, so they take the VAO alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal The index buffer recorded into the VAO. */\n _indexBuffer: GLIndexBuffer;\n /** @internal Resolved attribute bindings, reused to re-record on restore. */\n _bindings: _ResolvedBinding[];\n /** @internal `webglcontextrestored` re-record hook. */\n _restore?: () => void;\n}\n\n/** @internal A single attribute with its location resolved once at record time\n * (locations are stable across re-link via `bindAttribLocation`, so the VAO can\n * re-record on context-restore without the effect). */\ninterface _ResolvedAttr {\n loc: number;\n size: number;\n type: number;\n normalized: boolean;\n stride: number;\n offset: number;\n divisor: number;\n}\n\n/** @internal A vertex buffer + its resolved attributes. */\ninterface _ResolvedBinding {\n buffer: GLVertexBuffer;\n attrs: _ResolvedAttr[];\n}\n\n/**\n * Record a static mesh's attribute layout + index binding into a new VAO. The\n * effect MUST be ready (its attribute locations are resolved here, once). Returns\n * a {@link GLMeshVao} to draw with {@link drawMesh}.\n *\n * @param engine - The engine.\n * @param vertexBuffers - One or more buffers + their attribute layouts.\n * @param indexBuffer - The index buffer recorded into the VAO.\n * @param effect - The effect whose attribute locations resolve unnamed indices.\n * @returns The recorded {@link GLMeshVao}.\n */\nexport function createMeshVao(engine: GLEngineContext, vertexBuffers: readonly GLMeshVertexBuffer[], indexBuffer: GLIndexBuffer, effect: GLEffect): GLMeshVao {\n const gl = engine.gl;\n // The effect's attribute locations are resolved (once) below; an unready effect\n // would resolve every name to -1 → a silently-empty VAO. Fail fast — callers\n // must gate on isEffectReady (see scene10's first-ready-frame creation).\n if (!effect.isReady) {\n throw new Error(\"lite-gl: createMeshVao requires a ready effect (poll isEffectReady first)\");\n }\n const handle = gl.createVertexArray();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createVertexArray returned null (mesh VAO)\");\n }\n // Resolve every attribute location ONCE (stable across re-link), so a restore\n // re-record needs only the buffer handles, not the effect.\n const bindings: _ResolvedBinding[] = [];\n for (const vbb of vertexBuffers) {\n let stride = 0;\n if (vbb.computeStride) {\n for (let i = 0; i < vbb.attributes.length; i++) {\n stride += (vbb.attributes[i] as GLAttributeDescriptor).size * 4;\n }\n }\n const attrs: _ResolvedAttr[] = [];\n for (let i = 0; i < vbb.attributes.length; i++) {\n const d = vbb.attributes[i] as GLAttributeDescriptor;\n const loc = d.index !== undefined ? d.index : d.name !== undefined ? getEffectAttributeLocation(effect, d.name) : -1;\n if (loc < 0) {\n continue;\n }\n attrs.push({\n loc,\n size: d.size,\n type: d.type ?? FLOAT,\n normalized: d.normalized ?? false,\n stride,\n offset: d.offset ?? 0,\n divisor: d.divisor === undefined ? 1 : d.divisor,\n });\n }\n bindings.push({ buffer: vbb.buffer, attrs });\n }\n const vao: GLMeshVao = { handle, _engine: engine, _disposed: false, _indexBuffer: indexBuffer, _bindings: bindings };\n if (!engine._noRestore) {\n vao._restore = (): void => {\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const fresh = engine.gl.createVertexArray();\n if (fresh === null) {\n return;\n }\n vao.handle = fresh;\n recordMeshVao(engine, vao);\n };\n onContextRestored(engine, vao._restore);\n }\n recordMeshVao(engine, vao);\n if (engine._noRestore) {\n bindings.length = 0;\n }\n return vao;\n}\n\n/**\n * Bind a {@link GLMeshVao} (cached `gl.bindVertexArray`). Rarely called directly —\n * {@link drawMesh} binds it for you. Binding restores the VAO's recorded element\n * binding, so the element-buffer cache is updated in lock-step.\n *\n * @param vao - The mesh VAO to bind.\n */\nexport function bindMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n const s = engine._state;\n if (s.boundVao === vao.handle) {\n return;\n }\n engine.gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n s.boundElementBuffer = vao._indexBuffer.handle;\n}\n\n/**\n * Draw a static mesh recorded with {@link createMeshVao}: binds its VAO (cached),\n * flushes deferred GL state, and issues ONE `drawElements` (or\n * `drawElementsInstanced` when `instanceCount > 0`) over the VAO's full index\n * buffer. No per-draw attribute (re)binding. No-op on a lost/disposed context, a\n * disposed VAO, or when no program is current.\n *\n * @param vao - The mesh VAO to draw.\n * @param instanceCount - Instance count for instanced draws. Default 0 (non-instanced).\n * @param indexStart - First index in the retained mesh.\n * @param indexCount - Number of indices; defaults to the indices from `indexStart` to the end of the mesh.\n * @throws RangeError when the range is not whole indices within the mesh.\n */\nexport function drawMesh(vao: GLMeshVao, instanceCount = 0, indexStart = 0, indexCount = vao._indexBuffer.count - indexStart): void {\n const total = vao._indexBuffer.count;\n if (!Number.isInteger(indexStart) || !Number.isInteger(indexCount) || indexStart < 0 || indexCount < 0 || indexStart + indexCount > total) {\n throw new RangeError(`lite-gl: drawMesh range (start ${indexStart}, count ${indexCount}) must be whole indices within the mesh's ${total}`);\n }\n const engine = vao._engine;\n if (engine._isLost || engine._disposed || vao._disposed) {\n return;\n }\n if (engine._state.currentProgram === null) {\n return;\n }\n bindMeshVao(vao);\n applyGLStates(engine);\n const ib = vao._indexBuffer;\n const gl = engine.gl;\n const type = ib.is32Bits ? UNSIGNED_INT : UNSIGNED_SHORT;\n if (instanceCount > 0) {\n gl.drawElementsInstanced(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2), instanceCount);\n } else {\n gl.drawElements(TRIANGLES, indexCount, type, indexStart * (ib.is32Bits ? 4 : 2));\n }\n}\n\n/** Dispose a {@link GLMeshVao}: delete the VAO and unregister its restore hook.\n * Does NOT dispose the vertex/index buffers (the caller owns those). Idempotent. */\nexport function disposeMeshVao(vao: GLMeshVao): void {\n const engine = vao._engine;\n if (vao._disposed) {\n return;\n }\n vao._disposed = true;\n if (vao._restore) {\n offContextRestored(engine, vao._restore);\n }\n if (!engine._isLost && !engine._disposed) {\n const s = engine._state;\n engine.gl.deleteVertexArray(vao.handle);\n if (s.boundVao === vao.handle) {\n // Return to the default VAO so the cache stays coherent.\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n }\n}\n\n/** @internal Record `vao._bindings` + the index binding into `vao.handle`. Leaves\n * the default (null) VAO bound afterwards (so the mesh VAO is not left current),\n * forgetting the element-buffer cache. Touches neither `s.enabledAttribs` (those\n * track the DEFAULT VAO) nor the divisor reset — all of that lives in the VAO. */\nfunction recordMeshVao(engine: GLEngineContext, vao: GLMeshVao): void {\n const gl = engine.gl;\n const s = engine._state;\n gl.bindVertexArray(vao.handle);\n s.boundVao = vao.handle;\n for (const b of vao._bindings) {\n bindArrayBufferRaw(engine, b.buffer.handle);\n for (const a of b.attrs) {\n gl.enableVertexAttribArray(a.loc);\n gl.vertexAttribPointer(a.loc, a.size, a.type, a.normalized, a.stride, a.offset);\n gl.vertexAttribDivisor(a.loc, a.divisor);\n }\n }\n gl.bindBuffer(ELEMENT_ARRAY_BUFFER, vao._indexBuffer.handle);\n gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n}\n\n/* ──────────────────────────── internal helpers ──────────────────────────── */\n\n/** Bind the default (null) VAO if not already bound. The mesh path lives here so\n * it never disturbs the quad / sprite VAO state. Binding a VAO restores ITS\n * element-array binding, so the element-buffer cache is forgotten on the\n * switch (the next `bindIndexBuffer` re-binds). */\nfunction bindDefaultVao(engine: GLEngineContext): void {\n const s = engine._state;\n if (s.boundVao !== null) {\n engine.gl.bindVertexArray(null);\n s.boundVao = null;\n s.boundElementBuffer = null;\n }\n}\n\n/** Cached `gl.bindBuffer(ARRAY_BUFFER, …)`. ARRAY_BUFFER binding is global (not\n * VAO state), so this cache is coherent across VAO switches. */\nfunction bindArrayBufferRaw(engine: GLEngineContext, handle: WebGLBuffer): void {\n const s = engine._state;\n if (s.boundArrayBuffer === handle) {\n return;\n }\n engine.gl.bindBuffer(ARRAY_BUFFER, handle);\n s.boundArrayBuffer = handle;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/lite-gl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "Function-based, tree-shakeable WebGL2 micro-engine for fullscreen effects, sprites and dynamic textures — the WebGL counterpart of @babylonjs/lite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babylon",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"babylonLiteRelease": {
|
|
46
|
-
"azureBuildId": "
|
|
47
|
-
"sourceVersion": "
|
|
46
|
+
"azureBuildId": "165221199",
|
|
47
|
+
"sourceVersion": "8c00303e30cdbb2ac623d9707e8f1bab894c09d8"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"tag": "latest"
|
package/render-target.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* carries the `RGBA16F` / `RGBA32F` table, so RGBA8 consumers tree-shake it
|
|
20
20
|
* away).
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Unless the engine is host-owned (`createHostOwnedGLEngine`), the full color/depth/stencil GPU set is rebuilt automatically on
|
|
23
23
|
* `webglcontextrestored` — the render target registers itself with the engine's
|
|
24
24
|
* `_renderTargets` registry, and the context-restore protocol calls its
|
|
25
25
|
* `_restore` closure AFTER the standalone texture replay. A caller-supplied
|
|
@@ -133,13 +133,14 @@ export interface GLRenderTarget {
|
|
|
133
133
|
* caller-managed (BYO) one. Mirrors Babylon's `createRenderTargetTexture`.
|
|
134
134
|
*
|
|
135
135
|
* @param engine - The engine to allocate GL resources on.
|
|
136
|
-
* @param width - Color attachment width in texels. Must be a positive integer.
|
|
137
|
-
* @param height - Color attachment height in texels. Must be a positive integer.
|
|
136
|
+
* @param width - Color attachment width in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
137
|
+
* @param height - Color attachment height in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
138
138
|
* @param options - See {@link GLRenderTargetOptions}.
|
|
139
139
|
* @returns The new {@link GLRenderTarget}.
|
|
140
140
|
* @throws If `format` is not `RGBA` / `RG` / `RED`, `width`/`height` are not
|
|
141
|
-
* positive integers
|
|
142
|
-
* framebuffer is not complete
|
|
141
|
+
* positive integers up to `caps.maxTextureSize`, a GL handle could not be allocated, or the resulting
|
|
142
|
+
* framebuffer is not complete (unless `setFramebufferValidation(engine, false)`
|
|
143
|
+
* opted out of completeness checks). On failure every partial GPU object (including
|
|
143
144
|
* an owned color texture) is released first.
|
|
144
145
|
*/
|
|
145
146
|
export declare function createRenderTarget(engine: GLEngineContext, width: number, height: number, options?: GLRenderTargetOptions): GLRenderTarget;
|
|
@@ -154,8 +155,8 @@ export declare function createRenderTarget(engine: GLEngineContext, width: numbe
|
|
|
154
155
|
* supports (mirroring Babylon's `getTextureType`).
|
|
155
156
|
*
|
|
156
157
|
* @param engine - The engine to allocate GL resources on.
|
|
157
|
-
* @param width - Color attachment width in texels. Must be a positive integer.
|
|
158
|
-
* @param height - Color attachment height in texels. Must be a positive integer.
|
|
158
|
+
* @param width - Color attachment width in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
159
|
+
* @param height - Color attachment height in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
159
160
|
* @param options - See {@link GLFloatRenderTargetOptions}.
|
|
160
161
|
* @returns The new {@link GLRenderTarget}.
|
|
161
162
|
* @throws As {@link createRenderTarget}.
|
|
@@ -199,8 +200,9 @@ export declare function generateRenderTargetMipMaps(rt: GLRenderTarget): void;
|
|
|
199
200
|
* restore hook.
|
|
200
201
|
*
|
|
201
202
|
* @param rt - The render target to resize.
|
|
202
|
-
* @param width - New width in texels (
|
|
203
|
-
* @param height - New height in texels (
|
|
203
|
+
* @param width - New width in texels (1 to `caps.maxTextureSize`).
|
|
204
|
+
* @param height - New height in texels (1 to `caps.maxTextureSize`).
|
|
205
|
+
* @throws If the size is invalid; the target keeps its current size.
|
|
204
206
|
*/
|
|
205
207
|
export declare function resizeRenderTarget(rt: GLRenderTarget, width: number, height: number): void;
|
|
206
208
|
/**
|
package/render-target.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* carries the `RGBA16F` / `RGBA32F` table, so RGBA8 consumers tree-shake it
|
|
20
20
|
* away).
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Unless the engine is host-owned (`createHostOwnedGLEngine`), the full color/depth/stencil GPU set is rebuilt automatically on
|
|
23
23
|
* `webglcontextrestored` — the render target registers itself with the engine's
|
|
24
24
|
* `_renderTargets` registry, and the context-restore protocol calls its
|
|
25
25
|
* `_restore` closure AFTER the standalone texture replay. A caller-supplied
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* there first; the RT then re-attaches its freshly-swapped handle.
|
|
28
28
|
*/
|
|
29
29
|
import { bindTextureForUpload, pickSizedInternalFormat, resolveLdrInternalFormat, setBoundTextureParams } from "./texture.js";
|
|
30
|
+
import { validateFramebuffer } from "./framebuffer-validation.js";
|
|
30
31
|
/**
|
|
31
32
|
* Presents a retained composition target to the whole canvas without disturbing
|
|
32
33
|
* its contents; an active scissor rectangle does not clip the presentation.
|
|
@@ -40,10 +41,6 @@ export function presentRenderTarget(target) {
|
|
|
40
41
|
}
|
|
41
42
|
const gl = engine.gl;
|
|
42
43
|
const s = engine._state;
|
|
43
|
-
// A wiped cache records the canvas binding whatever is actually bound, so that binding is reissued.
|
|
44
|
-
if (s.boundFramebuffer === null) {
|
|
45
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
46
|
-
}
|
|
47
44
|
restoreDefaultFramebuffer(engine);
|
|
48
45
|
// Queried with the canvas framebuffer bound; its sample count is fixed when the context is created.
|
|
49
46
|
engine._canvasSamples ??= Number(gl.getParameter(gl.SAMPLES));
|
|
@@ -90,13 +87,14 @@ const CLAMP_TO_EDGE = 0x812f;
|
|
|
90
87
|
* caller-managed (BYO) one. Mirrors Babylon's `createRenderTargetTexture`.
|
|
91
88
|
*
|
|
92
89
|
* @param engine - The engine to allocate GL resources on.
|
|
93
|
-
* @param width - Color attachment width in texels. Must be a positive integer.
|
|
94
|
-
* @param height - Color attachment height in texels. Must be a positive integer.
|
|
90
|
+
* @param width - Color attachment width in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
91
|
+
* @param height - Color attachment height in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
95
92
|
* @param options - See {@link GLRenderTargetOptions}.
|
|
96
93
|
* @returns The new {@link GLRenderTarget}.
|
|
97
94
|
* @throws If `format` is not `RGBA` / `RG` / `RED`, `width`/`height` are not
|
|
98
|
-
* positive integers
|
|
99
|
-
* framebuffer is not complete
|
|
95
|
+
* positive integers up to `caps.maxTextureSize`, a GL handle could not be allocated, or the resulting
|
|
96
|
+
* framebuffer is not complete (unless `setFramebufferValidation(engine, false)`
|
|
97
|
+
* opted out of completeness checks). On failure every partial GPU object (including
|
|
100
98
|
* an owned color texture) is released first.
|
|
101
99
|
*/
|
|
102
100
|
export function createRenderTarget(engine, width, height, options) {
|
|
@@ -118,8 +116,8 @@ export function createRenderTarget(engine, width, height, options) {
|
|
|
118
116
|
* supports (mirroring Babylon's `getTextureType`).
|
|
119
117
|
*
|
|
120
118
|
* @param engine - The engine to allocate GL resources on.
|
|
121
|
-
* @param width - Color attachment width in texels. Must be a positive integer.
|
|
122
|
-
* @param height - Color attachment height in texels. Must be a positive integer.
|
|
119
|
+
* @param width - Color attachment width in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
120
|
+
* @param height - Color attachment height in texels. Must be a positive integer up to `caps.maxTextureSize`.
|
|
123
121
|
* @param options - See {@link GLFloatRenderTargetOptions}.
|
|
124
122
|
* @returns The new {@link GLRenderTarget}.
|
|
125
123
|
* @throws As {@link createRenderTarget}.
|
|
@@ -195,15 +193,16 @@ export function generateRenderTargetMipMaps(rt) {
|
|
|
195
193
|
* restore hook.
|
|
196
194
|
*
|
|
197
195
|
* @param rt - The render target to resize.
|
|
198
|
-
* @param width - New width in texels (
|
|
199
|
-
* @param height - New height in texels (
|
|
196
|
+
* @param width - New width in texels (1 to `caps.maxTextureSize`).
|
|
197
|
+
* @param height - New height in texels (1 to `caps.maxTextureSize`).
|
|
198
|
+
* @throws If the size is invalid; the target keeps its current size.
|
|
200
199
|
*/
|
|
201
200
|
export function resizeRenderTarget(rt, width, height) {
|
|
202
201
|
const engine = rt._engine;
|
|
203
202
|
if (rt._disposed) {
|
|
204
203
|
return;
|
|
205
204
|
}
|
|
206
|
-
validateSize(width, height);
|
|
205
|
+
validateSize(engine, width, height);
|
|
207
206
|
if (rt.width === width && rt.height === height) {
|
|
208
207
|
return;
|
|
209
208
|
}
|
|
@@ -383,7 +382,7 @@ export function disposeRenderTarget(rt) {
|
|
|
383
382
|
* the owned-or-BYO color texture, allocates the GPU set atomically, and
|
|
384
383
|
* registers the target. */
|
|
385
384
|
function buildRT(engine, width, height, options, internalFormat, format, type) {
|
|
386
|
-
validateSize(width, height);
|
|
385
|
+
validateSize(engine, width, height);
|
|
387
386
|
const gl = engine.gl;
|
|
388
387
|
const byo = options.colorTexture;
|
|
389
388
|
const config = {
|
|
@@ -423,7 +422,6 @@ function buildRT(engine, width, height, options, internalFormat, format, type) {
|
|
|
423
422
|
_engine: engine,
|
|
424
423
|
_disposed: false,
|
|
425
424
|
_deleteGpu: () => { },
|
|
426
|
-
_restore: () => { },
|
|
427
425
|
};
|
|
428
426
|
rt._deleteGpu = (glc) => {
|
|
429
427
|
const s = engine._state;
|
|
@@ -448,15 +446,29 @@ function buildRT(engine, width, height, options, internalFormat, format, type) {
|
|
|
448
446
|
rt.texture.isReady = false;
|
|
449
447
|
rt.isReady = false;
|
|
450
448
|
};
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
449
|
+
if (!engine._noRestore) {
|
|
450
|
+
rt._restore = (target) => {
|
|
451
|
+
// Resilient: a restore failure must not break the engine's restore loop.
|
|
452
|
+
try {
|
|
453
|
+
// The restored context may support a smaller size; fail before
|
|
454
|
+
// re-specifying storage and leave the target not ready.
|
|
455
|
+
validateSize(target, rt.width, rt.height);
|
|
456
|
+
const tex = rt.texture;
|
|
457
|
+
// A BYO raw texture replays its last upload; apply a resize made
|
|
458
|
+
// during loss before reattaching it (contents discarded, as in resize).
|
|
459
|
+
if (!config.ownsColorTexture && (tex.width !== rt.width || tex.height !== rt.height)) {
|
|
460
|
+
tex._updateRaw?.(target, null, rt.width, rt.height, 4);
|
|
461
|
+
}
|
|
462
|
+
allocateRenderTargetGpu(target, rt);
|
|
463
|
+
}
|
|
464
|
+
catch (err) {
|
|
465
|
+
// Loss leaves the flag set; a target whose rebuild failed must not
|
|
466
|
+
// report ready over its dead framebuffer.
|
|
467
|
+
rt.isReady = false;
|
|
468
|
+
console.error("lite-gl: render target restore failed", err);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
460
472
|
allocateRenderTargetGpu(engine, rt);
|
|
461
473
|
engine._renderTargets.push(rt);
|
|
462
474
|
return rt;
|
|
@@ -473,15 +485,20 @@ function resolveColorType(engine, type) {
|
|
|
473
485
|
}
|
|
474
486
|
return type;
|
|
475
487
|
}
|
|
476
|
-
/** Validate a render-target size is a pair of positive integers
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
488
|
+
/** Validate a render-target size is a pair of positive integers within the
|
|
489
|
+
* engine's `MAX_TEXTURE_SIZE`. Checked before any storage is (re)specified:
|
|
490
|
+
* WebGL rejects an oversized `texImage2D` without throwing, and a caller-owned
|
|
491
|
+
* color texture would keep its old storage, completing the framebuffer at the
|
|
492
|
+
* wrong size. */
|
|
493
|
+
function validateSize(engine, width, height) {
|
|
494
|
+
const max = engine.caps.maxTextureSize;
|
|
495
|
+
if (!Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1 || width > max || height > max) {
|
|
496
|
+
throw new Error(`lite-gl: render target size must be positive integers up to ${max}, got ${width}x${height}`);
|
|
480
497
|
}
|
|
481
498
|
}
|
|
482
499
|
/**
|
|
483
500
|
* (Re)allocate the color texture (iff owned), framebuffer and depth/stencil
|
|
484
|
-
* renderbuffer into fresh handles, attach them, and validate completeness.
|
|
501
|
+
* renderbuffer into fresh handles, attach them, and validate completeness (unless opted out).
|
|
485
502
|
* Shared by create / resize / context-restore. No-op on a lost/disposed context.
|
|
486
503
|
*
|
|
487
504
|
* ATOMIC: captures the previously-bound framebuffer and restores it in a
|
|
@@ -496,7 +513,8 @@ function allocateRenderTargetGpu(engine, rt) {
|
|
|
496
513
|
const gl = engine.gl;
|
|
497
514
|
const s = engine._state;
|
|
498
515
|
const c = rt._config;
|
|
499
|
-
|
|
516
|
+
// An unknown (wiped) binding is restored as the canvas.
|
|
517
|
+
const prevFb = s.boundFramebuffer ?? null;
|
|
500
518
|
let createdTexture = null;
|
|
501
519
|
let fb = null;
|
|
502
520
|
let rb = null;
|
|
@@ -546,10 +564,7 @@ function allocateRenderTargetGpu(engine, rt) {
|
|
|
546
564
|
}
|
|
547
565
|
// A helper-attached stencil replaces/augments the depth-only buffer.
|
|
548
566
|
rt._rebuildDepthStencil?.(engine);
|
|
549
|
-
|
|
550
|
-
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
551
|
-
throw new Error(`lite-gl: render target framebuffer incomplete (status 0x${status.toString(16)})`);
|
|
552
|
-
}
|
|
567
|
+
validateFramebuffer(engine, false);
|
|
553
568
|
rt.isReady = true;
|
|
554
569
|
}
|
|
555
570
|
catch (e) {
|