Add build system support for SSE2.

This commit is contained in:
Rodrigo Kumpera 2008-03-14 19:11:17 -04:00 committed by Søren Sandmann
parent ddfb69ae87
commit 6cb327be1f
5 changed files with 163 additions and 1 deletions

View File

@ -165,8 +165,37 @@ fi
AM_CONDITIONAL(USE_SSE, test $have_sse_intrinsics = yes)
dnl ===========================================================================
dnl Check for SSE2
SSE_CFLAGS="-mmmx -msse2 -Winline --param inline-unit-growth=10000 --param large-function-growth=10000"
have_sse2_intrinsics=no
AC_MSG_CHECKING(whether to use SSE2 intrinsics)
xserver_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -msse2 $MMX_CFLAGS"
AC_COMPILE_IFELSE([
#include <mmintrin.h>
#include <xmmintrin.h>
int main () {
__m128i a, b, c;
c = _mm_xor_si128 (a, b);
return 0;
}], have_sse2_intrinsics=yes)
CFLAGS=$xserver_save_CFLAGS
AC_MSG_RESULT($have_sse2_intrinsics)
if test $have_sse2_intrinsics = yes ; then
AC_DEFINE(USE_SSE2, 1, [use SSE compiler intrinsics])
fi
AM_CONDITIONAL(USE_SSE2, test $have_sse2_intrinsics = yes)
dnl ========================================================
AC_SUBST(MMX_CFLAGS)
AC_SUBST(SSE_CFLAGS)
PKG_CHECK_MODULES(GTK, [gtk+-2.0], [HAVE_GTK=yes], [HAVE_GTK=no])
AM_CONDITIONAL(HAVE_GTK, [test "x$HAVE_GTK" = xyes])

View File

@ -30,3 +30,16 @@ libpixman_mmx_la_CFLAGS = $(DEP_CFLAGS) $(MMX_CFLAGS)
libpixman_mmx_la_LIBADD = $(DEP_LIBS)
libpixman_1_la_LIBADD += libpixman-mmx.la
endif
# sse2 code
if USE_SSE2
noinst_LTLIBRARIES = libpixman-sse.la
libpixman_sse_la_SOURCES = \
pixman-sse.c \
pixman-sse.h
libpixman_sse_la_CFLAGS = $(DEP_CFLAGS) $(SSE_CFLAGS)
libpixman_sse_la_LIBADD = $(DEP_LIBS)
libpixman_1_la_LIBADD += libpixman-sse.la
endif

View File

@ -33,6 +33,7 @@
#include "pixman-private.h"
#include "pixman-mmx.h"
#include "pixman-sse.h"
#define FbFullMask(n) ((n) == 32 ? (uint32_t)-1 : ((((uint32_t) 1) << n) - 1))
@ -1555,6 +1556,14 @@ static const FastPathInfo c_fast_paths[] =
{ PIXMAN_OP_NONE },
};
#ifdef USE_SSE2
static const FastPathInfo sse_fast_paths[] =
{
{ PIXMAN_OP_NONE },
};
#endif
static pixman_bool_t
mask_is_solid (pixman_image_t *mask)
{
@ -1655,6 +1664,15 @@ pixman_image_composite (pixman_op_t op,
pixman_bool_t dstAlphaMap = pDst->common.alpha_map != NULL;
CompositeFunc func = NULL;
#ifdef USE_SSE2
static pixman_bool_t sse_setup = FALSE;
if (!sse_setup)
{
fbComposeSetupSSE();
sse_setup = TRUE;
}
#endif
#ifdef USE_MMX
static pixman_bool_t mmx_setup = FALSE;
if (!mmx_setup)
@ -1706,9 +1724,16 @@ pixman_image_composite (pixman_op_t op,
ySrc == yMask &&
!pMask->common.component_alpha &&
!maskRepeat;
info = NULL;
#ifdef USE_SSE2
if (pixman_have_sse ())
info = get_fast_path (sse_fast_paths, op, pSrc, pMask, pDst, pixbuf);
if (!info)
#endif
#ifdef USE_MMX
info = NULL;
if (pixman_have_mmx())
info = get_fast_path (mmx_fast_paths, op, pSrc, pMask, pDst, pixbuf);
if (!info)
@ -1976,5 +2001,21 @@ pixman_have_mmx (void)
return mmx_present;
}
pixman_bool_t
pixman_have_sse (void)
{
static pixman_bool_t initialized = FALSE;
static pixman_bool_t sse_present;
if (!initialized)
{
unsigned int features = detectCPUFeatures();
sse_present = (features & (SSE|SSE2)) == (SSE|SSE2);
initialized = TRUE;
}
return sse_present;
}
#endif /* __amd64__ */
#endif

41
pixman/pixman-sse.c Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright © 2008 Rodrigo Kumpera
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Rodrigo Kumpera (kumpera@gmail.com)
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef USE_SSE2
void fbComposeSetupSSE(void)
{
/* check if we have SSE2 support and initialize accordingly */
if (pixman_have_sse())
{
}
}
#endif /* USE_SSE2 */

38
pixman/pixman-sse.h Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright © 2008 Rodrigo Kumpera
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Author: Rodrigo Kumpera (kumpera@gmail.com)
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "pixman-private.h"
#ifdef USE_SSE2
pixman_bool_t pixman_have_sse(void);
void fbComposeSetupSSE(void);
#endif /* USE_SSE2 */