nvidia-texture-tools/src/nvmath/Half.h

31 lines
584 B
C
Raw Normal View History

2010-05-27 23:19:24 +00:00
#pragma once
#ifndef NV_MATH_HALF_H
#define NV_MATH_HALF_H
2010-05-27 23:19:24 +00:00
#include "nvmath.h"
2010-05-27 23:19:24 +00:00
namespace nv {
2010-05-27 23:19:24 +00:00
uint32 half_to_float( uint16 h );
uint16 half_from_float( uint32 f );
2011-09-27 17:48:46 +00:00
void half_init_tables();
uint32 fast_half_to_float(uint16 h);
2010-05-27 23:19:24 +00:00
2011-04-06 02:41:15 +00:00
inline uint16 to_half(float c) {
union { float f; uint32 u; } f;
f.f = c;
return nv::half_from_float( f.u );
}
inline float to_float(uint16 c) {
union { float f; uint32 u; } f;
f.u = nv::fast_half_to_float( c );
return f.f;
}
2010-05-27 23:19:24 +00:00
} // nv namespace
#endif // NV_MATH_HALF_H