[SDL] SDL under Mac OS X

Albert Cahalan albert at users.sf.net
Tue Jan 25 07:41:49 PST 2005

On Sun, 2005-01-23 at 08:02 -0500, Ryan C. Gordon wrote:

> In terms of high-end game development, it's not unreasonable to cut the 
> G3 out at this point; Apple doesn't ship them anymore since the iBook 
> went to the G4, and it's a real pain in some cases to conditionalize 
> code based on the presence of a vector unit. Unlike MMX/SSE on x86 
> chips, you can't use Altivec in a function that a G3 will enter, since 
> the compiler adds setup code at the start of the function when it sees a 
> vector variable/function. This means function call overhead and/or ugly 
> code.

So don't use little tiny AltiVec functions. Use normal-sized ones,
cutting out the excess overhead. To avoid duplicating your code,
simply compile the functions twice:

#define foo foo_G3
#define bar bar_G3
#include "foobar.c"
#undef foo
#undef bar

#define foo foo_G4
#define bar bar_G4
#include "foobar.c"
#undef foo
#undef bar

// some function pointers, initialized to G3 versions
int(*foo)(SDL_Surface *, const char *) = foo_G3;
void(*bar)(double, const void *) = bar_G3;

> > Furthermore, -Os can be one of the best optimizations you can apply. The 
> > more you can fit into your i-cache the better. Apple recommends all 
> > shipping code be -Os. So unless you know for certain that these binaries 
> > are built optimized for size, you shouldn't ship them.
> For what it's worth, I think this is bunk. The CPU bottleneck is almost 
> never the code cache, it's the data cache.

Most apps are fast enough, except at start-up. It is then that
you really want -Os for reducing cache misses, disk seeks, page
faults, TLB misses, and so on.

You can compile the 10% hottest paths with -O3 if you like.
Leaving the bulk of the app at -Os would be good.

More information about the SDL mailing list