Sign in to follow this  

Subset of indices from index buffer

This topic is 3296 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

Hi, imagine that for some reason you want to draw only a certain number of faces from a mesh that you're already completely drawing by using DrawIndexed etc. So you've got the vertex buffer containing all the vertices, and an index buffer. I can't think of another way rather than (oww..) varying the index buffer every time by updatesubresource or whatever. Am I missing something?

Share this post


Link to post
Share on other sites
The StartIndex parameter to DrawIndexedPrimitive allows you to specify the offset into the index buffer to start reading indices.

If you have a list of 10 triangles in your index buffer, and you want to render triangles 4-6 (0 based), you'd set StartIndex to 4*3=12, and PrimitiveCount to 6-4=2.

Share this post


Link to post
Share on other sites
Quote:
Original post by resle
Hi,
imagine that for some reason you want to draw only a certain number of faces from a mesh that you're already completely drawing by using DrawIndexed etc.
So you've got the vertex buffer containing all the vertices, and an index buffer.

I can't think of another way rather than (oww..) varying the index buffer every time by updatesubresource or whatever. Am I missing something?


Do you mean like a second pass through the shader pipeline for arbitrary primitives. D3D10 Effect system can do multiple passes, not sure on the implementation details for your problem though... :|

Share this post


Link to post
Share on other sites
@Guthur

No, it's something like this:
There's a huge grid made up from, say, 5000 faces.
Frame 1: I want to draw all the faces whose index is divisible by 5.
Frame 2: I want to draw all the faces whose index is odd
Frame 3: I want to draw a bunch of random faces
Frame 4: I want to draw faces 1, 92, 1000 and 4755

Share this post


Link to post
Share on other sites
Approaches I think might work:

Use SV_PrimitiveID shader semantic and skip draw in the shader depending on this value and whatever operation flags set in a constant buffer.

Create a new index buffer each time and draw with it, remember to be careful to pick out the correct indices for the primitive (triangle) you want to draw.

Not really sure where would be the best. Possibly shader but then if you only draw 1 out of 5000 its abit wasteful :p

Share this post


Link to post
Share on other sites
I am testing the regeneration way and.. well, I thought UpdateSubResource would perform worse. Possible this experience is teaching me that after all having lost DrawPrimitivesUP isn't a tragedy..

Share this post


Link to post
Share on other sites

This topic is 3296 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