PDA

View Full Version : Repeated data in vbo



M/\dm/\n
06-16-2003, 04:50 AM
I'm just curios what to do if I have a array of colors, lets say float c[3][30]={1} & I must get according vertices to vbo. Do I need to call glColor3f(1,1,1); before drawelements once or waste memory fo this array c?

Korval
06-16-2003, 11:06 AM
That is an interesting question. It all depends on how well the implementation aliases immediate-mode state commands with VBO's. It is entirely possible that the driver would be forced to play certain tricks to pass this information along (like creating a VBO in the background, copy the data to it, and using it that way). This would, almost certainly, be slower than just having the color be part of the VBO data.

Unless one of the driver developers comes along, you'll just have to benchmark it.

Csiki
06-16-2003, 12:45 PM
Originally posted by M/\dm/\n:
I'm just curios what to do if I have a array of colors, lets say float c[3][30]={1} & I must get according vertices to vbo. Do I need to call glColor3f(1,1,1); before drawelements once or waste memory fo this array c?

Surely enough once.
Think a bit: this is same as you would have only one normal.
If you don't give any normal vector the card use the last (if needed for lighting for example) and ofcourse there is no performance lost...
So simply call glColor.

Korval
06-16-2003, 01:29 PM
and ofcourse there is no performance lost

Assuming your card works like OpenGL does. IE, has some constant registers for vertex attribute state. However, it's entirely possible that the card only accepts data via vertex arrays, and the driver implements this behind the scenes. It certainly saves on silicon, and virtually all hardware makers stress using vertex arrays over immediate mode as a means of achieving performance.

cass
06-16-2003, 02:48 PM
You don't need to create a "dummy" array on any NVIDIA hardware. Just use immediate mode to change parameters that do not vary inside begin/end (or array-drawing calls).

Thanks -
Cass

Cab
06-17-2003, 01:00 AM
OpenGL is a state machine. If you set a state (in this case the color using glColor3f(1,1,1)) it should be valid until you change it with this or another command that changes this state (primary color). i.e. You don't need to create the color array.

Hope this helps.

M/\dm/\n
06-17-2003, 01:18 AM
Thanks, I'm glad that the way I have implemented is right one. But VBO's are real dissapointment for static, simply shaded data, even for 2x AGP there is NO!!!! performance gain. Or maybe FX5200 on GF2 core isn't doing the best?

Cab
06-17-2003, 01:44 AM
Originally posted by M/\dm/\n:
Thanks, I'm glad that the way I have implemented is right one. But VBO's are real dissapointment for static, simply shaded data, even for 2x AGP there is NO!!!! performance gain. Or maybe FX5200 on GF2 core isn't doing the best?

I'm sorry but I've done different testing with VBO with static and dynamic geometry in GFFX, GF4Ti and GF4MX (i.e. GF2) and the results are very similar of the ones using NV_VAR (which I tested on all the GeForce range). And the speedup is significant. Currently, I haven't checked in an AGP2x machine but I checked it sometimes when it was using VAR.
The only problem I remember (three years ago) was with some machines (Dell in this case) where I can't allocate AGP memory (with NV_VAR). It was because a bad AGP configuration.
Test your code. I think there are some examples in the web. In the extension spec there are also a few examples (the only thing I don't like in the spec is that they don't use glGenBuffersARB to get the buffer's name so it can generate confusion).
Check for OpenGL errors.
Be sure you are drawing a good number of polygons per call (at least 100) to see the speedup. (To test, try with models that you can draw 30000 polys (i.e) per call and draw the same model in different places in the same scene.
Hope this helps.


[This message has been edited by Cab (edited 06-17-2003).]

M/\dm/\n
06-18-2003, 11:20 PM
Well, actually there is 1 fps gain in comparison to vertex arrays 'compiled' in display list, and when & only when custom vertex program is on (in current situation ligting override). Model polly count isn't that small either. Maybe
glBindBuffer(GL_A_B, vb);
glBindBuffer(GL_E_A_B, ind);
draw stuff;
glBindBuffer(GL_A_B, 0);
glBindBuffer(GL_E_A_B, 0);
approach isn't the best, but I have to bind unbind my buffer as I have classic va's out there, and anyway it's not NV's heavyweight binding (I'm creating buffers in init f/n or when switching res).
BTW, what's about size of VBO's, is it better to have one huge VBO (and what's the limit) with 10 models inside or smaler vbos => vertex cache thingy?

I'm waiting for the PBO http://www.opengl.org/discussion_boards/ubb/biggrin.gif

[This message has been edited by M/\dm/\n (edited 06-19-2003).]