gallium: implement seamless cubemap extensions
[mesa.git] / src / mesa / state_tracker / st_extensions.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright (c) 2008 VMware, Inc.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 **************************************************************************/
28
29 #include "main/imports.h"
30 #include "main/context.h"
31 #include "main/macros.h"
32 #include "main/mfeatures.h"
33
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_screen.h"
37
38 #include "st_context.h"
39 #include "st_extensions.h"
40
41
42 static int _min(int a, int b)
43 {
44 return (a < b) ? a : b;
45 }
46
47 static float _maxf(float a, float b)
48 {
49 return (a > b) ? a : b;
50 }
51
52 static int _clamp(int a, int min, int max)
53 {
54 if (a < min)
55 return min;
56 else if (a > max)
57 return max;
58 else
59 return a;
60 }
61
62
63 /**
64 * Query driver to get implementation limits.
65 * Note that we have to limit/clamp against Mesa's internal limits too.
66 */
67 void st_init_limits(struct st_context *st)
68 {
69 struct pipe_screen *screen = st->pipe->screen;
70 struct gl_constants *c = &st->ctx->Const;
71 gl_shader_type sh;
72
73 c->MaxTextureLevels
74 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
75 MAX_TEXTURE_LEVELS);
76
77 c->Max3DTextureLevels
78 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
79 MAX_3D_TEXTURE_LEVELS);
80
81 c->MaxCubeTextureLevels
82 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
83 MAX_CUBE_TEXTURE_LEVELS);
84
85 c->MaxTextureRectSize
86 = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
87
88 c->MaxTextureImageUnits
89 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
90 MAX_TEXTURE_IMAGE_UNITS);
91
92 c->MaxVertexTextureImageUnits
93 = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
94 MAX_VERTEX_TEXTURE_IMAGE_UNITS);
95
96 c->MaxCombinedTextureImageUnits
97 = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS),
98 MAX_COMBINED_TEXTURE_IMAGE_UNITS);
99
100 c->MaxTextureCoordUnits
101 = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
102
103 c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits);
104
105 c->MaxDrawBuffers
106 = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
107 1, MAX_DRAW_BUFFERS);
108
109 c->MaxLineWidth
110 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH));
111 c->MaxLineWidthAA
112 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA));
113
114 c->MaxPointSize
115 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH));
116 c->MaxPointSizeAA
117 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA));
118 /* called after _mesa_create_context/_mesa_init_point, fix default user
119 * settable max point size up
120 */
121 st->ctx->Point.MaxSize = MAX2(c->MaxPointSize, c->MaxPointSizeAA);
122 /* these are not queryable. Note that GL basically mandates a 1.0 minimum
123 * for non-aa sizes, but we can go down to 0.0 for aa points.
124 */
125 c->MinPointSize = 1.0f;
126 c->MinPointSizeAA = 0.0f;
127
128 c->MaxTextureMaxAnisotropy
129 = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY));
130
131 c->MaxTextureLodBias
132 = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
133
134 c->MaxDrawBuffers
135 = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
136 1, MAX_DRAW_BUFFERS);
137
138 /* Quads always follow GL provoking rules. */
139 c->QuadsFollowProvokingVertexConvention = GL_FALSE;
140
141 for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) {
142 struct gl_shader_compiler_options *options =
143 &st->ctx->ShaderCompilerOptions[sh];
144 struct gl_program_constants *pc;
145
146 switch (sh) {
147 case PIPE_SHADER_FRAGMENT:
148 pc = &c->FragmentProgram;
149 break;
150 case PIPE_SHADER_VERTEX:
151 pc = &c->VertexProgram;
152 break;
153 case PIPE_SHADER_GEOMETRY:
154 pc = &c->GeometryProgram;
155 break;
156 default:
157 assert(0);
158 continue;
159 }
160
161 pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS);
162 pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS);
163 pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS);
164 pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS);
165 pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS);
166 pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS);
167 pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS);
168 pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
169 pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
170 /* raise MaxParameters if native support is higher */
171 pc->MaxParameters = MAX2(pc->MaxParameters, pc->MaxNativeParameters);
172
173 options->EmitNoNoise = TRUE;
174
175 /* TODO: make these more fine-grained if anyone needs it */
176 options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
177 options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
178 options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
179 options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
180
181 options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);
182
183 options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh,
184 PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);
185 options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh,
186 PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR);
187 options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh,
188 PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR);
189 options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh,
190 PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
191
192 if (options->EmitNoLoops)
193 options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
194 }
195
196 /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
197 * and is set in MaxNativeAttribs. It's always 2 colors + N generic
198 * attributes. The GLSL compiler never uses COLORn for varyings, so we
199 * subtract the 2 colors to get the maximum number of varyings (generic
200 * attributes) supported by a driver. */
201 c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
202 c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
203
204 /* XXX we'll need a better query here someday */
205 if (screen->get_param(screen, PIPE_CAP_GLSL)) {
206 c->GLSLVersion = 120;
207 }
208 }
209
210
211 /**
212 * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
213 * which GL extensions are supported.
214 * Quite a few extensions are always supported because they are standard
215 * features or can be built on top of other gallium features.
216 * Some fine tuning may still be needed.
217 */
218 void st_init_extensions(struct st_context *st)
219 {
220 struct pipe_screen *screen = st->pipe->screen;
221 struct gl_context *ctx = st->ctx;
222
223 /*
224 * Extensions that are supported by all Gallium drivers:
225 */
226 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
227 ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
228 ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
229 ctx->Extensions.ARB_fragment_program = GL_TRUE;
230 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
231 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
232 ctx->Extensions.ARB_multisample = GL_TRUE;
233 ctx->Extensions.ARB_sampler_objects = GL_TRUE;
234 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
235 ctx->Extensions.ARB_texture_compression = GL_TRUE;
236 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
237 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
238 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
239 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
240 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
241 ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
242 ctx->Extensions.ARB_vertex_program = GL_TRUE;
243 ctx->Extensions.ARB_window_pos = GL_TRUE;
244
245 ctx->Extensions.EXT_blend_color = GL_TRUE;
246 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
247 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
248 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
249 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
250 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
251 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
252 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
253 ctx->Extensions.EXT_fog_coord = GL_TRUE;
254 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
255 ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
256 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
257 ctx->Extensions.EXT_point_parameters = GL_TRUE;
258 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
259 ctx->Extensions.EXT_secondary_color = GL_TRUE;
260 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
261 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
262 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
263 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
264 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
265 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
266 if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2)
267 ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE;
268
269 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
270
271 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
272
273 ctx->Extensions.MESA_pack_invert = GL_TRUE;
274
275 ctx->Extensions.NV_blend_square = GL_TRUE;
276 ctx->Extensions.NV_texgen_reflection = GL_TRUE;
277 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
278 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
279 #if 0
280 /* possibly could support the following two */
281 ctx->Extensions.NV_vertex_program = GL_TRUE;
282 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
283 #endif
284
285 #if FEATURE_OES_EGL_image
286 ctx->Extensions.OES_EGL_image = GL_TRUE;
287 #endif
288 #if FEATURE_OES_draw_texture
289 ctx->Extensions.OES_draw_texture = GL_TRUE;
290 #endif
291
292 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
293
294 /*
295 * Extensions that depend on the driver/hardware:
296 */
297 if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) {
298 ctx->Extensions.ARB_draw_buffers = GL_TRUE;
299 }
300
301 if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) {
302 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
303 }
304
305 if (screen->get_param(screen, PIPE_CAP_GLSL)) {
306 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
307 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
308 ctx->Extensions.ARB_shader_objects = GL_TRUE;
309 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
310 ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
311 ctx->Extensions.EXT_separate_shader_objects = GL_TRUE;
312 }
313
314 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
315 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
316 }
317
318 if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) {
319 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
320 }
321
322 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
323 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
324 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
325 }
326
327 if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) {
328 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
329 }
330
331 if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) {
332 ctx->Extensions.ARB_multitexture = GL_TRUE;
333 }
334
335 if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) {
336 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
337 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
338 }
339
340 if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
341 ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
342 }
343
344 if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
345 ctx->Extensions.ARB_point_sprite = GL_TRUE;
346 /* GL_NV_point_sprite is not supported by gallium because we don't
347 * support the GL_POINT_SPRITE_R_MODE_NV option.
348 */
349 }
350
351 if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
352 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
353 ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
354 }
355 if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
356 ctx->Extensions.EXT_timer_query = GL_TRUE;
357 }
358
359 if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
360 ctx->Extensions.ARB_depth_texture = GL_TRUE;
361 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
362 ctx->Extensions.ARB_shadow = GL_TRUE;
363 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
364 /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
365 }
366
367 /* GL_EXT_packed_depth_stencil requires both the ability to render to
368 * a depth/stencil buffer and texture from depth/stencil source.
369 */
370 if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
371 PIPE_TEXTURE_2D, 0,
372 PIPE_BIND_DEPTH_STENCIL) &&
373 screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
374 PIPE_TEXTURE_2D, 0,
375 PIPE_BIND_SAMPLER_VIEW)) {
376 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
377 }
378 else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
379 PIPE_TEXTURE_2D, 0,
380 PIPE_BIND_DEPTH_STENCIL) &&
381 screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
382 PIPE_TEXTURE_2D, 0,
383 PIPE_BIND_SAMPLER_VIEW)) {
384 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
385 }
386
387 /* float support - assume nothing exclusively supports 64-bit floats */
388 if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT,
389 PIPE_TEXTURE_2D, 0,
390 PIPE_BIND_SAMPLER_VIEW |
391 PIPE_BIND_RENDER_TARGET) &&
392 screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
393 PIPE_TEXTURE_2D, 0,
394 PIPE_BIND_SAMPLER_VIEW |
395 PIPE_BIND_RENDER_TARGET)) {
396 ctx->Extensions.ARB_texture_float = GL_TRUE;
397 }
398
399 /* sRGB support */
400 if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
401 PIPE_TEXTURE_2D, 0,
402 PIPE_BIND_SAMPLER_VIEW) ||
403 screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
404 PIPE_TEXTURE_2D, 0,
405 PIPE_BIND_SAMPLER_VIEW)) {
406 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
407 ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
408 if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
409 PIPE_TEXTURE_2D, 0,
410 PIPE_BIND_RENDER_TARGET) ||
411 screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
412 PIPE_TEXTURE_2D, 0,
413 PIPE_BIND_RENDER_TARGET)) {
414 ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE;
415 ctx->Const.sRGBCapable = GL_TRUE;
416 }
417 }
418
419 if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM,
420 PIPE_TEXTURE_2D, 0,
421 PIPE_BIND_SAMPLER_VIEW)) {
422 ctx->Extensions.ARB_texture_rg = GL_TRUE;
423 }
424
425 /* s3tc support */
426 if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
427 PIPE_TEXTURE_2D, 0,
428 PIPE_BIND_SAMPLER_VIEW) &&
429 ctx->Mesa_DXTn) {
430 ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
431 ctx->Extensions.S3_s3tc = GL_TRUE;
432 }
433
434 if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM,
435 PIPE_TEXTURE_2D, 0,
436 PIPE_BIND_SAMPLER_VIEW) &&
437 screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM,
438 PIPE_TEXTURE_2D, 0,
439 PIPE_BIND_SAMPLER_VIEW) &&
440 screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM,
441 PIPE_TEXTURE_2D, 0,
442 PIPE_BIND_SAMPLER_VIEW) &&
443 screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM,
444 PIPE_TEXTURE_2D, 0,
445 PIPE_BIND_SAMPLER_VIEW)
446 ) {
447 ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
448 }
449
450 if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM,
451 PIPE_TEXTURE_2D, 0,
452 PIPE_BIND_SAMPLER_VIEW) &&
453 screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM,
454 PIPE_TEXTURE_2D, 0,
455 PIPE_BIND_SAMPLER_VIEW) &&
456 screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
457 PIPE_TEXTURE_2D, 0,
458 PIPE_BIND_SAMPLER_VIEW) &&
459 screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM,
460 PIPE_TEXTURE_2D, 0,
461 PIPE_BIND_SAMPLER_VIEW)) {
462 ctx->Extensions.EXT_texture_compression_latc = GL_TRUE;
463 }
464
465 if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
466 PIPE_TEXTURE_2D, 0,
467 PIPE_BIND_SAMPLER_VIEW)) {
468 ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
469 }
470
471 if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM,
472 PIPE_TEXTURE_2D, 0,
473 PIPE_BIND_SAMPLER_VIEW)) {
474 ctx->Extensions.EXT_texture_snorm = GL_TRUE;
475 }
476
477 /* ycbcr support */
478 if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
479 PIPE_TEXTURE_2D, 0,
480 PIPE_BIND_SAMPLER_VIEW) ||
481 screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
482 PIPE_TEXTURE_2D, 0,
483 PIPE_BIND_SAMPLER_VIEW)) {
484 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
485 }
486
487 /* GL_EXT_texture_array */
488 if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) {
489 ctx->Extensions.EXT_texture_array = GL_TRUE;
490 ctx->Extensions.MESA_texture_array = GL_TRUE;
491 }
492
493 /* GL_ARB_framebuffer_object */
494 if (ctx->Extensions.EXT_packed_depth_stencil) {
495 /* we support always support GL_EXT_framebuffer_blit */
496 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
497 }
498
499 if (st->pipe->render_condition) {
500 ctx->Extensions.NV_conditional_render = GL_TRUE;
501 }
502
503 if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) {
504 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
505 }
506
507 if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) {
508 ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE;
509 }
510
511 /* GL_ARB_half_float_vertex */
512 if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
513 PIPE_BUFFER, 0,
514 PIPE_BIND_VERTEX_BUFFER)) {
515 ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
516 }
517
518 if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FIXED,
519 PIPE_BUFFER, 0,
520 PIPE_BIND_VERTEX_BUFFER)) {
521 ctx->Extensions.ARB_ES2_compatibility = GL_TRUE;
522 }
523
524 if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
525 #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
526 ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
527 #endif
528 }
529
530 if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) {
531 ctx->Extensions.NV_primitive_restart = GL_TRUE;
532 }
533
534 if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) {
535 ctx->Extensions.ARB_depth_clamp = GL_TRUE;
536 }
537
538 /* This extension does not actually require support of floating point
539 * render targets, just clamping controls.
540 * Advertise this extension if either fragment color clamping is supported
541 * or no render targets having color values outside of the range [0, 1]
542 * are supported, in which case the fragment color clamping has no effect
543 * on rendering.
544 */
545 if (screen->get_param(screen, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL) ||
546 (!screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM,
547 PIPE_TEXTURE_2D, 0,
548 PIPE_BIND_RENDER_TARGET) &&
549 !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM,
550 PIPE_TEXTURE_2D, 0,
551 PIPE_BIND_RENDER_TARGET) &&
552 !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
553 PIPE_TEXTURE_2D, 0,
554 PIPE_BIND_RENDER_TARGET) &&
555 !screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT,
556 PIPE_TEXTURE_2D, 0,
557 PIPE_BIND_RENDER_TARGET) &&
558 !screen->is_format_supported(screen, PIPE_FORMAT_R11G11B10_FLOAT,
559 PIPE_TEXTURE_2D, 0,
560 PIPE_BIND_RENDER_TARGET) &&
561 !screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT,
562 PIPE_TEXTURE_2D, 0,
563 PIPE_BIND_RENDER_TARGET))) {
564 ctx->Extensions.ARB_color_buffer_float = GL_TRUE;
565 }
566
567 if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
568 ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;
569 }
570
571 if (screen->get_param(screen, PIPE_CAP_TGSI_INSTANCEID)) {
572 ctx->Extensions.ARB_draw_instanced = GL_TRUE;
573 }
574 if (screen->get_param(screen, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR)) {
575 ctx->Extensions.ARB_instanced_arrays = GL_TRUE;
576 }
577
578 if (screen->fence_finish) {
579 ctx->Extensions.ARB_sync = GL_TRUE;
580 }
581
582 if (st->pipe->texture_barrier) {
583 ctx->Extensions.NV_texture_barrier = GL_TRUE;
584 }
585
586 if (screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT,
587 PIPE_TEXTURE_2D, 0,
588 PIPE_BIND_SAMPLER_VIEW)) {
589 ctx->Extensions.EXT_texture_shared_exponent = GL_TRUE;
590 }
591
592 if (screen->is_format_supported(screen, PIPE_FORMAT_R11G11B10_FLOAT,
593 PIPE_TEXTURE_2D, 0,
594 PIPE_BIND_RENDER_TARGET |
595 PIPE_BIND_SAMPLER_VIEW)) {
596 ctx->Extensions.EXT_packed_float = GL_TRUE;
597 }
598
599 if (screen->get_param(screen, PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE)) {
600 ctx->Extensions.ARB_seamless_cube_map = GL_TRUE;
601 ctx->Extensions.AMD_seamless_cubemap_per_texture = GL_TRUE;
602 }
603 else if (screen->get_param(screen, PIPE_CAP_SEAMLESS_CUBE_MAP)) {
604 ctx->Extensions.ARB_seamless_cube_map = GL_TRUE;
605 }
606 }