PDA

View Full Version : Which OpenGL calls are expensive?



ViolentHamster
12-02-2009, 07:56 AM
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.

ZbuffeR
12-02-2009, 09:14 AM
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)
}

overlay
12-02-2009, 10:20 AM
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

Alfonse Reinheart
12-02-2009, 10:39 AM
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.

pjcozzi
12-02-2009, 10:44 AM
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

overlay
12-02-2009, 11:18 AM
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.