src/video/SDL_blit_copy.c
author Ryan C. Gordon <icculus@icculus.org>
Sat, 29 Oct 2011 01:03:50 -0400
changeset 6033 8788e295d3c8
parent 6032 aa31cad2451f
child 6034 e228e94fef7f
permissions -rw-r--r--
SDL_memcpyMMX(): Make sure srcskip and dstskip are 8-byte aligned. Thanks to Patrick Baggett for the fix!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     2
  Simple DirectMedia Layer
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     7
  arising from the use of this software.
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    11
  freely, subject to the following restrictions:
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5325
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#include "SDL_video.h"
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#include "SDL_blit.h"
2254
79e00f5561f4 Oops, didn't want to rename those files...
Sam Lantinga <slouken@libsdl.org>
parents: 2253
diff changeset
    25
#include "SDL_blit_copy.h"
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
2253
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    28
#ifdef __SSE__
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    29
/* This assumes 16-byte aligned src and dst */
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    30
static __inline__ void
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    31
SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len)
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    32
{
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    33
    int i;
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    34
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    35
    __m128 values[4];
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    36
    for (i = len / 64; i--;) {
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    37
        _mm_prefetch(src, _MM_HINT_NTA);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    38
        values[0] = *(__m128 *) (src + 0);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    39
        values[1] = *(__m128 *) (src + 16);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    40
        values[2] = *(__m128 *) (src + 32);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    41
        values[3] = *(__m128 *) (src + 48);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    42
        _mm_stream_ps((float *) (dst + 0), values[0]);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    43
        _mm_stream_ps((float *) (dst + 16), values[1]);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    44
        _mm_stream_ps((float *) (dst + 32), values[2]);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    45
        _mm_stream_ps((float *) (dst + 48), values[3]);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    46
        src += 64;
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    47
        dst += 64;
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    48
    }
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    49
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    50
    if (len & 63)
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    51
        SDL_memcpy(dst, src, len & 63);
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    52
}
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    53
#endif /* __SSE__ */
6d99edd791bf Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2252
diff changeset
    54
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
#ifdef __MMX__
2780
cc15254e44b6 Disable spurious warning
Sam Lantinga <slouken@libsdl.org>
parents: 2267
diff changeset
    56
#ifdef _MSC_VER
cc15254e44b6 Disable spurious warning
Sam Lantinga <slouken@libsdl.org>
parents: 2267
diff changeset
    57
#pragma warning(disable:4799)
cc15254e44b6 Disable spurious warning
Sam Lantinga <slouken@libsdl.org>
parents: 2267
diff changeset
    58
#endif
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
static __inline__ void
2248
5cd2a2293cf0 Okay, I figured out the intrinsics for SIMD memcpy
Sam Lantinga <slouken@libsdl.org>
parents: 2247
diff changeset
    60
SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len)
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
{
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    int i;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
6032
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    64
    __m64* d64 = (__m64*)dst;
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    65
    __m64* s64 = (__m64*)src;
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    66
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    67
    for(i= len / 64; i--;) {
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    68
        d64[0] = s64[0];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    69
        d64[1] = s64[1];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    70
        d64[2] = s64[2];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    71
        d64[3] = s64[3];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    72
        d64[4] = s64[4];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    73
        d64[5] = s64[5];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    74
        d64[6] = s64[6];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    75
        d64[7] = s64[7];
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    76
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    77
        d64 += 8;
aa31cad2451f Removed tabs and DOS endlines from SDL_blit_copy.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 5887
diff changeset
    78
        s64 += 8;
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    }
2248
5cd2a2293cf0 Okay, I figured out the intrinsics for SIMD memcpy
Sam Lantinga <slouken@libsdl.org>
parents: 2247
diff changeset
    80
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    if (len & 63)
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        SDL_memcpy(dst, src, len & 63);
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
}
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
#endif /* __MMX__ */
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
void
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
SDL_BlitCopy(SDL_BlitInfo * info)
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
{
5325
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    89
    SDL_bool overlap;
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
    Uint8 *src, *dst;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    int w, h;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    int srcskip, dstskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
    94
    w = info->dst_w * info->dst_fmt->BytesPerPixel;
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents: 2254
diff changeset
    95
    h = info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents: 2254
diff changeset
    96
    src = info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents: 2254
diff changeset
    97
    dst = info->dst;
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
    98
    srcskip = info->src_pitch;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
    99
    dstskip = info->dst_pitch;
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
5325
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   101
    /* Properly handle overlapping blits */
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   102
    if (src < dst) {
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   103
        overlap = (dst < (src + h*srcskip));
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   104
    } else {
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   105
        overlap = (src < (dst + h*dstskip));
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   106
    }
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   107
    if (overlap) {
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   108
        while (h--) {
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   109
            SDL_memmove(dst, src, w);
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   110
            src += srcskip;
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   111
            dst += dstskip;
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   112
        }
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   113
        return;
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   114
    }
b9c224e16859 Fixed bug #1090 (SDL_BlitCopyOverlap() assumes memcpy() operates in order)
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   115
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
#ifdef __SSE__
2826
cd4a49d5c1ba Fixed crash on 64-bit systems
Sam Lantinga <slouken@libsdl.org>
parents: 2780
diff changeset
   117
    if (SDL_HasSSE() &&
cd4a49d5c1ba Fixed crash on 64-bit systems
Sam Lantinga <slouken@libsdl.org>
parents: 2780
diff changeset
   118
        !((uintptr_t) src & 15) && !(srcskip & 15) &&
cd4a49d5c1ba Fixed crash on 64-bit systems
Sam Lantinga <slouken@libsdl.org>
parents: 2780
diff changeset
   119
        !((uintptr_t) dst & 15) && !(dstskip & 15)) {
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
        while (h--) {
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
            SDL_memcpySSE(dst, src, w);
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
            src += srcskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
            dst += dstskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        }
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        return;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    }
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
#endif
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
#ifdef __MMX__
6033
8788e295d3c8 SDL_memcpyMMX(): Make sure srcskip and dstskip are 8-byte aligned.
Ryan C. Gordon <icculus@icculus.org>
parents: 6032
diff changeset
   130
    if (SDL_HasMMX() && !(srcskip & 7) && !(dstskip & 7)) {
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
        while (h--) {
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
            SDL_memcpyMMX(dst, src, w);
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            src += srcskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
            dst += dstskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
        }
2248
5cd2a2293cf0 Okay, I figured out the intrinsics for SIMD memcpy
Sam Lantinga <slouken@libsdl.org>
parents: 2247
diff changeset
   136
        _mm_empty();
2247
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        return;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    }
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
#endif
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
    while (h--) {
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
        SDL_memcpy(dst, src, w);
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        src += srcskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        dst += dstskip;
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
    }
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
}
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
93994f65c74c Removed hermes since it's LGPL and not compatible with a commercial license.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
/* vi: set ts=4 sw=4 expandtab: */