Fixed bug 2241 - SSE intrinsic in fillrect MMX path
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Nov 2013 11:54:16 -0800
changeset 7998097e3fac1979
parent 7997 4ad94134d372
child 7999 2c9aedfba740
Fixed bug 2241 - SSE intrinsic in fillrect MMX path

norfanin

The MMX path in SDL_fillrect.c uses the SSE intrinsic _mm_stream_pi. The function or symbol provided by the compiler will not be present because the SSE header may not get included. The linker will complain about an undefined reference.

Since this is the only intrinsic used here (and someone forgot to create one for MOVQ), I think the MMX path can be removed completely. At least I don't see another way to move 64-bits from an MMX register to memory.
src/video/SDL_fillrect.c
     1.1 --- a/src/video/SDL_fillrect.c	Sat Nov 16 10:27:46 2013 -0800
     1.2 +++ b/src/video/SDL_fillrect.c	Sat Nov 16 11:54:16 2013 -0800
     1.3 @@ -132,105 +132,6 @@
     1.4  /* *INDENT-ON* */
     1.5  #endif /* __SSE__ */
     1.6  
     1.7 -#ifdef __MMX__
     1.8 -/* *INDENT-OFF* */
     1.9 -
    1.10 -#define MMX_BEGIN \
    1.11 -    __m64 c64 = _mm_set_pi32(color, color)
    1.12 -
    1.13 -#define MMX_WORK \
    1.14 -    for (i = n / 64; i--;) { \
    1.15 -        _mm_stream_pi((__m64 *)(p+0), c64); \
    1.16 -        _mm_stream_pi((__m64 *)(p+8), c64); \
    1.17 -        _mm_stream_pi((__m64 *)(p+16), c64); \
    1.18 -        _mm_stream_pi((__m64 *)(p+24), c64); \
    1.19 -        _mm_stream_pi((__m64 *)(p+32), c64); \
    1.20 -        _mm_stream_pi((__m64 *)(p+40), c64); \
    1.21 -        _mm_stream_pi((__m64 *)(p+48), c64); \
    1.22 -        _mm_stream_pi((__m64 *)(p+56), c64); \
    1.23 -        p += 64; \
    1.24 -    }
    1.25 -
    1.26 -#define MMX_END \
    1.27 -    _mm_empty()
    1.28 -
    1.29 -#define DEFINE_MMX_FILLRECT(bpp, type) \
    1.30 -static void \
    1.31 -SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
    1.32 -{ \
    1.33 -    int i, n; \
    1.34 -    Uint8 *p = NULL; \
    1.35 - \
    1.36 -    MMX_BEGIN; \
    1.37 - \
    1.38 -    while (h--) { \
    1.39 -        n = w * bpp; \
    1.40 -        p = pixels; \
    1.41 - \
    1.42 -        if (n > 63) { \
    1.43 -            int adjust = 8 - ((uintptr_t)p & 7); \
    1.44 -            if (adjust < 8) { \
    1.45 -                n -= adjust; \
    1.46 -                adjust /= bpp; \
    1.47 -                while (adjust--) { \
    1.48 -                    *((type *)p) = (type)color; \
    1.49 -                    p += bpp; \
    1.50 -                } \
    1.51 -            } \
    1.52 -            MMX_WORK; \
    1.53 -        } \
    1.54 -        if (n & 63) { \
    1.55 -            int remainder = (n & 63); \
    1.56 -            remainder /= bpp; \
    1.57 -            while (remainder--) { \
    1.58 -                *((type *)p) = (type)color; \
    1.59 -                p += bpp; \
    1.60 -            } \
    1.61 -        } \
    1.62 -        pixels += pitch; \
    1.63 -    } \
    1.64 - \
    1.65 -    MMX_END; \
    1.66 -}
    1.67 -
    1.68 -static void
    1.69 -SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
    1.70 -{
    1.71 -    int i, n;
    1.72 -    Uint8 *p = NULL;
    1.73 -    
    1.74 -    MMX_BEGIN;
    1.75 -
    1.76 -    while (h--) {
    1.77 -        n = w;
    1.78 -        p = pixels;
    1.79 -
    1.80 -        if (n > 63) {
    1.81 -            int adjust = 8 - ((uintptr_t)p & 7);
    1.82 -            if (adjust) {
    1.83 -                n -= adjust;
    1.84 -                SDL_memset(p, color, adjust);
    1.85 -                p += adjust;
    1.86 -            }
    1.87 -            MMX_WORK;
    1.88 -        }
    1.89 -        if (n & 63) {
    1.90 -            int remainder = (n & 63);
    1.91 -            SDL_memset(p, color, remainder);
    1.92 -            p += remainder;
    1.93 -        }
    1.94 -        pixels += pitch;
    1.95 -    }
    1.96 -
    1.97 -    MMX_END;
    1.98 -}
    1.99 -/* DEFINE_MMX_FILLRECT(1, Uint8) */
   1.100 -DEFINE_MMX_FILLRECT(2, Uint16)
   1.101 -DEFINE_MMX_FILLRECT(4, Uint32)
   1.102 -
   1.103 -/* *INDENT-ON* */
   1.104 -#endif /* __MMX__ */
   1.105 -
   1.106  static void
   1.107  SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   1.108  {
   1.109 @@ -373,12 +274,6 @@
   1.110                  break;
   1.111              }
   1.112  #endif
   1.113 -#ifdef __MMX__
   1.114 -            if (SDL_HasMMX()) {
   1.115 -                SDL_FillRect1MMX(pixels, dst->pitch, color, rect->w, rect->h);
   1.116 -                break;
   1.117 -            }
   1.118 -#endif
   1.119              SDL_FillRect1(pixels, dst->pitch, color, rect->w, rect->h);
   1.120              break;
   1.121          }
   1.122 @@ -392,12 +287,6 @@
   1.123                  break;
   1.124              }
   1.125  #endif
   1.126 -#ifdef __MMX__
   1.127 -            if (SDL_HasMMX()) {
   1.128 -                SDL_FillRect2MMX(pixels, dst->pitch, color, rect->w, rect->h);
   1.129 -                break;
   1.130 -            }
   1.131 -#endif
   1.132              SDL_FillRect2(pixels, dst->pitch, color, rect->w, rect->h);
   1.133              break;
   1.134          }
   1.135 @@ -417,12 +306,6 @@
   1.136                  break;
   1.137              }
   1.138  #endif
   1.139 -#ifdef __MMX__
   1.140 -            if (SDL_HasMMX()) {
   1.141 -                SDL_FillRect4MMX(pixels, dst->pitch, color, rect->w, rect->h);
   1.142 -                break;
   1.143 -            }
   1.144 -#endif
   1.145              SDL_FillRect4(pixels, dst->pitch, color, rect->w, rect->h);
   1.146              break;
   1.147          }