Sign in to follow this  
lucky6969b

How to get around D3DXCreateMesh 65535 vertices limit?

Recommended Posts

while I was importing a big mesh into DX9 from assimp,

the D3DXCreateMesh function fails if that mesh contains more than 65535 vertices,

how do I work around it?

Thanks

Jack

Share this post


Link to post
Share on other sites

Looking at the documentation for D3DXCreateMesh, we see that it takes an Options parameter.  This is described as "Combination of one or more flags from the D3DXMESH enumeration, specifying options for the mesh", so we look at the documentation for the D3DXMESH enumeration and we see that the first item is:

D3DXMESH_32BIT
The mesh has 32-bit indices instead of 16-bit indices. See Remarks.

 

And the Remarks state:

 

A 32-bit mesh (D3DXMESH_32BIT) can theoretically support (2^32)-1 faces and vertices. However, allocating memory for a mesh that large on a 32-bit operating system is not practical.

 

So in order to overcome this limitation you simply specify D3DXMESH_32BIT in your D3DXCreateMesh call.

There are valid reasons to prefer 16-bit indices, including that they may perform faster and that your hardware may not even support 32-bit indices.  Both of these (particularly the latter) are unlikely to be issues with any reasonably modern (10 years old or newer) hardware however, so unless you know that you're targetting really old hardware you can safely ignore them.

Share this post


Link to post
Share on other sites
1) don't. Having more than 65k verts in one draw means that your index format has to change from 16bit to 32bit, which is bad. Just use multiple draws.

2) stop using D3DX and write it yourself :wink:

Share this post


Link to post
Share on other sites

GPU are beast made to deal with latency, and you will not achieve the bandwidth peak unless you wrote a very edge case just for it that is not applicable. The truth is that the little difference here will never show up because some other parts of the graphic pipeline will take longer and you will never observe a scenario where the GPU is waiting for a index read.

 

This is also the same reason this days we use triangle list and not triangle strip unless you need to save memory on a low memory platform ( phone or 3DS ? ). We can do a better job with triangles in regards to the post transform cache than with strips. There is no pre vertex cache his days either for that matters too.

Share this post


Link to post
Share on other sites

In addition to bandwidth, and this is going to be vendor-dependent so please take it with the appropriately-sized grain of salt, using 32-bit indices can halve the size of your GPU's vertex cache.

Share this post


Link to post
Share on other sites

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