1
0

mat2.h 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c), Recep Aslantas.
  3. *
  4. * MIT License (MIT), http://opensource.org/licenses/MIT
  5. * Full license can be found in the LICENSE file
  6. */
  7. #ifndef cglm_mat2_neon_h
  8. #define cglm_mat2_neon_h
  9. #if defined(CGLM_NEON_FP)
  10. #include "../../common.h"
  11. #include "../intrin.h"
  12. CGLM_INLINE
  13. void
  14. glm_mat2_mul_neon(mat2 m1, mat2 m2, mat2 dest) {
  15. float32x4x2_t a1;
  16. glmm_128 x0, x1, x2;
  17. float32x2_t dc, ba;
  18. x1 = glmm_load(m1[0]); /* d c b a */
  19. x2 = glmm_load(m2[0]); /* h g f e */
  20. dc = vget_high_f32(x1);
  21. ba = vget_low_f32(x1);
  22. /* g g e e, h h f f */
  23. a1 = vtrnq_f32(x2, x2);
  24. /*
  25. dest[0][0] = a * e + c * f;
  26. dest[0][1] = b * e + d * f;
  27. dest[1][0] = a * g + c * h;
  28. dest[1][1] = b * g + d * h;
  29. */
  30. x0 = glmm_fmadd(vcombine_f32(ba, ba), a1.val[0],
  31. vmulq_f32(vcombine_f32(dc, dc), a1.val[1]));
  32. glmm_store(dest[0], x0);
  33. }
  34. #endif
  35. #endif /* cglm_mat2_neon_h */