View Full Version : Weird VBO speed boost?

06-06-2006, 07:53 PM

I have been toying with a rather large VBO to try and speed it up and I have been able to double the framerate but I am not sure how it works.

This is the code I am using to draw my VBO.

glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );

glDrawArrays( GL_TRIANGLES, 0, m_nVertexCount );
Now if I alter the glDrawArrays line to look like:

glDrawArrays( GL_TRIANGLES, 0, m_nVertexCount/10 );
It speeds up incredibly. But isn't the last parameter supposed to be how many vertices I am using?

Please note that when I do this, I lose nothing visually whatsoever. Which is the puzzling part for me. But it only seems to work for numbers between 6 and 10.

So if I divide it by 4 or 20, I get parts of my VBO missing.

Why is this so?

06-07-2006, 01:24 AM
"But isn't the last parameter supposed to be how many vertices I am using?"

That's how it reads in the red book...

When you say you lose nothing visually whatsoever, do you mean that a difference calculation (like in photoshop) between a screenshot without the altered line, and a screenshot with the altered line, produces a result of zero?

Or is it that there's no obvious difference by visual inspection?

Does the same thing happen with some simple data that you generate in-program, ie a 2D array of triangles on a square grid?

What is the data in the VBO, and where did it come from?

06-07-2006, 02:38 AM
Well... you don't see difference because your cam is not aimed to missing part of mesh :)

I suppose that your problem is in vertex dataset. Maybe vertices in your dataset is duplicated.

Better check for GL errors. You'll find something odd!

06-07-2006, 02:45 AM
you don't see difference because your cam is not aimed to missing part of mesh I have been all over the mesh and nothing is missing. It is only when I use values less than 6 and higher than 10 that I get pieces missing.

I will try the GL errors and see what it says.

And as for the no visual difference, it was on inspection, but I just did a screenshot of before and after and still no difference in comparison.

06-07-2006, 02:56 AM
Just tried error checking and it came up clean as a whistle.

The data in the VBO is created at runtime from values in an image.

I have not tried this with smaller, simpler VBO's.

But even so. I should not be able to divide the number of vertices I am currently sending by 10 and not see any visible difference.

** I am sending a total of (2048*2048*6)/10 vertices before the extra divide by 10.

Which then makes it (2048*2048*6)/100 after the divide which still produces the same results, no visual loss, increase in speed?

06-07-2006, 05:32 AM
tried it with a cube?

06-07-2006, 09:18 AM
I too experienced all sorts of speed boosts, loss, spikes and valleys with nVidia drivers < 90.0 when using VBO and PBO. I switch to 91.28 beta and life is much better now.

06-07-2006, 10:11 AM
I think knackered got head+nail. :)

To add my own 0.02,
2048^2*6/10*sizof(float)*3 = 28.8MB. That could be considered a rather substantial amount of vertex data in a single VBO. Btw, 2048^2*6/10 = 2516582.4. That's not an even number of triangles. If you send an invalid count for a specified primitive to DrawArrays (in this case, (count%3)!=0), an error is flagged and nothing is drawn.

This is not perchance a continuation of this thread (http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=3;t=014416) ?

06-07-2006, 09:52 PM
I am not getting any errors :S and it is all drawn :S

I am (int)ing it but just checked and that does not even create enough for triangles.

I am now dividing it by multiples of 3, I can divide it by up to 99, as before I was dividing by a total of 100, to get the same speed boost, and am still not losing anything on the screen.

BTW, just checked and a division of 99 still isn't correct for triangles.

I am using drivers 84.43 with my 6800, I will try newer drivers and report back.

But even still, I am getting no errors, everything is drawing correctly, yet I am telling it to draw ALOT less than before, and the speed has increased dramatically. This does not make any sense.

** Just updated the drivers and now nothing shows, which does suggest an error. I want my old drivers back :(

So how can I get this to work? It must be just a little mathematical error.

My loop to create the vbo vertices looks like:

int tLOD = 10;
int vertexCount = (int)(2048*2048*6)/tLOD;
for (mapZ = 0; mapZ < Height; mapZ+=tLOD){
for (mapX = 0; mapX < Width; mapX+=tLOD){
Create 6 vertices for 2 triangles for each section
So in that, I am creating 6 vertices for every 10 places. Setting tLOD to 1 looks a little better, but takes so much longer to create and is alot slower to run, I came to the conclusion that tLOD set to 10 is best.

Should I have it something like:
vertexCount = ((MapWidth/8)*(MapHeight/8)*6)?

So I am still creating 6 per space, but I am creating 8 times less and it is still divisible by 3. But still shows nothing on screen.

And is not reporting any errors.

*It was originally based on NeHe code for the VBO, have just gone back and tried it with the exact same variables as on the NeHe tutorial, and it still shows up blank. Is there a limit to how big a VBO can be?

06-08-2006, 12:56 AM
I think I have fixed it, I am getting even faster frame rates now.

The reason it was showing blank in the last post, I found out was due to the change in the VBO disrupting the diffuse colour in my shader (maybe I moved something incorrectly).

Anwyay, now all the calculations add up to correct multiples. (thnx Tamlin)

Thanks guys.

p.s. The new drivers wouldn't have caused the change in my shader would it?