Skip to content

Commit 7044538

Browse files
authored
Merge pull request #840 from zeux/cquant
Make meshopt_quantizeHalf/Float extern "C"
2 parents 331f1ce + e184154 commit 7044538

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/meshoptimizer.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,27 @@ MESHOPTIMIZER_API void meshopt_spatialSortRemap(unsigned int* destination, const
608608
*/
609609
MESHOPTIMIZER_EXPERIMENTAL void meshopt_spatialSortTriangles(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
610610

611+
/**
612+
* Quantize a float into half-precision (as defined by IEEE-754 fp16) floating point value
613+
* Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest
614+
* Representable magnitude range: [6e-5; 65504]
615+
* Maximum relative reconstruction error: 5e-4
616+
*/
617+
MESHOPTIMIZER_API unsigned short meshopt_quantizeHalf(float v);
618+
619+
/**
620+
* Quantize a float into a floating point value with a limited number of significant mantissa bits, preserving the IEEE-754 fp32 binary representation
621+
* Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest
622+
* Assumes N is in a valid mantissa precision range, which is 1..23
623+
*/
624+
MESHOPTIMIZER_API float meshopt_quantizeFloat(float v, int N);
625+
626+
/**
627+
* Reverse quantization of a half-precision (as defined by IEEE-754 fp16) floating point value
628+
* Preserves Inf/NaN, flushes denormals to zero
629+
*/
630+
MESHOPTIMIZER_API float meshopt_dequantizeHalf(unsigned short h);
631+
611632
/**
612633
* Set allocation callbacks
613634
* These callbacks will be used instead of the default operator new/operator delete for all temporary allocations in the library.
@@ -620,7 +641,7 @@ MESHOPTIMIZER_API void meshopt_setAllocator(void* (MESHOPTIMIZER_ALLOC_CALLCONV*
620641
} /* extern "C" */
621642
#endif
622643

623-
/* Quantization into commonly supported data formats */
644+
/* Quantization into fixed point normalized formats; these are only available as inline C++ functions */
624645
#ifdef __cplusplus
625646
/**
626647
* Quantize a float in [0..1] range into an N-bit fixed point unorm value
@@ -635,27 +656,6 @@ inline int meshopt_quantizeUnorm(float v, int N);
635656
* Maximum reconstruction error: 1/2^N
636657
*/
637658
inline int meshopt_quantizeSnorm(float v, int N);
638-
639-
/**
640-
* Quantize a float into half-precision (as defined by IEEE-754 fp16) floating point value
641-
* Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest
642-
* Representable magnitude range: [6e-5; 65504]
643-
* Maximum relative reconstruction error: 5e-4
644-
*/
645-
MESHOPTIMIZER_API unsigned short meshopt_quantizeHalf(float v);
646-
647-
/**
648-
* Quantize a float into a floating point value with a limited number of significant mantissa bits, preserving the IEEE-754 fp32 binary representation
649-
* Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest
650-
* Assumes N is in a valid mantissa precision range, which is 1..23
651-
*/
652-
MESHOPTIMIZER_API float meshopt_quantizeFloat(float v, int N);
653-
654-
/**
655-
* Reverse quantization of a half-precision (as defined by IEEE-754 fp16) floating point value
656-
* Preserves Inf/NaN, flushes denormals to zero
657-
*/
658-
MESHOPTIMIZER_API float meshopt_dequantizeHalf(unsigned short h);
659659
#endif
660660

661661
/**

0 commit comments

Comments
 (0)