external/cairo/ExternalProject_pixman.mk |    2 
 external/cairo/UnpackedTarball_pixman.mk |    1 
 external/cairo/pixman/pixman-wasm.patch  |  108 +++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 1 deletion(-)

New commits:
commit 43669709b81b9ca8487294a5d9d0d18d54dd361b
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Thu Feb 9 14:24:07 2023 +0200
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Thu Feb 23 18:31:37 2023 +0000

    Use SIMD in pixman for WASM
    
    Emscripten and WASM do have some support for SSSE3, so let's try to
    use it, with -msimd128. See
    https://emscripten.org/docs/porting/simd.html.
    
    WASM is not x86, though, so avoid use of inline x86 assembly, like the
    CPUID instruction.
    
    Emscripten does not have <mmintrin.h> but does have <xmmintrin.h>,
    <emmintrin.h>, and <tmmintrin.h>.
    
    Change-Id: Ic3a47291f6c6dee6843e93ccecc92a643b269cb1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146691
    Tested-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147530

diff --git a/external/cairo/ExternalProject_pixman.mk 
b/external/cairo/ExternalProject_pixman.mk
index ac78b23d5c9e..29902b4c1f5c 100644
--- a/external/cairo/ExternalProject_pixman.mk
+++ b/external/cairo/ExternalProject_pixman.mk
@@ -28,7 +28,7 @@ $(call gb_ExternalProject_get_state_target,pixman,build) :
                $(if $(filter ANDROID,$(OS)),--disable-arm-simd 
--disable-arm-neon --disable-arm-a64-neon --disable-arm-iwmmxt) \
                $(gb_CONFIGURE_PLATFORMS) \
                $(if $(CROSS_COMPILING),$(if $(filter INTEL 
ARM,$(CPUNAME)),ac_cv_c_bigendian=no)) \
-               $(if $(filter EMSCRIPTEN,$(OS)),CFLAGS="-O3 -pthread") \
+               $(if $(filter EMSCRIPTEN,$(OS)),CFLAGS="-O3 -pthread 
-msimd128") \
                && $(MAKE) \
        )
        $(call gb_Trace_EndRange,pixman,EXTERNAL)
diff --git a/external/cairo/UnpackedTarball_pixman.mk 
b/external/cairo/UnpackedTarball_pixman.mk
index 3f1f75616611..922ed9f24f22 100644
--- a/external/cairo/UnpackedTarball_pixman.mk
+++ b/external/cairo/UnpackedTarball_pixman.mk
@@ -14,6 +14,7 @@ $(eval $(call 
gb_UnpackedTarball_set_tarball,pixman,$(PIXMAN_TARBALL),,cairo))
 $(eval $(call gb_UnpackedTarball_add_patches,pixman,\
        external/cairo/pixman/pixman-0.24.4.patch \
        external/cairo/pixman/pixman-ubsan.patch \
+       external/cairo/pixman/pixman-wasm.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/cairo/pixman/pixman-wasm.patch 
b/external/cairo/pixman/pixman-wasm.patch
new file mode 100644
index 000000000000..c76af875cd51
--- /dev/null
+++ b/external/cairo/pixman/pixman-wasm.patch
@@ -0,0 +1,108 @@
+--- a/pixman/pixman/pixman-x86.c
++++ b/pixman/pixman/pixman-x86.c
+@@ -77,13 +77,20 @@
+ 
+ #else
+ 
+-#define _PIXMAN_X86_64                                                        
\
+-    (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
++#if (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
++#define _PIXMAN_X86_64 1
++#else
++#define _PIXMAN_X86_64 0
++#endif
+ 
+ static pixman_bool_t
+ have_cpuid (void)
+ {
+-#if _PIXMAN_X86_64 || defined (_MSC_VER)
++#if defined(__EMSCRIPTEN__)
++
++    return FALSE;
++
++#elif _PIXMAN_X86_64 || defined (_MSC_VER)
+ 
+     return TRUE;
+ 
+@@ -109,6 +109,8 @@
+ #endif
+ }
+ 
++#if !defined(__EMSCRIPTEN__)
++
+ static void
+ pixman_cpuid (uint32_t feature,
+             uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d)
+@@ -156,10 +156,17 @@
+ #error Unknown compiler
+ #endif
+ }
++ 
++#endif // !__EMSCRIPTEN__
+ 
+ static cpu_features_t
+ detect_cpu_features (void)
+ {
++#if defined(__EMSCRIPTEN__)
++
++    return X86_SSE | X86_SSE2 | X86_SSSE3;
++
++#else
+     uint32_t a, b, c, d;
+     cpu_features_t features = 0;
+ 
+@@ -202,6 +202,8 @@
+     }
+ 
+     return features;
++
++#endif // !__EMSCRIPTEN__
+ }
+ 
+ #endif
+--- a/pixman/pixman/pixman-ssse3.c
++++ b/pixman/pixman/pixman-ssse3.c
+@@ -28,7 +28,9 @@
+ #endif
+ 
+ #include <stdlib.h>
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ #include <tmmintrin.h>
+--- a/pixman/configure
++++ b/pixman/configure
+@@ -14207,7 +14207,11 @@
+ #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 
4))
+ #error "Need GCC >= 3.4 for MMX intrinsics"
+ #endif
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#else
++#include <xmmintrin.h>
++#endif
+ #include <stdint.h>
+ 
+ /* Check support for block expressions */
+@@ -14308,7 +14308,9 @@
+ #      error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
+ #   endif
+ #endif
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ int param;
+@@ -14380,7 +14380,9 @@
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ #include <tmmintrin.h>

Reply via email to