Archived

This topic is now archived and is closed to further replies.

neneboricua19

DrawIndexedPrimitive and large meshes

Recommended Posts

Hi everyone, I have a question I hope someone can help me out with. I''ve written a class to import .x files so that I can render them using shaders. My class follows the optimized mesh sample from the DX9 sdk but it only uses multiple strips per materal whereas the SDK sample lets you pick between using single strips and multiple strips for each material. It calls ID3DXMESH::Optimize along with a few other mesh utility functions to help clean up and optimize the given mesh. The class works just fine for small meshes, but when I try very large meshes where the number of vertices is larger than what the caps bits says my card can handle, naturally, I get errors. My DrawIndexedPrimitive call is failing because of it. Currently, my call looks like this: hr = m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, m_pMesh->GetNumVertices(), startIndex, primitiveCount); I understand that it is failing because there are too many vertices for my card (a Radeon 9600 Pro - MaxPrimitiveCount==65,535) to handle. I''m not trying to render all these vertices at once. My index buffers are no where near that size. But the problem is that I''m not sure how to adjust the MinIndex and NumVertices parameters of the call so that it uses only the vertices that I really need. The model I''m trying to load was created by an artist using 3D Studio Max. I know that ID3DXMESH::Optimize reoganizes the index buffer but I''m not sure what (if anything) it does to the vertex buffer data for the mesh. I''ve tried to look through the source code for the Mesh Viewer utility that comes with the SDK but I wasn''t able to find the section of code that does what I''m trying to do. I''m sure it''s in there (somewhere) but I haven''t been able to see exactly where just yet. Does anyone have any ideas on what I can do? Thanks a lot, neneboricua

Share this post


Link to post
Share on other sites
quote:
But the problem is that I''m not sure how to adjust the MinIndex and NumVertices parameters of the call so that it uses only the vertices that I really need.

Say your DIP call renders the vertices in the range [50,400] (inclusive) from the vertex buffer.
MinIndex would be 50, numVertices would be (400 - 50 + 1)

quote:
Aren''t ID3DXMESH''es triangle lists?

Yes, but he is using the D3DXConvertMeshSubsetToSingleStrip() (or similar) functionality, which gives you an index buffer of a tri strip.

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites
quote:
Original post by Coder
Say your DIP call renders the vertices in the range [50,400] (inclusive) from the vertex buffer.
MinIndex would be 50, numVertices would be (400 - 50 + 1)


Ok, I understand that. But how do I find out what vertices each DIP call is actually using? I don''t think I can just take a look at the first and last indices of the index buffer because I think that the functions to convert a mesh to a bunch of strips reorganize the index buffer but I don''t think they touch the vertex buffer. I''m not sure about that though. So I think you could have a situation where one triangle specified in your index buffer uses the first, middle, and last vertices in the index buffer. I hope I''m wrong about that and that it doesn''t really work that way because it would be very inefficient.

Or do I have to go through all the index buffers at load time and see what the minimum and maximum vertices used for each call? That would really suck but if that''s the way it has to be...

The reason I''m trying to render a model with so many primitives is because it is a special model used frequently in radiosity competitions. I''m slowly trying to build something that allows you to have a good radiosity solution in a dynamic environment. I want to use this model to see if I get similar results to other people who just use a software renderer.

Thanks for the help,
neneboricua

Share this post


Link to post
Share on other sites
quote:
Or do I have to go through all the index buffers at load time and see what the minimum and maximum vertices used for each call? That would really suck but if that''s the way it has to be...

I believe that''s what you''ll have to do. I don''t think it''s going to be that slow. If it turns out slower than what you can tolerate, make it a pre-processing step (if possible).

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites