mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
Initial Commit
This commit is contained in:
49
.gitignore
vendored
Normal file
49
.gitignore
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
*.xcodeproj
|
||||||
|
*.xcworkspace
|
||||||
|
*.sln
|
||||||
|
*.vcxproj
|
||||||
|
*.vcxproj.*
|
||||||
|
*.suo
|
||||||
|
*.sdf
|
||||||
|
*.opensdf
|
||||||
|
ipch/
|
||||||
|
Debug/
|
||||||
|
Release/
|
||||||
|
.DS_Store
|
||||||
|
.vs
|
||||||
|
*.nupkg
|
||||||
|
*.opendb
|
||||||
|
packages.config
|
||||||
|
/aclocal.m4
|
||||||
|
/ar-lib
|
||||||
|
/autom4te.cache/
|
||||||
|
/compile
|
||||||
|
/config.guess
|
||||||
|
/config.log
|
||||||
|
/config.status
|
||||||
|
/config.sub
|
||||||
|
/configure
|
||||||
|
/depcomp
|
||||||
|
/install-sh
|
||||||
|
/ltmain.sh
|
||||||
|
/missing
|
||||||
|
/libtool
|
||||||
|
/.libs/
|
||||||
|
.deps/
|
||||||
|
*.[oa]
|
||||||
|
*.l[oa]
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
m4/*.m4
|
||||||
|
.buildstamp
|
||||||
|
.dirstamp
|
||||||
|
packages/
|
||||||
|
.anjuta/*
|
||||||
|
*.anjuta*
|
||||||
|
config.h.*
|
||||||
|
config.h
|
||||||
|
stamp*
|
||||||
|
COPYING
|
||||||
|
.idea/*
|
||||||
|
*.VC.db
|
||||||
|
cscope.*
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 Recep Aslantas <info@recp.me>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
17
include/cglm-common.h
Normal file
17
include/cglm-common.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef glm_common_h
|
||||||
|
#define glm_common_h
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# define CGLM_INLINE __forceinline
|
||||||
|
#else
|
||||||
|
# define CGLM_INLINE static inline __attribute((always_inline))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* glm_common_h */
|
23
include/cglm-intrin.h
Normal file
23
include/cglm-intrin.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_intrin_h
|
||||||
|
#define cglm_intrin_h
|
||||||
|
|
||||||
|
#include <xmmintrin.h>
|
||||||
|
#include <emmintrin.h>
|
||||||
|
|
||||||
|
/* float */
|
||||||
|
#define _mm_madd_ps(L, R0, R1) \
|
||||||
|
_mm_add_ps(_mm_mul_ps(_mm_set1_ps(*(L)), R0), \
|
||||||
|
_mm_mul_ps(_mm_set1_ps(*(L + 1)), R1))
|
||||||
|
|
||||||
|
#define _mm_madd4_ps(L, R0, R1, R2, R3) \
|
||||||
|
_mm_add_ps(_mm_madd_ps(L, R0, R1), \
|
||||||
|
_mm_madd_ps(L + 2, R2, R3))
|
||||||
|
|
||||||
|
#endif /* cglm_intrin_h */
|
31
include/cglm-mat-simd.h
Normal file
31
include/cglm-mat-simd.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat_sse_h
|
||||||
|
#define cglm_mat_sse_h
|
||||||
|
|
||||||
|
#include "cglm-intrin.h"
|
||||||
|
|
||||||
|
#define CGLM_MAT_MUL_SSE_4x4f(L, R, D) \
|
||||||
|
do { \
|
||||||
|
__m128 r0; \
|
||||||
|
__m128 r1; \
|
||||||
|
__m128 r2; \
|
||||||
|
__m128 r3; \
|
||||||
|
\
|
||||||
|
r0 = _mm_load_ps(R); \
|
||||||
|
r1 = _mm_load_ps(R + 4); \
|
||||||
|
r2 = _mm_load_ps(R + 8); \
|
||||||
|
r3 = _mm_load_ps(R + 12); \
|
||||||
|
\
|
||||||
|
_mm_store_ps(D, _mm_madd4_ps(L, r0, r1, r2, r3)); \
|
||||||
|
_mm_store_ps(D + 4, _mm_madd4_ps(L + 4, r0, r1, r2, r3)); \
|
||||||
|
_mm_store_ps(D + 8, _mm_madd4_ps(L + 8, r0, r1, r2, r3)); \
|
||||||
|
_mm_store_ps(D + 12, _mm_madd4_ps(L + 12, r0, r1, r2, r3)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* cglm_mat_sse_h */
|
46
include/cglm-mat.h
Normal file
46
include/cglm-mat.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_mat_h
|
||||||
|
#define cglm_mat_h
|
||||||
|
|
||||||
|
#include "cglm.h"
|
||||||
|
#include "cglm-mat-simd.h"
|
||||||
|
|
||||||
|
#define glm_mat_mul4_impl(l, r, d) \
|
||||||
|
do { \
|
||||||
|
d[0] = l[0] * r[0] + l[1] * r[4] + l[2] * r[8] + l[3] * r[12]; \
|
||||||
|
d[1] = l[0] * r[1] + l[1] * r[5] + l[2] * r[9] + l[3] * r[13]; \
|
||||||
|
d[2] = l[0] * r[2] + l[1] * r[6] + l[2] * r[10] + l[3] * r[14]; \
|
||||||
|
d[3] = l[0] * r[3] + l[1] * r[7] + l[2] * r[11] + l[3] * r[15]; \
|
||||||
|
d[4] = l[4] * r[0] + l[5] * r[4] + l[6] * r[8] + l[7] * r[12]; \
|
||||||
|
d[5] = l[4] * r[1] + l[5] * r[5] + l[6] * r[9] + l[7] * r[13]; \
|
||||||
|
d[6] = l[4] * r[2] + l[5] * r[6] + l[6] * r[10] + l[7] * r[14]; \
|
||||||
|
d[7] = l[4] * r[3] + l[5] * r[7] + l[6] * r[11] + l[7] * r[15]; \
|
||||||
|
d[8] = l[8] * r[0] + l[9] * r[4] + l[10] * r[8] + l[11] * r[12]; \
|
||||||
|
d[9] = l[8] * r[1] + l[9] * r[5] + l[10] * r[9] + l[11] * r[13]; \
|
||||||
|
d[10] = l[8] * r[2] + l[9] * r[6] + l[10] * r[10] + l[11] * r[14]; \
|
||||||
|
d[11] = l[8] * r[3] + l[9] * r[7] + l[10] * r[11] + l[11] * r[15]; \
|
||||||
|
d[12] = l[12] * r[0] + l[13] * r[4] + l[14] * r[8] + l[15] * r[12]; \
|
||||||
|
d[13] = l[12] * r[1] + l[13] * r[5] + l[14] * r[9] + l[15] * r[13]; \
|
||||||
|
d[14] = l[12] * r[2] + l[13] * r[6] + l[14] * r[10] + l[15] * r[14]; \
|
||||||
|
d[15] = l[12] * r[3] + l[13] * r[7] + l[14] * r[11] + l[15] * r[15]; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat_mul4(float * __restrict m1,
|
||||||
|
float * __restrict m2,
|
||||||
|
float * __restrict dest) {
|
||||||
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
|
CGLM_MAT_MUL_SSE_4x4f(m1, m2, dest);
|
||||||
|
#else
|
||||||
|
glm_mat_mul4_impl(m1, m2, dest);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglm_mat_h */
|
13
include/cglm-vec.h
Normal file
13
include/cglm-vec.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_vec_h
|
||||||
|
#define cglm_vec_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* cglm_vec_h */
|
28
include/cglm.h
Normal file
28
include/cglm.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef glm_h
|
||||||
|
#define glm_h
|
||||||
|
|
||||||
|
#include "cglm-common.h"
|
||||||
|
|
||||||
|
typedef float vec3[3];
|
||||||
|
typedef float vec4[4];
|
||||||
|
|
||||||
|
typedef float mat3[3];
|
||||||
|
typedef float mat4[16];
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat_mul4(float * __restrict m1,
|
||||||
|
float * __restrict m2,
|
||||||
|
float * __restrict dest);
|
||||||
|
|
||||||
|
#include "cglm-vec.h"
|
||||||
|
#include "cglm-mat.h"
|
||||||
|
|
||||||
|
#endif /* glm_h */
|
Reference in New Issue
Block a user