intel_extensions.c revision f9995b30756140724f41daf963fa06167912be7f
1/**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * 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
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28#include "intel_chipset.h"
29#include "intel_context.h"
30#include "intel_extensions.h"
31#include "utils.h"
32
33
34#define need_GL_ARB_draw_elements_base_vertex
35#define need_GL_ARB_framebuffer_object
36#define need_GL_ARB_map_buffer_range
37#define need_GL_ARB_occlusion_query
38#define need_GL_ARB_point_parameters
39#define need_GL_ARB_shader_objects
40#define need_GL_ARB_sync
41#define need_GL_ARB_vertex_array_object
42#define need_GL_ARB_vertex_program
43#define need_GL_ARB_vertex_shader
44#define need_GL_ARB_window_pos
45#define need_GL_EXT_blend_color
46#define need_GL_EXT_blend_equation_separate
47#define need_GL_EXT_blend_func_separate
48#define need_GL_EXT_blend_minmax
49#define need_GL_EXT_draw_buffers2
50#define need_GL_EXT_fog_coord
51#define need_GL_EXT_framebuffer_blit
52#define need_GL_EXT_framebuffer_multisample
53#define need_GL_EXT_framebuffer_object
54#define need_GL_EXT_gpu_program_parameters
55#define need_GL_EXT_point_parameters
56#define need_GL_EXT_provoking_vertex
57#define need_GL_EXT_secondary_color
58#define need_GL_EXT_stencil_two_side
59#define need_GL_EXT_timer_query
60#define need_GL_APPLE_vertex_array_object
61#define need_GL_APPLE_object_purgeable
62#define need_GL_ATI_separate_stencil
63#define need_GL_ATI_envmap_bumpmap
64#define need_GL_NV_point_sprite
65#define need_GL_NV_vertex_program
66#define need_GL_OES_EGL_image
67#define need_GL_VERSION_2_0
68#define need_GL_VERSION_2_1
69
70#include "main/remap_helper.h"
71
72
73/**
74 * Extension strings exported by the intel driver.
75 *
76 * Extensions supported by all chips supported by i830_dri, i915_dri, or
77 * i965_dri.
78 */
79static const struct dri_extension card_extensions[] = {
80   { "GL_ARB_draw_elements_base_vertex",  GL_ARB_draw_elements_base_vertex_functions },
81   { "GL_ARB_explicit_attrib_location",   NULL },
82   { "GL_ARB_half_float_pixel",           NULL },
83   { "GL_ARB_map_buffer_range",           GL_ARB_map_buffer_range_functions },
84   { "GL_ARB_multitexture",               NULL },
85   { "GL_ARB_pixel_buffer_object",      NULL },
86   { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
87   { "GL_ARB_point_sprite",               NULL },
88   { "GL_ARB_shader_objects",             GL_ARB_shader_objects_functions },
89   { "GL_ARB_shading_language_100",       GL_VERSION_2_0_functions },
90   { "GL_ARB_sync",                       GL_ARB_sync_functions },
91   { "GL_ARB_texture_border_clamp",       NULL },
92   { "GL_ARB_texture_cube_map",           NULL },
93   { "GL_ARB_texture_env_add",            NULL },
94   { "GL_ARB_texture_env_combine",        NULL },
95   { "GL_ARB_texture_env_crossbar",       NULL },
96   { "GL_ARB_texture_env_dot3",           NULL },
97   { "GL_ARB_texture_mirrored_repeat",    NULL },
98   { "GL_ARB_texture_rectangle",          NULL },
99   { "GL_ARB_vertex_array_object",        GL_ARB_vertex_array_object_functions},
100   { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions },
101   { "GL_ARB_vertex_shader",              GL_ARB_vertex_shader_functions },
102   { "GL_ARB_window_pos",                 GL_ARB_window_pos_functions },
103   { "GL_EXT_blend_color",                GL_EXT_blend_color_functions },
104   { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },
105   { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },
106   { "GL_EXT_blend_minmax",               GL_EXT_blend_minmax_functions },
107   { "GL_EXT_blend_logic_op",             NULL },
108   { "GL_EXT_blend_subtract",             NULL },
109   { "GL_EXT_framebuffer_blit",         GL_EXT_framebuffer_blit_functions },
110   { "GL_EXT_framebuffer_object",       GL_EXT_framebuffer_object_functions },
111   { "GL_EXT_framebuffer_multisample",    GL_EXT_framebuffer_multisample_functions },
112   { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
113   { "GL_EXT_gpu_program_parameters",     GL_EXT_gpu_program_parameters_functions },
114   { "GL_EXT_packed_depth_stencil",       NULL },
115   { "GL_EXT_provoking_vertex",           GL_EXT_provoking_vertex_functions },
116   { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
117   { "GL_EXT_stencil_wrap",               NULL },
118   { "GL_EXT_texture_edge_clamp",         NULL },
119   { "GL_EXT_texture_env_combine",        NULL },
120   { "GL_EXT_texture_env_dot3",           NULL },
121   { "GL_EXT_texture_filter_anisotropic", NULL },
122   { "GL_EXT_texture_lod_bias",           NULL },
123   { "GL_3DFX_texture_compression_FXT1",  NULL },
124   { "GL_APPLE_client_storage",           NULL },
125   { "GL_APPLE_object_purgeable",         GL_APPLE_object_purgeable_functions },
126   { "GL_APPLE_vertex_array_object",      GL_APPLE_vertex_array_object_functions},
127   { "GL_MESA_pack_invert",               NULL },
128   { "GL_MESA_ycbcr_texture",             NULL },
129   { "GL_NV_blend_square",                NULL },
130   { "GL_NV_vertex_program",              GL_NV_vertex_program_functions },
131   { "GL_NV_vertex_program1_1",           NULL },
132#if FEATURE_OES_EGL_image
133   { "GL_OES_EGL_image",                  GL_OES_EGL_image_functions },
134#endif
135   { NULL, NULL }
136};
137
138
139/** i915 / i945-only extensions */
140static const struct dri_extension i915_extensions[] = {
141   { "GL_ARB_depth_texture",              NULL },
142   { "GL_ARB_fragment_program",           NULL },
143   { "GL_ARB_shadow",                     NULL },
144   { "GL_ARB_texture_non_power_of_two",   NULL },
145   { "GL_ATI_separate_stencil",           GL_ATI_separate_stencil_functions },
146   { "GL_ATI_texture_env_combine3",       NULL },
147   { "GL_EXT_shadow_funcs",               NULL },
148   { "GL_EXT_stencil_two_side",           GL_EXT_stencil_two_side_functions },
149   { "GL_NV_texture_env_combine4",        NULL },
150   { NULL,                                NULL }
151};
152
153
154/** i965-only extensions */
155static const struct dri_extension brw_extensions[] = {
156   { "GL_ARB_depth_clamp",                NULL },
157   { "GL_ARB_depth_texture",              NULL },
158   { "GL_ARB_fragment_coord_conventions", NULL },
159   { "GL_ARB_fragment_program",           NULL },
160   { "GL_ARB_fragment_program_shadow",    NULL },
161   { "GL_ARB_fragment_shader",            NULL },
162   { "GL_ARB_framebuffer_object",         GL_ARB_framebuffer_object_functions},
163   { "GL_ARB_half_float_vertex",          NULL },
164   { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
165   { "GL_ARB_point_sprite", 		  NULL },
166   { "GL_ARB_seamless_cube_map",          NULL },
167   { "GL_ARB_shadow",                     NULL },
168   { "GL_MESA_texture_signed_rgba",       NULL },
169   { "GL_ARB_texture_non_power_of_two",   NULL },
170   { "GL_ARB_texture_rg",                 NULL },
171   { "GL_EXT_draw_buffers2",              GL_EXT_draw_buffers2_functions },
172   { "GL_EXT_shadow_funcs",               NULL },
173   { "GL_EXT_stencil_two_side",           GL_EXT_stencil_two_side_functions },
174   { "GL_EXT_texture_sRGB",		  NULL },
175   { "GL_EXT_texture_swizzle",		  NULL },
176   { "GL_EXT_vertex_array_bgra",	  NULL },
177   { "GL_ATI_envmap_bumpmap",             GL_ATI_envmap_bumpmap_functions },
178   { "GL_ATI_separate_stencil",           GL_ATI_separate_stencil_functions },
179   { "GL_ATI_texture_env_combine3",       NULL },
180   { "GL_NV_texture_env_combine4",        NULL },
181   { NULL,                                NULL }
182};
183
184static const struct dri_extension ironlake_extensions[] = {
185   { "GL_EXT_timer_query",                GL_EXT_timer_query_functions },
186};
187
188static const struct dri_extension arb_oq_extensions[] = {
189   { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
190   { NULL, NULL }
191};
192
193
194static const struct dri_extension fragment_shader_extensions[] = {
195   { "GL_ARB_fragment_shader",            NULL },
196   { NULL, NULL }
197};
198
199/**
200 * \brief Get GLSL version from the environment.
201 *
202 * If the environment variable INTEL_GLSL_VERSION is set, convert its value
203 * to an integer and return it. Otherwise, return the default version, 120.
204 */
205static GLuint
206get_glsl_version()
207{
208    const char * s = getenv("INTEL_GLSL_VERSION");
209    if (s == NULL)
210        return 120;
211    else
212        return (GLuint) atoi(s);
213}
214
215/**
216 * Initializes potential list of extensions if ctx == NULL, or actually enables
217 * extensions for a context.
218 */
219void
220intelInitExtensions(struct gl_context *ctx)
221{
222   struct intel_context *intel = intel_context(ctx);
223
224   driInitExtensions(ctx, card_extensions, GL_FALSE);
225
226   _mesa_map_function_array(GL_VERSION_2_1_functions);
227
228   ctx->Const.GLSLVersion = get_glsl_version();
229
230   if (intel->gen >= 5)
231      driInitExtensions(ctx, ironlake_extensions, GL_FALSE);
232
233   if (intel->gen >= 4)
234      driInitExtensions(ctx, brw_extensions, GL_FALSE);
235
236   if (intel->gen == 3) {
237      driInitExtensions(ctx, i915_extensions, GL_FALSE);
238
239      if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
240	 driInitExtensions(ctx, fragment_shader_extensions, GL_FALSE);
241
242      if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
243	 driInitExtensions(ctx, arb_oq_extensions, GL_FALSE);
244   }
245}
246