Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11dyn.h @ 1542:a8bf1aa21020
Fixed bug #15
SDL_blit_A.mmx-speed.patch.txt --
Speed improvements and a bugfix for the current GCC inline mmx
asm code:
- Changed some ops and removed some resulting useless ones.
- Added some instruction parallelism (some gain)
The resulting speed on my Xeon improved upto 35% depending on
the function (measured in fps).
- Fixed a bug where BlitRGBtoRGBSurfaceAlphaMMX() was
setting the alpha component on the destination surfaces (to
opaque-alpha) even when the surface had none.
SDL_blit_A.mmx-msvc.patch.txt --
MSVC mmx intrinsics version of the same GCC asm code.
MSVC compiler tries to parallelize the code and to avoid
register stalls, but does not always do a very good job.
Per-surface blending MSVC functions run quite a bit faster
than their pure-asm counterparts (upto 55% faster for 16bit
ones), but the per-pixel blending runs somewhat slower than asm.
- BlitRGBtoRGBSurfaceAlphaMMX and BlitRGBtoRGBPixelAlphaMMX (and all
variants) can now also handle formats other than (A)RGB8888. Formats
like RGBA8888 and some quite exotic ones are allowed -- like
RAGB8888, or actually anything having channels aligned on 8bit
boundary and full 8bit alpha (for per-pixel alpha blending).
The performance cost of this change is virtually 0 for per-surface
alpha blending (no extra ops inside the loop) and a single non-MMX
op inside the loop for per-pixel blending. In testing, the per-pixel
alpha blending takes a ~2% performance hit, but it still runs much
faster than the current code in CVS. If necessary, a separate function
with this functionality can be made.
This code requires Processor Pack for VC6.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 15 Mar 2006 15:39:29 +0000 |
parents | 1f4f09641645 |
children | 3ba88cb7eb1b |
rev | line source |
---|---|
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 Sam Lantinga |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 #ifndef _SDL_x11dyn_h |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 #define _SDL_x11dyn_h |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 #include <X11/Xlib.h> |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 #include <X11/Xutil.h> |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 #include <X11/Xatom.h> |
1351
82c38796c7ca
Changed X11 header order so it works on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents:
1314
diff
changeset
|
30 #include <X11/Xlibint.h> |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #include <X11/Xproto.h> |
1169
4b3e2294782d
Date: Sun, 06 Nov 2005 18:23:03 +0900
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
32 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1351
diff
changeset
|
33 #include "../Xext/extensions/extutil.h" |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 #ifndef NO_SHARED_MEMORY |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #include <sys/ipc.h> |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include <sys/shm.h> |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 #include <X11/extensions/XShm.h> |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 #endif |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 /* |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 * Never reference Xlib directly...we might load it dynamically at runtime. |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 * Even if we don't, for readability, we still use the function pointers |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 * (although the symbol resolution will be done by the loader in that case). |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 * |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 * We define SDL_X11_SYM and include SDL_x11sym.h to accomplish various |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 * goals, without having to duplicate those function signatures. |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 */ |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 #ifdef __cplusplus |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 extern "C" { |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 #endif |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
1438
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
53 #ifdef __osf__ |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
54 extern int _XData32(Display *,register long *,unsigned); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
55 extern void _XRead32(Display *,register long *,long); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
56 extern void _SmtBufferOverflow(Display *,register smtDisplayPtr); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
57 extern void _SmtIpError(Display *,register smtDisplayPtr, int); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
58 extern int ipAllocateData(ChannelPtr, IPCard, IPDataPtr *); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
59 extern int ipUnallocateAndSendData(ChannelPtr, IPCard); |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
60 #endif |
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
61 |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 /* evil function signatures... */ |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 typedef int (*SDL_X11_XSynchronizeRetType)(Display*); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*); |
1248
d2c6881935be
Catch X11 extension errors...since most of these are notifications that we
Ryan C. Gordon <icculus@icculus.org>
parents:
1244
diff
changeset
|
66 typedef int (*SDL_X11_XSetExtensionErrorHandlerType)(Display *,char *,char *); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
1235
f60f6f4ffc6f
Make some dynamic X11 symbols option. _XData32 and _XRead32 are only available
Ryan C. Gordon <icculus@icculus.org>
parents:
1226
diff
changeset
|
68 #define SDL_X11_SYM(req,ret,fn,params) extern ret (*p##fn) params; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 #include "SDL_x11sym.h" |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 #undef SDL_X11_SYM |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 /* Macro in the xlib headers, not an actual symbol... */ |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 #define pXDestroyImage XDestroyImage |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 |
1226
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
75 /* Workaround code in headers... */ |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
76 #if !__SDL_NO_REDEFINE_X11_HEADER_SYMS |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
77 #define _XFlush p_XFlush |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
78 #define _XFlushGCCache p_XFlushGCCache |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
79 #define _XReply p_XReply |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
80 #define _XSend p_XSend |
1299
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
81 #define XFree pXFree |
1226
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
82 #define _XData32 p_XData32 |
d05306f0dc21
More dynamic X11 fixes...catches some code in Xlib headers that caused
Ryan C. Gordon <icculus@icculus.org>
parents:
1169
diff
changeset
|
83 |
1438
1f4f09641645
Date: Sun, 26 Feb 2006 11:25:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
84 #if defined(__osf__) |
1299
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
85 #define _SmtBufferOverflow p_SmtBufferOverflow |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
86 #define _SmtIpError p_SmtIpError |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
87 #define ipAllocateData pipAllocateData |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
88 #define ipUnallocateAndSendData pipUnallocateAndSendData |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
89 #endif |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
90 |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
91 #endif /* !__SDL_NO_REDEFINE_X11_HEADER_SYMS */ |
2bf9dda618e5
Corrects dynamic X11 code on Tru64 systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
1248
diff
changeset
|
92 |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 int SDL_X11_LoadSymbols(void); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 void SDL_X11_UnloadSymbols(void); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 #ifdef __cplusplus |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 } |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 #endif |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 #endif /* !defined _SDL_x11dyn_h */ |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 |