You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3d8e9b8
Browse filesBrowse the repository at this point in the historyBrowse files
> Note that the library expects the allocation function to either throw in case of out-of-memory (in which case the exception will propagate to the caller) or abort, so technically the use of `malloc` above isn't safe. If you want to handle out-of-memory errors without using C++ exceptions, you can use `setjmp`/`longjmp` instead.
980
980
981
+
For applications that end up using many allocations, such as when processing many small meshes or individual clusters as part of `clusterlod.h`, it may be beneficial to set up the allocator cache:
982
+
983
+
```c++
984
+
meshopt_setAllocatorCache(16, 32 << 20); // 16 threads x 32MB per thread
985
+
```
986
+
987
+
This will allocate a pool of memory that will be used for subsequent temporary allocations; this is particularly helpful for allocators that don't reuse larger allocations, or use global locks to manage heap memory, such as the default Windows heap. After processing is finished, `meshopt_setAllocatorCache(0, 0)` frees the cache; while the cache is active, the allocation callbacks can't be overridden, but if the cache is configured after `meshopt_setAllocator`, the cache itself and any allocations that don't fit will use the callbacks too.
988
+
989
+
> Note that the combination of allocator cache and `setjmp`/`longjmp` allocation error handling is not supported.
990
+
981
991
When building meshoptimizer as a shared library, allocations from the templated index wrappers provided in the header (used when index data is not `unsigned int`) will only be redirected to these callbacks if the library is built with `MESHOPTIMIZER_ALLOC_EXPORT` defined.
982
992
983
993
When building meshoptimizer with MSVC, if a non-default calling convention is used such as `__vectorcall` (via `/Gv`), `MESHOPTIMIZER_ALLOC_CALLCONV` should be defined to match the calling convention of `operator new`/`delete`.
@@ -1001,6 +1011,7 @@ Currently, the following APIs are experimental:
1001
1011
- `meshopt_SimplifyPreserveFolds` and `meshopt_SimplifyErrorClamped` flags for `meshopt_simplify*` functions
1002
1012
- `meshopt_generateNormals` function
1003
1013
- `meshopt_remesh` function and `meshopt_Remesh*` flags
// for cluster connectivity analysis and boundary statistics, we need a position-only remap that maps vertices with the same position to the same index
// note: all previously allocated blocks must have been returned at this point; this is guaranteed by the absence of concurrent execution with meshopt_ functions
* Allocates a fixed number of memory blocks to be used for temporary allocations in the library.
1049
+
* Each thread performing temporary allocations can only use one block at a time; block count should be set according to expected concurrency.
1050
+
* Once cache is setup, using meshopt_setAllocator is prohibited; cache needs to be disabled (using block_count=0) before reconfiguring allocation callbacks.
1051
+
* This function is not thread safe and must not be called concurrently with any other meshopt_ function.
1052
+
*
1053
+
* block_count can be at most 64; when set to 0, the allocation cache is disabled.
0 commit comments