Reputation: 6726
I have some parameters being passed from CPU to GPU that are constant for all fragments but which change on every frame (I'm using GLSL ES 1.1). Should I use uniforms or attributes for such values? Attributes can vary from vertex to vertex so my intuition is that using attributes for values that are constant across the entire frame would be inefficient. However, I've read that uniforms are for values which change "relatively infrequently", suggesting that changing uniforms on every frame might be inefficient.
In terms of hardware, I'm most interested in optimizing for the iPhone 4S.
Upvotes: 30
Views: 16329
Reputation: 11961
I vote for uniforms.
One of the reasons is already explained in your question: uniforms are constants for each vertex/fragment.
Other reasons to prefer uniforms against attributes would be:
Upvotes: 35