mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
Merge branch 'master' into aabb2d
This commit is contained in:
79
.github/workflows/meson-wasm.yml
vendored
Normal file
79
.github/workflows/meson-wasm.yml
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
name: Meson WebAssembly
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
wasmtime_version: v7.0.0
|
||||||
|
wasmer_version: v3.1.1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_emsdk:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
BUILD_TYPE: [debug, debugoptimized, release, minsize]
|
||||||
|
C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup emsdk
|
||||||
|
uses: mymindstorm/setup-emsdk@v13
|
||||||
|
|
||||||
|
- name: Verify emsdk
|
||||||
|
run: emcc -v
|
||||||
|
|
||||||
|
- name: Creating cross file
|
||||||
|
run: |
|
||||||
|
cat << EOF > ${{github.workspace}}/meson_cross_emsdk.txt
|
||||||
|
[binaries]
|
||||||
|
c = '`which emcc`'
|
||||||
|
cpp = '`which em++`'
|
||||||
|
ar = '`which emar`'
|
||||||
|
|
||||||
|
[built-in options]
|
||||||
|
|
||||||
|
c_args = ['-Wno-unused-parameter']
|
||||||
|
c_link_args = ['-s', 'STANDALONE_WASM']
|
||||||
|
cpp_args = ['-Wno-unused-parameter']
|
||||||
|
cpp_link_args = ['-s', 'STANDALONE_WASM']
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
|
||||||
|
system = 'emscripten'
|
||||||
|
cpu_family = 'wasm32'
|
||||||
|
cpu = 'wasm32'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
EOF
|
||||||
|
cat ${{github.workspace}}/meson_cross_emsdk.txt
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
|
||||||
|
- name: Install meson
|
||||||
|
run: |
|
||||||
|
sudo python3 -m pip install meson ninja
|
||||||
|
|
||||||
|
- name: Build with meson
|
||||||
|
run: |
|
||||||
|
meson setup build -Dbuildtype=${{matrix.BUILD_TYPE}} --cross-file ${{github.workspace}}/meson_cross_emsdk.txt --default-library=static -Dbuild_tests=true
|
||||||
|
meson test -C build
|
||||||
|
|
||||||
|
- name: Test with wasmtime
|
||||||
|
run: |
|
||||||
|
cd ${{github.workspace}}
|
||||||
|
ls -lh ${{github.workspace}}/build/
|
||||||
|
wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
|
||||||
|
tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
|
||||||
|
./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests.wasm
|
||||||
|
|
||||||
|
- name: Test with wasmer
|
||||||
|
run: |
|
||||||
|
cd ${{github.workspace}}
|
||||||
|
mkdir wasmer
|
||||||
|
cd wasmer
|
||||||
|
wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
|
||||||
|
tar xf wasmer-linux-amd64.tar.gz
|
||||||
|
./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests.wasm
|
@@ -43,7 +43,6 @@
|
|||||||
CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest);
|
CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest);
|
||||||
CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_negate(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_negate(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_inv(vec3s v);
|
|
||||||
CGLM_INLINE vec3s glms_vec3_normalize(vec3s v);
|
CGLM_INLINE vec3s glms_vec3_normalize(vec3s v);
|
||||||
CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b);
|
CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b);
|
||||||
CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b);
|
CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b);
|
||||||
|
@@ -42,7 +42,6 @@
|
|||||||
CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest);
|
CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest);
|
||||||
CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest);
|
CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest);
|
||||||
CGLM_INLINE vec4s glms_vec4_negate(vec4s v);
|
CGLM_INLINE vec4s glms_vec4_negate(vec4s v);
|
||||||
CGLM_INLINE vec4s glms_vec4_inv(vec4s v);
|
|
||||||
CGLM_INLINE vec4s glms_vec4_normalize(vec4s v);
|
CGLM_INLINE vec4s glms_vec4_normalize(vec4s v);
|
||||||
CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b);
|
CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b);
|
||||||
CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b);
|
CGLM_INLINE float glms_vec4_distance2(vec4s a, vec4s b);
|
||||||
|
@@ -8,6 +8,10 @@
|
|||||||
#ifndef cglm_types_h
|
#ifndef cglm_types_h
|
||||||
#define cglm_types_h
|
#define cglm_types_h
|
||||||
|
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||||
|
# include <stdalign.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
/* do not use alignment for older visual studio versions */
|
/* do not use alignment for older visual studio versions */
|
||||||
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
||||||
@@ -57,8 +61,16 @@
|
|||||||
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||||
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), alignof(type)))
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof(type)))
|
||||||
|
#else
|
||||||
|
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
|
||||||
|
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int ivec2[2];
|
typedef int ivec2[2];
|
||||||
typedef int ivec3[3];
|
typedef int ivec3[3];
|
||||||
|
@@ -649,7 +649,7 @@ glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_add(
|
glmm_store(dest, wasm_f32x4_add(
|
||||||
glmm_load(dest),
|
glmm_load(dest),
|
||||||
wasm_f32x4_max(glmm_load(a), glmm_load(b))));
|
wasm_f32x4_pmax(glmm_load(a), glmm_load(b))));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
||||||
_mm_max_ps(glmm_load(a),
|
_mm_max_ps(glmm_load(a),
|
||||||
@@ -681,7 +681,7 @@ glm_vec4_minadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_add(
|
glmm_store(dest, wasm_f32x4_add(
|
||||||
glmm_load(dest),
|
glmm_load(dest),
|
||||||
wasm_f32x4_min(glmm_load(a), glmm_load(b))));
|
wasm_f32x4_pmin(glmm_load(a), glmm_load(b))));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
glmm_store(dest, _mm_add_ps(glmm_load(dest),
|
||||||
_mm_min_ps(glmm_load(a),
|
_mm_min_ps(glmm_load(a),
|
||||||
@@ -854,7 +854,7 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_maxv(vec4 a, vec4 b, vec4 dest) {
|
glm_vec4_maxv(vec4 a, vec4 b, vec4 dest) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_max(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, wasm_f32x4_pmax(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_max_ps(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, _mm_max_ps(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
@@ -878,7 +878,7 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_minv(vec4 a, vec4 b, vec4 dest) {
|
glm_vec4_minv(vec4 a, vec4 b, vec4 dest) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(dest, wasm_f32x4_min(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, wasm_f32x4_pmin(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(dest, _mm_min_ps(glmm_load(a), glmm_load(b)));
|
glmm_store(dest, _mm_min_ps(glmm_load(a), glmm_load(b)));
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
@@ -902,8 +902,8 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_vec4_clamp(vec4 v, float minVal, float maxVal) {
|
glm_vec4_clamp(vec4 v, float minVal, float maxVal) {
|
||||||
#if defined(__wasm__) && defined(__wasm_simd128__)
|
#if defined(__wasm__) && defined(__wasm_simd128__)
|
||||||
glmm_store(v, wasm_f32x4_min(
|
glmm_store(v, wasm_f32x4_pmin(
|
||||||
wasm_f32x4_max(glmm_load(v), wasm_f32x4_splat(minVal)),
|
wasm_f32x4_pmax(glmm_load(v), wasm_f32x4_splat(minVal)),
|
||||||
wasm_f32x4_splat(maxVal)));
|
wasm_f32x4_splat(maxVal)));
|
||||||
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
#elif defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glmm_store(v, _mm_min_ps(_mm_max_ps(glmm_load(v), _mm_set1_ps(minVal)),
|
glmm_store(v, _mm_min_ps(_mm_max_ps(glmm_load(v), _mm_set1_ps(minVal)),
|
||||||
|
@@ -95,6 +95,7 @@ cglm_dep = declare_dependency(
|
|||||||
dependencies : cglm_deps,
|
dependencies : cglm_deps,
|
||||||
compile_args : cglm_args,
|
compile_args : cglm_args,
|
||||||
include_directories : cglm_inc,
|
include_directories : cglm_inc,
|
||||||
|
build_by_default: not meson.is_subproject(),
|
||||||
version : meson.project_version()
|
version : meson.project_version()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user