|
|
|
@ -29,6 +29,7 @@ |
|
|
|
|
#include <glm/glm.hpp> |
|
|
|
|
#include <glm/gtc/packing.hpp> |
|
|
|
|
#include <cstdio> |
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
void print_bits(glm::half const & s) |
|
|
|
|
{ |
|
|
|
@ -132,24 +133,96 @@ int test_half() |
|
|
|
|
return Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int test_F2x11_1x10() |
|
|
|
|
int test_Half1x16() |
|
|
|
|
{ |
|
|
|
|
int Error = 0; |
|
|
|
|
|
|
|
|
|
std::vector<glm::vec3> Tests; |
|
|
|
|
Tests.push_back(glm::vec3(1.0)); |
|
|
|
|
Tests.push_back(glm::vec3(0.0)); |
|
|
|
|
Tests.push_back(glm::vec3(2.0)); |
|
|
|
|
Tests.push_back(glm::vec3(0.1)); |
|
|
|
|
Tests.push_back(glm::vec3(0.5)); |
|
|
|
|
Tests.push_back(glm::vec3(0.9)); |
|
|
|
|
std::vector<float> Tests; |
|
|
|
|
Tests.push_back(0.0f); |
|
|
|
|
Tests.push_back(1.0f); |
|
|
|
|
Tests.push_back(-1.0f); |
|
|
|
|
Tests.push_back(2.0f); |
|
|
|
|
Tests.push_back(-2.0f); |
|
|
|
|
Tests.push_back(1.9f); |
|
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]); |
|
|
|
|
glm::vec3 v0 = glm::unpackF2x11_1x10(p0); |
|
|
|
|
glm::uint32 p1 = glm::packF2x11_1x10(v0); |
|
|
|
|
glm::vec3 v1 = glm::unpackF2x11_1x10(p0); |
|
|
|
|
glm::uint32 p0 = glm::packHalf1x16(Tests[i]); |
|
|
|
|
float v0 = glm::unpackHalf1x16(p0); |
|
|
|
|
glm::uint32 p1 = glm::packHalf1x16(v0); |
|
|
|
|
float v1 = glm::unpackHalf1x16(p0); |
|
|
|
|
Error += (v0 == v1) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int test_Half4x16() |
|
|
|
|
{ |
|
|
|
|
int Error = 0; |
|
|
|
|
|
|
|
|
|
std::vector<glm::vec4> Tests; |
|
|
|
|
Tests.push_back(glm::vec4(1.0)); |
|
|
|
|
Tests.push_back(glm::vec4(0.0)); |
|
|
|
|
Tests.push_back(glm::vec4(2.0)); |
|
|
|
|
Tests.push_back(glm::vec4(0.1)); |
|
|
|
|
Tests.push_back(glm::vec4(0.5)); |
|
|
|
|
Tests.push_back(glm::vec4(-0.9)); |
|
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint64 p0 = glm::packHalf4x16(Tests[i]); |
|
|
|
|
glm::vec4 v0 = glm::unpackHalf4x16(p0); |
|
|
|
|
glm::uint64 p1 = glm::packHalf4x16(v0); |
|
|
|
|
glm::vec4 v1 = glm::unpackHalf4x16(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int test_I3x10_1x2() |
|
|
|
|
{ |
|
|
|
|
int Error = 0; |
|
|
|
|
|
|
|
|
|
std::vector<glm::ivec4> Tests; |
|
|
|
|
Tests.push_back(glm::ivec4(0)); |
|
|
|
|
Tests.push_back(glm::ivec4(1)); |
|
|
|
|
Tests.push_back(glm::ivec4(-1)); |
|
|
|
|
Tests.push_back(glm::ivec4(2)); |
|
|
|
|
Tests.push_back(glm::ivec4(-2)); |
|
|
|
|
Tests.push_back(glm::ivec4(3)); |
|
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]); |
|
|
|
|
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0); |
|
|
|
|
glm::uint32 p1 = glm::packI3x10_1x2(v0); |
|
|
|
|
glm::ivec4 v1 = glm::unpackI3x10_1x2(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int test_U3x10_1x2() |
|
|
|
|
{ |
|
|
|
|
int Error = 0; |
|
|
|
|
|
|
|
|
|
std::vector<glm::uvec4> Tests; |
|
|
|
|
Tests.push_back(glm::uvec4(0)); |
|
|
|
|
Tests.push_back(glm::uvec4(1)); |
|
|
|
|
Tests.push_back(glm::uvec4(2)); |
|
|
|
|
Tests.push_back(glm::uvec4(3)); |
|
|
|
|
Tests.push_back(glm::uvec4(4)); |
|
|
|
|
Tests.push_back(glm::uvec4(5)); |
|
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]); |
|
|
|
|
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0); |
|
|
|
|
glm::uint32 p1 = glm::packU3x10_1x2(v0); |
|
|
|
|
glm::uvec4 v1 = glm::unpackU3x10_1x2(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -171,9 +244,9 @@ int test_Snorm3x10_1x2() |
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); |
|
|
|
|
glm::vec3 v0 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); |
|
|
|
|
glm::vec3 v1 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -195,9 +268,33 @@ int test_Unorm3x10_1x2() |
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); |
|
|
|
|
glm::vec3 v0 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); |
|
|
|
|
glm::vec3 v1 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int test_F2x11_1x10() |
|
|
|
|
{ |
|
|
|
|
int Error = 0; |
|
|
|
|
|
|
|
|
|
std::vector<glm::vec3> Tests; |
|
|
|
|
Tests.push_back(glm::vec3(1.0)); |
|
|
|
|
Tests.push_back(glm::vec3(0.0)); |
|
|
|
|
Tests.push_back(glm::vec3(2.0)); |
|
|
|
|
Tests.push_back(glm::vec3(0.1)); |
|
|
|
|
Tests.push_back(glm::vec3(0.5)); |
|
|
|
|
Tests.push_back(glm::vec3(0.9)); |
|
|
|
|
|
|
|
|
|
for(std::size_t i = 0; i < Tests.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]); |
|
|
|
|
glm::vec3 v0 = glm::unpackF2x11_1x10(p0); |
|
|
|
|
glm::uint32 p1 = glm::packF2x11_1x10(v0); |
|
|
|
|
glm::vec3 v1 = glm::unpackF2x11_1x10(p0); |
|
|
|
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|