Rework meshopt_Allocator callback storage #896
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using templated class static allowed us to avoid function calls even in
unoptimized builds, but results in conflicts with Clang's C++20 module
implementation when meshoptimizer.h is included in global module
fragment. Instead, we now use a function static to store this state and
require a function call to get access to it.
Additionally, while allocator callbacks were deduplicated by the linker
within an individual module, when meshoptimizer was compiled as a
shared library the library code and the calling code would get
separate configuration, and allocator overrides would not affect temporary
allocations done by meshopt_IndexAdapter. To fix that, this PR introduces
a separate configuration option,
MESHOPTIMIZER_ALLOC_EXPORT
,which can be used to declare the allocator storage function in the library
once.
Fixes #895.
This contribution is sponsored by Valve.