Reputation: 54
Let's say I have a very simple GLSL vertex shader:
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
in vec3 position;
in vec3 color;
out vec3 vertexColor;
void main()
{
mat4 mvp = projection * view * model;
vertexColor = color;
gl_Position = mvp * vec4(position, 1.0);
}
Is the variable mvp
recalculated for every vertex, or is it precalculated and stored until the the uniform variables it depends on change?
Upvotes: 3
Views: 565
Reputation: 474436
Could a particular implementation cache that value? Sure. Will they?
I would not assume that they would. Such caching would be difficult to implement, since it requires evaluating such expressions before draw calls, based on uniform state, then uploading those expressions to the code.
If you have some state that is computed from multiple uniform values, and you believe that such computation would be a performance problem, you are the one who should compute it.
Upvotes: 6