mutter/fix-i686-build.patch
Florian Müllner 585024ef97 Fix i686 build
2024-01-08 22:04:59 +01:00

91 lines
2.5 KiB
Diff

From cf685defcd0c0026fce7ef1fc3fb79a1f1a1edaa Mon Sep 17 00:00:00 2001
From: Sebastian Wick <sebastian.wick@redhat.com>
Date: Mon, 8 Jan 2024 15:52:09 +0100
Subject: [PATCH 1/2] cogl/half-float: Include SSE intrinsics
The intel intrinsics (including SSE) are only included in the header if
the arch is x86_64 which made the i686 build fail.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3234
Fixes: 568506ecb ("cogl: Add half float implementation")
---
cogl/cogl/cogl-half-float.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cogl/cogl/cogl-half-float.c b/cogl/cogl/cogl-half-float.c
index be2c48b815..ae0af0a6a2 100644
--- a/cogl/cogl/cogl-half-float.c
+++ b/cogl/cogl/cogl-half-float.c
@@ -31,6 +31,13 @@
#include <math.h>
+#if defined(__SSE__) || \
+ (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) || \
+ (defined(_M_X64) && !defined(_M_ARM64EC))
+#include <xmmintrin.h>
+#include <emmintrin.h>
+#endif
+
#include "cogl/cogl-half-float.h"
#include "cogl/cogl-soft-float.h"
@@ -262,3 +269,4 @@ uint16_t cogl_uint16_div_64k_to_half (uint16_t v)
return (e << 10) | m;
}
+
--
2.43.0
From 0096860d715e1842d755b1229b43e848c26fb0cb Mon Sep 17 00:00:00 2001
From: Sebastian Wick <sebastian.wick@redhat.com>
Date: Mon, 8 Jan 2024 16:08:37 +0100
Subject: [PATCH 2/2] cogl/bitmap-conversion: Don't break strict-aliasing for
flt_pack/unpack
Simply reinterpreting the bytes differently is a strict-aliasing
violation if the type of the object isn't char or the target type of the
reinterpretation. None of that is the case here, so we have to resort to
a memcpy.
Fixes: 60c082caa ("cogl/bitmap-conversion: Support packing fp16 formats")
---
cogl/cogl/cogl-bitmap-conversion.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/cogl/cogl/cogl-bitmap-conversion.c b/cogl/cogl/cogl-bitmap-conversion.c
index 76efbb9bb9..08ecce6a4d 100644
--- a/cogl/cogl/cogl-bitmap-conversion.c
+++ b/cogl/cogl/cogl-bitmap-conversion.c
@@ -45,16 +45,23 @@ typedef enum
MEDIUM_TYPE_FLOAT,
} MediumType;
+_Static_assert (sizeof (uint32_t) == sizeof (GLfloat),
+ "GLfloat doesn't have a size of 4 bytes");
+
inline static uint32_t
pack_flt (GLfloat b)
{
- return *(uint32_t *) &b;
+ uint32_t ret;
+ memcpy (&ret, &b, sizeof (uint32_t));
+ return ret;
}
inline static GLfloat
unpack_flt (uint32_t b)
{
- return *(GLfloat *) &b;
+ GLfloat ret;
+ memcpy (&ret, &b, sizeof (GLfloat));
+ return ret;
}
#define CLAMP_NORM(b) (MAX (MIN ((b), 1.0), 0.0))
--
2.43.0