2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
36 #ifdef HAVE_DIX_CONFIG_H
37 #include <dix-config.h>
41 #include <windowstr.h>
44 #include "glxserver.h"
48 const char GLServerVersion
[] = "1.4";
49 static const char GLServerExtensions
[] =
50 "GL_ARB_depth_texture "
51 "GL_ARB_draw_buffers "
52 "GL_ARB_fragment_program "
53 "GL_ARB_fragment_program_shadow "
56 "GL_ARB_multitexture "
57 "GL_ARB_occlusion_query "
58 "GL_ARB_point_parameters "
59 "GL_ARB_point_sprite "
61 "GL_ARB_shadow_ambient "
62 "GL_ARB_texture_border_clamp "
63 "GL_ARB_texture_compression "
64 "GL_ARB_texture_cube_map "
65 "GL_ARB_texture_env_add "
66 "GL_ARB_texture_env_combine "
67 "GL_ARB_texture_env_crossbar "
68 "GL_ARB_texture_env_dot3 "
69 "GL_ARB_texture_mirrored_repeat "
70 "GL_ARB_texture_non_power_of_two "
71 "GL_ARB_transpose_matrix "
72 "GL_ARB_vertex_program "
77 "GL_EXT_blend_equation_separate "
78 "GL_EXT_blend_func_separate "
79 "GL_EXT_blend_logic_op "
80 "GL_EXT_blend_minmax "
81 "GL_EXT_blend_subtract "
82 "GL_EXT_clip_volume_hint "
83 "GL_EXT_copy_texture "
84 "GL_EXT_draw_range_elements "
86 "GL_EXT_framebuffer_object "
87 "GL_EXT_multi_draw_arrays "
88 "GL_EXT_packed_pixels "
89 "GL_EXT_paletted_texture "
90 "GL_EXT_point_parameters "
91 "GL_EXT_polygon_offset "
92 "GL_EXT_rescale_normal "
93 "GL_EXT_secondary_color "
94 "GL_EXT_separate_specular_color "
95 "GL_EXT_shadow_funcs "
96 "GL_EXT_shared_texture_palette "
97 "GL_EXT_stencil_two_side "
98 "GL_EXT_stencil_wrap "
102 "GL_EXT_texture_compression_dxt1 "
103 "GL_EXT_texture_compression_s3tc "
104 "GL_EXT_texture_edge_clamp "
105 "GL_EXT_texture_env_add "
106 "GL_EXT_texture_env_combine "
107 "GL_EXT_texture_env_dot3 "
108 "GL_EXT_texture_filter_ansiotropic "
109 "GL_EXT_texture_lod "
110 "GL_EXT_texture_lod_bias "
111 "GL_EXT_texture_mirror_clamp "
112 "GL_EXT_texture_object "
113 "GL_EXT_texture_rectangle "
114 "GL_EXT_vertex_array "
115 "GL_3DFX_texture_compression_FXT1 "
116 "GL_APPLE_packed_pixels "
117 "GL_ATI_draw_buffers "
118 "GL_ATI_texture_env_combine3 "
119 "GL_ATI_texture_mirror_once "
120 "GL_HP_occlusion_test "
121 "GL_IBM_texture_mirrored_repeat "
122 "GL_INGR_blend_func_separate "
123 "GL_MESA_pack_invert "
124 "GL_MESA_ycbcr_texture "
125 "GL_NV_blend_square "
127 "GL_NV_fog_distance "
128 "GL_NV_fragment_program "
129 "GL_NV_fragment_program_option "
130 "GL_NV_fragment_program2 "
131 "GL_NV_light_max_exponent "
132 "GL_NV_multisample_filter_hint "
133 "GL_NV_point_sprite "
134 "GL_NV_texgen_reflection "
135 "GL_NV_texture_compression_vtc "
136 "GL_NV_texture_env_combine4 "
137 "GL_NV_texture_expand_normal "
138 "GL_NV_texture_rectangle "
139 "GL_NV_vertex_program "
140 "GL_NV_vertex_program1_1 "
141 "GL_NV_vertex_program2 "
142 "GL_NV_vertex_program2_option "
143 "GL_NV_vertex_program3 "
144 "GL_OES_compressed_paletted_texture "
145 "GL_SGI_color_matrix "
146 "GL_SGI_color_table "
147 "GL_SGIS_generate_mipmap "
148 "GL_SGIS_multisample "
149 "GL_SGIS_point_parameters "
150 "GL_SGIS_texture_border_clamp "
151 "GL_SGIS_texture_edge_clamp "
152 "GL_SGIS_texture_lod "
153 "GL_SGIX_depth_texture "
155 "GL_SGIX_shadow_ambient "
156 "GL_SUN_slice_accum "
160 ** We have made the simplifying assuption that the same extensions are
161 ** supported across all screens in a multi-screen system.
163 static char GLXServerVendorName
[] = "SGI";
164 static char GLXServerVersion
[] = "1.2";
165 static char GLXServerExtensions
[] =
166 "GLX_ARB_multisample "
167 "GLX_EXT_visual_info "
168 "GLX_EXT_visual_rating "
169 "GLX_EXT_import_context "
170 "GLX_EXT_texture_from_pixmap "
171 "GLX_OML_swap_method "
172 "GLX_SGI_make_current_read "
174 "GLX_SGIS_multisample "
175 "GLX_SGIX_hyperpipe "
176 "GLX_SGIX_swap_barrier "
179 "GLX_MESA_copy_sub_buffer "
182 __GLXscreen
**__glXActiveScreens
;
184 __GLXSwapBarrierExtensionFuncs
*__glXSwapBarrierFuncs
= NULL
;
185 static int __glXNumSwapBarrierFuncs
= 0;
186 __GLXHyperpipeExtensionFuncs
*__glXHyperpipeFuncs
= NULL
;
187 static int __glXNumHyperpipeFuncs
= 0;
189 __GLXscreen
*__glXgetActiveScreen(int num
) {
190 return __glXActiveScreens
[num
];
195 ** This hook gets called when a window moves or changes size.
197 static Bool
PositionWindow(WindowPtr pWin
, int x
, int y
)
201 __GLXdrawable
*glxPriv
;
205 ** Call wrapped position window routine
207 pScreen
= pWin
->drawable
.pScreen
;
208 pScreen
->PositionWindow
=
209 __glXActiveScreens
[pScreen
->myNum
]->WrappedPositionWindow
;
210 ret
= (*pScreen
->PositionWindow
)(pWin
, x
, y
);
211 pScreen
->PositionWindow
= PositionWindow
;
214 ** Tell all contexts rendering into this window that the window size
217 glxPriv
= (__GLXdrawable
*) LookupIDByType(pWin
->drawable
.id
,
219 if (glxPriv
== NULL
) {
221 ** This window is not being used by the OpenGL.
227 ** resize the drawable
229 /* first change the drawable size */
230 if (glxPriv
->resize(glxPriv
) == GL_FALSE
) {
232 /* XXX: what can we possibly do here? */
236 /* mark contexts as needing resize */
238 for (glxc
= glxPriv
->drawGlxc
; glxc
; glxc
= glxc
->nextDrawPriv
) {
239 glxc
->pendingState
|= __GLX_PENDING_RESIZE
;
242 for (glxc
= glxPriv
->readGlxc
; glxc
; glxc
= glxc
->nextReadPriv
) {
243 glxc
->pendingState
|= __GLX_PENDING_RESIZE
;
250 * If your DDX driver wants to register support for swap barriers or hyperpipe
251 * topology, it should call __glXHyperpipeInit() or __glXSwapBarrierInit()
252 * with a dispatch table of functions to handle the requests. In the XFree86
253 * DDX, for example, you would call these near the bottom of the driver's
254 * ScreenInit method, after DRI has been initialized.
256 * This should be replaced with a better method when we teach the server how
257 * to load DRI drivers.
260 void __glXHyperpipeInit(int screen
, __GLXHyperpipeExtensionFuncs
*funcs
)
262 if (__glXNumHyperpipeFuncs
< screen
+ 1) {
263 __glXHyperpipeFuncs
= xrealloc(__glXHyperpipeFuncs
,
264 (screen
+1) * sizeof(__GLXHyperpipeExtensionFuncs
));
265 __glXNumHyperpipeFuncs
= screen
+ 1;
268 __glXHyperpipeFuncs
[screen
].queryHyperpipeNetworkFunc
=
269 *funcs
->queryHyperpipeNetworkFunc
;
270 __glXHyperpipeFuncs
[screen
].queryHyperpipeConfigFunc
=
271 *funcs
->queryHyperpipeConfigFunc
;
272 __glXHyperpipeFuncs
[screen
].destroyHyperpipeConfigFunc
=
273 *funcs
->destroyHyperpipeConfigFunc
;
274 __glXHyperpipeFuncs
[screen
].hyperpipeConfigFunc
=
275 *funcs
->hyperpipeConfigFunc
;
278 void __glXSwapBarrierInit(int screen
, __GLXSwapBarrierExtensionFuncs
*funcs
)
280 if (__glXNumSwapBarrierFuncs
< screen
+ 1) {
281 __glXSwapBarrierFuncs
= xrealloc(__glXSwapBarrierFuncs
,
282 (screen
+1) * sizeof(__GLXSwapBarrierExtensionFuncs
));
283 __glXNumSwapBarrierFuncs
= screen
+ 1;
286 __glXSwapBarrierFuncs
[screen
].bindSwapBarrierFunc
=
287 funcs
->bindSwapBarrierFunc
;
288 __glXSwapBarrierFuncs
[screen
].queryMaxSwapBarriersFunc
=
289 funcs
->queryMaxSwapBarriersFunc
;
292 static __GLXprovider
*__glXProviderStack
;
294 void GlxPushProvider(__GLXprovider
*provider
)
296 provider
->next
= __glXProviderStack
;
297 __glXProviderStack
= provider
;
300 void __glXScreenInit(__GLXscreen
*screen
, ScreenPtr pScreen
)
302 screen
->pScreen
= pScreen
;
303 screen
->GLextensions
= xstrdup(GLServerExtensions
);
304 screen
->GLXvendor
= xstrdup(GLXServerVendorName
);
305 screen
->GLXversion
= xstrdup(GLXServerVersion
);
306 screen
->GLXextensions
= xstrdup(GLXServerExtensions
);
308 screen
->WrappedPositionWindow
= pScreen
->PositionWindow
;
309 pScreen
->PositionWindow
= PositionWindow
;
311 __glXScreenInitVisuals(screen
);
315 __glXScreenDestroy(__GLXscreen
*screen
)
317 xfree(screen
->GLXvendor
);
318 xfree(screen
->GLXversion
);
319 xfree(screen
->GLXextensions
);
320 xfree(screen
->GLextensions
);
323 void __glXInitScreens(void)
331 ** This alloc has to work or else the server might as well core dump.
333 size
= screenInfo
.numScreens
* sizeof(__GLXscreen
*);
334 __glXActiveScreens
= xalloc(size
);
335 memset(__glXActiveScreens
, 0, size
);
337 for (i
= 0; i
< screenInfo
.numScreens
; i
++) {
338 pScreen
= screenInfo
.screens
[i
];
340 for (p
= __glXProviderStack
; p
!= NULL
; p
= p
->next
) {
341 __glXActiveScreens
[i
] = p
->screenProbe(pScreen
);
342 if (__glXActiveScreens
[i
] != NULL
) {
344 "GLX: Initialized %s GL provider for screen %d\n",
352 void __glXResetScreens(void)
356 for (i
= 0; i
< screenInfo
.numScreens
; i
++)
357 if (__glXActiveScreens
[i
])
358 __glXActiveScreens
[i
]->destroy(__glXActiveScreens
[i
]);
360 xfree(__glXActiveScreens
);
361 xfree(__glXHyperpipeFuncs
);
362 xfree(__glXSwapBarrierFuncs
);
363 __glXNumHyperpipeFuncs
= 0;
364 __glXNumSwapBarrierFuncs
= 0;
365 __glXHyperpipeFuncs
= NULL
;
366 __glXSwapBarrierFuncs
= NULL
;
367 __glXActiveScreens
= NULL
;