2 * (C) Copyright IBM Corporation 2002, 2004
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file glxextensions.c
28 * \author Ian Romanick <idr@us.ibm.com>
31 #include "glxclient.h"
32 #include <X11/extensions/extutil.h>
33 #include <X11/extensions/Xext.h>
36 #include "glxextensions.h"
37 #include "simple_list.h"
39 #define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8)))
40 #define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
41 #define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
42 #define CONCAT(a,b) a ## b
43 #define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
44 #define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit
48 #define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
51 struct extension_info
{
52 const char * const name
;
57 /* This is the lowest version of GLX that "requires" this extension.
58 * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
59 * SGI_make_current_read. If the extension is not required by any known
60 * version of GLX, use 0, 0.
62 unsigned char version_major
;
63 unsigned char version_minor
;
64 unsigned char client_support
;
65 unsigned char direct_support
;
66 unsigned char client_only
; /** Is the extension client-side only? */
67 unsigned char direct_only
; /** Is the extension for direct
72 static const struct extension_info known_glx_extensions
[] = {
73 { GLX(ARB_get_proc_address
), VER(1,4), Y
, N
, Y
, N
},
74 { GLX(ARB_multisample
), VER(1,4), Y
, Y
, N
, N
},
75 { GLX(ARB_render_texture
), VER(0,0), N
, N
, N
, N
},
76 { GLX(ATI_pixel_format_float
), VER(0,0), N
, N
, N
, N
},
77 { GLX(EXT_import_context
), VER(0,0), Y
, Y
, N
, N
},
78 { GLX(EXT_visual_info
), VER(0,0), Y
, Y
, N
, N
},
79 { GLX(EXT_visual_rating
), VER(0,0), Y
, Y
, N
, N
},
80 { GLX(MESA_agp_offset
), VER(0,0), N
, N
, N
, Y
}, /* Deprecated */
81 { GLX(MESA_allocate_memory
), VER(0,0), Y
, N
, N
, Y
},
82 { GLX(MESA_copy_sub_buffer
), VER(0,0), Y
, N
, N
, N
},
83 { GLX(MESA_pixmap_colormap
), VER(0,0), N
, N
, N
, N
}, /* Deprecated */
84 { GLX(MESA_release_buffers
), VER(0,0), N
, N
, N
, N
}, /* Deprecated */
85 { GLX(MESA_swap_control
), VER(0,0), Y
, N
, N
, Y
},
86 { GLX(MESA_swap_frame_usage
), VER(0,0), Y
, N
, N
, Y
},
87 { GLX(NV_float_buffer
), VER(0,0), N
, N
, N
, N
},
88 { GLX(NV_render_depth_texture
), VER(0,0), N
, N
, N
, N
},
89 { GLX(NV_render_texture_rectangle
), VER(0,0), N
, N
, N
, N
},
90 { GLX(NV_vertex_array_range
), VER(0,0), N
, N
, N
, Y
}, /* Deprecated */
91 { GLX(OML_swap_method
), VER(0,0), Y
, Y
, N
, N
},
92 { GLX(OML_sync_control
), VER(0,0), Y
, N
, N
, Y
},
93 { GLX(SGI_make_current_read
), VER(1,3), Y
, N
, N
, N
},
94 { GLX(SGI_swap_control
), VER(0,0), Y
, N
, N
, N
},
95 { GLX(SGI_video_sync
), VER(0,0), Y
, N
, N
, Y
},
96 { GLX(SGIS_blended_overlay
), VER(0,0), N
, N
, N
, N
},
97 { GLX(SGIS_color_range
), VER(0,0), N
, N
, N
, N
},
98 { GLX(SGIS_multisample
), VER(0,0), Y
, Y
, N
, N
},
99 { GLX(SGIX_fbconfig
), VER(1,3), Y
, Y
, N
, N
},
100 { GLX(SGIX_pbuffer
), VER(1,3), Y
, N
, N
, N
},
101 { GLX(SGIX_swap_barrier
), VER(0,0), N
, N
, N
, N
},
102 { GLX(SGIX_swap_group
), VER(0,0), N
, N
, N
, N
},
103 { GLX(SGIX_visual_select_group
), VER(0,0), Y
, Y
, N
, N
},
104 { GLX(EXT_texture_from_pixmap
), VER(0,0), Y
, N
, N
, N
},
108 static const struct extension_info known_gl_extensions
[] = {
109 { GL(ARB_depth_texture
), VER(1,4), Y
, N
, N
, N
},
110 { GL(ARB_draw_buffers
), VER(0,0), Y
, N
, N
, N
},
111 { GL(ARB_fragment_program
), VER(0,0), Y
, N
, N
, N
},
112 { GL(ARB_fragment_program_shadow
), VER(0,0), Y
, N
, N
, N
},
113 { GL(ARB_imaging
), VER(0,0), Y
, N
, N
, N
},
114 { GL(ARB_multisample
), VER(1,3), Y
, N
, N
, N
},
115 { GL(ARB_multitexture
), VER(1,3), Y
, N
, N
, N
},
116 { GL(ARB_occlusion_query
), VER(1,5), Y
, N
, N
, N
},
117 { GL(ARB_point_parameters
), VER(1,4), Y
, N
, N
, N
},
118 { GL(ARB_point_sprite
), VER(0,0), Y
, N
, N
, N
},
119 { GL(ARB_shadow
), VER(1,4), Y
, N
, N
, N
},
120 { GL(ARB_shadow_ambient
), VER(0,0), Y
, N
, N
, N
},
121 { GL(ARB_texture_border_clamp
), VER(1,3), Y
, N
, N
, N
},
122 { GL(ARB_texture_compression
), VER(1,3), Y
, N
, N
, N
},
123 { GL(ARB_texture_cube_map
), VER(1,3), Y
, N
, N
, N
},
124 { GL(ARB_texture_env_add
), VER(1,3), Y
, N
, N
, N
},
125 { GL(ARB_texture_env_combine
), VER(1,3), Y
, N
, N
, N
},
126 { GL(ARB_texture_env_crossbar
), VER(1,4), Y
, N
, N
, N
},
127 { GL(ARB_texture_env_dot3
), VER(1,3), Y
, N
, N
, N
},
128 { GL(ARB_texture_mirrored_repeat
), VER(1,4), Y
, N
, N
, N
},
129 { GL(ARB_texture_non_power_of_two
), VER(1,5), Y
, N
, N
, N
},
130 { GL(ARB_texture_rectangle
), VER(0,0), Y
, N
, N
, N
},
131 { GL(ARB_transpose_matrix
), VER(1,3), Y
, N
, Y
, N
},
132 { GL(ARB_vertex_buffer_object
), VER(1,5), N
, N
, N
, N
},
133 { GL(ARB_vertex_program
), VER(0,0), Y
, N
, N
, N
},
134 { GL(ARB_window_pos
), VER(1,4), Y
, N
, N
, N
},
135 { GL(EXT_abgr
), VER(0,0), Y
, N
, N
, N
},
136 { GL(EXT_bgra
), VER(1,2), Y
, N
, N
, N
},
137 { GL(EXT_blend_color
), VER(1,4), Y
, N
, N
, N
},
138 { GL(EXT_blend_equation_separate
), VER(0,0), Y
, N
, N
, N
},
139 { GL(EXT_blend_func_separate
), VER(1,4), Y
, N
, N
, N
},
140 { GL(EXT_blend_logic_op
), VER(1,4), Y
, N
, N
, N
},
141 { GL(EXT_blend_minmax
), VER(1,4), Y
, N
, N
, N
},
142 { GL(EXT_blend_subtract
), VER(1,4), Y
, N
, N
, N
},
143 { GL(EXT_clip_volume_hint
), VER(0,0), Y
, N
, N
, N
},
144 { GL(EXT_compiled_vertex_array
), VER(0,0), N
, N
, N
, N
},
145 { GL(EXT_convolution
), VER(0,0), N
, N
, N
, N
},
146 { GL(EXT_copy_texture
), VER(1,1), Y
, N
, N
, N
},
147 { GL(EXT_cull_vertex
), VER(0,0), N
, N
, N
, N
},
148 { GL(EXT_depth_bounds_test
), VER(0,0), N
, N
, N
, N
},
149 { GL(EXT_draw_range_elements
), VER(1,2), Y
, N
, Y
, N
},
150 { GL(EXT_fog_coord
), VER(1,4), Y
, N
, N
, N
},
151 { GL(EXT_framebuffer_object
), VER(0,0), Y
, N
, N
, N
},
152 { GL(EXT_multi_draw_arrays
), VER(1,4), Y
, N
, Y
, N
},
153 { GL(EXT_packed_pixels
), VER(1,2), Y
, N
, N
, N
},
154 { GL(EXT_paletted_texture
), VER(0,0), Y
, N
, N
, N
},
155 { GL(EXT_pixel_buffer_object
), VER(0,0), N
, N
, N
, N
},
156 { GL(EXT_point_parameters
), VER(1,4), Y
, N
, N
, N
},
157 { GL(EXT_polygon_offset
), VER(1,1), Y
, N
, N
, N
},
158 { GL(EXT_rescale_normal
), VER(1,2), Y
, N
, N
, N
},
159 { GL(EXT_secondary_color
), VER(1,4), Y
, N
, N
, N
},
160 { GL(EXT_separate_specular_color
), VER(1,2), Y
, N
, N
, N
},
161 { GL(EXT_shadow_funcs
), VER(1,5), Y
, N
, N
, N
},
162 { GL(EXT_shared_texture_palette
), VER(0,0), Y
, N
, N
, N
},
163 { GL(EXT_stencil_two_side
), VER(0,0), Y
, N
, N
, N
},
164 { GL(EXT_stencil_wrap
), VER(1,4), Y
, N
, N
, N
},
165 { GL(EXT_subtexture
), VER(1,1), Y
, N
, N
, N
},
166 { GL(EXT_texture
), VER(1,1), Y
, N
, N
, N
},
167 { GL(EXT_texture3D
), VER(1,2), Y
, N
, N
, N
},
168 { GL(EXT_texture_compression_dxt1
), VER(0,0), Y
, N
, N
, N
},
169 { GL(EXT_texture_compression_s3tc
), VER(0,0), Y
, N
, N
, N
},
170 { GL(EXT_texture_edge_clamp
), VER(1,2), Y
, N
, N
, N
},
171 { GL(EXT_texture_env_add
), VER(1,3), Y
, N
, N
, N
},
172 { GL(EXT_texture_env_combine
), VER(1,3), Y
, N
, N
, N
},
173 { GL(EXT_texture_env_dot3
), VER(0,0), Y
, N
, N
, N
},
174 { GL(EXT_texture_filter_anisotropic
), VER(0,0), Y
, N
, N
, N
},
175 { GL(EXT_texture_lod
), VER(1,2), Y
, N
, N
, N
},
176 { GL(EXT_texture_lod_bias
), VER(1,4), Y
, N
, N
, N
},
177 { GL(EXT_texture_mirror_clamp
), VER(0,0), Y
, N
, N
, N
},
178 { GL(EXT_texture_object
), VER(1,1), Y
, N
, N
, N
},
179 { GL(EXT_texture_rectangle
), VER(0,0), Y
, N
, N
, N
},
180 { GL(EXT_vertex_array
), VER(0,0), Y
, N
, N
, N
},
181 { GL(3DFX_texture_compression_FXT1
), VER(0,0), Y
, N
, N
, N
},
182 { GL(APPLE_packed_pixels
), VER(1,2), Y
, N
, N
, N
},
183 { GL(APPLE_ycbcr_422
), VER(0,0), Y
, N
, N
, N
},
184 { GL(ATI_draw_buffers
), VER(0,0), Y
, N
, N
, N
},
185 { GL(ATI_text_fragment_shader
), VER(0,0), Y
, N
, N
, N
},
186 { GL(ATI_texture_env_combine3
), VER(0,0), Y
, N
, N
, N
},
187 { GL(ATI_texture_float
), VER(0,0), Y
, N
, N
, N
},
188 { GL(ATI_texture_mirror_once
), VER(0,0), Y
, N
, N
, N
},
189 { GL(ATIX_texture_env_combine3
), VER(0,0), Y
, N
, N
, N
},
190 { GL(HP_convolution_border_modes
), VER(0,0), Y
, N
, N
, N
},
191 { GL(HP_occlusion_test
), VER(0,0), Y
, N
, N
, N
},
192 { GL(IBM_cull_vertex
), VER(0,0), Y
, N
, N
, N
},
193 { GL(IBM_pixel_filter_hint
), VER(0,0), Y
, N
, N
, N
},
194 { GL(IBM_rasterpos_clip
), VER(0,0), Y
, N
, N
, N
},
195 { GL(IBM_texture_clamp_nodraw
), VER(0,0), Y
, N
, N
, N
},
196 { GL(IBM_texture_mirrored_repeat
), VER(0,0), Y
, N
, N
, N
},
197 { GL(INGR_blend_func_separate
), VER(0,0), Y
, N
, N
, N
},
198 { GL(INGR_interlace_read
), VER(0,0), Y
, N
, N
, N
},
199 { GL(MESA_pack_invert
), VER(0,0), Y
, N
, N
, N
},
200 { GL(MESA_ycbcr_texture
), VER(0,0), Y
, N
, N
, N
},
201 { GL(NV_blend_square
), VER(1,4), Y
, N
, N
, N
},
202 { GL(NV_copy_depth_to_color
), VER(0,0), Y
, N
, N
, N
},
203 { GL(NV_depth_clamp
), VER(0,0), Y
, N
, N
, N
},
204 { GL(NV_fog_distance
), VER(0,0), Y
, N
, N
, N
},
205 { GL(NV_fragment_program
), VER(0,0), Y
, N
, N
, N
},
206 { GL(NV_fragment_program_option
), VER(0,0), Y
, N
, N
, N
},
207 { GL(NV_fragment_program2
), VER(0,0), Y
, N
, N
, N
},
208 { GL(NV_light_max_exponent
), VER(0,0), Y
, N
, N
, N
},
209 { GL(NV_multisample_filter_hint
), VER(0,0), Y
, N
, N
, N
},
210 { GL(NV_point_sprite
), VER(0,0), Y
, N
, N
, N
},
211 { GL(NV_texgen_reflection
), VER(0,0), Y
, N
, N
, N
},
212 { GL(NV_texture_compression_vtc
), VER(0,0), Y
, N
, N
, N
},
213 { GL(NV_texture_env_combine4
), VER(0,0), Y
, N
, N
, N
},
214 { GL(NV_texture_rectangle
), VER(0,0), Y
, N
, N
, N
},
215 { GL(NV_vertex_program
), VER(0,0), Y
, N
, N
, N
},
216 { GL(NV_vertex_program1_1
), VER(0,0), Y
, N
, N
, N
},
217 { GL(NV_vertex_program2
), VER(0,0), Y
, N
, N
, N
},
218 { GL(NV_vertex_program2_option
), VER(0,0), Y
, N
, N
, N
},
219 { GL(NV_vertex_program3
), VER(0,0), Y
, N
, N
, N
},
220 { GL(OES_read_format
), VER(0,0), Y
, N
, N
, N
},
221 { GL(OES_compressed_paletted_texture
),VER(0,0), Y
, N
, N
, N
},
222 { GL(SGI_color_matrix
), VER(0,0), Y
, N
, N
, N
},
223 { GL(SGI_color_table
), VER(0,0), Y
, N
, N
, N
},
224 { GL(SGI_texture_color_table
), VER(0,0), Y
, N
, N
, N
},
225 { GL(SGIS_generate_mipmap
), VER(1,4), Y
, N
, N
, N
},
226 { GL(SGIS_multisample
), VER(0,0), Y
, N
, N
, N
},
227 { GL(SGIS_texture_border_clamp
), VER(1,3), Y
, N
, N
, N
},
228 { GL(SGIS_texture_edge_clamp
), VER(1,2), Y
, N
, N
, N
},
229 { GL(SGIS_texture_lod
), VER(1,2), Y
, N
, N
, N
},
230 { GL(SGIX_blend_alpha_minmax
), VER(0,0), Y
, N
, N
, N
},
231 { GL(SGIX_clipmap
), VER(0,0), Y
, N
, N
, N
},
232 { GL(SGIX_depth_texture
), VER(0,0), Y
, N
, N
, N
},
233 { GL(SGIX_fog_offset
), VER(0,0), Y
, N
, N
, N
},
234 { GL(SGIX_shadow
), VER(0,0), Y
, N
, N
, N
},
235 { GL(SGIX_shadow_ambient
), VER(0,0), Y
, N
, N
, N
},
236 { GL(SGIX_texture_coordinate_clamp
), VER(0,0), Y
, N
, N
, N
},
237 { GL(SGIX_texture_lod_bias
), VER(0,0), Y
, N
, N
, N
},
238 { GL(SGIX_texture_range
), VER(0,0), Y
, N
, N
, N
},
239 { GL(SGIX_texture_scale_bias
), VER(0,0), Y
, N
, N
, N
},
240 { GL(SGIX_vertex_preclip
), VER(0,0), Y
, N
, N
, N
},
241 { GL(SGIX_vertex_preclip_hint
), VER(0,0), Y
, N
, N
, N
},
242 { GL(SGIX_ycrcb
), VER(0,0), Y
, N
, N
, N
},
243 { GL(SUN_convolution_border_modes
), VER(0,0), Y
, N
, N
, N
},
244 { GL(SUN_multi_draw_arrays
), VER(0,0), Y
, N
, Y
, N
},
245 { GL(SUN_slice_accum
), VER(0,0), Y
, N
, N
, N
},
250 /* global bit-fields of available extensions and their characteristics */
251 static unsigned char client_glx_support
[8];
252 static unsigned char client_glx_only
[8];
253 static unsigned char direct_glx_only
[8];
254 static unsigned char client_gl_support
[ __GL_EXT_BYTES
];
255 static unsigned char client_gl_only
[ __GL_EXT_BYTES
];
258 * Bits representing the set of extensions that are enabled by default in all
259 * direct rendering drivers.
261 static unsigned char direct_glx_support
[8];
264 * Highest core GL version that can be supported for indirect rendering.
266 static const unsigned gl_major
= 1;
267 static const unsigned gl_minor
= 4;
269 /* client extensions string */
270 static const char * __glXGLXClientExtensions
= NULL
;
272 static void __glXExtensionsCtr( void );
273 static void __glXExtensionsCtrScreen( __GLXscreenConfigs
*psc
);
274 static void __glXProcessServerString( const struct extension_info
* ext
,
275 const char * server_string
, unsigned char * server_support
);
278 * Set the state of a GLX extension.
280 * \param name Name of the extension.
281 * \param name_len Length, in characters, of the extension name.
282 * \param state New state (either enabled or disabled) of the extension.
283 * \param supported Table in which the state of the extension is to be set.
286 set_glx_extension( const struct extension_info
* ext
,
287 const char * name
, unsigned name_len
, GLboolean state
,
288 unsigned char * supported
)
293 for ( i
= 0 ; ext
[i
].name
!= NULL
; i
++ ) {
294 if ( (name_len
== ext
[i
].name_len
)
295 && (strncmp( ext
[i
].name
, name
, name_len
) == 0) ) {
297 SET_BIT( supported
, ext
[i
].bit
);
300 CLR_BIT( supported
, ext
[i
].bit
);
310 #define SEPARATOR ' '
313 * Convert the server's extension string to a bit-field.
315 * \param server_string GLX extension string from the server.
316 * \param server_support Bit-field of supported extensions.
319 * This function is used to process both GLX and GL extension strings. The
320 * bit-fields used to track each of these have different sizes. Therefore,
321 * the data pointed by \c server_support must be preinitialized to zero.
324 __glXProcessServerString( const struct extension_info
* ext
,
325 const char * server_string
,
326 unsigned char * server_support
)
331 for ( base
= 0 ; server_string
[ base
] != NUL
; /* empty */ ) {
332 /* Determine the length of the next extension name.
335 ; (server_string
[ base
+ len
] != SEPARATOR
)
336 && (server_string
[ base
+ len
] != NUL
)
341 /* Set the bit for the extension in the server_support table.
343 set_glx_extension( ext
, & server_string
[ base
], len
, GL_TRUE
,
347 /* Advance to the next extension string. This means that we skip
348 * over the previous string and any trialing white-space.
351 (server_string
[ base
] == SEPARATOR
)
352 && (server_string
[ base
] != NUL
)
359 #ifdef GLX_DIRECT_RENDERING
362 __glXScrEnableDRIExtension(__GLXscreenConfigs
*psc
)
364 const __DRIextension
**extensions
;
367 __glXExtensionsCtr();
368 __glXExtensionsCtrScreen(psc
);
370 extensions
= psc
->driScreen
.getExtensions(&psc
->driScreen
);
371 for (i
= 0; extensions
[i
]; i
++) {
372 #ifdef __DRI_COPY_SUB_BUFFER
373 if (strcmp(extensions
[i
]->name
, __DRI_COPY_SUB_BUFFER
) == 0) {
374 psc
->copySubBuffer
= (__DRIcopySubBufferExtension
*) extensions
[i
];
375 SET_BIT(psc
->direct_support
, MESA_copy_sub_buffer_bit
);
379 #ifdef __DRI_SWAP_CONTROL
380 if (strcmp(extensions
[i
]->name
, __DRI_SWAP_CONTROL
) == 0) {
381 psc
->swapControl
= (__DRIswapControlExtension
*) extensions
[i
];
382 SET_BIT(psc
->direct_support
, SGI_swap_control_bit
);
383 SET_BIT(psc
->direct_support
, MESA_swap_control_bit
);
387 #ifdef __DRI_ALLOCATE
388 if (strcmp(extensions
[i
]->name
, __DRI_ALLOCATE
) == 0) {
389 psc
->allocate
= (__DRIallocateExtension
*) extensions
[i
];
390 SET_BIT(psc
->direct_support
, MESA_allocate_memory_bit
);
394 #ifdef __DRI_FRAME_TRACKING
395 if (strcmp(extensions
[i
]->name
, __DRI_FRAME_TRACKING
) == 0) {
396 psc
->frameTracking
= (__DRIframeTrackingExtension
*) extensions
[i
];
397 SET_BIT(psc
->direct_support
, MESA_swap_frame_usage_bit
);
401 #ifdef __DRI_MEDIA_STREAM_COUNTER
402 if (strcmp(extensions
[i
]->name
, __DRI_MEDIA_STREAM_COUNTER
) == 0) {
403 psc
->msc
= (__DRImediaStreamCounterExtension
*) extensions
[i
];
404 SET_BIT(psc
->direct_support
, SGI_video_sync_bit
);
408 #ifdef __DRI_SWAP_BUFFER_COUNTER
409 /* No driver supports this at this time and the extension is
410 * not defined in dri_interface.h. Will enable
411 * GLX_OML_sync_control if implemented. */
414 #ifdef __DRI_READ_DRAWABLE
415 if (strcmp(extensions
[i
]->name
, __DRI_READ_DRAWABLE
) == 0) {
416 SET_BIT(psc
->direct_support
, SGI_make_current_read_bit
);
419 /* Ignore unknown extensions */
426 * Initialize global extension support tables.
430 __glXExtensionsCtr( void )
433 static GLboolean ext_list_first_time
= GL_TRUE
;
436 if ( ext_list_first_time
) {
437 ext_list_first_time
= GL_FALSE
;
439 (void) memset( client_glx_support
, 0, sizeof( client_glx_support
) );
440 (void) memset( direct_glx_support
, 0, sizeof( direct_glx_support
) );
441 (void) memset( client_glx_only
, 0, sizeof( client_glx_only
) );
442 (void) memset( direct_glx_only
, 0, sizeof( direct_glx_only
) );
444 (void) memset( client_gl_support
, 0, sizeof( client_gl_support
) );
445 (void) memset( client_gl_only
, 0, sizeof( client_gl_only
) );
447 for ( i
= 0 ; known_glx_extensions
[i
].name
!= NULL
; i
++ ) {
448 const unsigned bit
= known_glx_extensions
[i
].bit
;
450 if ( known_glx_extensions
[i
].client_support
) {
451 SET_BIT( client_glx_support
, bit
);
454 if ( known_glx_extensions
[i
].direct_support
) {
455 SET_BIT( direct_glx_support
, bit
);
458 if ( known_glx_extensions
[i
].client_only
) {
459 SET_BIT( client_glx_only
, bit
);
462 if ( known_glx_extensions
[i
].direct_only
) {
463 SET_BIT( direct_glx_only
, bit
);
467 for ( i
= 0 ; known_gl_extensions
[i
].name
!= NULL
; i
++ ) {
468 const unsigned bit
= known_gl_extensions
[i
].bit
;
470 if ( known_gl_extensions
[i
].client_support
) {
471 SET_BIT( client_gl_support
, bit
);
474 if ( known_gl_extensions
[i
].client_only
) {
475 SET_BIT( client_gl_only
, bit
);
480 fprintf( stderr
, "[%s:%u] Maximum client library version: %u.%u\n",
481 __func__
, __LINE__
, gl_major
, gl_minor
);
488 * Make sure that per-screen direct-support table is initialized.
490 * \param psc Pointer to GLX per-screen record.
494 __glXExtensionsCtrScreen( __GLXscreenConfigs
*psc
)
496 if (psc
->ext_list_first_time
) {
497 psc
->ext_list_first_time
= GL_FALSE
;
498 (void) memcpy( psc
->direct_support
, direct_glx_support
,
499 sizeof( direct_glx_support
) );
505 * Check if a certain extension is enabled on a given screen.
507 * \param psc Pointer to GLX per-screen record.
508 * \param bit Bit index in the direct-support table.
509 * \returns If the extension bit is enabled for the screen, \c GL_TRUE is
510 * returned. If the extension bit is not enabled or if \c psc is
511 * \c NULL, then \c GL_FALSE is returned.
514 __glXExtensionBitIsEnabled( __GLXscreenConfigs
*psc
, unsigned bit
)
516 GLboolean enabled
= GL_FALSE
;
519 __glXExtensionsCtr();
520 __glXExtensionsCtrScreen( psc
);
521 enabled
= EXT_ENABLED( bit
, psc
->direct_support
);
529 * Check if a certain extension is enabled in a given context.
533 __glExtensionBitIsEnabled( const __GLXcontext
* gc
, unsigned bit
)
535 GLboolean enabled
= GL_FALSE
;
538 enabled
= EXT_ENABLED( bit
, gc
->gl_extension_bits
);
547 * Convert a bit-field to a string of supported extensions.
550 __glXGetStringFromTable( const struct extension_info
* ext
,
551 const unsigned char * supported
)
554 unsigned ext_str_len
;
560 for ( i
= 0 ; ext
[i
].name
!= NULL
; i
++ ) {
561 if ( EXT_ENABLED( ext
[i
].bit
, supported
) ) {
562 ext_str_len
+= ext
[i
].name_len
+ 1;
566 ext_str
= Xmalloc( ext_str_len
+ 1 );
567 if ( ext_str
!= NULL
) {
570 for ( i
= 0 ; ext
[i
].name
!= NULL
; i
++ ) {
571 if ( EXT_ENABLED( ext
[i
].bit
, supported
) ) {
572 (void) memcpy( point
, ext
[i
].name
, ext
[i
].name_len
);
573 point
+= ext
[i
].name_len
;
588 * Get the string of client library supported extensions.
591 __glXGetClientExtensions( void )
593 if ( __glXGLXClientExtensions
== NULL
) {
594 __glXExtensionsCtr();
595 __glXGLXClientExtensions
= __glXGetStringFromTable( known_glx_extensions
,
596 client_glx_support
);
599 return __glXGLXClientExtensions
;
604 * Calculate the list of application usable extensions. The resulting
605 * string is stored in \c psc->effectiveGLXexts.
607 * \param psc Pointer to GLX per-screen record.
608 * \param display_is_direct_capable True if the display is capable of
610 * \param minor_version GLX minor version from the server.
614 __glXCalculateUsableExtensions( __GLXscreenConfigs
*psc
,
615 GLboolean display_is_direct_capable
,
618 unsigned char server_support
[8];
619 unsigned char usable
[8];
622 __glXExtensionsCtr();
623 __glXExtensionsCtrScreen( psc
);
625 (void) memset( server_support
, 0, sizeof( server_support
) );
626 __glXProcessServerString( known_glx_extensions
,
627 psc
->serverGLXexts
, server_support
);
630 /* This is a hack. Some servers support GLX 1.3 but don't export
631 * all of the extensions implied by GLX 1.3. If the server claims
632 * support for GLX 1.3, enable support for the extensions that can be
633 * "emulated" as well.
636 if ( minor_version
>= 3 ) {
637 SET_BIT( server_support
, EXT_visual_info_bit
);
638 SET_BIT( server_support
, EXT_visual_rating_bit
);
639 SET_BIT( server_support
, SGI_make_current_read_bit
);
640 SET_BIT( server_support
, SGIX_fbconfig_bit
);
641 SET_BIT( server_support
, SGIX_pbuffer_bit
);
643 /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this
644 * extension. However, the only part that is not strictly client-side
645 * is shared. That's the glXQueryContext / glXQueryContextInfoEXT
649 SET_BIT( server_support
, EXT_import_context_bit
);
653 /* An extension is supported if the client-side (i.e., libGL) supports
654 * it and the "server" supports it. In this case that means that either
655 * the true server supports it or it is only for direct-rendering and
656 * the direct rendering driver supports it.
658 * If the display is not capable of direct rendering, then the extension
659 * is enabled if and only if the client-side library and the server
663 if ( display_is_direct_capable
) {
664 for ( i
= 0 ; i
< 8 ; i
++ ) {
665 usable
[i
] = (client_glx_support
[i
] & client_glx_only
[i
])
666 | (client_glx_support
[i
] & psc
->direct_support
[i
] & server_support
[i
])
667 | (client_glx_support
[i
] & psc
->direct_support
[i
] & direct_glx_only
[i
]);
671 for ( i
= 0 ; i
< 8 ; i
++ ) {
672 usable
[i
] = (client_glx_support
[i
] & client_glx_only
[i
])
673 | (client_glx_support
[i
] & server_support
[i
]);
677 psc
->effectiveGLXexts
= __glXGetStringFromTable( known_glx_extensions
,
683 * Calculate the list of application usable extensions. The resulting
684 * string is stored in \c gc->extensions.
686 * \param gc Pointer to GLX context.
687 * \param server_string Extension string from the server.
688 * \param major_version GL major version from the server.
689 * \param minor_version GL minor version from the server.
693 __glXCalculateUsableGLExtensions( __GLXcontext
* gc
,
694 const char * server_string
,
695 int major_version
, int minor_version
)
697 unsigned char server_support
[ __GL_EXT_BYTES
];
698 unsigned char usable
[ __GL_EXT_BYTES
];
702 __glXExtensionsCtr();
704 (void) memset( server_support
, 0, sizeof( server_support
) );
705 __glXProcessServerString( known_gl_extensions
, server_string
,
709 /* Handle lazy servers that don't export all the extensions strings that
710 * are part of the GL core version that they support.
713 for ( i
= 0 ; i
< __GL_EXT_BYTES
; i
++ ) {
714 if ( (known_gl_extensions
[i
].version_major
!= 0)
715 && ((major_version
> known_gl_extensions
[i
].version_major
)
716 || ((major_version
== known_gl_extensions
[i
].version_major
)
717 && (minor_version
>= known_gl_extensions
[i
].version_minor
))) ) {
718 SET_BIT( server_support
, known_gl_extensions
[i
].bit
);
723 /* An extension is supported if the client-side (i.e., libGL) supports
724 * it and the server supports it or the client-side library supports it
725 * and it only needs client-side support.
728 for ( i
= 0 ; i
< __GL_EXT_BYTES
; i
++ ) {
729 usable
[i
] = (client_gl_support
[i
] & client_gl_only
[i
])
730 | (client_gl_support
[i
] & server_support
[i
]);
733 gc
->extensions
= (unsigned char *)
734 __glXGetStringFromTable( known_gl_extensions
, usable
);
735 (void) memcpy( gc
->gl_extension_bits
, usable
, sizeof( usable
) );
740 * Calculates the maximum core GL version that can be supported for indirect
744 __glXGetGLVersion( int * major_version
, int * minor_version
)
746 __glXExtensionsCtr();
747 *major_version
= gl_major
;
748 *minor_version
= gl_minor
;
753 * Get a string representing the set of extensions supported by the client
754 * library. This is currently only used to send the list of extensions
755 * supported by the client to the server.
758 __glXGetClientGLExtensionString( void )
760 __glXExtensionsCtr();
761 return __glXGetStringFromTable( known_gl_extensions
, client_gl_support
);