When I use the sample "ProgressiveMesh", I find when the num of a model's faces is beyond 65535, the sample will fail, return D3DERR_INVALIDCALL.
Then I find it's because ID3DXPMesh::ClonePMesh fails, but when I specify D3DXMESH_32BIT for the progressive mesh when calling ID3DXPMesh::ClonePMesh, ID3DXPMesh::TrimByVertices fails. The corresponding code is as follows, where pPMesh is the progressive mesh generated by D3DXGeneratePMesh.
hr = pPMesh->ClonePMeshFVF( D3DXMESH_MANAGED | D3DXMESH_VB_SHARE, pPMesh->GetFVF(), pd3dDevice, &g_ppPMeshes[iPMesh] );
hr = g_ppPMeshes[iPMesh]->TrimByVertices( cVerticesMin + cVerticesPerMesh * iPMesh, cVerticesMin + cVerticesPerMesh * (iPMesh+1), NULL, NULL);
Why i can't specify D3DXMESH_32BIT in ID3DXPMesh::ClonePMesh before calling ID3DXPMesh::TrimByVertices Can someone explain it for me, thanks!

A problem of the Sample "ProgressiveMesh " in DirectX SDK
Alexander Dragon
David R. Williamson MSFT
I'm sorry but the machine I'm on doesn't have the SDK samples installed...
Anyways, this is not the error report you should be receiving from D3DX.
This message is from DXUT. D3DX debug messages appear when you link to the debug version of the D3DX library (D3DXD.lib).
Also, make sure D3D is running the Debug libraries (DirectX Control Panel, Direct3D, Use Debug Version of D3D), and crank the Debug Output Level slider high up.
This way you should see debug messages from D3DX and D3D...
Father.Ryobi
Selim Dizdar
Toni Recio
The error messages in the debug output are as follows:
d:\program files\microsoft directx sdk (february 2006)\samples\c++\common\dxut.cpp(3347): DeviceCreated callback hr=D3DERR_INVALIDCALL (0x8876086c)
d:\program files\microsoft directx sdk (february 2006)\samples\c++\common\dxut.cpp(4536): DXUTCleanup3DEnvironment hr=DXUTERR_NONZEROREFCOUNT (0x80040904)
From them, I can't understand the reason.
The error can reappear easily, You only need change "pPMesh->ClonePMeshFVF( D3DXMESH_MANAGED | D3DXMESH_VB_SHARE,..." to "pPMesh->ClonePMeshFVF( D3DXMESH_MANAGED | D3DXMESH_VB_SHARE | D3DXMESH_32BIT,..." in the function "OnCreateDevice".
Then " hr = g_ppPMeshes[iPMesh]->TrimByVertices " return D3DERR_INVALIDCALL.