[Pixman] [PATCH 2/4] Add FPU-based implementation

Dmitri Vorobiev dmitri.vorobiev at movial.com
Tue Sep 21 05:17:46 PDT 2010


This patch provides an empty FPU-based implementation. The purpose
is to create a framework for adding a full set of floating-point
paths. For now, the new implementation is overridden by any of the
CPU-specific implementations, so for it to be actually run, one
needs to explicitly disable those at the configuration stage.
---
 pixman/Makefile.am      |   12 ++++++++++++
 pixman/pixman-cpu.c     |   14 +++++++++++++-
 pixman/pixman-float.c   |   43 +++++++++++++++++++++++++++++++++++++++++++
 pixman/pixman-private.h |    5 +++++
 4 files changed, 73 insertions(+), 1 deletions(-)
 create mode 100644 pixman/pixman-float.c

diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index ca31301..4b1768c 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -123,5 +123,17 @@ libpixman_1_la_LIBADD += libpixman-arm-neon.la
 ASM_CFLAGS_arm_neon=
 endif
 
+# float code
+if USE_FLOAT
+noinst_LTLIBRARIES += libpixman-float.la
+libpixman_float_la_SOURCES = \
+	pixman-float.c
+libpixman_float_la_CFLAGS = $(DEP_CFLAGS)
+libpixman_float_la_LIBADD = $(DEP_LIBS)
+libpixman_1_la_LIBADD += libpixman-float.la
+
+ASM_CFLAGS_float=
+endif
+
 .c.s : $(libpixmaninclude_HEADERS) $(BUILT_SOURCES)
 	$(CC) $(CFLAGS) $(ASM_CFLAGS_$(@:pixman-%.s=%)) $(ASM_CFLAGS_$(@:pixman-arm-%.s=arm_%)) -DHAVE_CONFIG_H -I$(srcdir) -I$(builddir) -I$(top_builddir) -S -o $@ $<
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index e4fb1e4..96ce7c0 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -568,6 +568,15 @@ pixman_have_sse2 (void)
 #endif /* __amd64__ */
 #endif
 
+/*
+ * For the FPU-based implementation, it's better to have a dedicated
+ * floating-point unit. For now, when using such an implementation,
+ * we just assume that FPU is available for our platform. However, in
+ * future we might want to add runtime tests in a platform-specific
+ * manner.
+ */
+#define pixman_have_float() TRUE
+
 pixman_implementation_t *
 _pixman_choose_implementation (void)
 {
@@ -592,7 +601,10 @@ _pixman_choose_implementation (void)
     if (pixman_have_vmx ())
 	return _pixman_implementation_create_vmx ();
 #endif
+#ifdef USE_FLOAT
+    if (pixman_have_float ())
+	return _pixman_implementation_create_float ();
+#endif
 
     return _pixman_implementation_create_fast_path ();
 }
-
diff --git a/pixman/pixman-float.c b/pixman/pixman-float.c
new file mode 100644
index 0000000..e7591c2
--- /dev/null
+++ b/pixman/pixman-float.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2010 Movial Creative Technologies Oy
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pixman-private.h"
+
+static const pixman_fast_path_t float_fast_paths[] =
+{
+    { PIXMAN_OP_NONE },
+};
+
+pixman_implementation_t *
+_pixman_implementation_create_float (void)
+{
+    pixman_implementation_t *fallback = _pixman_implementation_create_fast_path ();
+    pixman_implementation_t *imp = _pixman_implementation_create (fallback, float_fast_paths);
+
+    return imp;
+}
+
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 3557fb2..e622866 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -527,6 +527,11 @@ pixman_implementation_t *
 _pixman_implementation_create_vmx (void);
 #endif
 
+#ifdef USE_FLOAT
+pixman_implementation_t *
+_pixman_implementation_create_float (void);
+#endif
+
 pixman_implementation_t *
 _pixman_choose_implementation (void);
 
-- 
1.6.3.3



More information about the Pixman mailing list