mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-23 19:54:39 +00:00
(GLM) Cleanups
This commit is contained in:
parent
0fd569983c
commit
af9136c341
27
deps/glm/detail/intrinsic_exponential.inl
vendored
27
deps/glm/detail/intrinsic_exponential.inl
vendored
@ -1,27 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref core
|
||||
/// @file glm/core/intrinsic_exponential.inl
|
||||
/// @date 2011-06-15 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
10
deps/glm/detail/type_half.hpp
vendored
10
deps/glm/detail/type_half.hpp
vendored
@ -34,16 +34,10 @@
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
typedef short hdata;
|
||||
|
||||
GLM_FUNC_DECL float toFloat32(hdata value);
|
||||
GLM_FUNC_DECL hdata toFloat16(float const & value);
|
||||
GLM_FUNC_DECL float toFloat32(int16_t value);
|
||||
GLM_FUNC_DECL int16_t toFloat16(float const & value);
|
||||
|
||||
}//namespace detail
|
||||
|
||||
/// half-precision floating-point numbers.
|
||||
//typedef detail::hdata half;
|
||||
|
||||
}//namespace glm
|
||||
|
||||
#include "type_half.inl"
|
||||
|
223
deps/glm/detail/type_half.inl
vendored
223
deps/glm/detail/type_half.inl
vendored
@ -61,7 +61,7 @@ namespace detail
|
||||
uint32 i;
|
||||
};
|
||||
|
||||
GLM_FUNC_QUALIFIER float toFloat32(hdata value)
|
||||
GLM_FUNC_QUALIFIER float toFloat32(int16_t value)
|
||||
{
|
||||
int s = (value >> 15) & 0x00000001;
|
||||
int e = (value >> 10) & 0x0000001f;
|
||||
@ -135,140 +135,137 @@ namespace detail
|
||||
return Result.f;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER hdata toFloat16(float const & f)
|
||||
{
|
||||
uif32 Entry;
|
||||
Entry.f = f;
|
||||
int i = (int)Entry.i;
|
||||
GLM_FUNC_QUALIFIER int16_t toFloat16(float const & f)
|
||||
{
|
||||
uif32 Entry;
|
||||
Entry.f = f;
|
||||
int i = (int)Entry.i;
|
||||
|
||||
//
|
||||
// Our floating point number, f, is represented by the bit
|
||||
// pattern in integer i. Disassemble that bit pattern into
|
||||
// the sign, s, the exponent, e, and the significand, m.
|
||||
// Shift s into the position where it will go in in the
|
||||
// resulting half number.
|
||||
// Adjust e, accounting for the different exponent bias
|
||||
// of float and half (127 versus 15).
|
||||
//
|
||||
//
|
||||
// Our floating point number, f, is represented by the bit
|
||||
// pattern in integer i. Disassemble that bit pattern into
|
||||
// the sign, s, the exponent, e, and the significand, m.
|
||||
// Shift s into the position where it will go in in the
|
||||
// resulting half number.
|
||||
// Adjust e, accounting for the different exponent bias
|
||||
// of float and half (127 versus 15).
|
||||
//
|
||||
|
||||
int s = (i >> 16) & 0x00008000;
|
||||
int e = ((i >> 23) & 0x000000ff) - (127 - 15);
|
||||
int m = i & 0x007fffff;
|
||||
int s = (i >> 16) & 0x00008000;
|
||||
int e = ((i >> 23) & 0x000000ff) - (127 - 15);
|
||||
int m = i & 0x007fffff;
|
||||
|
||||
//
|
||||
// Now reassemble s, e and m into a half:
|
||||
//
|
||||
//
|
||||
// Now reassemble s, e and m into a half:
|
||||
//
|
||||
|
||||
if(e <= 0)
|
||||
{
|
||||
if(e < -10)
|
||||
{
|
||||
//
|
||||
// E is less than -10. The absolute value of f is
|
||||
// less than half_MIN (f may be a small normalized
|
||||
// float, a denormalized float or a zero).
|
||||
//
|
||||
// We convert f to a half zero.
|
||||
//
|
||||
if(e <= 0)
|
||||
{
|
||||
if(e < -10)
|
||||
{
|
||||
//
|
||||
// E is less than -10. The absolute value of f is
|
||||
// less than half_MIN (f may be a small normalized
|
||||
// float, a denormalized float or a zero).
|
||||
//
|
||||
// We convert f to a half zero.
|
||||
//
|
||||
|
||||
return hdata(s);
|
||||
}
|
||||
return (int16_t)(s);
|
||||
}
|
||||
|
||||
//
|
||||
// E is between -10 and 0. F is a normalized float,
|
||||
// whose magnitude is less than __half_NRM_MIN.
|
||||
//
|
||||
// We convert f to a denormalized half.
|
||||
//
|
||||
//
|
||||
// E is between -10 and 0. F is a normalized float,
|
||||
// whose magnitude is less than __half_NRM_MIN.
|
||||
//
|
||||
// We convert f to a denormalized half.
|
||||
//
|
||||
|
||||
m = (m | 0x00800000) >> (1 - e);
|
||||
m = (m | 0x00800000) >> (1 - e);
|
||||
|
||||
//
|
||||
// Round to nearest, round "0.5" up.
|
||||
//
|
||||
// Rounding may cause the significand to overflow and make
|
||||
// our number normalized. Because of the way a half's bits
|
||||
// are laid out, we don't have to treat this case separately;
|
||||
// the code below will handle it correctly.
|
||||
//
|
||||
//
|
||||
// Round to nearest, round "0.5" up.
|
||||
//
|
||||
// Rounding may cause the significand to overflow and make
|
||||
// our number normalized. Because of the way a half's bits
|
||||
// are laid out, we don't have to treat this case separately;
|
||||
// the code below will handle it correctly.
|
||||
//
|
||||
|
||||
if(m & 0x00001000)
|
||||
m += 0x00002000;
|
||||
if(m & 0x00001000)
|
||||
m += 0x00002000;
|
||||
|
||||
//
|
||||
// Assemble the half from s, e (zero) and m.
|
||||
//
|
||||
//
|
||||
// Assemble the half from s, e (zero) and m.
|
||||
//
|
||||
|
||||
return hdata(s | (m >> 13));
|
||||
}
|
||||
else if(e == 0xff - (127 - 15))
|
||||
{
|
||||
if(m == 0)
|
||||
{
|
||||
//
|
||||
// F is an infinity; convert f to a half
|
||||
// infinity with the same sign as f.
|
||||
//
|
||||
return (int16_t)(s | (m >> 13));
|
||||
}
|
||||
|
||||
return hdata(s | 0x7c00);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// F is a NAN; we produce a half NAN that preserves
|
||||
// the sign bit and the 10 leftmost bits of the
|
||||
// significand of f, with one exception: If the 10
|
||||
// leftmost bits are all zero, the NAN would turn
|
||||
// into an infinity, so we have to set at least one
|
||||
// bit in the significand.
|
||||
//
|
||||
if(e == 0xff - (127 - 15))
|
||||
{
|
||||
if(m == 0)
|
||||
{
|
||||
//
|
||||
// F is an infinity; convert f to a half
|
||||
// infinity with the same sign as f.
|
||||
//
|
||||
|
||||
m >>= 13;
|
||||
return (int16_t)(s | 0x7c00);
|
||||
}
|
||||
|
||||
return hdata(s | 0x7c00 | m | (m == 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// E is greater than zero. F is a normalized float.
|
||||
// We try to convert f to a normalized half.
|
||||
//
|
||||
//
|
||||
// F is a NAN; we produce a half NAN that preserves
|
||||
// the sign bit and the 10 leftmost bits of the
|
||||
// significand of f, with one exception: If the 10
|
||||
// leftmost bits are all zero, the NAN would turn
|
||||
// into an infinity, so we have to set at least one
|
||||
// bit in the significand.
|
||||
//
|
||||
|
||||
//
|
||||
// Round to nearest, round "0.5" up
|
||||
//
|
||||
m >>= 13;
|
||||
|
||||
if(m & 0x00001000)
|
||||
{
|
||||
m += 0x00002000;
|
||||
return (int16_t)(s | 0x7c00 | m | (m == 0));
|
||||
}
|
||||
|
||||
if(m & 0x00800000)
|
||||
{
|
||||
m = 0; // overflow in significand,
|
||||
e += 1; // adjust exponent
|
||||
}
|
||||
}
|
||||
//
|
||||
// E is greater than zero. F is a normalized float.
|
||||
// We try to convert f to a normalized half.
|
||||
//
|
||||
|
||||
//
|
||||
// Handle exponent overflow
|
||||
//
|
||||
//
|
||||
// Round to nearest, round "0.5" up
|
||||
//
|
||||
|
||||
if (e > 30)
|
||||
{
|
||||
overflow(); // Cause a hardware floating point overflow;
|
||||
if(m & 0x00001000)
|
||||
{
|
||||
m += 0x00002000;
|
||||
|
||||
return hdata(s | 0x7c00);
|
||||
// if this returns, the half becomes an
|
||||
} // infinity with the same sign as f.
|
||||
if(m & 0x00800000)
|
||||
{
|
||||
m = 0; // overflow in significand,
|
||||
e += 1; // adjust exponent
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Assemble the half from s, e and m.
|
||||
//
|
||||
//
|
||||
// Handle exponent overflow
|
||||
//
|
||||
|
||||
return hdata(s | (e << 10) | (m >> 13));
|
||||
}
|
||||
}
|
||||
if (e > 30)
|
||||
{
|
||||
overflow(); // Cause a hardware floating point overflow;
|
||||
|
||||
return (int16_t)(s | 0x7c00);
|
||||
// if this returns, the half becomes an
|
||||
} // infinity with the same sign as f.
|
||||
|
||||
//
|
||||
// Assemble the half from s, e and m.
|
||||
//
|
||||
|
||||
return (int16_t)(s | (e << 10) | (m >> 13));
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
Loading…
x
Reference in New Issue
Block a user