View Full Version : When a call is really a redundant call...

01-29-2009, 08:51 PM
I am profiling my app at the moment looking for any untidy bits and pieces.

I am getting a massive amount of redundant call alerts. Many more than I expected, but on close examination I don't think they are..

But perhaps they are...

Basically I am using a lot of Buffer Objects, and AFAIK when you attach a buffer such as a GL_TEXTURE_COORD_ARRAY it is the act of setting the glTexCoordPointer to NULL that updates that with the currently bound buffer..

I am basing that on this from the glBufferObject OpenGL docs...

When vertex array pointer state is changed, for example by a call to glNormalPointer, the current buffer object binding (GL_ARRAY_BUFFER_BINDING) is copied into the corresponding client state for the vertex array type being changed, for example GL_NORMAL_ARRAY_BUFFER_BINDING. While a non-zero buffer object is bound to the GL_ARRAY_BUFFER target, the vertex array pointer parameter that is traditionally interpreted as a pointer to client-side memory is instead interpreted as an offset within the buffer object measured in basic machine units.

The setting of the TexCoordPointer to NULL in this case in a loop is showing as 100% redundant, but I am actually changing the Buffer it is bound to with an always NULL offset.

So I don't think it is redundant, even though it was previously set to NULL many times before in the same loop..

Obviously I could simply have offsets into that same buffer for sets of Texture Coords, and reduce Binding calls. I am aware of that, but I would still then have to call the Pointer parameter anyway to change the offset. What I want to know is am I right in mistrusting the profile in this specific case.

Can anyone else clarify for me?

01-30-2009, 02:17 AM
"Obviously I could simply have offsets into that same buffer for sets of Texture Coords, and reduce Binding calls"

best that worked for me is to sort my scenegraph nodes by the vertex data. then bind it once, render all, bind another once, render all and so on. this reduced redundant calls to 0.
sorry i cant help on the rudandancy thing here guess it highly depends on the application and architecture. if you profiling with GDEBugger i guess its ok to trust him but still double check. would like to know better.

01-30-2009, 03:11 AM
I agree I really shouldn't do so many bindings!

I have left it a while to tidy that up because it simply does not impact performance at the moment. About 2% of the overall OpenGL time.

Thanks for the feedback _NK47. If anyone can simply confirm my understanding is correct I'd be grateful.

It certainly seems to be, because if I remove the 'redundant' calls, and just set the pointer to NULL once at the beginning of the loop things start breaking!

01-30-2009, 09:11 AM
My understanding is exactly the same as yours scratt. Things also work this way in practice as well.