gdk: optimize i386 MMX and MMXEXT pixel compositing

This commit is contained in:
Daemonratte 2026-09-14 06:39:46 +02:00
commit 99823d458b
4 changed files with 788 additions and 43 deletions

View file

@ -132,6 +132,7 @@ gdk_pixelops_arch_libs += libgdk-x86-mmx.la
libgdk_x86_mmx_la_SOURCES = \
gdkpixelops-x86-mmx.c \
gdkpixelops-x86-mmxext.c \
gdkrgb-x86-mmx.c
libgdk_x86_mmx_la_CFLAGS = \
$(AM_CFLAGS) \

View file

@ -57,6 +57,20 @@ _gdk_pixel_ops_composite_0888_mmx (guchar *src_buf,
const __m64 ff = _mm_srli_pi16 (ones, 8);
const __m64 bias = _mm_set1_pi16 (0x80);
const __m64 rgb_mask = _mm_srli_si64 (ones, 16);
/*
* Pure-MMX masks for:
*
* [ R G B A ] -> [ B G R A ]
*
* No scalar R/B shuffle.
*/
const __m64 r_mask =
_mm_set_pi16 (0, 0, 0, (short) -1);
const __m64 b_mask =
_mm_set_pi16 (0, (short) -1, 0, 0);
const __m64 ga_mask =
_mm_set_pi16 ((short) -1, 0, (short) -1, 0);
guchar *src = src_buf;
guchar *dest = dest_buf;
@ -87,23 +101,40 @@ _gdk_pixel_ops_composite_0888_mmx (guchar *src_buf,
__m64 d;
__m64 a;
__m64 t;
__m64 rb;
memcpy (&sp, p, sizeof sp);
memcpy (&dp, q, sizeof dp);
sp = ((sp & 0xff00ff00U) |
((sp & 0x000000ffU) << 16) |
((sp & 0x00ff0000U) >> 16));
s = _mm_cvtsi32_si64 ((int) sp);
d = _mm_cvtsi32_si64 ((int) dp);
s = _mm_unpacklo_pi8 (s, zero);
d = _mm_unpacklo_pi8 (d, zero);
a = _mm_srli_si64 (s, 48);
a = _mm_unpacklo_pi16 (a, a);
a = _mm_unpacklo_pi32 (a, a);
/*
* s starts as:
*
* [ R G B A ]
*
* Swap R/B entirely inside base MMX:
*
* [ B G R A ]
*/
rb =
_mm_or_si64 (
_mm_slli_si64 (
_mm_and_si64 (s, r_mask), 32),
_mm_srli_si64 (
_mm_and_si64 (s, b_mask), 32));
s =
_mm_or_si64 (
_mm_and_si64 (s, ga_mask),
rb);
a = _mm_unpackhi_pi16 (s, s);
a = _mm_unpackhi_pi32 (a, a);
a = _mm_and_si64 (a, rgb_mask);
t = blend_words_mmx (s, d, a, ff, bias);
@ -150,25 +181,85 @@ expand_565 (guint16 value)
((hi >> 6) & 0x00000300U);
}
static __inline__ guint16
pack_555 (guint32 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 7) |
((rgb & 0x0000f800U) >> 6) |
((rgb & 0x00f80000U) >> 19));
}
static __inline__ guint16
pack_565 (guint32 rgb)
pack_555 (__m64 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 8) |
((rgb & 0x0000fc00U) >> 5) |
((rgb & 0x00f80000U) >> 19));
const __m64 coeff =
_mm_set_pi16 (0, 1, 32, 1024);
__m64 v;
__m64 hi;
/*
* rgb = [ R G B A ]
*
* Common >>3 gives:
*
* [ R5 G5 B5 x ]
*/
v = _mm_srli_pi16 (rgb, 3);
/*
* Pure MMX PMADDWD:
*
* low32 = R5*1024 + G5*32
* high32 = B5
*/
v = _mm_madd_pi16 (v, coeff);
hi = _mm_srli_si64 (v, 32);
v = _mm_add_pi32 (v, hi);
return (guint16) _mm_cvtsi64_si32 (v);
}
static __inline__ guint32
static __inline__ guint16
pack_565 (__m64 rgb)
{
const __m64 coeff =
_mm_set_pi16 (0, 1, 64, 2048);
const __m64 four =
_mm_set_pi16 (0, 0, 0, 4);
__m64 v;
__m64 hi;
__m64 gbit;
/*
* Common >>3:
*
* [ R5 G5 B5 x ]
*/
v = _mm_srli_pi16 (rgb, 3);
/*
* low32 = R5*2048 + G5*64
* high32 = B5
*/
v = _mm_madd_pi16 (v, coeff);
hi = _mm_srli_si64 (v, 32);
v = _mm_add_pi32 (v, hi);
/*
* Sixth green bit:
*
* (G & 4) << 3
*/
gbit = _mm_srli_si64 (rgb, 16);
gbit = _mm_and_si64 (gbit, four);
gbit = _mm_slli_pi16 (gbit, 3);
v = _mm_add_pi32 (v, gbit);
return (guint16) _mm_cvtsi64_si32 (v);
}
static __inline__ __m64
blend_rgb16_mmx (__m64 zero,
__m64 ff,
__m64 bias,
@ -180,7 +271,6 @@ blend_rgb16_mmx (__m64 zero,
__m64 a;
__m64 ia;
__m64 t;
guint32 result;
s = _mm_cvtsi32_si64 ((int) src);
d = _mm_cvtsi32_si64 ((int) dest);
@ -188,28 +278,90 @@ blend_rgb16_mmx (__m64 zero,
s = _mm_unpacklo_pi8 (s, zero);
d = _mm_unpacklo_pi8 (d, zero);
a = _mm_srli_si64 (s, 48);
a = _mm_unpacklo_pi16 (a, a);
a = _mm_unpacklo_pi32 (a, a);
/*
* Pure-MMX alpha broadcast:
*
* A -> [ A A A A ]
*/
a = _mm_unpackhi_pi16 (s, s);
a = _mm_unpackhi_pi32 (a, a);
ia = _mm_sub_pi16 (ff, a);
t = _mm_add_pi16 (_mm_mullo_pi16 (s, a),
_mm_mullo_pi16 (d, ia));
t = _mm_add_pi16 (
_mm_mullo_pi16 (s, a),
_mm_mullo_pi16 (d, ia));
/*
* Exact integer /255 using base MMX only.
*/
t = _mm_add_pi16 (t, bias);
t = _mm_add_pi16 (t, _mm_srli_pi16 (t, 8));
t = _mm_add_pi16 (
t,
_mm_srli_pi16 (t, 8));
t = _mm_srli_pi16 (t, 8);
t = _mm_packs_pu16 (t, t);
__asm__ ("movd %1,%0"
: "=r" (result)
: "y" (t));
return result;
return t;
}
#define DEFINE_RGB16_MMX_COMPOSITOR(name, expand_pixel, pack_pixel) \
static __inline__ guint32
blend_rgb16_scalar_tail (guint32 src,
guint32 dest)
{
guint32 a;
guint32 ia;
guint32 r;
guint32 g;
guint32 b;
a = src >> 24;
ia = 255U - a;
r = (src & 0xffU) * a +
(dest & 0xffU) * ia;
g = ((src >> 8) & 0xffU) * a +
((dest >> 8) & 0xffU) * ia;
b = ((src >> 16) & 0xffU) * a +
((dest >> 16) & 0xffU) * ia;
r += 128U;
r += r >> 8;
r >>= 8;
g += 128U;
g += g >> 8;
g >>= 8;
b += 128U;
b += b >> 8;
b >>= 8;
return r | (g << 8) | (b << 16);
}
static __inline__ guint16
pack_555_scalar_tail (guint32 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 7) |
((rgb & 0x0000f800U) >> 6) |
((rgb & 0x00f80000U) >> 19));
}
static __inline__ guint16
pack_565_scalar_tail (guint32 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 8) |
((rgb & 0x0000fc00U) >> 5) |
((rgb & 0x00f80000U) >> 19));
}
#define DEFINE_RGB16_MMX_COMPOSITOR(name, expand_pixel, pack_pixel, scalar_pack_pixel) \
G_GNUC_INTERNAL void \
name (guchar *src_buf, \
gint src_rowstride, \
@ -219,6 +371,36 @@ name (guchar *src_buf, \
gint width, \
gint height) \
{ \
if (width == 1) \
{ \
guchar *sp_row = src_buf; \
guchar *dp_row = dest_buf; \
gint h = height; \
\
while (h--) \
{ \
guint32 sp; \
guint16 dp16; \
guint32 dp; \
guint32 rgb; \
guint16 result; \
\
memcpy (&sp, sp_row, sizeof sp); \
memcpy (&dp16, dp_row, sizeof dp16); \
\
dp = expand_pixel (dp16); \
rgb = blend_rgb16_scalar_tail (sp, dp); \
result = scalar_pack_pixel (rgb); \
\
memcpy (dp_row, &result, sizeof result); \
\
sp_row += src_rowstride; \
dp_row += dest_rowstride; \
} \
\
return; \
} \
\
const __m64 zero = _mm_setzero_si64 (); \
const __m64 ones = _mm_cmpeq_pi16 (zero, zero); \
const __m64 ff = _mm_srli_pi16 (ones, 8); \
@ -241,8 +423,8 @@ name (guchar *src_buf, \
guint32 dpair; \
guint32 dp0; \
guint32 dp1; \
guint32 rgb0; \
guint32 rgb1; \
__m64 rgb0; \
__m64 rgb1; \
guint32 result; \
\
memcpy (&sp0, p, sizeof sp0); \
@ -276,8 +458,8 @@ name (guchar *src_buf, \
memcpy (&dp16, q, sizeof dp16); \
\
dp = expand_pixel (dp16); \
rgb = blend_rgb16_mmx (zero, ff, bias, sp, dp); \
result = pack_pixel (rgb); \
rgb = blend_rgb16_scalar_tail (sp, dp); \
result = scalar_pack_pixel (rgb); \
\
memcpy (q, &result, sizeof result); \
} \
@ -292,11 +474,13 @@ name (guchar *src_buf, \
DEFINE_RGB16_MMX_COMPOSITOR (
_gdk_pixel_ops_composite_555_mmx,
expand_555,
pack_555)
pack_555,
pack_555_scalar_tail)
DEFINE_RGB16_MMX_COMPOSITOR (
_gdk_pixel_ops_composite_565_mmx,
expand_565,
pack_565)
pack_565,
pack_565_scalar_tail)
#undef DEFINE_RGB16_MMX_COMPOSITOR

View file

@ -0,0 +1,493 @@
/* GDK - The GIMP Drawing Kit
*
* MMX pixel operations for 32-bit x86.
*/
#include "config.h"
#include <string.h>
#include <mmintrin.h>
#include "gdkpixelops.h"
#ifndef __i386__
#error "gdkpixelops-x86-mmx.c requires a 32-bit x86 target"
#endif
G_GNUC_INTERNAL void
_gdk_pixel_ops_composite_0888_generic (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height);
static __inline__ __m64
blend_words_mmx (__m64 s,
__m64 d,
__m64 a,
__m64 ff,
__m64 bias,
__m64 c257)
{
__m64 t;
t = _mm_add_pi16 (_mm_mullo_pi16 (s, a),
_mm_mullo_pi16 (d,
_mm_sub_pi16 (ff, a)));
t = _mm_add_pi16 (t, bias);
__asm__ ("pmulhuw %1,%0"
: "+y" (t)
: "y" (c257));
return t;
}
G_GNUC_INTERNAL void
_gdk_pixel_ops_composite_0888_mmxext (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height)
{
const __m64 zero = _mm_setzero_si64 ();
const __m64 ones = _mm_cmpeq_pi16 (zero, zero);
const __m64 ff = _mm_srli_pi16 (ones, 8);
const __m64 bias = _mm_set1_pi16 (0x80);
const __m64 c257 = _mm_set1_pi16 (257);
const __m64 rgb_mask = _mm_srli_si64 (ones, 16);
guchar *src = src_buf;
guchar *dest = dest_buf;
if (dest_byte_order != GDK_LSB_FIRST)
{
_gdk_pixel_ops_composite_0888_generic (src_buf,
src_rowstride,
dest_buf,
dest_rowstride,
dest_byte_order,
width,
height);
return;
}
while (height--)
{
gint twidth = width;
guchar *p = src;
guchar *q = dest;
while (twidth--)
{
guint32 sp;
guint32 dp;
guint32 result;
__m64 s;
__m64 d;
__m64 a;
__m64 t;
memcpy (&sp, p, sizeof sp);
memcpy (&dp, q, sizeof dp);
s = _mm_cvtsi32_si64 ((int) sp);
d = _mm_cvtsi32_si64 ((int) dp);
s = _mm_unpacklo_pi8 (s, zero);
d = _mm_unpacklo_pi8 (d, zero);
/*
* Input lanes after unpack:
*
* [ R G B A ]
*
* Destination LSB layout wants:
*
* [ B G R X ]
*
* Keep the complete 4 x 16-bit vector occupied and do
* both channel ordering and alpha broadcast in MMXEXT.
*/
a = s;
__asm__ ("pshufw $0xff,%0,%0"
: "+y" (a));
__asm__ ("pshufw $0xc6,%0,%0"
: "+y" (s));
a = _mm_and_si64 (a, rgb_mask);
t = blend_words_mmx (s, d, a, ff, bias, c257);
t = _mm_packs_pu16 (t, t);
result = (guint32) _mm_cvtsi64_si32 (t);
memcpy (q, &result, sizeof result);
p += 4;
q += 4;
}
src += src_rowstride;
dest += dest_rowstride;
}
_mm_empty ();
}
static __inline__ guint32
expand_555 (guint16 value)
{
guint32 hi;
hi = (((guint32) value & 0x7c00U) >> 7) |
(((guint32) value & 0x03e0U) << 6) |
(((guint32) value & 0x001fU) << 19);
return hi |
((hi >> 5) & 0x00070707U);
}
static __inline__ guint32
expand_565 (guint16 value)
{
guint32 hi;
hi = (((guint32) value & 0xf800U) >> 8) |
(((guint32) value & 0x07e0U) << 5) |
(((guint32) value & 0x001fU) << 19);
return hi |
((hi >> 5) & 0x00070007U) |
((hi >> 6) & 0x00000300U);
}
static __inline__ guint16
pack_555_mmx (__m64 rgb)
{
const __m64 coeff =
_mm_set_pi16 (0, 1, 32, 1024);
__m64 v;
__m64 hi;
/*
* Input lanes:
* [ R G B A ]
*
* After shift:
* [ R5 G5 B5 x ]
*/
v = _mm_srli_pi16 (rgb, 3);
/*
* PMADDWD:
*
* low32 = R5 * 1024 + G5 * 32
* high32 = B5 * 1 + x * 0
*/
v = _mm_madd_pi16 (v, coeff);
hi = _mm_srli_si64 (v, 32);
v = _mm_add_pi32 (v, hi);
return (guint16) _mm_cvtsi64_si32 (v);
}
static __inline__ guint16
pack_565_mmx (__m64 rgb)
{
const __m64 coeff =
_mm_set_pi16 (0, 1, 64, 2048);
const __m64 four =
_mm_set_pi16 (0, 0, 0, 4);
__m64 v;
__m64 hi;
__m64 gbit;
/*
* Full vector:
*
* rgb = [ R G B A ]
*
* Common shift:
*
* v = [ R5 G5 B5 x ]
*/
v = _mm_srli_pi16 (rgb, 3);
/*
* low32 = R5 * 2048 + G5 * 64
* high32 = B5
*/
v = _mm_madd_pi16 (v, coeff);
hi = _mm_srli_si64 (v, 32);
v = _mm_add_pi32 (v, hi);
/*
* Extract original green into the low word.
*
* rgb >> 16 → low word = G
*
* The only green bit not represented by G>>3 is
* original bit 2.
*
* Its final RGB565 contribution is bit 5:
*
* (G & 4) << 3
*/
gbit = _mm_srli_si64 (rgb, 16);
gbit = _mm_and_si64 (gbit, four);
gbit = _mm_slli_pi16 (gbit, 3);
v = _mm_add_pi32 (v, gbit);
return (guint16) _mm_cvtsi64_si32 (v);
}
static __inline__ __m64
blend_rgb16_mmx (__m64 zero,
__m64 ff,
__m64 bias,
__m64 c257,
guint32 src,
guint32 dest)
{
__m64 s;
__m64 d;
__m64 a;
__m64 ia;
__m64 t;
s = _mm_cvtsi32_si64 ((int) src);
d = _mm_cvtsi32_si64 ((int) dest);
/*
* Fully occupied 4 x 16-bit vectors:
*
* s = [ R G B A ]
* d = [ R G B 0 ]
*/
s = _mm_unpacklo_pi8 (s, zero);
d = _mm_unpacklo_pi8 (d, zero);
/*
* Broadcast A through all four 16-bit lanes.
*/
a = _mm_srli_si64 (s, 48);
__asm__ ("pshufw $0x00,%0,%0"
: "+y" (a));
ia = _mm_sub_pi16 (ff, a);
t = _mm_add_pi16 (_mm_mullo_pi16 (s, a),
_mm_mullo_pi16 (d, ia));
t = _mm_add_pi16 (t, bias);
/*
* Exact /255 for all four lanes:
*
* ((x + 128) * 257) >> 16
*/
__asm__ ("pmulhuw %1,%0"
: "+y" (t)
: "y" (c257));
return t;
}
static __inline__ guint32
blend_rgb16_scalar_tail (guint32 src,
guint32 dest)
{
guint32 a;
guint32 ia;
guint32 r;
guint32 g;
guint32 b;
a = src >> 24;
ia = 255U - a;
r = (src & 0xffU) * a +
(dest & 0xffU) * ia;
g = ((src >> 8) & 0xffU) * a +
((dest >> 8) & 0xffU) * ia;
b = ((src >> 16) & 0xffU) * a +
((dest >> 16) & 0xffU) * ia;
r += 128U;
r += r >> 8;
r >>= 8;
g += 128U;
g += g >> 8;
g >>= 8;
b += 128U;
b += b >> 8;
b >>= 8;
return r | (g << 8) | (b << 16);
}
static __inline__ guint16
pack_555_scalar_tail (guint32 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 7) |
((rgb & 0x0000f800U) >> 6) |
((rgb & 0x00f80000U) >> 19));
}
static __inline__ guint16
pack_565_scalar_tail (guint32 rgb)
{
return (guint16)
(((rgb & 0x000000f8U) << 8) |
((rgb & 0x0000fc00U) >> 5) |
((rgb & 0x00f80000U) >> 19));
}
#define DEFINE_RGB16_MMX_COMPOSITOR(name, expand_pixel, pack_pixel, scalar_pack_pixel) \
G_GNUC_INTERNAL void \
name (guchar *src_buf, \
gint src_rowstride, \
guchar *dest_buf, \
gint dest_rowstride, \
GdkByteOrder dest_byte_order, \
gint width, \
gint height) \
{ \
if (width == 1) \
{ \
guchar *sp_row = src_buf; \
guchar *dp_row = dest_buf; \
gint h = height; \
\
while (h--) \
{ \
guint32 sp; \
guint16 dp16; \
guint32 dp; \
guint32 rgb; \
guint16 result; \
\
memcpy (&sp, sp_row, sizeof sp); \
memcpy (&dp16, dp_row, sizeof dp16); \
\
dp = expand_pixel (dp16); \
rgb = blend_rgb16_scalar_tail (sp, dp); \
result = scalar_pack_pixel (rgb); \
\
memcpy (dp_row, &result, sizeof result); \
\
sp_row += src_rowstride; \
dp_row += dest_rowstride; \
} \
\
return; \
} \
\
const __m64 zero = _mm_setzero_si64 (); \
const __m64 ones = _mm_cmpeq_pi16 (zero, zero); \
const __m64 ff = _mm_srli_pi16 (ones, 8); \
const __m64 bias = _mm_set1_pi16 (0x80); \
const __m64 c257 = _mm_set1_pi16 (257); \
guchar *src = src_buf; \
guchar *dest = dest_buf; \
\
(void) dest_byte_order; \
\
while (height--) \
{ \
gint pairs = width >> 1; \
guchar *p = src; \
guchar *q = dest; \
\
while (pairs--) \
{ \
guint32 sp0; \
guint32 sp1; \
guint32 dpair; \
guint32 dp0; \
guint32 dp1; \
__m64 rgb0; \
__m64 rgb1; \
guint32 result; \
\
memcpy (&sp0, p, sizeof sp0); \
memcpy (&sp1, p + 4, sizeof sp1); \
memcpy (&dpair, q, sizeof dpair); \
\
dp0 = expand_pixel ((guint16) dpair); \
dp1 = expand_pixel ((guint16) (dpair >> 16)); \
\
rgb0 = blend_rgb16_mmx (zero, ff, bias, c257, sp0, dp0); \
rgb1 = blend_rgb16_mmx (zero, ff, bias, c257, sp1, dp1); \
\
result = (guint32) pack_pixel (rgb0); \
result |= (guint32) pack_pixel (rgb1) << 16; \
\
memcpy (q, &result, sizeof result); \
\
p += 8; \
q += 4; \
} \
\
if (width & 1) \
{ \
guint32 sp; \
guint16 dp16; \
guint16 result; \
guint32 dp; \
guint32 rgb; \
\
memcpy (&sp, p, sizeof sp); \
memcpy (&dp16, q, sizeof dp16); \
\
dp = expand_pixel (dp16); \
rgb = blend_rgb16_scalar_tail (sp, dp); \
result = scalar_pack_pixel (rgb); \
\
memcpy (q, &result, sizeof result); \
} \
\
src += src_rowstride; \
dest += dest_rowstride; \
} \
\
_mm_empty (); \
}
DEFINE_RGB16_MMX_COMPOSITOR (
_gdk_pixel_ops_composite_555_mmxext,
expand_555,
pack_555_mmx,
pack_555_scalar_tail)
DEFINE_RGB16_MMX_COMPOSITOR (
_gdk_pixel_ops_composite_565_mmxext,
expand_565,
pack_565_mmx,
pack_565_scalar_tail)
#undef DEFINE_RGB16_MMX_COMPOSITOR

