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