comparison src/video/SDL_blit.c @ 5281:15a71bec4a55

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 19:16:09 -0800
parents b530ef003506
children
comparison
equal deleted inserted replaced
5219:adfcdd311ae0 5281:15a71bec4a55
1 /* 1 /*
2 SDL - Simple DirectMedia Layer 2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga 3 Copyright (C) 1997-2011 Sam Lantinga
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
98 } 98 }
99 /* Blit is done! */ 99 /* Blit is done! */
100 return (okay ? 0 : -1); 100 return (okay ? 0 : -1);
101 } 101 }
102 102
103 #ifdef __MACOSX__
104 #include <sys/sysctl.h>
105
106 static SDL_bool
107 SDL_UseAltivecPrefetch()
108 {
109 const char key[] = "hw.l3cachesize";
110 u_int64_t result = 0;
111 size_t typeSize = sizeof(result);
112
113 if (sysctlbyname(key, &result, &typeSize, NULL, 0) == 0 && result > 0) {
114 return SDL_TRUE;
115 } else {
116 return SDL_FALSE;
117 }
118 }
119 #else
120 static SDL_bool
121 SDL_UseAltivecPrefetch()
122 {
123 /* Just guess G4 */
124 return SDL_TRUE;
125 }
126 #endif /* __MACOSX__ */
127 103
128 static SDL_BlitFunc 104 static SDL_BlitFunc
129 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, 105 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
130 SDL_BlitFuncEntry * entries) 106 SDL_BlitFuncEntry * entries)
131 { 107 {
143 SDL_sscanf(override, "%u", &features); 119 SDL_sscanf(override, "%u", &features);
144 } else { 120 } else {
145 if (SDL_HasMMX()) { 121 if (SDL_HasMMX()) {
146 features |= SDL_CPU_MMX; 122 features |= SDL_CPU_MMX;
147 } 123 }
148 if (SDL_Has3DNow()) {
149 features |= SDL_CPU_3DNOW;
150 }
151 if (SDL_HasSSE()) { 124 if (SDL_HasSSE()) {
152 features |= SDL_CPU_SSE; 125 features |= SDL_CPU_SSE;
153 } 126 }
154 if (SDL_HasSSE2()) { 127 if (SDL_HasSSE2()) {
155 features |= SDL_CPU_SSE2; 128 features |= SDL_CPU_SSE2;
156 }
157 if (SDL_HasAltiVec()) {
158 if (SDL_UseAltivecPrefetch()) {
159 features |= SDL_CPU_ALTIVEC_PREFETCH;
160 } else {
161 features |= SDL_CPU_ALTIVEC_NOPREFETCH;
162 }
163 } 129 }
164 } 130 }
165 } 131 }
166 132
167 for (i = 0; entries[i].func; ++i) { 133 for (i = 0; entries[i].func; ++i) {