2
\$\begingroup\$

I'm running into a bottleneck where I'm drawing many basic disconnected colored triangle strips in DirectX 9 (XNA). The problem comes with drawing them all in seperate draw calls, so I'd like to batch them all together into a single buffer and draw them in one draw call.

I understand that in DirectX10 and above, there's a way to draw many triangle strips in the same draw call by inserting a special "cut" index (-1) into the index buffer after every line strip.

Is there a way to do this without the use of the cut index? (Which as far as I know, isn't present in directx 9?)

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

If the triangle strips, while being disconnected, are all sharing the same material (shaders, textures, shader constants) then you can join them together with a degenerate triangle. Since degenerate triangles have zero area they should not show up. The only case they would is if you are drawing wireframe.

You make a degenerate triangle by defining the two of the three vertices as being the same. This is a bit complicated in triangle strips where you only use two vertices to define each triangle.

Look at the following diagram:

enter image description here

Triangle strip A,B,C is connected with triangle strip E,F via a degenerate triangle D. Triangle D would be defined as two points of C, then two points of E. In this way it is a zero-area triangle, but it is still connected.

You can find information on this stack overflow article where the wireframe problem is illustrated.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, this worked perfectly! I thought that even degenerate triangles would get passed to the fragment shader and produce a line, but apparently not. \$\endgroup\$
    – mklingen
    Jan 11, 2015 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .