Optimized GTC_packing implementation

This commit is contained in:
Christophe Riccio 2016-11-20 19:54:03 +01:00
parent 3cc726c7a4
commit 32cfecba97
3 changed files with 13 additions and 12 deletions

View File

@ -554,11 +554,13 @@ namespace detail
GLM_FUNC_QUALIFIER uint32 packSnorm3x10_1x2(vec4 const & v)
{
ivec4 const Pack(round(clamp(v,-1.0f, 1.0f) * vec4(511.f, 511.f, 511.f, 1.f)));
detail::i10i10i10i2 Result;
Result.data.x = int(round(clamp(v.x,-1.0f, 1.0f) * 511.f));
Result.data.y = int(round(clamp(v.y,-1.0f, 1.0f) * 511.f));
Result.data.z = int(round(clamp(v.z,-1.0f, 1.0f) * 511.f));
Result.data.w = int(round(clamp(v.w,-1.0f, 1.0f) * 1.f));
Result.data.x = Pack.x;
Result.data.y = Pack.y;
Result.data.z = Pack.z;
Result.data.w = Pack.w;
return Result.pack;
}
@ -566,12 +568,10 @@ namespace detail
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
vec4 Result;
Result.x = clamp(float(Unpack.data.x) / 511.f, -1.0f, 1.0f);
Result.y = clamp(float(Unpack.data.y) / 511.f, -1.0f, 1.0f);
Result.z = clamp(float(Unpack.data.z) / 511.f, -1.0f, 1.0f);
Result.w = clamp(float(Unpack.data.w) / 1.f, -1.0f, 1.0f);
return Result;
vec4 const Result(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w);
return clamp(Result * vec4(1.f / 511.f, 1.f / 511.f, 1.f / 511.f, 1.f), -1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER uint32 packUnorm3x10_1x2(vec4 const & v)

View File

@ -62,6 +62,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
#### Improvements:
- Added lowp variant of GTC_colorspace convertLinearToSRGB #419
- Replaced the manual by a markdown version #458
- Optimized GTC_packing implementation
#### Fixes:
- Removed doxygen references to GTC_half_float which was removed in 0.9.4

View File

@ -690,10 +690,10 @@ int main()
Error += test_RGBM();
// It looks like GLM has a but that travis CI shows in this configuration #577
#if !((GLM_ARCH == GLM_ARCH_PURE) && (GLM_COMPILER & GLM_COMPILER_GCC))
//#if !((GLM_ARCH == GLM_ARCH_PURE) && (GLM_COMPILER & GLM_COMPILER_GCC))
Error += test_Unorm3x10_1x2();
#endif
Error += test_Snorm3x10_1x2();
//#endif
Error += test_I3x10_1x2();
Error += test_U3x10_1x2();