2 * Mesa 3-D graphics library
4 * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 * Examine enabled GL extensions to determine GL version.
36 * Return major and minor version numbers.
39 compute_version(struct gl_context
*ctx
)
42 static const int max
= 100;
44 const GLboolean ver_1_3
= (ctx
->Extensions
.ARB_multisample
&&
45 ctx
->Extensions
.ARB_multitexture
&&
46 ctx
->Extensions
.ARB_texture_border_clamp
&&
47 ctx
->Extensions
.ARB_texture_compression
&&
48 ctx
->Extensions
.ARB_texture_cube_map
&&
49 ctx
->Extensions
.EXT_texture_env_add
&&
50 ctx
->Extensions
.ARB_texture_env_combine
&&
51 ctx
->Extensions
.ARB_texture_env_dot3
);
52 const GLboolean ver_1_4
= (ver_1_3
&&
53 ctx
->Extensions
.ARB_depth_texture
&&
54 ctx
->Extensions
.ARB_shadow
&&
55 ctx
->Extensions
.ARB_texture_env_crossbar
&&
56 ctx
->Extensions
.ARB_texture_mirrored_repeat
&&
57 ctx
->Extensions
.ARB_window_pos
&&
58 ctx
->Extensions
.EXT_blend_color
&&
59 ctx
->Extensions
.EXT_blend_func_separate
&&
60 ctx
->Extensions
.EXT_blend_minmax
&&
61 ctx
->Extensions
.EXT_blend_subtract
&&
62 ctx
->Extensions
.EXT_fog_coord
&&
63 ctx
->Extensions
.EXT_multi_draw_arrays
&&
64 ctx
->Extensions
.EXT_point_parameters
&&
65 ctx
->Extensions
.EXT_secondary_color
&&
66 ctx
->Extensions
.EXT_stencil_wrap
&&
67 ctx
->Extensions
.EXT_texture_lod_bias
&&
68 ctx
->Extensions
.SGIS_generate_mipmap
);
69 const GLboolean ver_1_5
= (ver_1_4
&&
70 ctx
->Extensions
.ARB_occlusion_query
&&
71 ctx
->Extensions
.ARB_vertex_buffer_object
&&
72 ctx
->Extensions
.EXT_shadow_funcs
);
73 const GLboolean ver_2_0
= (ver_1_5
&&
74 ctx
->Extensions
.ARB_draw_buffers
&&
75 ctx
->Extensions
.ARB_point_sprite
&&
76 ctx
->Extensions
.ARB_shader_objects
&&
77 ctx
->Extensions
.ARB_vertex_shader
&&
78 ctx
->Extensions
.ARB_fragment_shader
&&
79 ctx
->Extensions
.ARB_texture_non_power_of_two
&&
80 ctx
->Extensions
.EXT_blend_equation_separate
&&
82 /* Technically, 2.0 requires the functionality
83 * of the EXT version. Enable 2.0 if either
84 * extension is available, and assume that a
85 * driver that only exposes the ATI extension
86 * will fallback to software when necessary.
88 (ctx
->Extensions
.EXT_stencil_two_side
89 || ctx
->Extensions
.ATI_separate_stencil
));
90 const GLboolean ver_2_1
= (ver_2_0
&&
91 ctx
->Const
.GLSLVersion
>= 120 &&
92 ctx
->Extensions
.EXT_pixel_buffer_object
&&
93 ctx
->Extensions
.EXT_texture_sRGB
);
94 const GLboolean ver_3_0
= (ver_2_1
&&
95 ctx
->Extensions
.ARB_color_buffer_float
&&
96 ctx
->Extensions
.ARB_depth_buffer_float
&&
97 ctx
->Extensions
.ARB_half_float_pixel
&&
98 ctx
->Extensions
.ARB_map_buffer_range
&&
99 ctx
->Extensions
.ARB_texture_float
&&
100 ctx
->Extensions
.ARB_texture_rg
&&
101 ctx
->Extensions
.ARB_texture_compression_rgtc
&&
102 ctx
->Extensions
.APPLE_vertex_array_object
&&
103 ctx
->Extensions
.EXT_draw_buffers2
&&
104 ctx
->Extensions
.EXT_framebuffer_blit
&&
105 ctx
->Extensions
.EXT_framebuffer_multisample
&&
106 ctx
->Extensions
.EXT_framebuffer_object
&&
107 ctx
->Extensions
.EXT_framebuffer_sRGB
&&
108 ctx
->Extensions
.EXT_packed_depth_stencil
&&
109 ctx
->Extensions
.EXT_packed_float
&&
110 ctx
->Extensions
.EXT_texture_array
&&
111 ctx
->Extensions
.EXT_texture_integer
&&
112 ctx
->Extensions
.EXT_texture_shared_exponent
&&
113 ctx
->Extensions
.EXT_transform_feedback
&&
114 ctx
->Extensions
.NV_conditional_render
);
115 const GLboolean ver_3_1
= (ver_3_0
&&
116 ctx
->Extensions
.ARB_copy_buffer
&&
117 ctx
->Extensions
.ARB_draw_instanced
&&
118 ctx
->Extensions
.ARB_texture_buffer_object
&&
119 ctx
->Extensions
.ARB_uniform_buffer_object
&&
120 ctx
->Extensions
.EXT_texture_snorm
&&
121 ctx
->Extensions
.NV_primitive_restart
&&
122 ctx
->Extensions
.NV_texture_rectangle
&&
123 ctx
->Const
.MaxVertexTextureImageUnits
>= 16);
124 const GLboolean ver_3_2
= (ver_3_1
&&
125 ctx
->Extensions
.ARB_depth_clamp
&&
126 ctx
->Extensions
.ARB_draw_elements_base_vertex
&&
127 ctx
->Extensions
.ARB_fragment_coord_conventions
&&
128 ctx
->Extensions
.ARB_geometry_shader4
&&
129 ctx
->Extensions
.EXT_provoking_vertex
&&
130 ctx
->Extensions
.ARB_seamless_cube_map
&&
131 ctx
->Extensions
.ARB_sync
&&
132 ctx
->Extensions
.ARB_texture_multisample
&&
133 ctx
->Extensions
.EXT_vertex_array_bgra
);
134 const GLboolean ver_3_3
= (ver_3_2
&&
135 ctx
->Extensions
.ARB_blend_func_extended
&&
136 ctx
->Extensions
.ARB_explicit_attrib_location
&&
137 ctx
->Extensions
.ARB_instanced_arrays
&&
138 ctx
->Extensions
.ARB_occlusion_query2
&&
139 ctx
->Extensions
.ARB_sampler_objects
&&
140 ctx
->Extensions
.ARB_texture_rgb10_a2ui
&&
141 ctx
->Extensions
.ARB_timer_query
&&
142 ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
&&
143 ctx
->Extensions
.EXT_texture_swizzle
);
186 ctx
->VersionMajor
= major
;
187 ctx
->VersionMinor
= minor
;
188 ctx
->VersionString
= (char *) malloc(max
);
189 if (ctx
->VersionString
) {
190 _mesa_snprintf(ctx
->VersionString
, max
,
191 "%u.%u Mesa " MESA_VERSION_STRING
193 " (" MESA_GIT_SHA1
")"
196 ctx
->VersionMajor
, ctx
->VersionMinor
);
201 compute_version_es1(struct gl_context
*ctx
)
203 static const int max
= 100;
205 /* OpenGL ES 1.0 is derived from OpenGL 1.3 */
206 const GLboolean ver_1_0
= (ctx
->Extensions
.ARB_multisample
&&
207 ctx
->Extensions
.ARB_multitexture
&&
208 ctx
->Extensions
.ARB_texture_compression
&&
209 ctx
->Extensions
.EXT_texture_env_add
&&
210 ctx
->Extensions
.ARB_texture_env_combine
&&
211 ctx
->Extensions
.ARB_texture_env_dot3
);
212 /* OpenGL ES 1.1 is derived from OpenGL 1.5 */
213 const GLboolean ver_1_1
= (ver_1_0
&&
214 ctx
->Extensions
.EXT_point_parameters
&&
215 ctx
->Extensions
.SGIS_generate_mipmap
&&
216 ctx
->Extensions
.ARB_vertex_buffer_object
);
219 ctx
->VersionMajor
= 1;
220 ctx
->VersionMinor
= 1;
221 } else if (ver_1_0
) {
222 ctx
->VersionMajor
= 1;
223 ctx
->VersionMinor
= 0;
225 _mesa_problem(ctx
, "Incomplete OpenGL ES 1.0 support.");
228 ctx
->VersionString
= (char *) malloc(max
);
229 if (ctx
->VersionString
) {
230 _mesa_snprintf(ctx
->VersionString
, max
,
231 "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING
,
237 compute_version_es2(struct gl_context
*ctx
)
239 static const int max
= 100;
241 /* OpenGL ES 2.0 is derived from OpenGL 2.0 */
242 const GLboolean ver_2_0
= (ctx
->Extensions
.ARB_multisample
&&
243 ctx
->Extensions
.ARB_multitexture
&&
244 ctx
->Extensions
.ARB_texture_compression
&&
245 ctx
->Extensions
.ARB_texture_cube_map
&&
246 ctx
->Extensions
.ARB_texture_mirrored_repeat
&&
247 ctx
->Extensions
.EXT_blend_color
&&
248 ctx
->Extensions
.EXT_blend_func_separate
&&
249 ctx
->Extensions
.EXT_blend_minmax
&&
250 ctx
->Extensions
.EXT_blend_subtract
&&
251 ctx
->Extensions
.EXT_stencil_wrap
&&
252 ctx
->Extensions
.ARB_vertex_buffer_object
&&
253 ctx
->Extensions
.ARB_shader_objects
&&
254 ctx
->Extensions
.ARB_vertex_shader
&&
255 ctx
->Extensions
.ARB_fragment_shader
&&
256 ctx
->Extensions
.ARB_texture_non_power_of_two
&&
257 ctx
->Extensions
.EXT_blend_equation_separate
);
259 ctx
->VersionMajor
= 2;
260 ctx
->VersionMinor
= 0;
262 _mesa_problem(ctx
, "Incomplete OpenGL ES 2.0 support.");
265 ctx
->VersionString
= (char *) malloc(max
);
266 if (ctx
->VersionString
) {
267 _mesa_snprintf(ctx
->VersionString
, max
,
268 "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING
);
273 * Set the context's VersionMajor, VersionMinor, VersionString fields.
274 * This should only be called once as part of context initialization
275 * or to perform version check for GLX_ARB_create_context_profile.
278 _mesa_compute_version(struct gl_context
*ctx
)
280 if (ctx
->VersionMajor
)
285 compute_version(ctx
);
288 compute_version_es1(ctx
);
291 compute_version_es2(ctx
);