Merge branch 'gallium_draw_llvm'
[mesa.git] / src / mesa / main / extensions.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.6
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #include "glheader.h"
28 #include "imports.h"
29 #include "context.h"
30 #include "extensions.h"
31 #include "simple_list.h"
32 #include "mtypes.h"
33
34
35 #define F(x) offsetof(struct gl_extensions, x)
36 #define ON GL_TRUE
37 #define OFF GL_FALSE
38
39
40 /*
41 * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
42 */
43 static const struct {
44 GLboolean enabled;
45 const char *name;
46 int flag_offset;
47 } default_extensions[] = {
48 { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) },
49 { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
50 { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) },
51 { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
52 { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) },
53 { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) },
54 { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) },
55 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
56 { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) },
57 { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
58 { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) },
59 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
60 { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) },
61 { OFF, "GL_ARB_imaging", F(ARB_imaging) },
62 { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) },
63 { ON, "GL_ARB_multisample", F(ARB_multisample) },
64 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
65 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
66 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
67 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
68 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
69 { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) },
70 { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) },
71 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
72 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
73 { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) },
74 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
75 { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) },
76 { OFF, "GL_ARB_sync", F(ARB_sync) },
77 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
78 { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) },
79 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
80 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
81 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
82 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
83 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
84 { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
85 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
86 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
87 { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
88 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
89 { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) },
90 { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) },
91 { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
92 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
93 { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
94 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
95 { ON, "GL_EXT_abgr", F(EXT_abgr) },
96 { ON, "GL_EXT_bgra", F(EXT_bgra) },
97 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
98 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
99 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
100 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
101 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
102 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
103 { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
104 { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
105 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
106 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
107 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
108 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
109 { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) },
110 { OFF, "GL_EXT_draw_instanced", F(ARB_draw_instanced) },
111 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
112 { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) },
113 { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) },
114 { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
115 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
116 { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) },
117 { OFF, "GL_EXT_histogram", F(EXT_histogram) },
118 { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
119 { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
120 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
121 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
122 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
123 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
124 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
125 { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) },
126 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
127 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
128 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
129 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
130 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
131 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
132 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
133 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
134 { ON, "GL_EXT_texture", F(EXT_texture) },
135 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
136 { OFF, "GL_EXT_texture_array", F(EXT_texture_array) },
137 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
138 { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) },
139 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
140 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
141 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
142 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
143 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
144 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
145 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
146 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
147 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
148 { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
149 { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
150 { OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
151 { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) },
152 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
153 { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
154 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
155 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
156 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
157 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
158 { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
159 { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) },
160 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
161 { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) },
162 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
163 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
164 { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
165 { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
166 { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
167 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
168 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
169 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
170 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
171 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
172 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
173 { OFF, "GL_MESA_texture_array", F(MESA_texture_array) },
174 { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) },
175 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
176 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
177 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
178 { OFF, "GL_NV_conditional_render", F(NV_conditional_render) },
179 { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) },
180 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
181 { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) },
182 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
183 { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) },
184 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
185 { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) },
186 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
187 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
188 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
189 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
190 { ON, "GL_OES_read_format", F(OES_read_format) },
191 { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
192 { OFF, "GL_SGI_color_table", F(SGI_color_table) },
193 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
194 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
195 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
196 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
197 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
198 { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
199 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
200 #if FEATURE_OES_EGL_image
201 { OFF, "GL_OES_EGL_image", F(OES_EGL_image) },
202 #endif
203 #if FEATURE_OES_draw_texture
204 { OFF, "GL_OES_draw_texture", F(OES_draw_texture) },
205 #endif /* FEATURE_OES_draw_texture */
206 };
207
208
209
210 /**
211 * Enable all extensions suitable for a software-only renderer.
212 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
213 */
214 void
215 _mesa_enable_sw_extensions(GLcontext *ctx)
216 {
217 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
218 ctx->Extensions.ARB_depth_clamp = GL_TRUE;
219 ctx->Extensions.ARB_depth_texture = GL_TRUE;
220 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
221 ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
222 ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
223 #if FEATURE_ARB_fragment_program
224 ctx->Extensions.ARB_fragment_program = GL_TRUE;
225 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
226 #endif
227 #if FEATURE_ARB_fragment_shader
228 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
229 #endif
230 #if FEATURE_ARB_framebuffer_object
231 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
232 #endif
233 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
234 ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
235 ctx->Extensions.ARB_imaging = GL_TRUE;
236 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
237 ctx->Extensions.ARB_multitexture = GL_TRUE;
238 #if FEATURE_queryobj
239 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
240 #endif
241 ctx->Extensions.ARB_point_sprite = GL_TRUE;
242 #if FEATURE_ARB_shader_objects
243 ctx->Extensions.ARB_shader_objects = GL_TRUE;
244 #endif
245 #if FEATURE_ARB_shading_language_100
246 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
247 #endif
248 #if FEATURE_ARB_shading_language_120
249 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
250 #endif
251 ctx->Extensions.ARB_shadow = GL_TRUE;
252 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
253 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
254 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
255 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
256 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
257 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
258 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
259 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
260 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
261 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
262 #if FEATURE_ARB_vertex_program
263 ctx->Extensions.ARB_vertex_program = GL_TRUE;
264 #endif
265 #if FEATURE_ARB_vertex_shader
266 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
267 #endif
268 #if FEATURE_ARB_vertex_buffer_object
269 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
270 #endif
271 #if FEATURE_ARB_sync
272 ctx->Extensions.ARB_sync = GL_TRUE;
273 #endif
274 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
275 #if FEATURE_APPLE_object_purgeable
276 ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
277 #endif
278 ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
279 #if FEATURE_ATI_fragment_shader
280 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
281 #endif
282 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
283 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
284 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
285 ctx->Extensions.EXT_blend_color = GL_TRUE;
286 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
287 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
288 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
289 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
290 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
291 ctx->Extensions.EXT_convolution = GL_TRUE;
292 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
293 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
294 ctx->Extensions.EXT_fog_coord = GL_TRUE;
295 #if FEATURE_EXT_framebuffer_object
296 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
297 #endif
298 #if FEATURE_EXT_framebuffer_blit
299 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
300 #endif
301 #if FEATURE_ARB_framebuffer_object
302 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
303 #endif
304 ctx->Extensions.EXT_histogram = GL_TRUE;
305 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
306 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
307 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
308 #if FEATURE_EXT_pixel_buffer_object
309 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
310 #endif
311 ctx->Extensions.EXT_point_parameters = GL_TRUE;
312 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
313 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
314 ctx->Extensions.EXT_secondary_color = GL_TRUE;
315 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
316 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
317 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
318 ctx->Extensions.EXT_texture_array = GL_TRUE;
319 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
320 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
321 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
322 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
323 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
324 #if FEATURE_EXT_texture_sRGB
325 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
326 #endif
327 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
328 #if FEATURE_EXT_transform_feedback
329 /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
330 #endif
331 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
332 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
333 ctx->Extensions.MESA_pack_invert = GL_TRUE;
334 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
335 ctx->Extensions.MESA_texture_array = GL_TRUE;
336 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
337 ctx->Extensions.NV_blend_square = GL_TRUE;
338 ctx->Extensions.NV_conditional_render = GL_TRUE;
339 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
340 ctx->Extensions.NV_point_sprite = GL_TRUE;
341 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
342 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
343 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
344 #if FEATURE_NV_vertex_program
345 ctx->Extensions.NV_vertex_program = GL_TRUE;
346 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
347 #endif
348 #if FEATURE_NV_fragment_program
349 ctx->Extensions.NV_fragment_program = GL_TRUE;
350 #endif
351 #if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
352 ctx->Extensions.NV_fragment_program_option = GL_TRUE;
353 #endif
354 ctx->Extensions.SGI_color_matrix = GL_TRUE;
355 ctx->Extensions.SGI_color_table = GL_TRUE;
356 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
357 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
358 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
359 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
360 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
361 #endif
362 #if FEATURE_texture_fxt1
363 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
364 #endif
365 #if FEATURE_texture_s3tc
366 if (ctx->Mesa_DXTn) {
367 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
368 _mesa_enable_extension(ctx, "GL_S3_s3tc");
369 }
370 #endif
371 }
372
373
374 /**
375 * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
376 */
377 void
378 _mesa_enable_imaging_extensions(GLcontext *ctx)
379 {
380 ctx->Extensions.ARB_imaging = GL_TRUE;
381 ctx->Extensions.EXT_blend_color = GL_TRUE;
382 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
383 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
384 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
385 ctx->Extensions.EXT_convolution = GL_TRUE;
386 ctx->Extensions.EXT_histogram = GL_TRUE;
387 ctx->Extensions.SGI_color_matrix = GL_TRUE;
388 ctx->Extensions.SGI_color_table = GL_TRUE;
389 }
390
391
392
393 /**
394 * Enable all OpenGL 1.3 features and extensions.
395 * A convenience function to be called by drivers.
396 */
397 void
398 _mesa_enable_1_3_extensions(GLcontext *ctx)
399 {
400 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
401 ctx->Extensions.ARB_multitexture = GL_TRUE;
402 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
403 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
404 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
405 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
406 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
407 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
408 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
409 }
410
411
412
413 /**
414 * Enable all OpenGL 1.4 features and extensions.
415 * A convenience function to be called by drivers.
416 */
417 void
418 _mesa_enable_1_4_extensions(GLcontext *ctx)
419 {
420 ctx->Extensions.ARB_depth_texture = GL_TRUE;
421 ctx->Extensions.ARB_shadow = GL_TRUE;
422 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
423 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
424 ctx->Extensions.ARB_window_pos = GL_TRUE;
425 ctx->Extensions.EXT_blend_color = GL_TRUE;
426 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
427 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
428 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
429 ctx->Extensions.EXT_fog_coord = GL_TRUE;
430 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
431 ctx->Extensions.EXT_point_parameters = GL_TRUE;
432 ctx->Extensions.EXT_secondary_color = GL_TRUE;
433 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
434 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
435 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
436 }
437
438
439 /**
440 * Enable all OpenGL 1.5 features and extensions.
441 * A convenience function to be called by drivers.
442 */
443 void
444 _mesa_enable_1_5_extensions(GLcontext *ctx)
445 {
446 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
447 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
448 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
449 }
450
451
452 /**
453 * Enable all OpenGL 2.0 features and extensions.
454 * A convenience function to be called by drivers.
455 */
456 void
457 _mesa_enable_2_0_extensions(GLcontext *ctx)
458 {
459 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
460 #if FEATURE_ARB_fragment_shader
461 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
462 #endif
463 ctx->Extensions.ARB_point_sprite = GL_TRUE;
464 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
465 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
466 #if FEATURE_ARB_shader_objects
467 ctx->Extensions.ARB_shader_objects = GL_TRUE;
468 #endif
469 #if FEATURE_ARB_shading_language_100
470 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
471 #endif
472 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
473 #if FEATURE_ARB_vertex_shader
474 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
475 #endif
476 }
477
478
479 /**
480 * Enable all OpenGL 2.1 features and extensions.
481 * A convenience function to be called by drivers.
482 */
483 void
484 _mesa_enable_2_1_extensions(GLcontext *ctx)
485 {
486 #if FEATURE_EXT_pixel_buffer_object
487 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
488 #endif
489 #if FEATURE_EXT_texture_sRGB
490 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
491 #endif
492 #if FEATURE_ARB_shading_language_120
493 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
494 #endif
495 }
496
497
498
499 /**
500 * Either enable or disable the named extension.
501 * \return GL_TRUE for success, GL_FALSE if invalid extension name
502 */
503 static GLboolean
504 set_extension( GLcontext *ctx, const char *name, GLboolean state )
505 {
506 GLboolean *base = (GLboolean *) &ctx->Extensions;
507 GLuint i;
508
509 if (ctx->Extensions.String) {
510 /* The string was already queried - can't change it now! */
511 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
512 return GL_FALSE;
513 }
514
515 for (i = 0 ; i < Elements(default_extensions) ; i++) {
516 if (strcmp(default_extensions[i].name, name) == 0) {
517 if (default_extensions[i].flag_offset) {
518 GLboolean *enabled = base + default_extensions[i].flag_offset;
519 *enabled = state;
520 }
521 return GL_TRUE;
522 }
523 }
524 return GL_FALSE;
525 }
526
527
528 /**
529 * Enable the named extension.
530 * Typically called by drivers.
531 */
532 void
533 _mesa_enable_extension( GLcontext *ctx, const char *name )
534 {
535 if (!set_extension(ctx, name, GL_TRUE))
536 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
537 }
538
539
540 /**
541 * Disable the named extension.
542 * XXX is this really needed???
543 */
544 void
545 _mesa_disable_extension( GLcontext *ctx, const char *name )
546 {
547 if (!set_extension(ctx, name, GL_FALSE))
548 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
549 }
550
551
552 /**
553 * Check if the i-th extension is enabled.
554 */
555 static GLboolean
556 extension_enabled(GLcontext *ctx, GLuint index)
557 {
558 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
559 if (!default_extensions[index].flag_offset ||
560 *(base + default_extensions[index].flag_offset)) {
561 return GL_TRUE;
562 }
563 else {
564 return GL_FALSE;
565 }
566 }
567
568
569 /**
570 * Test if the named extension is enabled in this context.
571 */
572 GLboolean
573 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
574 {
575 GLuint i;
576
577 for (i = 0 ; i < Elements(default_extensions) ; i++) {
578 if (strcmp(default_extensions[i].name, name) == 0) {
579 return extension_enabled(ctx, i);
580 }
581 }
582 return GL_FALSE;
583 }
584
585
586 /**
587 * Append string 'b' onto string 'a'. Free 'a' and return new string.
588 */
589 static char *
590 append(const char *a, const char *b)
591 {
592 const GLuint aLen = a ? strlen(a) : 0;
593 const GLuint bLen = b ? strlen(b) : 0;
594 char *s = calloc(1, aLen + bLen + 1);
595 if (s) {
596 if (a)
597 memcpy(s, a, aLen);
598 if (b)
599 memcpy(s + aLen, b, bLen);
600 s[aLen + bLen] = '\0';
601 }
602 if (a)
603 free((void *) a);
604 return s;
605 }
606
607
608 /**
609 * Check the MESA_EXTENSION_OVERRIDE env var.
610 * For extension names that are recognized, turn them on. For extension
611 * names that are recognized and prefixed with '-', turn them off.
612 * Return a string of the unknown/leftover names.
613 */
614 static const char *
615 get_extension_override( GLcontext *ctx )
616 {
617 const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
618 char *extraExt = NULL;
619 char ext[1000];
620 GLuint extLen = 0;
621 GLuint i;
622 GLboolean disableExt = GL_FALSE;
623
624 if (!envExt)
625 return NULL;
626
627 for (i = 0; ; i++) {
628 if (envExt[i] == '\0' || envExt[i] == ' ') {
629 /* terminate/process 'ext' if extLen > 0 */
630 if (extLen > 0) {
631 assert(extLen < sizeof(ext));
632 /* enable extension named by 'ext' */
633 ext[extLen] = 0;
634 if (!set_extension(ctx, ext, !disableExt)) {
635 /* unknown extension name, append it to extraExt */
636 if (extraExt) {
637 extraExt = append(extraExt, " ");
638 }
639 extraExt = append(extraExt, ext);
640 }
641 extLen = 0;
642 disableExt = GL_FALSE;
643 }
644 if (envExt[i] == '\0')
645 break;
646 }
647 else if (envExt[i] == '-') {
648 disableExt = GL_TRUE;
649 }
650 else {
651 /* accumulate this non-space character */
652 ext[extLen++] = envExt[i];
653 }
654 }
655
656 return extraExt;
657 }
658
659
660 /**
661 * Run through the default_extensions array above and set the
662 * ctx->Extensions.ARB/EXT_* flags accordingly.
663 * To be called during context initialization.
664 */
665 void
666 _mesa_init_extensions( GLcontext *ctx )
667 {
668 GLboolean *base = (GLboolean *) &ctx->Extensions;
669 GLuint i;
670
671 for (i = 0 ; i < Elements(default_extensions) ; i++) {
672 if (default_extensions[i].enabled &&
673 default_extensions[i].flag_offset) {
674 *(base + default_extensions[i].flag_offset) = GL_TRUE;
675 }
676 }
677 }
678
679
680 /**
681 * Construct the GL_EXTENSIONS string. Called the first time that
682 * glGetString(GL_EXTENSIONS) is called.
683 */
684 GLubyte *
685 _mesa_make_extension_string( GLcontext *ctx )
686 {
687 const char *extraExt = get_extension_override(ctx);
688 GLuint extStrLen = 0;
689 char *s;
690 GLuint i;
691
692 /* first, compute length of the extension string */
693 for (i = 0 ; i < Elements(default_extensions) ; i++) {
694 if (extension_enabled(ctx, i)) {
695 extStrLen += (GLuint) strlen(default_extensions[i].name) + 1;
696 }
697 }
698
699 if (extraExt)
700 extStrLen += strlen(extraExt) + 1; /* +1 for space */
701
702 /* allocate the extension string */
703 s = (char *) malloc(extStrLen);
704 if (!s)
705 return NULL;
706
707 /* second, build the extension string */
708 extStrLen = 0;
709 for (i = 0 ; i < Elements(default_extensions) ; i++) {
710 if (extension_enabled(ctx, i)) {
711 GLuint len = (GLuint) strlen(default_extensions[i].name);
712 memcpy(s + extStrLen, default_extensions[i].name, len);
713 extStrLen += len;
714 s[extStrLen] = ' ';
715 extStrLen++;
716 }
717 }
718 ASSERT(extStrLen > 0);
719
720 s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
721
722 if (extraExt) {
723 s = append(s, " ");
724 s = append(s, extraExt);
725 }
726
727 return (GLubyte *) s;
728 }
729
730
731 /**
732 * Return number of enabled extensions.
733 */
734 GLuint
735 _mesa_get_extension_count(GLcontext *ctx)
736 {
737 GLuint i;
738
739 /* only count once */
740 if (!ctx->Extensions.Count) {
741 for (i = 0; i < Elements(default_extensions); i++) {
742 if (extension_enabled(ctx, i)) {
743 ctx->Extensions.Count++;
744 }
745 }
746 }
747
748 if (0)
749 _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
750 Elements(default_extensions));
751
752 return ctx->Extensions.Count;
753 }
754
755
756 /**
757 * Return name of i-th enabled extension
758 */
759 const GLubyte *
760 _mesa_get_enabled_extension(GLcontext *ctx, GLuint index)
761 {
762 GLuint i;
763
764 for (i = 0; i < Elements(default_extensions); i++) {
765 if (extension_enabled(ctx, i)) {
766 if (index == 0)
767 return (const GLubyte *) default_extensions[i].name;
768 index--;
769 }
770 }
771
772 return NULL;
773 }