graphene: aarch64 detection fixes, fix gcc vector checking

This commit is contained in:
q66 2021-06-09 15:48:04 +02:00
parent 184c3a0681
commit bc7a63ffa0
8 changed files with 303 additions and 5 deletions

View file

@ -1,7 +1,7 @@
diff --git src/graphene-ray.c src/graphene-ray.c
index 66c3393..9151300 100644
--- src/graphene-ray.c
+++ src/graphene-ray.c
--- a/src/graphene-ray.c
+++ b/src/graphene-ray.c
@@ -563,7 +563,7 @@ graphene_ray_intersect_box (const graphene_ray_t *r,
#else
if (ty_min > tx_min || fpclassify (tx_min) == FP_NAN)

View file

@ -0,0 +1,26 @@
From 2aae5d2280d02812669ac38e3981692b98de7c10 Mon Sep 17 00:00:00 2001
From: Dor Askayo <dor.askayo@gmail.com>
Date: Sat, 3 Apr 2021 16:37:30 +0300
Subject: [PATCH] graphene-config: Enable NEON for AArch64 on Linux
NEON is fully supported by AArch64. However, GCC doesn't seem to define
__ARM_NEON__ or _M_ARM64 for AArch64.
Using __aarch64__ should allow a proper detection of this case.
---
include/graphene-config.h.meson | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/graphene-config.h.meson b/include/graphene-config.h.meson
index 949eee7..96192cc 100644
--- a/include/graphene-config.h.meson
+++ b/include/graphene-config.h.meson
@@ -19,7 +19,7 @@ extern "C" {
#mesondefine GRAPHENE_HAS_SSE
# endif
-# if defined(__ARM_NEON__) || defined (_M_ARM64)
+# if defined(__ARM_NEON__) || defined (_M_ARM64) || defined (__aarch64__)
#mesondefine GRAPHENE_HAS_ARM_NEON
# endif

View file

@ -0,0 +1,41 @@
From 5b746339c70cef3ce767841385d8eb3a2a5e852f Mon Sep 17 00:00:00 2001
From: Emmanuele Bassi <ebassi@gnome.org>
Date: Thu, 1 Apr 2021 23:14:16 +0100
Subject: [PATCH] Avoid shadowing for nested cross/dot calls
---
include/graphene-simd4f.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/graphene-simd4f.h b/include/graphene-simd4f.h
index ca711e5..f95fe04 100644
--- a/include/graphene-simd4f.h
+++ b/include/graphene-simd4f.h
@@ -897,19 +897,19 @@ typedef int graphene_simd4i_t __attribute__((vector_size (16)));
# define graphene_simd4f_cross3(a,b) \
(__extension__ ({ \
- const graphene_simd4f_t __a = (a); \
- const graphene_simd4f_t __b = (b); \
- graphene_simd4f_init (__a[1] * __b[2] - __a[2] * __b[1], \
- __a[2] * __b[0] - __a[0] * __b[2], \
- __a[0] * __b[1] - __a[1] * __b[0], \
+ const graphene_simd4f_t __cross_a = (a); \
+ const graphene_simd4f_t __cross_b = (b); \
+ graphene_simd4f_init (__cross_a[1] * __cross_b[2] - __cross_a[2] * __cross_b[1], \
+ __cross_a[2] * __cross_b[0] - __cross_a[0] * __cross_b[2], \
+ __cross_a[0] * __cross_b[1] - __cross_a[1] * __cross_b[0], \
0.f); \
}))
# define graphene_simd4f_dot3(a,b) \
(__extension__ ({ \
- const graphene_simd4f_t __a = (a); \
- const graphene_simd4f_t __b = (b); \
- const float __res = __a[0] * __b[0] + __a[1] * __b[1] + __a[2] * __b[2]; \
+ const graphene_simd4f_t __dot_a = (a); \
+ const graphene_simd4f_t __dot_b = (b); \
+ const float __res = __dot_a[0] * __dot_b[0] + __dot_a[1] * __dot_b[1] + __dot_a[2] * __dot_b[2]; \
graphene_simd4f_init (__res, __res, __res, __res); \
}))

View file

@ -0,0 +1,30 @@
From 74845d6cd3abcf7586f32e222131849c66cc6ad8 Mon Sep 17 00:00:00 2001
From: Emmanuele Bassi <ebassi@gnome.org>
Date: Thu, 1 Apr 2021 22:58:34 +0100
Subject: [PATCH] Fix the GCC check in graphene-config.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We want GCC ≥ 4.9 on non-ARM architectures, so we need to check for:
- GCC
- GCC ≥ 5 or GCC == 4.9
- !ARM
---
include/graphene-config.h.meson | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/graphene-config.h.meson b/include/graphene-config.h.meson
index ab72d53..949eee7 100644
--- a/include/graphene-config.h.meson
+++ b/include/graphene-config.h.meson
@@ -23,7 +23,7 @@ extern "C" {
#mesondefine GRAPHENE_HAS_ARM_NEON
# endif
-# if defined(__GNUC__) && (__GNUC__ >= 4 && __GNUC_MINOR__ >= 9) && !defined(__arm__)
+# if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__arm__)
#mesondefine GRAPHENE_HAS_GCC
# endif

View file

@ -0,0 +1,112 @@
From 8e5c25109898fa4894df810a546b26c387eaae93 Mon Sep 17 00:00:00 2001
From: Emmanuele Bassi <ebassi@gnome.org>
Date: Thu, 1 Apr 2021 23:13:06 +0100
Subject: [PATCH] Ignore float equality checks
There is a well-defined representation for 0 with single precision
floating point values, so we can disable the float-equal warning.
---
include/graphene-simd4f.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/graphene-simd4f.h b/include/graphene-simd4f.h
index 55a1b5b..ca711e5 100644
--- a/include/graphene-simd4f.h
+++ b/include/graphene-simd4f.h
@@ -856,12 +856,15 @@ typedef int graphene_simd4i_t __attribute__((vector_size (16)));
# define graphene_simd4f_reciprocal(v) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
(graphene_simd4f_t) { \
(v)[0] != 0.f ? 1.f / (v)[0] : 0.f, \
(v)[1] != 0.f ? 1.f / (v)[1] : 0.f, \
(v)[2] != 0.f ? 1.f / (v)[2] : 0.f, \
(v)[3] != 0.f ? 1.f / (v)[3] : 0.f, \
}; \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_sqrt(v) \
@@ -876,12 +879,15 @@ typedef int graphene_simd4i_t __attribute__((vector_size (16)));
# define graphene_simd4f_rsqrt(v) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
(graphene_simd4f_t) { \
(v)[0] != 0.f ? 1.f / sqrtf ((v)[0]) : 0.f, \
(v)[1] != 0.f ? 1.f / sqrtf ((v)[1]) : 0.f, \
(v)[2] != 0.f ? 1.f / sqrtf ((v)[2]) : 0.f, \
(v)[3] != 0.f ? 1.f / sqrtf ((v)[3]) : 0.f, \
}; \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_add(a,b) (__extension__ ({ (graphene_simd4f_t) ((a) + (b)); }))
@@ -994,49 +1000,64 @@ typedef int graphene_simd4i_t __attribute__((vector_size (16)));
# define graphene_simd4f_cmp_eq(a,b) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
const graphene_simd4i_t __res = (a) == (b); \
(bool) (__res[0] != 0 && \
__res[1] != 0 && \
__res[2] != 0 && \
__res[3] != 0); \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_cmp_neq(a,b) (!graphene_simd4f_cmp_eq (a,b))
# define graphene_simd4f_cmp_lt(a,b) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
const graphene_simd4i_t __res = (a) < (b); \
(bool) (__res[0] != 0 && \
__res[1] != 0 && \
__res[2] != 0 && \
__res[3] != 0); \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_cmp_le(a,b) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
const graphene_simd4i_t __res = (a) <= (b); \
(bool) (__res[0] != 0 && \
__res[1] != 0 && \
__res[2] != 0 && \
__res[3] != 0); \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_cmp_ge(a,b) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
const graphene_simd4i_t __res = (a) >= (b); \
(bool) (__res[0] != 0 && \
__res[1] != 0 && \
__res[2] != 0 && \
__res[3] != 0); \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_cmp_gt(a,b) \
(__extension__ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") \
const graphene_simd4i_t __res = (a) > (b); \
(bool) (__res[0] != 0 && \
__res[1] != 0 && \
__res[2] != 0 && \
__res[3] != 0); \
+ _Pragma ("GCC diagnostic pop") \
}))
# define graphene_simd4f_neg(s) \

View file

@ -0,0 +1,51 @@
From fbfbdad5a3f38ddbe543ee8c236b4315bba111b9 Mon Sep 17 00:00:00 2001
From: Dor Askayo <dor.askayo@gmail.com>
Date: Sat, 3 Apr 2021 16:40:30 +0300
Subject: [PATCH] meson: Fix detection of AArch64 on Linux
Neither __ARM_EABI__ nor __ARM_NEON__ are defined by GCC for AArch64,
and -mfpu=neon is not required as NEON is always supported in AArch64.
---
meson.build | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/meson.build b/meson.build
index c96aded..86d8eb8 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,7 @@ project('graphene', 'c',
cc = meson.get_compiler('c')
host_system = host_machine.system()
+host_cpu_family = host_machine.cpu_family()
add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
@@ -352,11 +353,13 @@ neon_cflags = []
if get_option('arm_neon')
neon_prog = '''
#if !defined (_MSC_VER) || defined (__clang__)
-# ifndef __ARM_EABI__
-# error "EABI is required (to be sure that calling conventions are compatible)"
-# endif
-# ifndef __ARM_NEON__
-# error "No ARM NEON instructions available"
+# if !defined (_M_ARM64) && !defined (__aarch64__)
+# ifndef __ARM_EABI__
+# error "EABI is required (to be sure that calling conventions are compatible)"
+# endif
+# ifndef __ARM_NEON__
+# error "No ARM NEON instructions available"
+# endif
# endif
#endif
#include <arm_neon.h>
@@ -376,7 +379,7 @@ int main () {
test_neon_cflags = []
- if cc.get_id() != 'msvc'
+ if cc.get_id() != 'msvc' and host_cpu_family != 'aarch64'
test_neon_cflags += ['-mfpu=neon']
endif

View file

@ -0,0 +1,25 @@
From 2da1217742648496c44dff86fd0b477d40d9b067 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Wed, 9 Jun 2021 15:47:14 +0200
Subject: [PATCH] fix gcc vector 64-bit check
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 0ef4f5a..669773f 100644
--- a/meson.build
+++ b/meson.build
@@ -311,7 +311,7 @@ if get_option('gcc_vector')
# error "GCC vector intrinsics are disabled on GCC prior to 4.9"
# elif defined(__arm__)
# error "GCC vector intrinsics are disabled on ARM"
-# elif !defined(__x86_64__)
+# elif (__SIZEOF_POINTER__ < 8)
# error "GCC vector intrinsics are disabled on 32bit"
# endif
#else
--
2.31.1

View file

@ -1,11 +1,11 @@
# Template file for 'graphene'
pkgname=graphene
version=1.10.6
revision=1
revision=2
build_style=meson
build_helper="gir"
configure_args="-Dbenchmarks=false -Dinstalled_tests=false
-Dintrospection=$(vopt_if gir enabled disabled) -Dsse2=true"
-Dintrospection=$(vopt_if gir enabled disabled)"
hostmakedepends="pkg-config"
makedepends="libglib-devel"
short_desc="Thin layer of types for graphic libraries"
@ -14,11 +14,24 @@ license="MIT"
homepage="https://github.com/ebassi/graphene"
distfiles="${GNOME_SITE}/graphene/${version%.*}/graphene-${version}.tar.xz"
checksum=80ae57723e4608e6875626a88aaa6f56dd25df75024bd16e9d77e718c3560b25
patch_args="-Np1"
case "$XBPS_TARGET_MACHINE" in
arm*) configure_args+=" -Darm_neon=false" ;;
x86_64*) configure_args+=" -Dsse2=true" ;;
*) configure_args+=" -Dsse2=false" ;;
esac
case "$XBPS_TARGET_MACHINE" in
aarch64*) configure_args+=" -Darm_neon=true" ;;
*) configure_args+=" -Darm_neon=false" ;;
esac
if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
configure_args+=" -Dgcc_vector=true"
else
configure_args+=" -Dgcc_vector=false"
fi
build_options="gir"
build_options_default="gir"