Use length_t instead of int for vec and mat lengths #584

This commit is contained in:
Christophe Riccio
2016-12-30 20:05:04 +01:00
parent b92fdf5a59
commit c2fe3fccf6
217 changed files with 4724 additions and 4799 deletions

View File

@@ -344,7 +344,7 @@ namespace clamp_
namespace mix_
{
template <typename T, typename B>
template<typename T, typename B>
struct entry
{
T x;
@@ -514,7 +514,7 @@ namespace mix_
namespace step_
{
template <typename EDGE, typename VEC>
template<typename EDGE, typename VEC>
struct entry
{
EDGE edge;
@@ -817,7 +817,7 @@ namespace isinf_
namespace sign
{
template <typename genFIType>
template<typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_if(genFIType x)
{
GLM_STATIC_ASSERT(
@@ -834,7 +834,7 @@ namespace sign
return result;
}
template <typename genFIType>
template<typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_alu1(genFIType x)
{
GLM_STATIC_ASSERT(
@@ -844,7 +844,7 @@ namespace sign
return (x >> 31) | ((unsigned)-x >> 31);
}
template <typename genFIType>
template<typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_alu2(genFIType x)
{
GLM_STATIC_ASSERT(
@@ -854,7 +854,7 @@ namespace sign
return -((unsigned)x >> 31) | (-(unsigned)x >> 31);
}
template <typename genFIType>
template<typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_sub(genFIType x)
{
GLM_STATIC_ASSERT(
@@ -864,7 +864,7 @@ namespace sign
return ((unsigned)-x >> 31) - ((unsigned)x >> 31);
}
template <typename genFIType>
template<typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_cmp(genFIType x)
{
GLM_STATIC_ASSERT(
@@ -874,7 +874,7 @@ namespace sign
return (x > 0) - (x < 0);
}
template <typename genType>
template<typename genType>
struct type
{
genType Value;

View File

@@ -15,7 +15,7 @@ enum result
namespace bitfieldInsert
{
template <typename genType, typename sizeType>
template<typename genType, typename sizeType>
struct type
{
genType Base;
@@ -59,7 +59,7 @@ namespace bitfieldInsert
namespace bitfieldExtract
{
template <typename genType, typename sizeType>
template<typename genType, typename sizeType>
struct type
{
genType Value;
@@ -151,23 +151,23 @@ namespace bitfieldReverse
return Result;
}
*/
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldReverseLoop(vecType<D, T, P> const & v)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldReverseLoop(vecType<L, T, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldReverse' only accept integer values");
vecType<D, T, P> Result(0);
vecType<L, T, P> Result(0);
T const BitSize = static_cast<T>(sizeof(T) * 8);
for(T i = 0; i < BitSize; ++i)
{
vecType<D, T, P> const BitSet(v & (static_cast<T>(1) << i));
vecType<D, T, P> const BitFirst(BitSet >> i);
vecType<L, T, P> const BitSet(v & (static_cast<T>(1) << i));
vecType<L, T, P> const BitFirst(BitSet >> i);
Result |= BitFirst << (BitSize - 1 - i);
}
return Result;
}
template <typename T>
template<typename T>
GLM_FUNC_QUALIFIER T bitfieldReverseLoop(T v)
{
return bitfieldReverseLoop(glm::vec<1, T>(v)).x;
@@ -194,30 +194,30 @@ namespace bitfieldReverse
return x;
}
template <bool EXEC = false>
template<bool EXEC = false>
struct compute_bitfieldReverseStep
{
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T, T)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T, T)
{
return v;
}
};
template <>
template<>
struct compute_bitfieldReverseStep<true>
{
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T Mask, T Shift)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T Mask, T Shift)
{
return (v & Mask) << Shift | (v & (~Mask)) >> Shift;
}
};
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, T, P> bitfieldReverseOps(vecType<D, T, P> const & v)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldReverseOps(vecType<L, T, P> const & v)
{
vecType<D, T, P> x(v);
vecType<L, T, P> x(v);
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 2>::call(x, T(0x5555555555555555ull), static_cast<T>( 1));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 4>::call(x, T(0x3333333333333333ull), static_cast<T>( 2));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
@@ -227,13 +227,13 @@ namespace bitfieldReverse
return x;
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER genType bitfieldReverseOps(genType x)
{
return bitfieldReverseOps(glm::vec<1, genType, glm::defaultp>(x)).x;
}
template <typename genType>
template<typename genType>
struct type
{
genType Value;
@@ -538,7 +538,7 @@ namespace bitfieldReverse
namespace findMSB
{
template <typename genType, typename retType>
template<typename genType, typename retType>
struct type
{
genType Value;
@@ -546,7 +546,7 @@ namespace findMSB
};
# if GLM_HAS_BITSCAN_WINDOWS
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
@@ -561,7 +561,7 @@ namespace findMSB
# endif//GLM_HAS_BITSCAN_WINDOWS
# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_avx(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
@@ -573,7 +573,7 @@ namespace findMSB
}
# endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
@@ -597,7 +597,7 @@ namespace findMSB
}
}
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_nlz1(genIUType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
@@ -927,7 +927,7 @@ namespace findMSB
namespace findLSB
{
template <typename genType, typename retType>
template<typename genType, typename retType>
struct type
{
genType Value;
@@ -950,7 +950,7 @@ namespace findLSB
};
# if GLM_HAS_BITSCAN_WINDOWS
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
@@ -964,7 +964,7 @@ namespace findLSB
}
# endif
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
@@ -976,7 +976,7 @@ namespace findLSB
return Bit;
}
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_ntz2(genIUType x)
{
if(x == 0)
@@ -985,7 +985,7 @@ namespace findLSB
return glm::bitCount(~x & (x - static_cast<genIUType>(1)));
}
template <typename genIUType>
template<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_branchfree(genIUType x)
{
bool IsNull(x == 0);
@@ -1361,7 +1361,7 @@ namespace imulExtended
namespace bitCount
{
template <typename genType>
template<typename genType>
struct type
{
genType Value;
@@ -1377,7 +1377,7 @@ namespace bitCount
{0x00000000, 0}
};
template <typename T>
template<typename T>
inline int bitCount_if(T v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");
@@ -1391,7 +1391,7 @@ namespace bitCount
return Count;
}
template <typename T>
template<typename T>
inline int bitCount_vec(T v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");
@@ -1404,40 +1404,40 @@ namespace bitCount
return Count;
}
template <bool EXEC = false>
template<bool EXEC = false>
struct compute_bitfieldBitCountStep
{
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T, T)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T, T)
{
return v;
}
};
template <>
template<>
struct compute_bitfieldBitCountStep<true>
{
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<D, T, P> call(vecType<D, T, P> const & v, T Mask, T Shift)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T Mask, T Shift)
{
return (v & Mask) + ((v >> Shift) & Mask);
}
};
template <int D, typename T, glm::precision P, template <int, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<D, int, P> bitCount_bitfield(vecType<D, T, P> const & v)
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> bitCount_bitfield(vecType<L, T, P> const & v)
{
vecType<D, typename glm::detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vecType<D, typename glm::detail::make_unsigned<T>::type, P> const *>(&v));
vecType<L, typename glm::detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vecType<L, typename glm::detail::make_unsigned<T>::type, P> const *>(&v));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 2>::call(x, typename glm::detail::make_unsigned<T>::type(0x5555555555555555ull), typename glm::detail::make_unsigned<T>::type( 1));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 4>::call(x, typename glm::detail::make_unsigned<T>::type(0x3333333333333333ull), typename glm::detail::make_unsigned<T>::type( 2));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 8>::call(x, typename glm::detail::make_unsigned<T>::type(0x0F0F0F0F0F0F0F0Full), typename glm::detail::make_unsigned<T>::type( 4));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 16>::call(x, typename glm::detail::make_unsigned<T>::type(0x00FF00FF00FF00FFull), typename glm::detail::make_unsigned<T>::type( 8));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 32>::call(x, typename glm::detail::make_unsigned<T>::type(0x0000FFFF0000FFFFull), typename glm::detail::make_unsigned<T>::type(16));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 64>::call(x, typename glm::detail::make_unsigned<T>::type(0x00000000FFFFFFFFull), typename glm::detail::make_unsigned<T>::type(32));
return vecType<D, int, P>(x);
return vecType<L, int, P>(x);
}
template <typename genType>
template<typename genType>
GLM_FUNC_QUALIFIER int bitCount_bitfield(genType x)
{
return bitCount_bitfield(glm::vec<1, genType, glm::defaultp>(x)).x;

View File

@@ -208,7 +208,7 @@ int test_inverse_simd()
return Error;
}
template <typename VEC3, typename MAT4>
template<typename VEC3, typename MAT4>
int test_inverse_perf(std::size_t Count, std::size_t Instance, char const * Message)
{
std::vector<MAT4> TestInputs;

View File

@@ -196,19 +196,19 @@ int test_operators()
return (S && !R) ? 0 : 1;
}
template <typename T>
template<typename T>
struct vec
{
};
template <template <typename> class C, typename T>
template<template<typename> class C, typename T>
struct Class
{
};
template <typename T>
template<typename T>
struct Class<vec, T>
{

View File

@@ -99,7 +99,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -73,7 +73,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -73,7 +73,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -77,7 +77,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -136,7 +136,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -77,7 +77,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -81,7 +81,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -81,7 +81,7 @@ int test_ctr()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -13,7 +13,7 @@
#include <vector>
template <typename genType>
template<typename genType>
void print(genType const & Mat0)
{
printf("mat4(\n");
@@ -253,7 +253,7 @@ int perf_mul()
namespace cast
{
template <typename genType>
template<typename genType>
int entry()
{
int Error = 0;

View File

@@ -8,7 +8,7 @@
#include <ctime>
#include <vector>
template <int Value>
template<int Value>
struct mask
{
enum{value = Value};