g3dvl: Use sobel filter for chroma interpolation
[mesa/nouveau-pmpeg.git] / src / gallium / targets / libgl-xlib / xlib.c
blob0ede7e6096b3a5e736dafe818ff74ae39b10e715
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
4 * All Rights Reserved.
5 *
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
24 * of the Software.
27 **************************************************************************/
30 * Authors:
31 * Keith Whitwell
33 #include "pipe/p_compiler.h"
34 #include "util/u_debug.h"
35 #include "state_tracker/xlib_sw_winsys.h"
36 #include "xm_public.h"
38 #include "state_tracker/st_gl_api.h"
39 #include "target-helpers/inline_sw_helper.h"
40 #include "target-helpers/inline_debug_helper.h"
44 /* Helper function to build a subset of a driver stack consisting of
45 * one of the software rasterizers (llvmpipe, softpipe) and the
46 * xlib winsys.
48 static struct pipe_screen *
49 swrast_xlib_create_screen( Display *display )
51 struct sw_winsys *winsys;
52 struct pipe_screen *screen = NULL;
54 /* Create the underlying winsys, which performs presents to Xlib
55 * drawables:
57 winsys = xlib_create_sw_winsys( display );
58 if (winsys == NULL)
59 return NULL;
61 /* Create a software rasterizer on top of that winsys:
63 screen = sw_screen_create( winsys );
64 if (screen == NULL)
65 goto fail;
67 /* Inject any wrapping layers we want to here:
69 return debug_screen_wrap( screen );
71 fail:
72 if (winsys)
73 winsys->destroy( winsys );
75 return NULL;
78 static struct xm_driver xlib_driver =
80 .create_pipe_screen = swrast_xlib_create_screen,
81 .create_st_api = st_gl_api_create,
85 /* Build the rendering stack.
87 static void _init( void ) __attribute__((constructor));
88 static void _init( void )
90 /* Initialize the xlib libgl code, pass in the winsys:
92 xmesa_set_driver( &xlib_driver );
96 /***********************************************************************
98 * Butt-ugly hack to convince the linker not to throw away public GL
99 * symbols (they are all referenced from getprocaddress, I guess).
101 extern void (*linker_foo(const unsigned char *procName))();
102 extern void (*glXGetProcAddress(const unsigned char *procName))();
104 extern void (*linker_foo(const unsigned char *procName))()
106 return glXGetProcAddress(procName);
111 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
112 * libglapi.a. We need to define them here.
114 #ifdef GLX_INDIRECT_RENDERING
116 #define GL_GLEXT_PROTOTYPES
117 #include "GL/gl.h"
118 #include "glapi/glapi.h"
119 #include "glapi/glapitable.h"
121 #if defined(USE_MGL_NAMESPACE)
122 #define NAME(func) mgl##func
123 #else
124 #define NAME(func) gl##func
125 #endif
127 #define DISPATCH(FUNC, ARGS, MESSAGE) \
128 GET_DISPATCH()->FUNC ARGS
130 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
131 return GET_DISPATCH()->FUNC ARGS
133 /* skip normal ones */
134 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
135 #include "glapi/glapitemp.h"
137 #endif /* GLX_INDIRECT_RENDERING */