src/video/SDL_blit.c
changeset 5389 24903690f48a
parent 5325 b9c224e16859
child 5535 96594ac5fd1a
     1.1 --- a/src/video/SDL_blit.c	Mon Feb 21 23:45:48 2011 -0800
     1.2 +++ b/src/video/SDL_blit.c	Tue Feb 22 21:44:36 2011 -0800
     1.3 @@ -100,6 +100,30 @@
     1.4      return (okay ? 0 : -1);
     1.5  }
     1.6  
     1.7 +#ifdef __MACOSX__
     1.8 +#include <sys/sysctl.h>
     1.9 +
    1.10 +static SDL_bool
    1.11 +SDL_UseAltivecPrefetch()
    1.12 +{
    1.13 +    const char key[] = "hw.l3cachesize";
    1.14 +    u_int64_t result = 0;
    1.15 +    size_t typeSize = sizeof(result);
    1.16 +
    1.17 +    if (sysctlbyname(key, &result, &typeSize, NULL, 0) == 0 && result > 0) {
    1.18 +        return SDL_TRUE;
    1.19 +    } else {
    1.20 +        return SDL_FALSE;
    1.21 +    }
    1.22 +}
    1.23 +#else
    1.24 +static SDL_bool
    1.25 +SDL_UseAltivecPrefetch()
    1.26 +{
    1.27 +    /* Just guess G4 */
    1.28 +    return SDL_TRUE;
    1.29 +}
    1.30 +#endif /* __MACOSX__ */
    1.31  
    1.32  static SDL_BlitFunc
    1.33  SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
    1.34 @@ -121,12 +145,22 @@
    1.35              if (SDL_HasMMX()) {
    1.36                  features |= SDL_CPU_MMX;
    1.37              }
    1.38 +            if (SDL_Has3DNow()) {
    1.39 +                features |= SDL_CPU_3DNOW;
    1.40 +            }
    1.41              if (SDL_HasSSE()) {
    1.42                  features |= SDL_CPU_SSE;
    1.43              }
    1.44              if (SDL_HasSSE2()) {
    1.45                  features |= SDL_CPU_SSE2;
    1.46              }
    1.47 +            if (SDL_HasAltiVec()) {
    1.48 +                if (SDL_UseAltivecPrefetch()) {
    1.49 +                    features |= SDL_CPU_ALTIVEC_PREFETCH;
    1.50 +                } else {
    1.51 +                    features |= SDL_CPU_ALTIVEC_NOPREFETCH;
    1.52 +                }
    1.53 +            }
    1.54          }
    1.55      }
    1.56