@pixi/core
Version:
Core PixiJS
114 lines (113 loc) • 4.58 kB
TypeScript
import type { ExtensionMetadata } from '@pixi/extensions';
import type { Dict } from '@pixi/utils';
import type { IRenderingContext } from '../IRenderer';
import type { Renderer } from '../Renderer';
import type { ISystem } from '../system/ISystem';
import type { GLProgram } from './GLProgram';
import type { Program } from './Program';
import type { Shader } from './Shader';
import type { UniformGroup } from './UniformGroup';
import type { UniformsSyncCallback } from './utils';
/**
* System plugin to the renderer to manage shaders.
* @memberof PIXI
*/
export declare class ShaderSystem implements ISystem {
/** @ignore */
static extension: ExtensionMetadata;
/**
* The current WebGL rendering context.
* @member {WebGLRenderingContext}
*/
protected gl: IRenderingContext;
shader: Shader;
program: Program;
id: number;
destroyed: boolean;
/** Cache to holds the generated functions. Stored against UniformObjects unique signature. */
private cache;
private _uboCache;
private renderer;
/** @param renderer - The renderer this System works for. */
constructor(renderer: Renderer);
/**
* Overrideable function by `@pixi/unsafe-eval` to silence
* throwing an error if platform doesn't support unsafe-evals.
* @private
*/
private systemCheck;
protected contextChange(gl: IRenderingContext): void;
/**
* Changes the current shader to the one given in parameter.
* @param shader - the new shader
* @param dontSync - false if the shader should automatically sync its uniforms.
* @returns the glProgram that belongs to the shader.
*/
bind(shader: Shader, dontSync?: boolean): GLProgram;
/**
* Uploads the uniforms values to the currently bound shader.
* @param uniforms - the uniforms values that be applied to the current shader
*/
setUniforms(uniforms: Dict<any>): void;
/**
* Syncs uniforms on the group
* @param group - the uniform group to sync
* @param syncData - this is data that is passed to the sync function and any nested sync functions
*/
syncUniformGroup(group: UniformGroup, syncData?: any): void;
/**
* Overrideable by the @pixi/unsafe-eval package to use static syncUniforms instead.
* @param group
* @param glProgram
* @param syncData
*/
syncUniforms(group: UniformGroup, glProgram: GLProgram, syncData: any): void;
createSyncGroups(group: UniformGroup): UniformsSyncCallback;
/**
* Syncs uniform buffers
* @param group - the uniform buffer group to sync
* @param name - the name of the uniform buffer
*/
syncUniformBufferGroup(group: UniformGroup, name?: string): void;
/**
* Will create a function that uploads a uniform buffer using the STD140 standard.
* The upload function will then be cached for future calls
* If a group is manually managed, then a simple upload function is generated
* @param group - the uniform buffer group to sync
* @param glProgram - the gl program to attach the uniform bindings to
* @param name - the name of the uniform buffer (must exist on the shader)
*/
protected createSyncBufferGroup(group: UniformGroup, glProgram: GLProgram, name: string): UniformsSyncCallback;
/**
* Takes a uniform group and data and generates a unique signature for them.
* @param group - The uniform group to get signature of
* @param group.uniforms
* @param uniformData - Uniform information generated by the shader
* @param preFix
* @returns Unique signature of the uniform group
*/
private getSignature;
/**
* Returns the underlying GLShade rof the currently bound shader.
*
* This can be handy for when you to have a little more control over the setting of your uniforms.
* @returns The glProgram for the currently bound Shader for this context
*/
getGlProgram(): GLProgram;
/**
* Generates a glProgram version of the Shader provided.
* @param shader - The shader that the glProgram will be based on.
* @returns A shiny new glProgram!
*/
generateProgram(shader: Shader): GLProgram;
/** Resets ShaderSystem state, does not affect WebGL state. */
reset(): void;
/**
* Disposes shader.
* If disposing one equals with current shader, set current as null.
* @param shader - Shader object
*/
disposeShader(shader: Shader): void;
/** Destroys this System and removes all its textures. */
destroy(): void;
}