- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
import type { Dict } from '@pixi/utils';
/**
* @private
*/
export class IGLUniformData
{
location: WebGLUniformLocation;
value: number | boolean | Float32Array | Int32Array | Uint32Array | boolean[];
}
/**
* Helper class to create a WebGL Program
* @memberof PIXI
*/
export class GLProgram
{
/** The shader program. */
public program: WebGLProgram;
/**
* Holds the uniform data which contains uniform locations
* and current uniform values used for caching and preventing unneeded GPU commands.
*/
public uniformData: Dict<any>;
/**
* UniformGroups holds the various upload functions for the shader. Each uniform group
* and program have a unique upload function generated.
*/
public uniformGroups: Dict<any>;
/** A hash that stores where UBOs are bound to on the program. */
public uniformBufferBindings: Dict<any>;
/** A hash for lazily-generated uniform uploading functions. */
public uniformSync: Dict<any>;
/**
* A place where dirty ticks are stored for groups
* If a tick here does not match with the Higher level Programs tick, it means
* we should re upload the data.
*/
public uniformDirtyGroups: Dict<any>;
/**
* Makes a new Pixi program.
* @param program - webgl program
* @param uniformData - uniforms
*/
constructor(program: WebGLProgram, uniformData: {[key: string]: IGLUniformData})
{
this.program = program;
this.uniformData = uniformData;
this.uniformGroups = {};
this.uniformDirtyGroups = {};
this.uniformBufferBindings = {};
}
/** Destroys this program. */
destroy(): void
{
this.uniformData = null;
this.uniformGroups = null;
this.uniformDirtyGroups = null;
this.uniformBufferBindings = null;
this.program = null;
}
}