Fixed GTC_packing unpackUnorm3x10_1x2 #414

This commit is contained in:
Christophe Riccio 2015-09-28 23:47:40 +02:00
parent 11bfa1eff7
commit 06ad5a2cd4
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) GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v)
{ {
detail::i10i10i10i2 Result; 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)));
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)); detail::u10u10u10u2 Result;
Result.data.z = int(round(clamp(v.z, 0.0f, 1.0f) * 1023.f)); Result.data.x = Unpack.x;
Result.data.w = int(round(clamp(v.w, 0.0f, 1.0f) * 3.f)); Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
Result.data.w = Unpack.w;
return Result.pack; return Result.pack;
} }
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v) 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; Unpack.pack = v;
vec4 Result; return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactors;
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;
} }
GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v) GLM_FUNC_QUALIFIER uint32 packF2x11_1x10(vec3 const & v)

View File

@ -54,6 +54,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX #### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX
##### Fixes: ##### Fixes:
- Fixed GTC_round floorMultiple/ceilMultiple #412 - 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 #### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/tag/0.9.7.1) - 2015-09-07
##### Improvements: ##### Improvements:

View File

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