mesa: Remove SGI_color_matrix.
[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 "mtypes.h"
32
33
34 #define F(x) offsetof(struct gl_extensions, x)
35 #define ON GL_TRUE
36 #define OFF GL_FALSE
37
38
39 /*
40 * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
41 */
42 static const struct {
43 GLboolean enabled;
44 const char *name;
45 int flag_offset;
46 } default_extensions[] = {
47 { OFF, "GL_ARB_blend_func_extended", F(ARB_blend_func_extended) },
48 { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) },
49 { OFF, "GL_ARB_depth_buffer_float", F(ARB_depth_buffer_float) },
50 { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) },
51 { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
52 { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
53 { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) },
54 { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) },
55 { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) },
56 { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
57 { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) },
58 { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
59 { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) },
60 { OFF, "GL_ARB_explicit_attrib_location", F(ARB_explicit_attrib_location) },
61 /* TODO: reenable this when the new GLSL compiler actually supports them */
62 /* { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, */
63 { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) },
64 { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) },
65 { OFF, "GL_ARB_instanced_arrays", F(ARB_instanced_arrays) },
66 { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) },
67 { ON, "GL_ARB_multisample", F(ARB_multisample) },
68 { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
69 { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
70 { OFF, "GL_ARB_occlusion_query2", F(ARB_occlusion_query2) },
71 { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
72 { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
73 { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
74 { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) },
75 { OFF, "GL_ARB_sampler_objects", F(ARB_sampler_objects) },
76 { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) },
77 { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
78 { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
79 { OFF, "GL_ARB_shadow", F(ARB_shadow) },
80 { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) },
81 { OFF, "GL_ARB_sync", F(ARB_sync) },
82 { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
83 { OFF, "GL_ARB_texture_buffer_object", F(ARB_texture_buffer_object) },
84 { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) },
85 { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
86 { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
87 { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
88 { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
89 { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
90 { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
91 { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
92 { OFF, "GL_ARB_texture_multisample", F(ARB_texture_multisample) },
93 { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
94 { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
95 { OFF, "GL_ARB_texture_rg", F(ARB_texture_rg) },
96 { OFF, "GL_ARB_texture_rgb10_a2ui", F(ARB_texture_rgb10_a2ui) },
97 { OFF, "GL_ARB_texture_swizzle", F(EXT_texture_swizzle) },
98 { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
99 { OFF, "GL_ARB_transform_feedback2", F(ARB_transform_feedback2) },
100 { OFF, "GL_ARB_uniform_buffer_object", F(ARB_uniform_buffer_object) },
101 { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) },
102 { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) },
103 { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
104 { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
105 { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
106 { OFF, "GL_ARB_vertex_type_2_10_10_10_rev", F(ARB_vertex_type_2_10_10_10_rev) },
107 { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
108 { ON, "GL_EXT_abgr", F(EXT_abgr) },
109 { ON, "GL_EXT_bgra", F(EXT_bgra) },
110 { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
111 { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
112 { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
113 { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
114 { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
115 { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
116 { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
117 { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
118 { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
119 { OFF, "GL_EXT_convolution", F(EXT_convolution) },
120 { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
121 { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
122 { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) },
123 { OFF, "GL_EXT_draw_instanced", F(ARB_draw_instanced) },
124 { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
125 { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) },
126 { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) },
127 { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
128 { OFF, "GL_EXT_framebuffer_sRGB", F(EXT_framebuffer_sRGB) },
129 { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
130 { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) },
131 { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
132 { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
133 { OFF, "GL_EXT_packed_float", F(EXT_packed_float) },
134 { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
135 { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
136 { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
137 { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
138 { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
139 { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) },
140 { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
141 { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
142 { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
143 { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
144 { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
145 { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
146 { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
147 { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
148 { ON, "GL_EXT_texture", F(EXT_texture) },
149 { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
150 { OFF, "GL_EXT_texture_array", F(EXT_texture_array) },
151 { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
152 { OFF, "GL_EXT_texture_compression_rgtc", F(EXT_texture_compression_rgtc) },
153 { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) },
154 { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
155 { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
156 { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
157 { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
158 { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
159 { OFF, "GL_EXT_texture_integer", F(EXT_texture_integer) },
160 { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
161 { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
162 { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
163 { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
164 { OFF, "GL_EXT_texture_shared_exponent", F(EXT_texture_shared_exponent) },
165 { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
166 { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
167 { OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
168 { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) },
169 { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
170 { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
171 { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
172 { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
173 { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
174 { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
175 { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
176 { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) },
177 { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
178 { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) },
179 { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
180 { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
181 { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
182 { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)},
183 { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
184 { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
185 { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
186 { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
187 { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
188 { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
189 { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
190 { OFF, "GL_MESA_texture_array", F(MESA_texture_array) },
191 { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) },
192 { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
193 { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
194 { OFF, "GL_NV_blend_square", F(NV_blend_square) },
195 { OFF, "GL_NV_conditional_render", F(NV_conditional_render) },
196 { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) },
197 { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
198 { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) },
199 { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
200 { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) },
201 { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
202 { OFF, "GL_NV_primitive_restart", F(NV_primitive_restart) },
203 { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
204 { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) },
205 { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
206 { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
207 { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
208 { ON, "GL_OES_read_format", F(OES_read_format) },
209 { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
210 { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
211 { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
212 { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
213 { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
214 { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
215 { OFF, "GL_S3_s3tc", F(S3_s3tc) },
216 #if FEATURE_OES_EGL_image
217 { OFF, "GL_OES_EGL_image", F(OES_EGL_image) },
218 #endif
219 #if FEATURE_OES_draw_texture
220 { OFF, "GL_OES_draw_texture", F(OES_draw_texture) },
221 #endif /* FEATURE_OES_draw_texture */
222 };
223
224
225
226 /**
227 * Enable all extensions suitable for a software-only renderer.
228 * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
229 */
230 void
231 _mesa_enable_sw_extensions(GLcontext *ctx)
232 {
233 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
234 ctx->Extensions.ARB_depth_clamp = GL_TRUE;
235 ctx->Extensions.ARB_depth_texture = GL_TRUE;
236 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
237 ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
238 ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
239 #if FEATURE_ARB_fragment_program
240 ctx->Extensions.ARB_fragment_program = GL_TRUE;
241 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
242 #endif
243 #if FEATURE_ARB_fragment_shader
244 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
245 #endif
246 #if FEATURE_ARB_framebuffer_object
247 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
248 #endif
249 #if FEATURE_ARB_geometry_shader4
250 ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
251 #endif
252 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
253 ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
254 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
255 ctx->Extensions.ARB_multitexture = GL_TRUE;
256 #if FEATURE_queryobj
257 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
258 #endif
259 ctx->Extensions.ARB_point_sprite = GL_TRUE;
260 #if FEATURE_ARB_shader_objects
261 ctx->Extensions.ARB_shader_objects = GL_TRUE;
262 #endif
263 #if FEATURE_ARB_shading_language_100
264 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
265 #endif
266 ctx->Extensions.ARB_shadow = GL_TRUE;
267 ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
268 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
269 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
270 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
271 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
272 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
273 /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
274 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
275 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
276 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
277 #if FEATURE_ARB_vertex_program
278 ctx->Extensions.ARB_vertex_program = GL_TRUE;
279 #endif
280 #if FEATURE_ARB_vertex_shader
281 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
282 #endif
283 #if FEATURE_ARB_vertex_buffer_object
284 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
285 #endif
286 #if FEATURE_ARB_sync
287 ctx->Extensions.ARB_sync = GL_TRUE;
288 #endif
289 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
290 #if FEATURE_APPLE_object_purgeable
291 ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
292 #endif
293 ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
294 #if FEATURE_ATI_fragment_shader
295 ctx->Extensions.ATI_fragment_shader = GL_TRUE;
296 #endif
297 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
298 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
299 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
300 ctx->Extensions.EXT_blend_color = GL_TRUE;
301 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
302 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
303 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
304 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
305 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
306 ctx->Extensions.EXT_convolution = GL_TRUE;
307 ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
308 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
309 ctx->Extensions.EXT_fog_coord = GL_TRUE;
310 #if FEATURE_EXT_framebuffer_object
311 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
312 #endif
313 #if FEATURE_EXT_framebuffer_blit
314 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
315 #endif
316 #if FEATURE_ARB_framebuffer_object
317 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
318 #endif
319 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
320 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
321 ctx->Extensions.EXT_paletted_texture = GL_TRUE;
322 #if FEATURE_EXT_pixel_buffer_object
323 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
324 #endif
325 ctx->Extensions.EXT_point_parameters = GL_TRUE;
326 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
327 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
328 ctx->Extensions.EXT_secondary_color = GL_TRUE;
329 ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
330 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
331 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
332 ctx->Extensions.EXT_texture_array = GL_TRUE;
333 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
334 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
335 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
336 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
337 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
338 #if FEATURE_EXT_texture_sRGB
339 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
340 #endif
341 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
342 #if FEATURE_EXT_transform_feedback
343 /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
344 #endif
345 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
346 /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
347 ctx->Extensions.MESA_pack_invert = GL_TRUE;
348 ctx->Extensions.MESA_resize_buffers = GL_TRUE;
349 ctx->Extensions.MESA_texture_array = GL_TRUE;
350 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
351 ctx->Extensions.NV_blend_square = GL_TRUE;
352 ctx->Extensions.NV_conditional_render = GL_TRUE;
353 /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
354 ctx->Extensions.NV_point_sprite = GL_TRUE;
355 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
356 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
357 /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
358 #if FEATURE_NV_vertex_program
359 ctx->Extensions.NV_vertex_program = GL_TRUE;
360 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
361 #endif
362 #if FEATURE_NV_fragment_program
363 ctx->Extensions.NV_fragment_program = GL_TRUE;
364 #endif
365 #if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
366 ctx->Extensions.NV_fragment_program_option = GL_TRUE;
367 #endif
368 ctx->Extensions.SGI_texture_color_table = GL_TRUE;
369 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
370 ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
371 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
372 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
373 #endif
374 #if FEATURE_texture_fxt1
375 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
376 #endif
377 #if FEATURE_texture_s3tc
378 if (ctx->Mesa_DXTn) {
379 _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
380 _mesa_enable_extension(ctx, "GL_S3_s3tc");
381 }
382 #endif
383 }
384
385
386 /**
387 * Enable common EXT extensions in the ARB_imaging subset.
388 */
389 void
390 _mesa_enable_imaging_extensions(GLcontext *ctx)
391 {
392 ctx->Extensions.EXT_blend_color = GL_TRUE;
393 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
394 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
395 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
396 ctx->Extensions.EXT_convolution = GL_TRUE;
397 }
398
399
400
401 /**
402 * Enable all OpenGL 1.3 features and extensions.
403 * A convenience function to be called by drivers.
404 */
405 void
406 _mesa_enable_1_3_extensions(GLcontext *ctx)
407 {
408 /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
409 ctx->Extensions.ARB_multitexture = GL_TRUE;
410 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
411 /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
412 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
413 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
414 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
415 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
416 /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
417 }
418
419
420
421 /**
422 * Enable all OpenGL 1.4 features and extensions.
423 * A convenience function to be called by drivers.
424 */
425 void
426 _mesa_enable_1_4_extensions(GLcontext *ctx)
427 {
428 ctx->Extensions.ARB_depth_texture = GL_TRUE;
429 ctx->Extensions.ARB_shadow = GL_TRUE;
430 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
431 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
432 ctx->Extensions.ARB_window_pos = GL_TRUE;
433 ctx->Extensions.EXT_blend_color = GL_TRUE;
434 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
435 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
436 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
437 ctx->Extensions.EXT_fog_coord = GL_TRUE;
438 /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
439 ctx->Extensions.EXT_point_parameters = GL_TRUE;
440 ctx->Extensions.EXT_secondary_color = GL_TRUE;
441 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
442 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
443 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
444 }
445
446
447 /**
448 * Enable all OpenGL 1.5 features and extensions.
449 * A convenience function to be called by drivers.
450 */
451 void
452 _mesa_enable_1_5_extensions(GLcontext *ctx)
453 {
454 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
455 /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
456 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
457 }
458
459
460 /**
461 * Enable all OpenGL 2.0 features and extensions.
462 * A convenience function to be called by drivers.
463 */
464 void
465 _mesa_enable_2_0_extensions(GLcontext *ctx)
466 {
467 /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
468 #if FEATURE_ARB_fragment_shader
469 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
470 #endif
471 ctx->Extensions.ARB_point_sprite = GL_TRUE;
472 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
473 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
474 #if FEATURE_ARB_shader_objects
475 ctx->Extensions.ARB_shader_objects = GL_TRUE;
476 #endif
477 #if FEATURE_ARB_shading_language_100
478 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
479 #endif
480 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
481 #if FEATURE_ARB_vertex_shader
482 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
483 #endif
484 }
485
486
487 /**
488 * Enable all OpenGL 2.1 features and extensions.
489 * A convenience function to be called by drivers.
490 */
491 void
492 _mesa_enable_2_1_extensions(GLcontext *ctx)
493 {
494 #if FEATURE_EXT_pixel_buffer_object
495 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
496 #endif
497 #if FEATURE_EXT_texture_sRGB
498 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
499 #endif
500 }
501
502
503 /**
504 * Either enable or disable the named extension.
505 * \return GL_TRUE for success, GL_FALSE if invalid extension name
506 */
507 static GLboolean
508 set_extension( GLcontext *ctx, const char *name, GLboolean state )
509 {
510 GLboolean *base = (GLboolean *) &ctx->Extensions;
511 GLuint i;
512
513 if (ctx->Extensions.String) {
514 /* The string was already queried - can't change it now! */
515 _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
516 return GL_FALSE;
517 }
518
519 for (i = 0 ; i < Elements(default_extensions) ; i++) {
520 if (strcmp(default_extensions[i].name, name) == 0) {
521 if (default_extensions[i].flag_offset) {
522 GLboolean *enabled = base + default_extensions[i].flag_offset;
523 *enabled = state;
524 }
525 return GL_TRUE;
526 }
527 }
528 return GL_FALSE;
529 }
530
531
532 /**
533 * Enable the named extension.
534 * Typically called by drivers.
535 */
536 void
537 _mesa_enable_extension( GLcontext *ctx, const char *name )
538 {
539 if (!set_extension(ctx, name, GL_TRUE))
540 _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
541 }
542
543
544 /**
545 * Disable the named extension.
546 * XXX is this really needed???
547 */
548 void
549 _mesa_disable_extension( GLcontext *ctx, const char *name )
550 {
551 if (!set_extension(ctx, name, GL_FALSE))
552 _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
553 }
554
555
556 /**
557 * Check if the i-th extension is enabled.
558 */
559 static GLboolean
560 extension_enabled(GLcontext *ctx, GLuint index)
561 {
562 const GLboolean *base = (const GLboolean *) &ctx->Extensions;
563 if (!default_extensions[index].flag_offset ||
564 *(base + default_extensions[index].flag_offset)) {
565 return GL_TRUE;
566 }
567 else {
568 return GL_FALSE;
569 }
570 }
571
572
573 /**
574 * Test if the named extension is enabled in this context.
575 */
576 GLboolean
577 _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
578 {
579 GLuint i;
580
581 for (i = 0 ; i < Elements(default_extensions) ; i++) {
582 if (strcmp(default_extensions[i].name, name) == 0) {
583 return extension_enabled(ctx, i);
584 }
585 }
586 return GL_FALSE;
587 }
588
589
590 /**
591 * Append string 'b' onto string 'a'. Free 'a' and return new string.
592 */
593 static char *
594 append(const char *a, const char *b)
595 {
596 const GLuint aLen = a ? strlen(a) : 0;
597 const GLuint bLen = b ? strlen(b) : 0;
598 char *s = calloc(1, aLen + bLen + 1);
599 if (s) {
600 if (a)
601 memcpy(s, a, aLen);
602 if (b)
603 memcpy(s + aLen, b, bLen);
604 s[aLen + bLen] = '\0';
605 }
606 if (a)
607 free((void *) a);
608 return s;
609 }
610
611
612 /**
613 * Check the MESA_EXTENSION_OVERRIDE env var.
614 * For extension names that are recognized, turn them on. For extension
615 * names that are recognized and prefixed with '-', turn them off.
616 * Return a string of the unknown/leftover names.
617 */
618 static const char *
619 get_extension_override( GLcontext *ctx )
620 {
621 const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
622 char *extraExt = NULL;
623 char ext[1000];
624 GLuint extLen = 0;
625 GLuint i;
626 GLboolean disableExt = GL_FALSE;
627
628 if (!envExt)
629 return NULL;
630
631 for (i = 0; ; i++) {
632 if (envExt[i] == '\0' || envExt[i] == ' ') {
633 /* terminate/process 'ext' if extLen > 0 */
634 if (extLen > 0) {
635 assert(extLen < sizeof(ext));
636 /* enable extension named by 'ext' */
637 ext[extLen] = 0;
638 if (!set_extension(ctx, ext, !disableExt)) {
639 /* unknown extension name, append it to extraExt */
640 if (extraExt) {
641 extraExt = append(extraExt, " ");
642 }
643 extraExt = append(extraExt, ext);
644 }
645 extLen = 0;
646 disableExt = GL_FALSE;
647 }
648 if (envExt[i] == '\0')
649 break;
650 }
651 else if (envExt[i] == '-') {
652 disableExt = GL_TRUE;
653 }
654 else {
655 /* accumulate this non-space character */
656 ext[extLen++] = envExt[i];
657 }
658 }
659
660 return extraExt;
661 }
662
663
664 /**
665 * Run through the default_extensions array above and set the
666 * ctx->Extensions.ARB/EXT_* flags accordingly.
667 * To be called during context initialization.
668 */
669 void
670 _mesa_init_extensions( GLcontext *ctx )
671 {
672 GLboolean *base = (GLboolean *) &ctx->Extensions;
673 GLuint i;
674
675 for (i = 0 ; i < Elements(default_extensions) ; i++) {
676 if (default_extensions[i].enabled &&
677 default_extensions[i].flag_offset) {
678 *(base + default_extensions[i].flag_offset) = GL_TRUE;
679 }
680 }
681 }
682
683
684 /**
685 * Construct the GL_EXTENSIONS string. Called the first time that
686 * glGetString(GL_EXTENSIONS) is called.
687 */
688 static GLubyte *
689 compute_extensions( GLcontext *ctx )
690 {
691 const char *extraExt = get_extension_override(ctx);
692 GLuint extStrLen = 0;
693 char *s;
694 GLuint i;
695
696 /* first, compute length of the extension string */
697 for (i = 0 ; i < Elements(default_extensions) ; i++) {
698 if (extension_enabled(ctx, i)) {
699 extStrLen += (GLuint) strlen(default_extensions[i].name) + 1;
700 }
701 }
702
703 if (extraExt)
704 extStrLen += strlen(extraExt) + 1; /* +1 for space */
705
706 /* allocate the extension string */
707 s = (char *) malloc(extStrLen);
708 if (!s)
709 return NULL;
710
711 /* second, build the extension string */
712 extStrLen = 0;
713 for (i = 0 ; i < Elements(default_extensions) ; i++) {
714 if (extension_enabled(ctx, i)) {
715 GLuint len = (GLuint) strlen(default_extensions[i].name);
716 memcpy(s + extStrLen, default_extensions[i].name, len);
717 extStrLen += len;
718 s[extStrLen] = ' ';
719 extStrLen++;
720 }
721 }
722 ASSERT(extStrLen > 0);
723
724 s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
725
726 if (extraExt) {
727 s = append(s, " ");
728 s = append(s, extraExt);
729 }
730
731 return (GLubyte *) s;
732 }
733
734 static size_t
735 append_extension(GLubyte **str, const char *ext)
736 {
737 GLubyte *s = *str;
738 size_t len = strlen(ext);
739
740 if (s) {
741 memcpy(s, ext, len);
742 s[len++] = ' ';
743 s[len] = '\0';
744
745 *str += len;
746 }
747 else {
748 len++;
749 }
750
751 return len;
752 }
753
754
755 static size_t
756 make_extension_string_es1(const GLcontext *ctx, GLubyte *str)
757 {
758 size_t len = 0;
759
760 /* Core additions */
761 len += append_extension(&str, "GL_OES_byte_coordinates");
762 len += append_extension(&str, "GL_OES_fixed_point");
763 len += append_extension(&str, "GL_OES_single_precision");
764 len += append_extension(&str, "GL_OES_matrix_get");
765
766 /* 1.1 required extensions */
767 len += append_extension(&str, "GL_OES_read_format");
768 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
769 len += append_extension(&str, "GL_OES_point_size_array");
770 len += append_extension(&str, "GL_OES_point_sprite");
771
772 /* 1.1 deprecated extensions */
773 len += append_extension(&str, "GL_OES_query_matrix");
774
775 #if FEATURE_OES_draw_texture
776 if (ctx->Extensions.OES_draw_texture)
777 len += append_extension(&str, "GL_OES_draw_texture");
778 #endif
779
780 if (ctx->Extensions.EXT_blend_equation_separate)
781 len += append_extension(&str, "GL_OES_blend_equation_separate");
782 if (ctx->Extensions.EXT_blend_func_separate)
783 len += append_extension(&str, "GL_OES_blend_func_separate");
784 if (ctx->Extensions.EXT_blend_subtract)
785 len += append_extension(&str, "GL_OES_blend_subtract");
786
787 if (ctx->Extensions.EXT_stencil_wrap)
788 len += append_extension(&str, "GL_OES_stencil_wrap");
789
790 if (ctx->Extensions.ARB_texture_cube_map)
791 len += append_extension(&str, "GL_OES_texture_cube_map");
792 if (ctx->Extensions.ARB_texture_env_crossbar)
793 len += append_extension(&str, "GL_OES_texture_env_crossbar");
794 if (ctx->Extensions.ARB_texture_mirrored_repeat)
795 len += append_extension(&str, "GL_OES_texture_mirrored_repeat");
796
797 if (ctx->Extensions.ARB_framebuffer_object) {
798 len += append_extension(&str, "GL_OES_framebuffer_object");
799 len += append_extension(&str, "GL_OES_depth24");
800 len += append_extension(&str, "GL_OES_depth32");
801 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
802 len += append_extension(&str, "GL_OES_rgb8_rgba8");
803 len += append_extension(&str, "GL_OES_stencil1");
804 len += append_extension(&str, "GL_OES_stencil4");
805 len += append_extension(&str, "GL_OES_stencil8");
806 }
807
808 if (ctx->Extensions.EXT_vertex_array)
809 len += append_extension(&str, "GL_OES_element_index_uint");
810 if (ctx->Extensions.ARB_vertex_buffer_object)
811 len += append_extension(&str, "GL_OES_mapbuffer");
812 if (ctx->Extensions.EXT_texture_filter_anisotropic)
813 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
814
815 /* some applications check this for NPOT support */
816 if (ctx->Extensions.ARB_texture_non_power_of_two)
817 len += append_extension(&str, "GL_ARB_texture_non_power_of_two");
818
819 if (ctx->Extensions.EXT_texture_compression_s3tc)
820 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
821 if (ctx->Extensions.EXT_texture_lod_bias)
822 len += append_extension(&str, "GL_EXT_texture_lod_bias");
823 if (ctx->Extensions.EXT_blend_minmax)
824 len += append_extension(&str, "GL_EXT_blend_minmax");
825 if (ctx->Extensions.EXT_multi_draw_arrays)
826 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
827
828 #if FEATURE_OES_EGL_image
829 if (ctx->Extensions.OES_EGL_image)
830 len += append_extension(&str, "GL_OES_EGL_image");
831 #endif
832
833 return len;
834 }
835
836
837 static GLubyte *
838 compute_extensions_es1(const GLcontext *ctx)
839 {
840 GLubyte *s;
841 unsigned int len;
842
843 len = make_extension_string_es1(ctx, NULL);
844 s = malloc(len + 1);
845 if (!s)
846 return NULL;
847 make_extension_string_es1(ctx, s);
848
849 return s;
850 }
851
852 static size_t
853 make_extension_string_es2(const GLcontext *ctx, GLubyte *str)
854 {
855 size_t len = 0;
856
857 len += append_extension(&str, "GL_OES_compressed_paletted_texture");
858
859 if (ctx->Extensions.ARB_framebuffer_object) {
860 len += append_extension(&str, "GL_OES_depth24");
861 len += append_extension(&str, "GL_OES_depth32");
862 len += append_extension(&str, "GL_OES_fbo_render_mipmap");
863 len += append_extension(&str, "GL_OES_rgb8_rgba8");
864 len += append_extension(&str, "GL_OES_stencil1");
865 len += append_extension(&str, "GL_OES_stencil4");
866 }
867
868 if (ctx->Extensions.EXT_vertex_array)
869 len += append_extension(&str, "GL_OES_element_index_uint");
870 if (ctx->Extensions.ARB_vertex_buffer_object)
871 len += append_extension(&str, "GL_OES_mapbuffer");
872
873 if (ctx->Extensions.EXT_texture3D)
874 len += append_extension(&str, "GL_OES_texture_3D");
875 if (ctx->Extensions.ARB_texture_non_power_of_two)
876 len += append_extension(&str, "GL_OES_texture_npot");
877 if (ctx->Extensions.EXT_texture_filter_anisotropic)
878 len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
879
880 len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV");
881 if (ctx->Extensions.ARB_depth_texture)
882 len += append_extension(&str, "GL_OES_depth_texture");
883 if (ctx->Extensions.EXT_packed_depth_stencil)
884 len += append_extension(&str, "GL_OES_packed_depth_stencil");
885 if (ctx->Extensions.ARB_fragment_shader)
886 len += append_extension(&str, "GL_OES_standard_derivatives");
887
888 if (ctx->Extensions.EXT_texture_compression_s3tc)
889 len += append_extension(&str, "GL_EXT_texture_compression_dxt1");
890 if (ctx->Extensions.EXT_blend_minmax)
891 len += append_extension(&str, "GL_EXT_blend_minmax");
892 if (ctx->Extensions.EXT_multi_draw_arrays)
893 len += append_extension(&str, "GL_EXT_multi_draw_arrays");
894
895 #if FEATURE_OES_EGL_image
896 if (ctx->Extensions.OES_EGL_image)
897 len += append_extension(&str, "GL_OES_EGL_image");
898 #endif
899
900 return len;
901 }
902
903 static GLubyte *
904 compute_extensions_es2(GLcontext *ctx)
905 {
906 GLubyte *s;
907 unsigned int len;
908
909 len = make_extension_string_es2(ctx, NULL);
910 s = malloc(len + 1);
911 if (!s)
912 return NULL;
913 make_extension_string_es2(ctx, s);
914
915 return s;
916 }
917
918
919 GLubyte *
920 _mesa_make_extension_string(GLcontext *ctx)
921 {
922 switch (ctx->API) {
923 case API_OPENGL:
924 return compute_extensions(ctx);
925 case API_OPENGLES2:
926 return compute_extensions_es2(ctx);
927 case API_OPENGLES:
928 return compute_extensions_es1(ctx);
929 default:
930 assert(0);
931 return NULL;
932 }
933 }
934
935 /**
936 * Return number of enabled extensions.
937 */
938 GLuint
939 _mesa_get_extension_count(GLcontext *ctx)
940 {
941 GLuint i;
942
943 /* only count once */
944 if (!ctx->Extensions.Count) {
945 for (i = 0; i < Elements(default_extensions); i++) {
946 if (extension_enabled(ctx, i)) {
947 ctx->Extensions.Count++;
948 }
949 }
950 }
951
952 if (0)
953 _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
954 (int) Elements(default_extensions));
955
956 return ctx->Extensions.Count;
957 }
958
959
960 /**
961 * Return name of i-th enabled extension
962 */
963 const GLubyte *
964 _mesa_get_enabled_extension(GLcontext *ctx, GLuint index)
965 {
966 GLuint i;
967
968 for (i = 0; i < Elements(default_extensions); i++) {
969 if (extension_enabled(ctx, i)) {
970 if (index == 0)
971 return (const GLubyte *) default_extensions[i].name;
972 index--;
973 }
974 }
975
976 return NULL;
977 }