Added bit interleave for 3 and 4 integers

This commit is contained in:
Christophe Riccio
2013-02-10 19:25:11 +01:00
parent 6799127ec6
commit bd7125c50b
4 changed files with 252 additions and 3 deletions

View File

@@ -11,6 +11,9 @@
#include <glm/gtc/random.hpp>
#include <glm/gtc/epsilon.hpp>
#include <iostream>
#if(GLM_LANG & GLM_LANG_CXX0X)
# include <array>
#endif
int test_linearRand()
{
@@ -136,6 +139,46 @@ int test_ballRand()
return Error;
}
#if(GLM_LANG & GLM_LANG_CXX0X)
int test_grid()
{
int Error = 0;
typedef std::array<int, 8> colors;
typedef std::array<int, 8 * 8> grid;
grid Grid;
colors Colors;
grid GridBest;
colors ColorsBest;
while(true)
{
for(std::size_t i = 0; i < Grid.size(); ++i)
Grid[i] = int(glm::linearRand(0.0, 8.0 * 8.0 * 8.0 - 1.0) / 64.0);
for(std::size_t i = 0; i < Grid.size(); ++i)
++Colors[Grid[i]];
bool Exit = true;
for(std::size_t i = 0; i < Colors.size(); ++i)
{
if(Colors[i] == 8)
continue;
Exit = false;
break;
}
if(Exit == true)
break;
}
return Error;
}
#endif
int main()
{
int Error = 0;

View File

@@ -7,6 +7,8 @@
// File : test/gtx/bit.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <emmintrin.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/bit.hpp>
@@ -19,8 +21,6 @@
#include <vector>
#include <ctime>
#include <emmintrin.h>
enum result
{
SUCCESS,
@@ -479,6 +479,17 @@ namespace bitfieldInterleave
std::cout << "sseUnalignedBitfieldInterleave Time " << Time << " clocks" << std::endl;
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::detail::bitfieldInterleave(Param[i].x, Param[i].y, Param[i].x);
std::clock_t Time = std::clock() - LastTime;
std::cout << "glm::detail::bitfieldInterleave Time " << Time << " clocks" << std::endl;
}
# if(GLM_ARCH != GLM_ARCH_PURE)
{
// SIMD
@@ -505,12 +516,28 @@ namespace bitfieldInterleave
}
}
namespace bitfieldInterleave3
{
int test()
{
int Error(0);
glm::uint64 Result = glm::detail::bitfieldInterleave(0xFFFFFFFF, 0x00000000, 0x00000000);
return Error;
}
}
int main()
{
int Error = 0;
int Error(0);
Error += ::bitfieldInterleave3::test();
Error += ::bitfieldInterleave::test();
Error += ::extractField::test();
Error += ::bitRevert::test();
while(true);
return Error;
}