1 | import type { ExtensionMetadata } from '@pixi/extensions';
|
2 | import type { Dict } from '@pixi/utils';
|
3 | import type { IRenderingContext } from '../IRenderer';
|
4 | import type { Renderer } from '../Renderer';
|
5 | import type { ISystem } from '../system/ISystem';
|
6 | import type { GLProgram } from './GLProgram';
|
7 | import type { Program } from './Program';
|
8 | import type { Shader } from './Shader';
|
9 | import type { UniformGroup } from './UniformGroup';
|
10 | import type { UniformsSyncCallback } from './utils';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export declare class ShaderSystem implements ISystem {
|
16 |
|
17 | static extension: ExtensionMetadata;
|
18 | |
19 |
|
20 |
|
21 |
|
22 | protected gl: IRenderingContext;
|
23 | shader: Shader;
|
24 | program: Program;
|
25 | id: number;
|
26 | destroyed: boolean;
|
27 |
|
28 | private cache;
|
29 | private _uboCache;
|
30 | private renderer;
|
31 |
|
32 | constructor(renderer: Renderer);
|
33 | /**
|
34 | * Overrideable function by `@pixi/unsafe-eval` to silence
|
35 | * throwing an error if platform doesn't support unsafe-evals.
|
36 | * @private
|
37 | */
|
38 | private systemCheck;
|
39 | protected contextChange(gl: IRenderingContext): void;
|
40 | /**
|
41 | * Changes the current shader to the one given in parameter.
|
42 | * @param shader - the new shader
|
43 | * @param dontSync - false if the shader should automatically sync its uniforms.
|
44 | * @returns the glProgram that belongs to the shader.
|
45 | */
|
46 | bind(shader: Shader, dontSync?: boolean): GLProgram;
|
47 | /**
|
48 | * Uploads the uniforms values to the currently bound shader.
|
49 | * @param uniforms - the uniforms values that be applied to the current shader
|
50 | */
|
51 | setUniforms(uniforms: Dict<any>): void;
|
52 | /**
|
53 | * Syncs uniforms on the group
|
54 | * @param group - the uniform group to sync
|
55 | * @param syncData - this is data that is passed to the sync function and any nested sync functions
|
56 | */
|
57 | syncUniformGroup(group: UniformGroup, syncData?: any): void;
|
58 | /**
|
59 | * Overrideable by the @pixi/unsafe-eval package to use static syncUniforms instead.
|
60 | * @param group
|
61 | * @param glProgram
|
62 | * @param syncData
|
63 | */
|
64 | syncUniforms(group: UniformGroup, glProgram: GLProgram, syncData: any): void;
|
65 | createSyncGroups(group: UniformGroup): UniformsSyncCallback;
|
66 | /**
|
67 | * Syncs uniform buffers
|
68 | * @param group - the uniform buffer group to sync
|
69 | * @param name - the name of the uniform buffer
|
70 | */
|
71 | syncUniformBufferGroup(group: UniformGroup, name?: string): void;
|
72 | /**
|
73 | * Will create a function that uploads a uniform buffer using the STD140 standard.
|
74 | * The upload function will then be cached for future calls
|
75 | * If a group is manually managed, then a simple upload function is generated
|
76 | * @param group - the uniform buffer group to sync
|
77 | * @param glProgram - the gl program to attach the uniform bindings to
|
78 | * @param name - the name of the uniform buffer (must exist on the shader)
|
79 | */
|
80 | protected createSyncBufferGroup(group: UniformGroup, glProgram: GLProgram, name: string): UniformsSyncCallback;
|
81 | /**
|
82 | * Takes a uniform group and data and generates a unique signature for them.
|
83 | * @param group - The uniform group to get signature of
|
84 | * @param group.uniforms
|
85 | * @param uniformData - Uniform information generated by the shader
|
86 | * @param preFix
|
87 | * @returns Unique signature of the uniform group
|
88 | */
|
89 | private getSignature;
|
90 | /**
|
91 | * Returns the underlying GLShade rof the currently bound shader.
|
92 | *
|
93 | * This can be handy for when you to have a little more control over the setting of your uniforms.
|
94 | * @returns The glProgram for the currently bound Shader for this context
|
95 | */
|
96 | getGlProgram(): GLProgram;
|
97 | /**
|
98 | * Generates a glProgram version of the Shader provided.
|
99 | * @param shader - The shader that the glProgram will be based on.
|
100 | * @returns A shiny new glProgram!
|
101 | */
|
102 | generateProgram(shader: Shader): GLProgram;
|
103 | /** Resets ShaderSystem state, does not affect WebGL state. */
|
104 | reset(): void;
|
105 | /**
|
106 | * Disposes shader.
|
107 | * If disposing one equals with current shader, set current as null.
|
108 | * @param shader - Shader object
|
109 | */
|
110 | disposeShader(shader: Shader): void;
|
111 | /** Destroys this System and removes all its textures. */
|
112 | destroy(): void;
|
113 | }
|