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