Commit Graph

4 Commits

Author SHA1 Message Date
Arseny Kapoulkine 060c63ec5c quantization: Extract union to a named type
This mostly helps clang-format that, in absence of a separate properly
formatted declaration, tries to format the union as several lines.
2023-12-10 22:56:53 -08:00
Arseny Kapoulkine 320dea8944 quantization: Implement meshopt_dequantizeHalf
This function reverses the transformation by meshopt_quantizeHalf; the
reverse conversion is easier since exponent and mantissa just need to be
expanded into the larger range. We still need to handle denormals and
specials; unlike quantization, here we choose to preserve NaN payload
because that allows us to fold inf and nan cases into a single
conditional add.
2023-08-24 13:25:23 -07:00
Arseny Kapoulkine 6ecf155417 quantization: Add assertions for quantizeFloat N argument
Also convert C comments to C++ - this is no longer part of
meshoptimizer.h so it doesn't need to be C89 compatible.
2023-08-24 12:04:49 -07:00
Arseny Kapoulkine 55ad650bb4 quantization: Introduce a new file, quantization.cpp
meshopt_quantizeFloat and meshopt_quantizeHalf are moved to the new
file. These are larger (esp. float->half), not as commonly used as
unorm/snorm, don't benefit as much from inlining as it's more rare that
they are used with constant arguments in perf-sensitive context, and
also not used anywhere inside meshoptimizer itself, which means we still
get to keep the independence between different translation units (we'll
need to be careful with this in the future...).

A new file makes for a convenient place to add more quantization
utilities in the future as well.

These are used in gltfpack, which doesn't see a noticeable perf
degradation on geometry-heavy meshes that use quantizeFloat.
2023-08-24 11:42:22 -07:00