Last active
May 23, 2018 10:53
-
-
Save recp/1ff8826d1b5db80f2be0f89575e0b57c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGLM_INLINE | |
void | |
glm_rotate_make_sse(mat4 m, float angle, vec3 axis) { | |
__m128 x0, x1, x2, x3, x4, x5, x6, x7, x8; | |
float c, s; | |
c = cosf(angle); | |
s = sinf(angle); | |
x0 = glmm_load3(axis); | |
x0 = _mm_div_ps(x0, glmm_norm(x0)); | |
x1 = _mm_set_ps(s, c, 1.0f, 0.0f); | |
x2 = _mm_mul_ps(x0, _mm_sub_ps(glmm_shuff1x(x1, 1), | |
glmm_shuff1x(x1, 2))); | |
x3 = _mm_mul_ps(x0, glmm_shuff1x(x2, 0)); | |
x4 = _mm_mul_ps(x0, glmm_shuff1x(x2, 1)); | |
x5 = _mm_mul_ps(x0, glmm_shuff1x(x2, 2)); | |
x2 = _mm_mul_ps(x0, glmm_shuff1x(x1, 3)); | |
x6 = glmm_shuff2(x1, x2, 1, 2, 2, 0, 0, 3, 2, 1); | |
x7 = glmm_shuff2(x1, x2, 0, 2, 2, 0, 0, 3, 1, 2); | |
x8 = glmm_shuff2(x1, x2, 0, 1, 2, 0, 0, 1, 3, 2); | |
x6 = _mm_xor_ps(x6, _mm_set_ps(0.f, -0.f, 0.f, 0.f)); | |
x7 = _mm_xor_ps(x7, _mm_set_ps(0.f, 0.f, 0.f, -0.f)); | |
x8 = _mm_xor_ps(x8, _mm_set_ps(0.f, 0.f, -0.f, 0.f)); | |
_mm_store_ps(m[0], _mm_add_ps(x3, x6)); | |
_mm_store_ps(m[1], _mm_add_ps(x4, x7)); | |
_mm_store_ps(m[2], _mm_add_ps(x5, x8)); | |
_mm_store_ps(m[3], glmm_shuff1(x1, 1, 0, 0, 0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment