Rendering multiple linestrips with one draw call in D3D9/XNA

Started by
5 comments, last by Evil Steve 15 years, 11 months ago
Hello, While browsing through the D3D10 docs to find help for our latest D3D convert, I came across this interesting bit of information:
Quote:
An index buffer can index multiple line or triangle strips by separating each with a strip-cut index. Use the maximum possible value for the index (0xffff for a 16-bit index, 0xffffffff for a 32-bit index).

(From these MSDN docs)
This would really come in handy in a project of mine, where I need to batch a big pile of linestrips that I'm currently rendering with seperate draw calls. I can't seem to find anything on MSDN about such an option for D3D9/XNA, but I was wondering if anyone happens to know a similar trick for those platforms. Up until now I was planning to just convert the strips to linelists so I can batch them all in one vertex/indexbuffer pair, but a trick like this would save me some work and might be more efficient. I recall reading some information that indexed lists can be more efficient than strips because of vertex caching, but since I'm dealing with lines instead of triangles I suspect this isn't the case here. So,
  1. Is there a (vendor specific) trick similar to this one available in D3D9?
  2. Are there any other options to batch strips I'm missing?
  3. Should I use linestrips in the first place, or would I be better off with lists anyway?
Thanks in advance!
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Advertisement
Quote:Original post by remigius

  1. Is there a (vendor specific) trick similar to this one available in D3D9?
  2. Are there any other options to batch strips I'm missing?
  3. Should I use linestrips in the first place, or would I be better off with lists anyway?
1. Nope.
2. Nope
3. AFAIK, line strips are preferable if your data comes in that form naturally. If you need line lists, use them rather than trying to emulate them with line strips.

And any caching only happens if you have an indexed list/strip.
Quote:Original post by Evil Steve
1. Nope.
2. Nope


Too bad, it really looked like a nifty trick.

Quote:
3. AFAIK, line strips are preferable if your data comes in that form naturally. If you need line lists, use them rather than trying to emulate them with line strips.


The catch is that my data comes in many seperate line strips naturally and it's easiest to work with in that form, but the large number of strips I need to draw simply requires batching for performance. Ah well, I guess I'm gonna have to switch to lists then and figure out a good way to deal with this.

Thanks for the reply, even if it wasn't what I was hoping to hear [smile]
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Quote:Original post by remigius
Quote:Original post by Evil Steve
1. Nope.
2. Nope

Too bad, it really looked like a nifty trick.
Unfortunately, using this method in D3D9 would require that all drivers implement it, or none do, which isn't really feasible. D3D10 is a "fresh start" so things like this can be put into the spec.

Quote:Original post by remigius
The catch is that my data comes in many seperate line strips naturally and it's easiest to work with in that form, but the large number of strips I need to draw simply requires batching for performance. Ah well, I guess I'm gonna have to switch to lists then and figure out a good way to deal with this.
How many seperate strips are there?
Quote:Original post by remigius
Ah well, I guess I'm gonna have to switch to lists then and figure out a good way to deal with this.

Shouldn't be hard to do. A strip is equal to indices 0,1,1,2,2,3,... You can just remove one segment and continue (0,1, 2,3), or, if you want to keep the indices fixed and just modify them locally (which may or may not be more efficient), just make a degenerate line by changing the end coordinate (0,1,1,1,2,3).
Quote:Original post by Evil Steve
Unfortunately, using this method in D3D9 would require that all drivers implement it, or none do, which isn't really feasible. D3D10 is a "fresh start" so things like this can be put into the spec.


Yeah, I figured as much. I guess I was just hoping for a lucky break, like the ATI SM2 instancing trick. It does seem a bit obscure though, so I'm secretly wondering if this actually works as advertised in D3D10.

Quote:How many seperate strips are there?


Right now I've got 300, but I gather I'll need > 4,000 eventually (yep, doing hair rendering)

Quote:Shouldn't be hard to do. A strip is equal to indices 0,1,1,2,2,3,... You can just remove one segment and continue (0,1, 2,3), or, if you want to keep the indices fixed and just modify them locally (which may or may not be more efficient), just make a degenerate line by changing the end coordinate (0,1,1,1,2,3).


I think I follow, but I realized my problem may be even simpler. To render the hairs I'll only need to set up the indices for the linelist batch once to mimic the strips (so the simple 0,1,1,2,2,3... form) and I can just keep happily modifying the vertices on the CPU like I'm doing now.

I don't know what I was thinking, but it was overly complex to be sure. Thanks anyway! [smile]
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Quote:Original post by remigius
Quote:How many seperate strips are there?


Right now I've got 300, but I gather I'll need > 4,000 eventually (yep, doing hair rendering)
Ah, yeah - you'll definitely wantto use a line list then [smile]

This topic is closed to new replies.

Advertisement