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 "main/mfeatures.h"
29#include "main/version.h"
30
31#include "intel_chipset.h"
32#include "intel_context.h"
33#include "intel_extensions.h"
34#include "intel_reg.h"
35#include "utils.h"
36
37/**
38 * Initializes potential list of extensions if ctx == NULL, or actually enables
39 * extensions for a context.
40 */
41void
42intelInitExtensions(struct gl_context *ctx)
43{
44   struct intel_context *intel = intel_context(ctx);
45
46   ctx->Extensions.ARB_draw_elements_base_vertex = true;
47   ctx->Extensions.ARB_explicit_attrib_location = true;
48   if (_mesa_is_desktop_gl(ctx))
49      ctx->Extensions.ARB_framebuffer_object = true;
50   ctx->Extensions.ARB_half_float_pixel = true;
51   ctx->Extensions.ARB_map_buffer_range = true;
52   ctx->Extensions.ARB_point_sprite = true;
53   ctx->Extensions.ARB_shader_objects = true;
54   ctx->Extensions.ARB_shading_language_100 = true;
55   ctx->Extensions.ARB_sync = true;
56   ctx->Extensions.ARB_texture_border_clamp = true;
57   ctx->Extensions.ARB_texture_cube_map = true;
58   ctx->Extensions.ARB_texture_env_combine = true;
59   ctx->Extensions.ARB_texture_env_crossbar = true;
60   ctx->Extensions.ARB_texture_env_dot3 = true;
61   ctx->Extensions.ARB_texture_storage = true;
62   ctx->Extensions.ARB_vertex_program = true;
63   ctx->Extensions.ARB_vertex_shader = true;
64   ctx->Extensions.EXT_blend_color = true;
65   ctx->Extensions.EXT_blend_equation_separate = true;
66   ctx->Extensions.EXT_blend_func_separate = true;
67   ctx->Extensions.EXT_blend_minmax = true;
68   ctx->Extensions.EXT_framebuffer_blit = true;
69   ctx->Extensions.EXT_framebuffer_object = true;
70   ctx->Extensions.EXT_framebuffer_multisample = true;
71   ctx->Extensions.EXT_fog_coord = true;
72   ctx->Extensions.EXT_gpu_program_parameters = true;
73   ctx->Extensions.EXT_packed_depth_stencil = true;
74   ctx->Extensions.EXT_pixel_buffer_object = true;
75   ctx->Extensions.EXT_point_parameters = true;
76   ctx->Extensions.EXT_provoking_vertex = true;
77   ctx->Extensions.EXT_secondary_color = true;
78   ctx->Extensions.EXT_separate_shader_objects = true;
79   ctx->Extensions.EXT_texture_env_dot3 = true;
80   ctx->Extensions.EXT_texture_filter_anisotropic = true;
81   ctx->Extensions.APPLE_object_purgeable = true;
82   ctx->Extensions.MESA_pack_invert = true;
83   ctx->Extensions.MESA_ycbcr_texture = true;
84   ctx->Extensions.NV_blend_square = true;
85   ctx->Extensions.NV_texture_rectangle = true;
86   ctx->Extensions.NV_vertex_program = true;
87   ctx->Extensions.NV_vertex_program1_1 = true;
88   ctx->Extensions.TDFX_texture_compression_FXT1 = true;
89#if FEATURE_OES_EGL_image
90   ctx->Extensions.OES_EGL_image = true;
91#endif
92   ctx->Extensions.OES_draw_texture = true;
93   ctx->Extensions.OES_compressed_ETC1_RGB8_texture = true;
94   ctx->Extensions.ARB_texture_rgb10_a2ui = true;
95
96   if (intel->gen >= 6)
97      if (ctx->API == API_OPENGL_CORE) {
98         ctx->Const.GLSLVersion = 140;
99      } else {
100         ctx->Const.GLSLVersion = 130;
101      }
102   else
103      ctx->Const.GLSLVersion = 120;
104   _mesa_override_glsl_version(ctx);
105
106   if (intel->gen == 6 ||
107       (intel->gen == 7 && intel->intelScreen->kernel_has_gen7_sol_reset))
108      ctx->Extensions.EXT_transform_feedback = true;
109
110   if (intel->gen >= 6) {
111      ctx->Extensions.ARB_blend_func_extended = !driQueryOptionb(&intel->optionCache, "disable_blend_func_extended");
112      ctx->Extensions.ARB_draw_buffers_blend = true;
113      ctx->Extensions.ARB_uniform_buffer_object = true;
114
115      if (ctx->API == API_OPENGL_CORE) {
116         ctx->Extensions.ARB_texture_buffer_object = true;
117      }
118   }
119
120   if (intel->gen >= 5)
121      ctx->Extensions.EXT_timer_query = true;
122
123   if (intel->gen >= 6) {
124      uint64_t dummy;
125      /* Test if the kernel has the ioctl. */
126      if (drm_intel_reg_read(intel->bufmgr, TIMESTAMP, &dummy) == 0)
127         ctx->Extensions.ARB_timer_query = true;
128   }
129
130   if (intel->gen >= 4) {
131      ctx->Extensions.ARB_color_buffer_float = true;
132      ctx->Extensions.ARB_depth_buffer_float = true;
133      ctx->Extensions.ARB_depth_clamp = true;
134      ctx->Extensions.ARB_draw_instanced = true;
135      ctx->Extensions.ARB_instanced_arrays = true;
136      ctx->Extensions.ARB_fragment_coord_conventions = true;
137      ctx->Extensions.ARB_fragment_program_shadow = true;
138      ctx->Extensions.ARB_fragment_shader = true;
139      ctx->Extensions.ARB_half_float_vertex = true;
140      ctx->Extensions.ARB_occlusion_query = true;
141      ctx->Extensions.ARB_occlusion_query2 = true;
142      ctx->Extensions.ARB_point_sprite = true;
143      ctx->Extensions.ARB_seamless_cube_map = true;
144      ctx->Extensions.ARB_shader_bit_encoding = true;
145      ctx->Extensions.ARB_shader_texture_lod = true;
146#ifdef TEXTURE_FLOAT_ENABLED
147      ctx->Extensions.ARB_texture_float = true;
148      ctx->Extensions.EXT_texture_shared_exponent = true;
149      ctx->Extensions.EXT_packed_float = true;
150#endif
151      ctx->Extensions.ARB_texture_compression_rgtc = true;
152      ctx->Extensions.ARB_texture_rg = true;
153      ctx->Extensions.EXT_draw_buffers2 = true;
154      ctx->Extensions.EXT_framebuffer_sRGB = true;
155      ctx->Extensions.EXT_texture_array = true;
156      ctx->Extensions.EXT_texture_integer = true;
157      ctx->Extensions.EXT_texture_snorm = true;
158      ctx->Extensions.EXT_texture_sRGB = true;
159      ctx->Extensions.EXT_texture_sRGB_decode = true;
160      ctx->Extensions.EXT_texture_swizzle = true;
161      ctx->Extensions.EXT_vertex_array_bgra = true;
162      ctx->Extensions.ATI_envmap_bumpmap = true;
163      ctx->Extensions.MESA_texture_array = true;
164      ctx->Extensions.NV_conditional_render = true;
165   }
166
167   if (intel->gen >= 3) {
168      ctx->Extensions.ARB_ES2_compatibility = true;
169      ctx->Extensions.ARB_depth_texture = true;
170      ctx->Extensions.ARB_fragment_program = true;
171      ctx->Extensions.ARB_shadow = true;
172      ctx->Extensions.ARB_texture_non_power_of_two = true;
173      ctx->Extensions.EXT_shadow_funcs = true;
174      ctx->Extensions.EXT_stencil_two_side = true;
175      ctx->Extensions.ATI_separate_stencil = true;
176      ctx->Extensions.ATI_texture_env_combine3 = true;
177      ctx->Extensions.NV_texture_env_combine4 = true;
178
179      if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
180	 ctx->Extensions.ARB_fragment_shader = true;
181
182      if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
183	 ctx->Extensions.ARB_occlusion_query = true;
184   }
185
186   if (intel->ctx.Mesa_DXTn) {
187      ctx->Extensions.EXT_texture_compression_s3tc = true;
188      ctx->Extensions.S3_s3tc = true;
189   }
190   else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
191      ctx->Extensions.EXT_texture_compression_s3tc = true;
192   }
193
194   if (intel->gen >= 4) {
195      ctx->Extensions.NV_primitive_restart = true;
196   }
197}
198