-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed library to use less memory when loading and processing models. #958
Conversation
@@ -129,27 +129,24 @@ struct aiFace | |||
//! The maximum value for this member is #AI_MAX_FACE_INDICES. | |||
unsigned int mNumIndices; | |||
|
|||
//! Pointer to the indices array. Size of the array is given in numIndices. | |||
unsigned int* mIndices; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break every single Assimp client in existence, and require non-trivial changes when upgrading. Ideally this kind of optimization would preserve the public-facing struct API in some fashion, otherwise it'll probably have to wait until the next major version bump.
I took a stab at something similar a while ago in an attempt to minimize heap usage (master...jdduke:noheap_face). It preserves the outward-facing aiFace struct data members, but eliminates heap allocations for faces with index count <= 4 (albeit in a somewhat crude fashion, index storage on the mesh is a better long term solution, but unless we make mIndices a pointer into the mesh index array, which has its own set of issues, this is a breaking change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change it to be a pointer that references the indices array in the mesh, will this PR be accepted? This solution works for us, and I'm happy to make the change if that's the only thing stopping it from being accepted, but I've already spent way too much time working on this.
I guess we need to release this changes ( when they are tested and reviewed ) in a release 4.0. As jdduke mentioned before this will break the API and every client need to change his code. |
What's the time frame on the 4.0 release?
If the breaking the API is the only thing blocking this from being merged, I can change the |
I think we can release 4.0 next ..... Samuel Surtees notifications@github.com schrieb am Fr., 29. Juli 2016
|
I think I'd be in favor of not breaking the API and have mIndices refer to the indices array. Also it should be backwards-compatible -- importers should still be able to allocate their own data arrays. I am not sure how it would work with deleting, perhaps we should add a boolean to aiFace so it knows whether to free the data. |
This kind of defeats the purpose of this PR. The large memory consumption I'm experiencing is due to the faces having their own allocations for indices. Additionally, adding more data per face doesn't help with the data consumption problems. This is why I favour the API changing, it prevents this issue from reoccurring by not allowing you to make mini-allocations for each face. |
One question: will this pull request in the current state break the ABI? If not: we should merge it! |
I thought quiet a long time about this patch. We should try a different approach before merging this one. I will prepare a special branch for testing this. |
@@ -1284,6 +1286,8 @@ unsigned int Converter::ConvertMeshSingleMaterial( const MeshGeometry& mesh, con | |||
if ( uvs.empty() ) { | |||
break; | |||
} | |||
out_mesh->mNumIndices = std::accumulate(faces.begin(), faces.end(), 0); | |||
out_mesh->mIndices = new unsigned int[out_mesh->mNumIndices]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line wipes out the existing mIndices (withing freeing) and results in the index buffer being unallocated.
…nates due to a bad merge
This is a pretty big change, but it removes all of the mini-allocations that occurred for indices. These mini-allocations would result in excessive memory usage, at least on Windows (potentially not an issue on Windows 10 though). Resolves #944