[Pixman] [PATCH] Move fallback decisions from implementations into pixman-cpu.c.
Søren Sandmann
sandmann at cs.au.dk
Mon Jan 24 10:02:46 PST 2011
From: Søren Sandmann Pedersen <ssp at redhat.com>
Instead of having each individual implementation decide which fallback
to use, move it into pixman-cpu.c, where a more global decision can be
made.
This is accomplished by adding a "fallback" argument to all the
pixman_implementation_create_*() implementations, and then in
_pixman_choose_implementation() pass in the desired fallback.
---
pixman/pixman-arm-neon.c | 7 +------
pixman/pixman-arm-simd.c | 5 ++---
pixman/pixman-cpu.c | 30 +++++++++++++++++++-----------
pixman/pixman-fast-path.c | 5 ++---
pixman/pixman-mmx.c | 5 ++---
pixman/pixman-private.h | 12 ++++++------
pixman/pixman-sse2.c | 7 +------
pixman/pixman-vmx.c | 5 ++---
8 files changed, 35 insertions(+), 41 deletions(-)
diff --git a/pixman/pixman-arm-neon.c b/pixman/pixman-arm-neon.c
index c28c481..7d6c837 100644
--- a/pixman/pixman-arm-neon.c
+++ b/pixman/pixman-arm-neon.c
@@ -414,13 +414,8 @@ BIND_COMBINE_U (add)
BIND_COMBINE_U (out_reverse)
pixman_implementation_t *
-_pixman_implementation_create_arm_neon (void)
+_pixman_implementation_create_arm_neon (pixman_implementation_t *fallback)
{
-#ifdef USE_ARM_SIMD
- pixman_implementation_t *fallback = _pixman_implementation_create_arm_simd ();
-#else
- pixman_implementation_t *fallback = _pixman_implementation_create_fast_path ();
-#endif
pixman_implementation_t *imp =
_pixman_implementation_create (fallback, arm_neon_fast_paths);
diff --git a/pixman/pixman-arm-simd.c b/pixman/pixman-arm-simd.c
index dc2f471..6bbc109 100644
--- a/pixman/pixman-arm-simd.c
+++ b/pixman/pixman-arm-simd.c
@@ -415,10 +415,9 @@ static const pixman_fast_path_t arm_simd_fast_paths[] =
};
pixman_implementation_t *
-_pixman_implementation_create_arm_simd (void)
+_pixman_implementation_create_arm_simd (pixman_implementation_t *fallback)
{
- pixman_implementation_t *general = _pixman_implementation_create_fast_path ();
- pixman_implementation_t *imp = _pixman_implementation_create (general, arm_simd_fast_paths);
+ pixman_implementation_t *imp = _pixman_implementation_create (fallback, arm_simd_fast_paths);
return imp;
}
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index 70253d1..0e14ecb 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -576,28 +576,36 @@ pixman_have_sse2 (void)
pixman_implementation_t *
_pixman_choose_implementation (void)
{
-#ifdef USE_SSE2
- if (pixman_have_sse2 ())
- return _pixman_implementation_create_sse2 ();
-#endif
+ pixman_implementation_t *imp;
+
+ imp = _pixman_implementation_create_general();
+ imp = _pixman_implementation_create_fast_path (imp);
+
#ifdef USE_MMX
if (pixman_have_mmx ())
- return _pixman_implementation_create_mmx ();
+ imp = _pixman_implementation_create_mmx (imp);
#endif
-#ifdef USE_ARM_NEON
- if (pixman_have_arm_neon ())
- return _pixman_implementation_create_arm_neon ();
+#ifdef USE_SSE2
+ if (pixman_have_sse2 ())
+ imp = _pixman_implementation_create_sse2 (imp);
#endif
+
#ifdef USE_ARM_SIMD
if (pixman_have_arm_simd ())
- return _pixman_implementation_create_arm_simd ();
+ imp = _pixman_implementation_create_arm_simd (imp);
+#endif
+
+#ifdef USE_ARM_NEON
+ if (pixman_have_arm_neon ())
+ imp = _pixman_implementation_create_arm_neon (imp);
#endif
+
#ifdef USE_VMX
if (pixman_have_vmx ())
- return _pixman_implementation_create_vmx ();
+ imp = _pixman_implementation_create_vmx (imp);
#endif
- return _pixman_implementation_create_fast_path ();
+ return imp;
}
diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 868175f..8c71371 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1926,10 +1926,9 @@ fast_path_fill (pixman_implementation_t *imp,
}
pixman_implementation_t *
-_pixman_implementation_create_fast_path (void)
+_pixman_implementation_create_fast_path (pixman_implementation_t *fallback)
{
- pixman_implementation_t *general = _pixman_implementation_create_general ();
- pixman_implementation_t *imp = _pixman_implementation_create (general, c_fast_paths);
+ pixman_implementation_t *imp = _pixman_implementation_create (fallback, c_fast_paths);
imp->fill = fast_path_fill;
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 6daa364..0272347 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -3340,10 +3340,9 @@ mmx_fill (pixman_implementation_t *imp,
}
pixman_implementation_t *
-_pixman_implementation_create_mmx (void)
+_pixman_implementation_create_mmx (pixman_implementation_t *fallback)
{
- pixman_implementation_t *general = _pixman_implementation_create_fast_path ();
- pixman_implementation_t *imp = _pixman_implementation_create (general, mmx_fast_paths);
+ pixman_implementation_t *imp = _pixman_implementation_create (fallback, mmx_fast_paths);
imp->combine_32[PIXMAN_OP_OVER] = mmx_combine_over_u;
imp->combine_32[PIXMAN_OP_OVER_REVERSE] = mmx_combine_over_reverse_u;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 1662d2c..664260b 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -534,31 +534,31 @@ pixman_implementation_t *
_pixman_implementation_create_general (void);
pixman_implementation_t *
-_pixman_implementation_create_fast_path (void);
+_pixman_implementation_create_fast_path (pixman_implementation_t *fallback);
#ifdef USE_MMX
pixman_implementation_t *
-_pixman_implementation_create_mmx (void);
+_pixman_implementation_create_mmx (pixman_implementation_t *fallback);
#endif
#ifdef USE_SSE2
pixman_implementation_t *
-_pixman_implementation_create_sse2 (void);
+_pixman_implementation_create_sse2 (pixman_implementation_t *fallback);
#endif
#ifdef USE_ARM_SIMD
pixman_implementation_t *
-_pixman_implementation_create_arm_simd (void);
+_pixman_implementation_create_arm_simd (pixman_implementation_t *fallback);
#endif
#ifdef USE_ARM_NEON
pixman_implementation_t *
-_pixman_implementation_create_arm_neon (void);
+_pixman_implementation_create_arm_neon (pixman_implementation_t *fallback);
#endif
#ifdef USE_VMX
pixman_implementation_t *
-_pixman_implementation_create_vmx (void);
+_pixman_implementation_create_vmx (pixman_implementation_t *fallback);
#endif
pixman_implementation_t *
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 3c0a42f..ae55456 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -5957,13 +5957,8 @@ sse2_fill (pixman_implementation_t *imp,
__attribute__((__force_align_arg_pointer__))
#endif
pixman_implementation_t *
-_pixman_implementation_create_sse2 (void)
+_pixman_implementation_create_sse2 (pixman_implementation_t *fallback)
{
-#ifdef USE_MMX
- pixman_implementation_t *fallback = _pixman_implementation_create_mmx ();
-#else
- pixman_implementation_t *fallback = _pixman_implementation_create_fast_path ();
-#endif
pixman_implementation_t *imp = _pixman_implementation_create (fallback, sse2_fast_paths);
/* SSE2 constants */
diff --git a/pixman/pixman-vmx.c b/pixman/pixman-vmx.c
index e811cf7..6868704 100644
--- a/pixman/pixman-vmx.c
+++ b/pixman/pixman-vmx.c
@@ -1613,10 +1613,9 @@ static const pixman_fast_path_t vmx_fast_paths[] =
};
pixman_implementation_t *
-_pixman_implementation_create_vmx (void)
+_pixman_implementation_create_vmx (pixman_implementation_t *fallback)
{
- pixman_implementation_t *fast = _pixman_implementation_create_fast_path ();
- pixman_implementation_t *imp = _pixman_implementation_create (fast, vmx_fast_paths);
+ pixman_implementation_t *imp = _pixman_implementation_create (fallback, vmx_fast_paths);
/* Set up function pointers */
--
1.7.3.1
More information about the Pixman
mailing list