It's well known that uniform and attributes are registers in GPU. And my question is what happens when different program bound? Does standard guarantee that previously set uniforms and/or attribute pointers will be reloaded or I need to reload them manually in any case? I want to create caching system. It seems for me that attributes are not reloaded (yes?) when program rebound and what about uniforms? Does GL ES driver reload their values for me?
No, it is not well-known that uniforms and attributes are registers in the GPU. In fact, it is wrong for at least in one widely-deployed OpenGL ES 2.0 GPU.
A uniform is zero unless explicitly initialized. The uniform values are states that follows the program object. In other words, if you set a uniform on a given program object, you CAN depend on the value being preserved across uses of the same program object, but you can not depend on a uniform at a given location being preserved across multiple program objects. In fact, an OpenGL ES implementation that does this would be in violation of the spec. This is not undefined behavior.
Attribute pointers are global context-state, and you CAN depend on these to be preserved between calls to the same OpenGL ES context. The same goes for current attribute values (set through the glVertexAttribute*-functions)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With