Different vertex formats within single vertex buffer

Started by
3 comments, last by darkelf2k5 17 years, 11 months ago
I'm woking on the GUI subsystem of my engine right now (I'm just making the engine as a educational/fun experience), and I'm trying to figure out the best way to render my GUI efficiently. All of the rendering done for my GUI is either of textured quads or simple colored lines/quads. I've read some things that say that switching vertex streams can be a costly renderr state change (though apparently not so much since DX8), and that mixing multiple vertex formats within a single buffer can be advantageous over having a number of smaller buffers that are swapped in and out. The optimal goal being to try to achieve buffers of around 1000 vertices each. Is it worthwhile to try and figure out to do this in DX9? I use a single dynamic buffer right now for the textured stuff (don't have anything in yet for untextured stuff). I'm thinking te easiest may be to just have two dynamic buffers, one for the textured vertices and one for simple colored vertices. Is this probably the best way to go? One other option I'm considering is to use the single buffer, and just have the untextured stuff have unused values in the texture coordinates and change the color operation to ignore the texture. This would waste space, but I'm thinking it'd be pretty fast (I assume changing color operation state is much faster than switching vertex streams). Anyone have any suggestions? Thanks.
Advertisement
Since you're talking about two buffers only, there's not much point in optimising them into one. Just make sure you render from one, then from the other (i.e., don't switch unnecessarily back and forth). There's only point in worrying about this kind of render state change when you're doing a few hundreds or thousands switches per frame.
Try multiple vertex streams. It worked fine for me to render ~10000 textured quads with 1 lock/unlock abd 1 draw call per frame.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Thanks, that was sort of what I assumed the answer would be. I'll just make sure that my render queue optimizer that I'm working on right now orders by vertex stream towards the top of my shader tree.

By any chance does anyone have a link to an example that makes use of a mixed format vertex stream? I won't implement it for what I'm doing now, but since I'm making this engine purely for enjoyment and educational purposes, I'm curious to see how that is done.
Quote:Original post by kastro
By any chance does anyone have a link to an example that makes use of a mixed format vertex stream? I won't implement it for what I'm doing now, but since I'm making this engine purely for enjoyment and educational purposes, I'm curious to see how that is done.


If you get the concept of VBs and declarations, you dont need an example.

SetVertexDecl 1
render 0-x vertices from the buffer
SetVertexDecl 2
render x-y vertices from the buffer
SetVertexDecl 3
...
..
.

P.S. IMHO anything that breaks batching should be avoided for now.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!

This topic is closed to new replies.

Advertisement