Which OpenGL calls are expensive?

I used gDEbugger to dump all the OpenGL calls in a frame. I see some redundant GL calls that can be optimized out, but I’m not sure what GL calls are heavy weight. Should I worry about redundant enables/disables? Which OpenGL calls should I be worried about?

Thanks.

The enable/disable can be costly, as it switches things on the hardware pipeline. Depends on the driver implementation too.
I heard people had measurable perf improvements by doing the gl enable/disable only when needed, with something like :

gloabl boolean _texture_2D = false

func myGlEnableTexture2d {
if (_texture_2D) {
// do nothing
} else {
_texture_2D = true;
glEnable(GL_TEXTURE_2D)
}

See “SIGGRAPH 2003 Half-day Course - Performance OpenGL, Platform Independent Techniques”, page 58, second slide

http://www.performanceopengl.com/perfogl_s2003.pdf

From most expensive to least expensive state change:

1.Texture Download
2.Modifying Lighting
3.Parameters
4.Matrix Operations
5.Vertex Data

See “SIGGRAPH 2003 Half-day Course - Performance OpenGL, Platform Independent Techniques”, page 58, second slide

That’s over 6 years old. It means nothing in modern implementations.

Although this isn’t OpenGL specific, TomF gives some good advice and explanations here:

http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Renderstate%20change%20costs]]

Patrick

To “Alfonse Reinheart”:

All they say about state validation stage and cost(from page 53) is definitely still relevant and is actually similar to the remarks from the blog post that “pjcozzi” just gave.