In the days of VAR a lot of stuff was more obvious, with VBOs it’s hard to find out what’s going on under the hood. I’m doing a rewrite of my first VBO implementation which was based on guesswork at best. I can’t say I’m having performance problems, and I doubt I have much to gain but as I’m making some changes anyway I want to be well informed.
So, this is what I’ve understood so far:
-
As switching VBOs is expensive, prefer sticking more data at the end of the VBO than getting it from another VBO.
-
Interleaving is definitely worthwhile.
-
In the case of dynamic attribs, putting those in a separate VBO can be beneficial.
I already attempt to reduce VBO binds and gl*pointer calls a little. I do optimise triangles and VB entries for cache. I stopped using interleaving after I benchmarked it exhaustively on a few different boards and found it did little or nothing.
The engine is used in numerous and diverse applications so it’s hard to optimise very specifically. The renderer is multi-pass. In a purely hypothetical example, if you had a surface rendered in 4 passes, having a total of 6 attribs and the passes use them like this:
[a0,a1]
[a0,a1,a2,a3]
[a0,a1,a2,a4]
[a0,a2,a5]
What would you do? Or better, what would you not do?
From tamlin’s post I gather he might suggesst something along the lines of interleaving a0, a1 and a2 and sticking the rest somewhere after in the same VBO.
tamlin, what do you mean by “are they at least properly aligned”?
Apologies for my initial post being a bit confusing (that was me trying to be clear). I should have put it in the form of questions rather than examples… Something like:
a) What is the overhead of binding a VBO that contains unnecessary attributes? Is this a really bad idea? What about interleaving unused attributes?
b) How does performance of spanning attribs across multiple VBOs compare to that of having them non-interleaved in the same VBO?
c) What does a considerably higher VBO memory usage result in? Memory being paged in?
Slower memory being used? What kind of hit can I expect?
Thanks everyone! (except for knackered)