Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


glVertexAttribPointer for interleaved array's.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 slicer4ever   Crossbones+   -  Reputation: 3949

Like
0Likes
Like

Posted 06 May 2013 - 06:34 AM

I can't seem to find an answer for this with openGL, but recently when using PSM i've found that I can pass an interleaved array to the shader, and the api can map my interleaved arrays to the shader inputs without any fuss. It reduces alot of additional calls for setting up where each specific part of the vbo has to go.

I'm curious if their is something like this for openGL that i haven't found. I'd like it to be 3.0 capable if possible, but instead of doing:
...
glVertexAttribPointer(PosIdx, 4, GL_FLOAT, sizeof(myvertex), 0x0);
glVertexAttribPointer(ClrIdx, 4, GL_FLOAT, sizeof(myvertex), 0x10);
glVertexAttribPointer(NrmIdx, 3, GL_FLOAT, sizeof(myvertex), 0x20); //I know, padding, just an example!
glVertexAttribPointer(TexIdx, 2, GL_FLOAT, sizeof(myvertex), 0x2C);
//etc, etc
...
i could do something like:
glVertexAttribBlock(BlockIdx, sizeof(myvertex), 0, 0x0);
//Index to attribute block, size of the block in bytes, stride(0 is tightly packed), offset into vbo)

Edited by slicer4ever, 06 May 2013 - 06:35 AM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2422

Like
0Likes
Like

Posted 06 May 2013 - 10:21 AM

A vertex array object can be used to reduce the 4 calls into 1 call, so that the per frame API overhead can be reduced.

 

However, setting up the VAO is going to involve adding more than 4 lines of code, so if you're wanting to improve runtime efficiency, then they might be useful, but if you're trying to reduce code complexity, then they're no help (I wasn't sure from your question which you were trying to achieve).



#3 slicer4ever   Crossbones+   -  Reputation: 3949

Like
0Likes
Like

Posted 10 May 2013 - 04:24 AM

A vertex array object can be used to reduce the 4 calls into 1 call, so that the per frame API overhead can be reduced.
 
However, setting up the VAO is going to involve adding more than 4 lines of code, so if you're wanting to improve runtime efficiency, then they might be useful, but if you're trying to reduce code complexity, then they're no help (I wasn't sure from your question which you were trying to achieve).

well, i am looking more into improving efficiency. I'm assuming the driver can figure out the vbo is interleaved, and load the data into the shader in chunks. but I'm surprised there's no native method for doing so. I'm not sure how efficient VAO's are, they remove a few calls during runtime, but they seem to only store the current state of the vertex attributes, so if I understand them correctly, it's similar to using Display Lists.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS