WebGL - Is the gl.useProgram() an expensive call to make?
opengl-es, webgl
Solution
- this says it's better to use `glUseProgram` than is to `glAttachShader`+`glLinkProgram`
- this says that changing shaders is always heavy, but `glUseProgram` is least heavy
- this says it's generally efficient
- this says that moderate and careful use won't become a bottleneck
- this talks a bit about shader-switching performance optimization
So, conslusion: use it moderately. If you don't have much objects - great, if you do - try optimizing shader switching, or reusing shaders multiple times, or use same shader that utilizes branching somehow.
`useProgram` has got medium performance hit. It's not super-light, neither it's super-heavy like `linkProgram` and `compileShader`.
Hope this helps.
Problem
I'm wondering if this API method used to load a shader program is expensive or not to call? Im considering making this call per object in my 3D scene. ``` gl.useProgram(shaderProgram); ``` thanks