import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js'; import type { CoreShaderProgram } from '../CoreShaderProgram.js'; import type { WebGlCtxTexture } from './WebGlCtxTexture.js'; import type { WebGlRenderer, WebGlRenderOp } from './WebGlRenderer.js'; import type { WebGlShaderType } from './WebGlShaderNode.js'; import type { BufferCollection } from './internal/BufferCollection.js'; import { CoreNode } from '../../CoreNode.js'; export declare class WebGlShaderProgram implements CoreShaderProgram { protected program: WebGLProgram | null; protected renderer: WebGlRenderer; protected glw: WebGlContextWrapper; protected attributeLocations: string[]; protected uniformLocations: Record | null; protected lifecycle: Pick; protected useSystemAlpha: boolean; protected useSystemDimensions: boolean; protected useTimeValue: boolean; isDestroyed: boolean; supportsIndexedTextures: boolean; /** * Shadow copies of this program's GL uniform state, used by * {@link bindRenderOp} to skip redundant gl.uniform* calls. * * @remarks * GL uniform values are state on the program object and persist across * useProgram switches, and bindRenderOp is the only writer of these * uniforms, so the shadows always mirror GL truth — even when ops using * other programs are interleaved between two ops of this program. * * `lastBoundUniforms` tracks the shader node's uniform collection by * identity: collections are created once, filled once, and shared by * reference across shader nodes with the same value key (see * WebGlShaderNode.update), so reference equality implies value equality. * The failure direction is safe — a new collection holding identical * values just causes a redundant upload, never a wrong skip. * * Sentinels: -1 never collides with real pixel ratios, resolutions, * alphas, dimensions, or time values (all >= 0). */ protected lastBoundUniforms: unknown; protected lastPixelRatio: number; protected lastResolutionW: number; protected lastResolutionH: number; protected lastAlpha: number; protected lastDimensionsW: number; protected lastDimensionsH: number; protected lastTime: number; /** * Cached Vertex Array Objects, keyed by the buffer collection they capture. * * @remarks * A VAO records this program's attribute layout (enabled arrays, pointers and * their source buffers) plus the shared element index buffer, so a draw only * needs a single `bindVertexArray` instead of re-pointing every attribute. In * practice a program only ever binds one collection, but keying by collection * keeps it correct if that ever changes. Empty / unused when the context has * no VAO support (see {@link WebGlContextWrapper.canUseVertexArrayObject}). */ protected vaos: Map; constructor(renderer: WebGlRenderer, config: WebGlShaderType, resolvedProps: Record); disableAttribute(location: number): void; disableAttributes(): void; reuseRenderOp(node: CoreNode, currentRenderOp: WebGlRenderOp): boolean; bindRenderOp(renderOp: WebGlRenderOp): void; bindBufferCollection(buffer: BufferCollection): void; /** * Point this program's vertex attributes at the given buffer collection. * When a VAO is bound this records into it; otherwise it mutates global state. */ private bindAttributes; /** * Create and populate a Vertex Array Object capturing this program's * attribute layout for the given buffer collection. The new VAO is left bound. * Returns null if the context reports VAO support but allocation fails (e.g. * under GL OOM), in which case the caller falls back to per-draw binding. */ private createVao; bindTextures(textures: WebGlCtxTexture[]): void; attach(): void; detach(): void; destroy(): void; }