Fixed bug 2241 - SSE intrinsic in fillrect MMX path
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Nov 2013 11:54:16 -0800
changeset 7998 097e3fac1979
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
--- a/src/video/SDL_fillrect.c	Sat Nov 16 10:27:46 2013 -0800
+++ b/src/video/SDL_fillrect.c	Sat Nov 16 11:54:16 2013 -0800
@@ -132,105 +132,6 @@
 /* *INDENT-ON* */
 #endif /* __SSE__ */
 
-#ifdef __MMX__
-/* *INDENT-OFF* */
-
-#define MMX_BEGIN \
-    __m64 c64 = _mm_set_pi32(color, color)
-
-#define MMX_WORK \
-    for (i = n / 64; i--;) { \
-        _mm_stream_pi((__m64 *)(p+0), c64); \
-        _mm_stream_pi((__m64 *)(p+8), c64); \
-        _mm_stream_pi((__m64 *)(p+16), c64); \
-        _mm_stream_pi((__m64 *)(p+24), c64); \
-        _mm_stream_pi((__m64 *)(p+32), c64); \
-        _mm_stream_pi((__m64 *)(p+40), c64); \
-        _mm_stream_pi((__m64 *)(p+48), c64); \
-        _mm_stream_pi((__m64 *)(p+56), c64); \
-        p += 64; \
-    }
-
-#define MMX_END \
-    _mm_empty()
-
-#define DEFINE_MMX_FILLRECT(bpp, type) \
-static void \
-SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
-{ \
-    int i, n; \
-    Uint8 *p = NULL; \
- \
-    MMX_BEGIN; \
- \
-    while (h--) { \
-        n = w * bpp; \
-        p = pixels; \
- \
-        if (n > 63) { \
-            int adjust = 8 - ((uintptr_t)p & 7); \
-            if (adjust < 8) { \
-                n -= adjust; \
-                adjust /= bpp; \
-                while (adjust--) { \
-                    *((type *)p) = (type)color; \
-                    p += bpp; \
-                } \
-            } \
-            MMX_WORK; \
-        } \
-        if (n & 63) { \
-            int remainder = (n & 63); \
-            remainder /= bpp; \
-            while (remainder--) { \
-                *((type *)p) = (type)color; \
-                p += bpp; \
-            } \
-        } \
-        pixels += pitch; \
-    } \
- \
-    MMX_END; \
-}
-
-static void
-SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
-{
-    int i, n;
-    Uint8 *p = NULL;
-    
-    MMX_BEGIN;
-
-    while (h--) {
-        n = w;
-        p = pixels;
-
-        if (n > 63) {
-            int adjust = 8 - ((uintptr_t)p & 7);
-            if (adjust) {
-                n -= adjust;
-                SDL_memset(p, color, adjust);
-                p += adjust;
-            }
-            MMX_WORK;
-        }
-        if (n & 63) {
-            int remainder = (n & 63);
-            SDL_memset(p, color, remainder);
-            p += remainder;
-        }
-        pixels += pitch;
-    }
-
-    MMX_END;
-}
-/* DEFINE_MMX_FILLRECT(1, Uint8) */
-DEFINE_MMX_FILLRECT(2, Uint16)
-DEFINE_MMX_FILLRECT(4, Uint32)
-
-/* *INDENT-ON* */
-#endif /* __MMX__ */
-
 static void
 SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
 {
@@ -373,12 +274,6 @@
                 break;
             }
 #endif
-#ifdef __MMX__
-            if (SDL_HasMMX()) {
-                SDL_FillRect1MMX(pixels, dst->pitch, color, rect->w, rect->h);
-                break;
-            }
-#endif
             SDL_FillRect1(pixels, dst->pitch, color, rect->w, rect->h);
             break;
         }
@@ -392,12 +287,6 @@
                 break;
             }
 #endif
-#ifdef __MMX__
-            if (SDL_HasMMX()) {
-                SDL_FillRect2MMX(pixels, dst->pitch, color, rect->w, rect->h);
-                break;
-            }
-#endif
             SDL_FillRect2(pixels, dst->pitch, color, rect->w, rect->h);
             break;
         }
@@ -417,12 +306,6 @@
                 break;
             }
 #endif
-#ifdef __MMX__
-            if (SDL_HasMMX()) {
-                SDL_FillRect4MMX(pixels, dst->pitch, color, rect->w, rect->h);
-                break;
-            }
-#endif
             SDL_FillRect4(pixels, dst->pitch, color, rect->w, rect->h);
             break;
         }