Sign in to follow this  

[MDX] Need speed improvement for LineStrip rendering

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got about half million triangles to be drawn as line strips. I managed to put them into 20 VertexBuffers and use
Device.DrawPrimitives(PrimitiveType.LineStrip, offset, 3);
to draw each triangle linestrip. That means I have to call the above code half million times. The rendering is very slow, about 2 seconds per frame. If I draw each VertexBuffer directly like this
Device.DrawPrimitives(PrimitiveType.LineStrip, 0, totalPrimitiveCountInVb);
I just have to call the above code 20 times and the result is less than 0.1 second per frame. But I end up with tangled lines like hairballs as MDX doesn't know where to end a linestrip and start a new one. Is there a way to draw those triangle linestrips within a reasonable time?

Share this post


Link to post
Share on other sites
I see a couple options:

1) Use a line list and an index buffer. Using a line list would allow you to use less DrawPrim calls. Using an index buffer would allow you to reduce the memory size of the vertex buffer, though it isn't required.

2) Use a triangle list, and set the fill mode to WireFrame. This would allow you to draw traingles with only lines on their edges. Since you're using a TriangleList, each primitive comes out to 3 lines, reducing much of the work for the GPU, and still allowing you to draw an entire buffer in one DrawPrim call.

Hope this helps.

Share this post


Link to post
Share on other sites
Thanks for the advice. I decided to use your first option as it can handle not just triangle, but normal linestrip and polygon as well. I just run a test and it is 20 times faster than draw each element one by one.

Share this post


Link to post
Share on other sites
Just for your information, the second method can also draw a line or line strip. If you set 2 of the triangle's 3 vertices to the same point, the output would be a single line.

Also, if you're not using an index buffer for rendering, I'd recommend you do, as you'll get a significant speed boost.

Share this post


Link to post
Share on other sites

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this