@itwin/core-frontend
Version:
iTwin.js frontend components
139 lines • 5.53 kB
TypeScript
/** @packageDocumentation
* @module WebGL
*/
import { AttributeDetails } from "./AttributeMap";
import { WebGLDisposable } from "./Disposable";
import { DrawParams, ShaderProgramParams } from "./DrawCommand";
import { Batch, Branch } from "./Graphic";
import { UniformHandle } from "./UniformHandle";
import { RenderPass } from "./RenderFlags";
import { Target } from "./Target";
/** Flags which control some conditional branches in shader code
* @internal
*/
export declare const enum ShaderFlags {
None = 0,
Monochrome = 1,
NonUniformColor = 2,
OITFlatAlphaWeight = 4,
OITScaleOutput = 8,
IgnoreNonLocatable = 16
}
/** Describes the location of a uniform variable within a shader program.
* @internal
*/
export declare class Uniform {
private readonly _name;
protected _handle?: UniformHandle;
protected constructor(name: string);
compile(prog: ShaderProgram): boolean;
get isValid(): boolean;
}
/**
* A function associated with a ProgramUniform which is invoked each time the shader program becomes active.
* The function is responsible for setting the value of the uniform.
* @internal
*/
export type BindProgramUniform = (uniform: UniformHandle, params: ShaderProgramParams) => void;
/**
* Describes the location of a uniform variable within a shader program, the value of which does not change while the program is active.
* The supplied binding function will be invoked once each time the shader becomes active to set the value of the uniform.
* @internal
*/
export declare class ProgramUniform extends Uniform {
private readonly _bind;
constructor(name: string, bind: BindProgramUniform);
bind(params: ShaderProgramParams): void;
}
/**
* A function associated with a GraphicUniform which is invoked each time a new graphic primitive is rendered using the associated shader.
* The function is responsible for setting the value of the uniform.
* @internal
*/
export type BindGraphicUniform = (uniform: UniformHandle, params: DrawParams) => void;
/**
* Describes the location of a uniform variable within a shader program, the value of which is dependent upon the graphic primitive
* currently being rendered by the program. The supplied binding function will be invoked once for each graphic primitive submitted
* to the program to set the value of the uniform.
* @internal
*/
export declare class GraphicUniform extends Uniform {
private readonly _bind;
constructor(name: string, bind: BindGraphicUniform);
bind(params: DrawParams): void;
}
/** Describes the compilation status of a shader program. Programs may be compiled during idle time, or upon first use.
* @internal
*/
export declare const enum CompileStatus {
Success = 0,// The program was successfully compiled.
Failure = 1,// The program failed to compile.
Uncompiled = 2
}
/** @internal */
export declare class ShaderProgram implements WebGLDisposable {
vertSource: string;
fragSource: string;
private _glProgram?;
private _inUse;
private _status;
private readonly _programUniforms;
private readonly _graphicUniforms;
private readonly _attrMap?;
readonly description: string;
private _fragDescription;
private _vertGNdx;
private _fragGNdx;
private _vertHNdx;
private _fragHNdx;
readonly outputsToPick: boolean;
constructor(gl: WebGL2RenderingContext, vertSource: string, fragSource: string, attrMap: Map<string, AttributeDetails> | undefined, description: string, fragDescription: string);
get isDisposed(): boolean;
[Symbol.dispose](): void;
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */
dispose(): void;
get glProgram(): WebGLProgram | undefined;
get isUncompiled(): boolean;
get isCompiled(): boolean;
private compileShader;
private linkProgram;
compile(forUse?: boolean): CompileStatus;
use(params: ShaderProgramParams): boolean;
endUse(): void;
draw(params: DrawParams): void;
addProgramUniform(name: string, binding: BindProgramUniform): void;
addGraphicUniform(name: string, binding: BindGraphicUniform): void;
private compileUniforms;
private setDebugShaderUsage;
private saveShaderCode;
}
/** Context in which ShaderPrograms are executed. Avoids switching shaders unnecessarily.
* Ensures shader programs are compiled before use and un-bound when scope is disposed.
* Instances of this class must *only* be declared with the `using` keyword!
* @internal
*/
export declare class ShaderProgramExecutor {
private _program?;
private static _params?;
constructor(target: Target, pass: RenderPass, program?: ShaderProgram);
static freeParams(): void;
private _isDisposed;
get isDisposed(): boolean;
/** Clears the current program to be executed. This does not free WebGL resources, since those are owned by Techniques. */
[Symbol.dispose](): void;
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */
dispose(): void;
setProgram(program: ShaderProgram): boolean;
get isValid(): boolean;
get target(): Target;
get renderPass(): RenderPass;
get params(): ShaderProgramParams;
draw(params: DrawParams): void;
drawInterrupt(params: DrawParams): void;
pushBranch(branch: Branch): void;
popBranch(): void;
pushBatch(batch: Batch): void;
popBatch(): void;
private changeProgram;
}
//# sourceMappingURL=ShaderProgram.d.ts.map