G
Groovounet
The following code is working on VC2010 but I don't think it's a
standard behaviours as it doesn't work on GCC as it says that Mask
must be a direct constant.
Is there some changes in C++0x?
Is there a workaround in C++98?
template<int a, int b, int c, int d>
__m128 swizzle(glm::vec4 const & v)
{
enum {Mask = ((d << 6) | (c << 4) | (b << 2) | (a << 0))};
__m128 Src = _mm_set_ps(v.w, v.z, v.y, v.x);
return _mm_shuffle_ps(Src, Src, Mask);
}
int main()
{
__m128 Data = swizzle<0, 1, 2, 3>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
return 0;
}
standard behaviours as it doesn't work on GCC as it says that Mask
must be a direct constant.
Is there some changes in C++0x?
Is there a workaround in C++98?
template<int a, int b, int c, int d>
__m128 swizzle(glm::vec4 const & v)
{
enum {Mask = ((d << 6) | (c << 4) | (b << 2) | (a << 0))};
__m128 Src = _mm_set_ps(v.w, v.z, v.y, v.x);
return _mm_shuffle_ps(Src, Src, Mask);
}
int main()
{
__m128 Data = swizzle<0, 1, 2, 3>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
return 0;
}