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 **************************************************************************/
33 #include "pipe/p_compiler.h"
34 #include "util/u_debug.h"
35 #include "target-helpers/wrap_screen.h"
36 #include "state_tracker/xlib_sw_winsys.h"
37 #include "xm_public.h"
39 #include "state_tracker/st_api.h"
40 #include "state_tracker/st_gl_api.h"
42 /* piggy back on this libGL for OpenGL support in EGL */
44 st_api_create_OpenGL()
46 return st_gl_api_create();
50 /* Helper function to choose and instantiate one of the software rasterizers:
51 * cell, llvmpipe, softpipe.
53 * This function could be shared, but currently causes headaches for
54 * the build systems, particularly scons if we try. Long term, want
55 * to avoid having global #defines for things like GALLIUM_LLVMPIPE,
56 * GALLIUM_CELL, etc. Scons already eliminates those #defines, so
57 * things that are painful for it now are likely to be painful for
58 * other build systems in the future.
60 * Copies (full or partial):
69 #ifdef GALLIUM_SOFTPIPE
70 #include "softpipe/sp_public.h"
73 #ifdef GALLIUM_LLVMPIPE
74 #include "llvmpipe/lp_public.h"
78 #include "cell/ppu/cell_public.h"
81 #ifdef GALLIUM_GALAHAD
82 #include "galahad/glhd_public.h"
85 static struct pipe_screen
*
86 swrast_create_screen(struct sw_winsys
*winsys
)
88 const char *default_driver
;
90 struct pipe_screen
*screen
= NULL
;
92 #if defined(GALLIUM_CELL)
93 default_driver
= "cell";
94 #elif defined(GALLIUM_LLVMPIPE)
95 default_driver
= "llvmpipe";
96 #elif defined(GALLIUM_SOFTPIPE)
97 default_driver
= "softpipe";
102 driver
= debug_get_option("GALLIUM_DRIVER", default_driver
);
104 #if defined(GALLIUM_CELL)
105 if (screen
== NULL
&& strcmp(driver
, "cell") == 0)
106 screen
= cell_create_screen( winsys
);
109 #if defined(GALLIUM_LLVMPIPE)
110 if (screen
== NULL
&& strcmp(driver
, "llvmpipe") == 0)
111 screen
= llvmpipe_create_screen( winsys
);
114 #if defined(GALLIUM_SOFTPIPE)
116 screen
= softpipe_create_screen( winsys
);
119 #if defined(GALLIUM_GALAHAD)
121 struct pipe_screen
*galahad_screen
= galahad_screen_create(screen
);
123 screen
= galahad_screen
;
130 /* Helper function to build a subset of a driver stack consisting of
131 * one of the software rasterizers (cell, llvmpipe, softpipe) and the
134 static struct pipe_screen
*
135 swrast_xlib_create_screen( Display
*display
)
137 struct sw_winsys
*winsys
;
138 struct pipe_screen
*screen
= NULL
;
140 /* Create the underlying winsys, which performs presents to Xlib
143 winsys
= xlib_create_sw_winsys( display
);
147 /* Create a software rasterizer on top of that winsys:
149 screen
= swrast_create_screen( winsys
);
153 /* Inject any wrapping layers we want to here:
155 return gallium_wrap_screen( screen
);
159 winsys
->destroy( winsys
);
164 static struct xm_driver xlib_driver
=
166 .create_pipe_screen
= swrast_xlib_create_screen
,
167 .create_st_api
= st_gl_api_create
,
171 /* Build the rendering stack.
173 static void _init( void ) __attribute__((constructor
));
174 static void _init( void )
176 /* Initialize the xlib libgl code, pass in the winsys:
178 xmesa_set_driver( &xlib_driver
);
182 /***********************************************************************
184 * Butt-ugly hack to convince the linker not to throw away public GL
185 * symbols (they are all referenced from getprocaddress, I guess).
187 extern void (*linker_foo(const unsigned char *procName
))();
188 extern void (*glXGetProcAddress(const unsigned char *procName
))();
190 extern void (*linker_foo(const unsigned char *procName
))()
192 return glXGetProcAddress(procName
);
197 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
198 * libglapi.a. We need to define them here.
200 #ifdef GLX_INDIRECT_RENDERING
202 #define GL_GLEXT_PROTOTYPES
204 #include "glapi/glapi.h"
205 #include "glapi/glapitable.h"
206 #include "glapi/glapidispatch.h"
208 #if defined(USE_MGL_NAMESPACE)
209 #define NAME(func) mgl##func
211 #define NAME(func) gl##func
214 #define DISPATCH(FUNC, ARGS, MESSAGE) \
215 CALL_ ## FUNC(GET_DISPATCH(), ARGS);
217 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
218 return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
220 /* skip normal ones */
221 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
222 #include "glapi/glapitemp.h"
224 #endif /* GLX_INDIRECT_RENDERING */