PDA

View Full Version : GLSL & VBO



yooyo
05-13-2004, 08:46 AM
Hi,

Im confused about interaction of this two extensions. Problem is in custom vertex attributes...

When setup some VBO I also setup standard vertex attribute pointers (pos, norm, color, texcoord).

In render stage, I bind some VBO and all pointers for this VBO are already prepared (no need to setup pointers again).

But, whats happend with custom vertex attributes in GLSL? For example I have several GLSL vert&frag programs for static geometry. Should I setup this custom vertex attribute pointers for each shader? Is this pointers safe from VBO switching?

yooyo

ps... soory for by bad english...

V-man
05-13-2004, 10:29 AM
But, whats happend with custom vertex attributes in GLSL? For example I have several GLSL vert&frag programs for static geometry. Should I setup this custom vertex attribute pointers for each shader? Is this pointers safe from VBO switching?Not sure I understand you.

In each shader, you have something like myvertex and mynormal and mytexcoord right?

You need to bind them with the generic attributes (for each shader of course).

For VBO, setup the offset pointers and render.

Axel Mamode
05-13-2004, 11:10 AM
Originally posted by yooyo:
Hi,

Im confused about interaction of this two extensions. Problem is in custom vertex attributes...

When setup some VBO I also setup standard vertex attribute pointers (pos, norm, color, texcoord).

In render stage, I bind some VBO and all pointers for this VBO are already prepared (no need to setup pointers again).

But, whats happend with custom vertex attributes in GLSL? For example I have several GLSL vert&frag programs for static geometry. Should I setup this custom vertex attribute pointers for each shader? Is this pointers safe from VBO switching?

yooyo

ps... soory for by bad english...What you seem to imply is that *Pointer calls and BindBuffer calls are unrelated.
They are not. The *Pointer calls capture the array buffer currently bound.
So if you do
BindBuffer(ARRAY_BUFFER, 1)
VertexPointer(...)
BindBuffer(ARRAY_BUFFER, 2)
DrawArrays(...)
your vertices will come from the vertex buffer 1, not 2. That is true for built in attribute as much as for generic ones.
If I understand your question correctly, you are wondering whether after calling UseProgramObject, you need to emit AttribPointer calls again. You do not need to. These are totally separated from the program.
Thinking more about it, I guess your question might be related to the fact that each program potentially maps a generic attribute to a different location.
You can force the mapping to one that you want (so that your generic attributes never move between programs) through BindAttribLocation before the link happened on the program. Hope this helps.

yooyo
05-13-2004, 01:02 PM
Thanx to all...

After carefull reading VBO, ARB_VP & ARB_vertex_shader spec I got a clue. VBO save all pointer thats used to it.

glBindAttribLocation do exactly what I want.

And another question... What is better (I mean faster) interleaved arrays or separated arrays for each attribute?

yooyo

Christian Schüler
05-17-2004, 10:24 AM
I think that the gl*Pointer semantics do current hardware more justice than the DirectX-style vertex declarations. Hardware typically has a set of DMA streams to fetch from.

I personally haven't measured any difference between interleaved and non-interleaved arrays, however this dates back to the times of GF2-GF4.