1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
34 #include "state_tracker/xlib_sw_winsys.h"
35 #include "xm_winsys.h"
36 #include "util/u_debug.h"
37 #include "softpipe/sp_public.h"
38 #include "llvmpipe/lp_public.h"
39 #include "cell/ppu/cell_public.h"
41 /* advertise OpenGL support */
42 PUBLIC
const int st_api_OpenGL
= 1;
45 static struct pipe_screen
*
46 create_screen( struct sw_winsys
*winsys
)
48 #if defined(GALLIUM_CELL)
49 if (!getenv("GALLIUM_NOCELL"))
50 return cell_create_screen( winsys
);
53 #if defined(GALLIUM_LLVMPIPE)
54 return llvmpipe_create_screen( winsys
);
57 return softpipe_create_screen( winsys
);
62 static struct pipe_screen
*
63 xlib_create_screen( Display
*display
)
65 struct sw_winsys
*winsys
;
66 struct pipe_screen
*screen
;
68 winsys
= xlib_create_sw_winsys( display
);
72 screen
= create_screen(winsys
);
80 winsys
->destroy( winsys
);
86 struct xm_driver xlib_driver
=
88 .create_pipe_screen
= xlib_create_screen
,
94 /* Build the rendering stack.
96 static void _init( void ) __attribute__((constructor
));
97 static void _init( void )
99 /* Initialize the xlib libgl code, pass in the winsys:
101 xmesa_set_driver( &xlib_driver
);
105 /***********************************************************************
107 * Butt-ugly hack to convince the linker not to throw away public GL
108 * symbols (they are all referenced from getprocaddress, I guess).
110 extern void (*linker_foo(const unsigned char *procName
))();
111 extern void (*glXGetProcAddress(const unsigned char *procName
))();
113 extern void (*linker_foo(const unsigned char *procName
))()
115 return glXGetProcAddress(procName
);
120 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
121 * libglapi.a. We need to define them here.
123 #ifdef GLX_INDIRECT_RENDERING
125 #define GL_GLEXT_PROTOTYPES
127 #include "glapi/glapi.h"
128 #include "glapi/glapitable.h"
129 #include "glapi/glapidispatch.h"
131 #if defined(USE_MGL_NAMESPACE)
132 #define NAME(func) mgl##func
134 #define NAME(func) gl##func
137 #define DISPATCH(FUNC, ARGS, MESSAGE) \
138 CALL_ ## FUNC(GET_DISPATCH(), ARGS);
140 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
141 return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
143 /* skip normal ones */
144 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
145 #include "glapi/glapitemp.h"
147 #endif /* GLX_INDIRECT_RENDERING */