gdk: add i386 SSE pixel compositing
This commit is contained in:
parent
db27c76d91
commit
6ec12b85f2
3 changed files with 69 additions and 0 deletions
|
|
@ -135,6 +135,15 @@ libgdk_pixelops_x86_mmx_la_CFLAGS = \
|
|||
$(AM_CFLAGS) \
|
||||
-mmmx -mno-sse -mno-sse2 -mno-3dnow
|
||||
|
||||
noinst_LTLIBRARIES += libgdk-pixelops-x86-sse.la
|
||||
gdk_pixelops_arch_libs += libgdk-pixelops-x86-sse.la
|
||||
|
||||
libgdk_pixelops_x86_sse_la_SOURCES = gdkpixelops-x86-mmx.c
|
||||
libgdk_pixelops_x86_sse_la_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
-mmmx -mno-sse -mno-sse2 -mno-3dnow \
|
||||
-DGDK_PIXELOPS_X86_SSE_IMPL
|
||||
|
||||
noinst_LTLIBRARIES += libgdk-pixelops-x86-3dnow.la
|
||||
gdk_pixelops_arch_libs += libgdk-pixelops-x86-3dnow.la
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
#define GDK_PIXELOPS_COMPOSITE_0888 _gdk_pixel_ops_composite_0888_3dnow
|
||||
#define GDK_PIXELOPS_COMPOSITE_565 _gdk_pixel_ops_composite_565_3dnow
|
||||
#define GDK_PIXELOPS_MMX_EMPTY() _m_femms ()
|
||||
#elif defined(GDK_PIXELOPS_X86_SSE_IMPL)
|
||||
#define GDK_PIXELOPS_COMPOSITE_0888 _gdk_pixel_ops_composite_0888_sse
|
||||
#define GDK_PIXELOPS_COMPOSITE_565 _gdk_pixel_ops_composite_565_sse
|
||||
#define GDK_PIXELOPS_MMX_EMPTY() _mm_empty ()
|
||||
#else
|
||||
#define GDK_PIXELOPS_COMPOSITE_0888 _gdk_pixel_ops_composite_0888_mmx
|
||||
#define GDK_PIXELOPS_COMPOSITE_565 _gdk_pixel_ops_composite_565_mmx
|
||||
|
|
@ -129,8 +133,13 @@ GDK_PIXELOPS_COMPOSITE_0888 (guchar *src_buf,
|
|||
d = _mm_unpacklo_pi8 (d, zero);
|
||||
|
||||
a = _mm_srli_si64 (s, 48);
|
||||
#ifdef GDK_PIXELOPS_X86_SSE_IMPL
|
||||
__asm__ ("pshufw $0x00,%0,%0"
|
||||
: "+y" (a));
|
||||
#else
|
||||
a = _mm_unpacklo_pi16 (a, a);
|
||||
a = _mm_unpacklo_pi32 (a, a);
|
||||
#endif
|
||||
a = _mm_and_si64 (a, rgb_mask);
|
||||
|
||||
#ifdef GDK_PIXELOPS_X86_3DNOW_IMPL
|
||||
|
|
@ -142,8 +151,18 @@ GDK_PIXELOPS_COMPOSITE_0888 (guchar *src_buf,
|
|||
_mm_mullo_pi16 (d, ia));
|
||||
|
||||
t = _mm_add_pi16 (t, bias);
|
||||
#ifdef GDK_PIXELOPS_X86_SSE_IMPL
|
||||
{
|
||||
__m64 scale = _mm_set1_pi16 (0x0101);
|
||||
|
||||
__asm__ ("pmulhuw %1,%0"
|
||||
: "+y" (t)
|
||||
: "y" (scale));
|
||||
}
|
||||
#else
|
||||
t = _mm_add_pi16 (t, _mm_srli_pi16 (t, 8));
|
||||
t = _mm_srli_pi16 (t, 8);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
packed = _mm_packs_pu16 (t, t);
|
||||
|
|
@ -209,8 +228,13 @@ blend_565_mmx (__m64 zero,
|
|||
d = _mm_unpacklo_pi8 (d, zero);
|
||||
|
||||
a = _mm_srli_si64 (s, 48);
|
||||
#ifdef GDK_PIXELOPS_X86_SSE_IMPL
|
||||
__asm__ ("pshufw $0x00,%0,%0"
|
||||
: "+y" (a));
|
||||
#else
|
||||
a = _mm_unpacklo_pi16 (a, a);
|
||||
a = _mm_unpacklo_pi32 (a, a);
|
||||
#endif
|
||||
|
||||
#ifdef GDK_PIXELOPS_X86_3DNOW_IMPL
|
||||
t = blend_3dnow (s, d, a);
|
||||
|
|
@ -221,8 +245,18 @@ blend_565_mmx (__m64 zero,
|
|||
_mm_mullo_pi16 (d, ia));
|
||||
|
||||
t = _mm_add_pi16 (t, bias);
|
||||
#ifdef GDK_PIXELOPS_X86_SSE_IMPL
|
||||
{
|
||||
__m64 scale = _mm_set1_pi16 (0x0101);
|
||||
|
||||
__asm__ ("pmulhuw %1,%0"
|
||||
: "+y" (t)
|
||||
: "y" (scale));
|
||||
}
|
||||
#else
|
||||
t = _mm_add_pi16 (t, _mm_srli_pi16 (t, 8));
|
||||
t = _mm_srli_pi16 (t, 8);
|
||||
#endif
|
||||
#endif
|
||||
t = _mm_packs_pu16 (t, t);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,24 @@ _gdk_pixel_ops_composite_565_mmx (guchar *src_buf,
|
|||
gint width,
|
||||
gint height);
|
||||
|
||||
G_GNUC_INTERNAL void
|
||||
_gdk_pixel_ops_composite_0888_sse (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
G_GNUC_INTERNAL void
|
||||
_gdk_pixel_ops_composite_565_sse (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
guchar *dest_buf,
|
||||
gint dest_rowstride,
|
||||
GdkByteOrder dest_byte_order,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
G_GNUC_INTERNAL void
|
||||
_gdk_pixel_ops_composite_0888_3dnow (guchar *src_buf,
|
||||
gint src_rowstride,
|
||||
|
|
@ -69,6 +87,14 @@ _gdk_pixel_ops_init (void)
|
|||
_gdk_pixel_ops.composite_565 =
|
||||
_gdk_pixel_ops_composite_565_mmx;
|
||||
|
||||
if ((edx & bit_SSE) != 0)
|
||||
{
|
||||
_gdk_pixel_ops.composite_0888 =
|
||||
_gdk_pixel_ops_composite_0888_sse;
|
||||
_gdk_pixel_ops.composite_565 =
|
||||
_gdk_pixel_ops_composite_565_sse;
|
||||
}
|
||||
|
||||
if (__get_cpuid (0x80000001U, &eax, &ebx, &ecx, &edx) &&
|
||||
(edx & bit_3DNOW) != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue