? VBO Performance - glDrawArrays (Mac vs PC) ?

I have a couple of performance questions related to VBO rendering using the gl.glDrawArrays(GL.GL_TRIANGLES, 0, num) call.

On a Mac OS computer I ran the exact same code using JOGL 1.1.1 and noticed that the first time my VBOs were being rendered, the glDrawArrays() call seemed to take a very large amount of time. And it didn’t seem to be proportionate to the number of triangles - e.g. I had 100,000 triangles drawn in 15 milliseconds, while 2000 triangles in another case drew in 3000 milliseconds (3 seconds). Again, this one on the very first rendering call - not the subsequent calls where the rendering time for that method reduced down to 0 milliseconds (i.e. less than a millisecond).

I noticed that this was not the case on a PC (which happens to be older and slower than the test Mac). On the PC this rendering, during the first call was tiny - in many cases less than a millisecond.

So effectively this is what timings I had…
What I’m actually rendering (using Joglutils code) is a 3DS graphics file composed of 3 objects having 100,000 triangles, 15,000 triangles and 6,000 triangles.

[tr]
[td]Render Loop[/td]
[td]# of Triangles[/td]
[td]Mac Time[/td]
[td]PC Time[/td]
[/tr]
[tr]
[td]1[/td]
[td]100,000[/td]
[td]17[/td]
[td]31[/td]
[/tr]
[tr]
[td]2[/td]
[td]100,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]
[tr]
[td]3[/td]
[td]100,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]

[tr]
[td]Render Loop[/td]
[td]# of Triangles[/td]
[td]Mac Time[/td]
[td]PC Time[/td]
[/tr]
[tr]
[td]1[/td]
[td]15,000[/td]
[td]2000[/td]
[td]0[/td]
[/tr]
[tr]
[td]2[/td]
[td]15,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]
[tr]
[td]3[/td]
[td]15,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]

[tr]
[td]Render Loop[/td]
[td]# of Triangles[/td]
[td]Mac Time[/td]
[td]PC Time[/td]
[/tr]
[tr]
[td]1[/td]
[td]6,000[/td]
[td]2250[/td]
[td]0[/td]
[/tr]
[tr]
[td]2[/td]
[td]6,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]
[tr]
[td]3[/td]
[td]6,000[/td]
[td]0[/td]
[td]0[/td]
[/tr]

As you can see, there appears to be no correlation between the # of triangles and the initiation time - ie the first rendering time. I mean, for 100,000 triangles the MAC time was only 17 milliseconds while for 15,000 triangles it was 2000 milliseconds. And on the PC side the timings are not even close to the MAC times in most cases.

I can probably understand why the first draw method has this issue and it likely has to do with the first time this is being rendered to the graphics card - ok, fine. Does that sound reasonable?

The other question (and probably my main issue) is why is the MAC first rendering soooooooo much more than the PC? Do you think the MAC JOGL implementation is not as robust as the PC one? Trust me when I say the MAC I was running on is far superior to the PC yet the first rendering loop is so long that I think that the program is dead when it runs on the MAC.

Are you updating the VBO at all after the first call, btw? I’m guessing not, and if you did you might see the same slowness every frame you update it.

I don’t have a solution for you, but I did run into a similar problem using VBO on a Mac. In my case, I was updating a small portion of it (maybe 10% or so) every frame and the performance was horrible on a Mac, and excellent on a PC. Wasn’t using large VBOs (around 500 vertices), but just one of those was enough to send the frame rate from 60 into single digits.

Ended up switching to vertex arrays, which were fast enough on both Mac and PC…

thanks for the reply.

No, no updates for me. This is a 3DS graphics model and I don’t change it between rendering loops.

it is good to see confirmation that others have this same issue on MACs. I guess I’ll have to look into Vertex Arrays and try them - never done it before so hopefully it won’t be hard.

again, thanks for the info.

GPU drivers work asynchronously (for the most part). Do not time individual GL calls, the driver might do a lot more than just execute your statement (or buffer it, which is also likely).

There’s probably some driver initialisation going on for your GL context.

That may be true, but these timing calls still give me a little insight to what might be happening because I can definitely see the MAC version taking about 2.0 minutes to render the first call while the PC version draws almost immediately (my 3ds model has more than the 3 parts I listed in the orig post). When I put those timing calls in I helped to verify what I was noticing in person.

I do agree with your statements, thanks … I wonder if you are right about “driver initialization”, it’s a good thought too.

Converted to using Vertex Arrays and it has spend up my init method and the first rendering, as well as seems to be faster for all future renderings.

I hope I’m doing the vertex arrays correctly … it seems to be nearly identical code to VBOs where I had to create all my FloatBuffers for the vertices/normals/colors/textures but without binding them and then when I render the calls to glDrawArrays is very similar to. I think I did it right since it does render so I can’t complain. Thanks for the suggestion.