Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES 2: Uniforms and attributes

Tags:

opengl-es

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?

like image 409
demi Avatar asked Feb 24 '10 11:02

demi


1 Answers

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)

like image 130
kusma Avatar answered Dec 11 '22 08:12

kusma