Fixed GTC_packing unpackUnorm3x10_1x2 #414

This commit is contained in:
Christophe Riccio 2015-09-28 23:47:40 +02:00
parent bc170cfc0f
commit cb5a2a86ca
3 changed files with 18 additions and 18 deletions

View File

@ -451,24 +451,23 @@ namespace detail
GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v)
{
detail::i10i10i10i2 Result;
Result.data.x = int(round(clamp(v.x, 0.0f, 1.0f) * 1023.f));
Result.data.y = int(round(clamp(v.y, 0.0f, 1.0f) * 1023.f));
Result.data.z = int(round(clamp(v.z, 0.0f, 1.0f) * 1023.f));
Result.data.w = int(round(clamp(v.w, 0.0f, 1.0f) * 3.f));
uvec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 3.f)));
detail::u10u10u10u2 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
Result.data.w = Unpack.w;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
vec4 const ScaleFactors(1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 1023.f, 1.0f / 3.f);
detail::u10u10u10u2 Unpack;
Unpack.pack = v;
vec4 Result;
Result.x = float(Unpack.data.x) / 1023.f;
Result.y = float(Unpack.data.y) / 1023.f;
Result.z = float(Unpack.data.z) / 1023.f;
Result.w = float(Unpack.data.w) / 3.f;
return Result;
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactors;
}
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v)

View File

@ -57,6 +57,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
##### Fixes:
- Fixed GTC_round floorMultiple/ceilMultiple #412
- Fixed GTC_packing unpackUnorm3x10_1x2 #414
#### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/tag/0.9.7.1) - 2015-09-07
##### Improvements:

View File

@ -220,10 +220,10 @@ int test_Unorm3x10_1x2()
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
glm::uint32 p0 = glm::packUnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackUnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packUnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackUnorm3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
@ -394,7 +394,7 @@ int test_packUnorm1x8()
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint16 C = glm::packUnorm1x8(B.x);
glm::uint8 C = glm::packUnorm1x8(B.x);
glm::vec1 D(glm::unpackUnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
@ -414,7 +414,7 @@ int test_packSnorm1x8()
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint16 C = glm::packSnorm1x8(B.x);
glm::uint8 C = glm::packSnorm1x8(B.x);
glm::vec1 D(glm::unpackSnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
}