View file

@ -13,6 +13,8 @@
#include <cpuid.h>
#define GDK_CPUID_AMD_MMXEXT (1U << 22)
G_GNUC_INTERNAL void
_gdk_pixel_ops_composite_0888_mmx (guchar *src_buf,
gint src_rowstride,
@ -40,6 +42,33 @@ _gdk_pixel_ops_composite_565_mmx (guchar *src_buf,
gint width,
gint height);
G_GNUC_INTERNAL void
_gdk_pixel_ops_composite_0888_mmxext (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_555_mmxext (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_mmxext (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkByteOrder dest_byte_order,
gint width,
gint height);
static gboolean gdk_pixel_ops_mmx_available;
G_GNUC_INTERNAL gboolean
@ -55,16 +84,54 @@ _gdk_pixel_ops_init (void)
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
gboolean enhanced_mmx = FALSE;
if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) &&
(edx & bit_MMX) != 0)
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx) ||
(edx & bit_MMX) == 0)
return;
gdk_pixel_ops_mmx_available = TRUE;
_gdk_pixel_ops.composite_0888 =
_gdk_pixel_ops_composite_0888_mmx;
_gdk_pixel_ops.composite_555 =
_gdk_pixel_ops_composite_555_mmx;
_gdk_pixel_ops.composite_565 =
_gdk_pixel_ops_composite_565_mmx;
/*
* Intel CPUs expose the MMX-form PSHUFW/PMULHUW
* instructions together with SSE.
*
* AMD CPUs may expose the same integer-MMX extension
* through extended CPUID bit 22 without SSE.
*/
if ((edx & bit_SSE) != 0)
enhanced_mmx = TRUE;
else if (__get_cpuid_max (0x80000000U, NULL) >=
0x80000001U)
{
unsigned int ext_eax;
unsigned int ext_ebx;
unsigned int ext_ecx;
unsigned int ext_edx;
if (__get_cpuid (0x80000001U,
&ext_eax,
&ext_ebx,
&ext_ecx,
&ext_edx) &&
(ext_edx & GDK_CPUID_AMD_MMXEXT) != 0)
enhanced_mmx = TRUE;
}
if (enhanced_mmx)
{
gdk_pixel_ops_mmx_available = TRUE;
_gdk_pixel_ops.composite_0888 =
_gdk_pixel_ops_composite_0888_mmx;
_gdk_pixel_ops_composite_0888_mmxext;
_gdk_pixel_ops.composite_555 =
_gdk_pixel_ops_composite_555_mmx;
_gdk_pixel_ops_composite_555_mmxext;
_gdk_pixel_ops.composite_565 =
_gdk_pixel_ops_composite_565_mmx;
_gdk_pixel_ops_composite_565_mmxext;
}
}