meshoptimizer icon indicating copy to clipboard operation
meshoptimizer copied to clipboard

Rework meshopt_Allocator callback storage

Open zeux opened this issue 9 months ago • 0 comments

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.

zeux avatar Jun 16 '25 20:06 zeux