st/mesa: convert Mesa float formats to Gallium
[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
171 options->EmitNoNoise = TRUE;
172
173 /* TODO: make these more fine-grained if anyone needs it */
174 options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
175 options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
176 options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
177 options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
178
179 options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);
180
181 options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh,
182 PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR);
183 options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh,
184 PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR);
185 options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh,
186 PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR);
187 options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh,
188 PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
189
190 if(options->EmitNoLoops)
191 options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
192 }
193
194 /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
195 * and is set in MaxNativeAttribs. It's always 2 colors + N generic
196 * attributes. The GLSL compiler never uses COLORn for varyings, so we
197 * subtract the 2 colors to get the maximum number of varyings (generic
198 * attributes) supported by a driver. */
199 c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
200 c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
201
202 /* XXX we'll need a better query here someday */
203 if (screen->get_param(screen, PIPE_CAP_GLSL)) {
204 c->GLSLVersion = 120;
205 }
206 }
207
208
209 /**
210 * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
211 * which GL extensions are supported.
212 * Quite a few extensions are always supported because they are standard
213 * features or can be built on top of other gallium features.
214 * Some fine tuning may still be needed.
215 */
216 void st_init_extensions(struct st_context *st)
217 {
218 struct pipe_screen *screen = st->pipe->screen;
219 struct gl_context *ctx = st->ctx;
220
221 /*
222 * Extensions that are supported by all Gallium drivers:
223 */
224 ctx->Extensions.ARB_copy_buffer = GL_TRUE;
225 ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
226 ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
227 ctx->Extensions.ARB_fragment_program = GL_TRUE;
228 ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
229 ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
230 ctx->Extensions.ARB_multisample = GL_TRUE;
231 ctx->Extensions.ARB_sampler_objects = GL_TRUE;
232 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
233 ctx->Extensions.ARB_texture_compression = GL_TRUE;
234 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
235 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
236 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
237 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
238 ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
239 ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
240 ctx->Extensions.ARB_vertex_program = GL_TRUE;
241 ctx->Extensions.ARB_window_pos = GL_TRUE;
242
243 ctx->Extensions.EXT_blend_color = GL_TRUE;
244 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
245 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
246 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
247 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
248 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
249 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
250 ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
251 ctx->Extensions.EXT_fog_coord = GL_TRUE;
252 ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
253 ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
254 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
255 ctx->Extensions.EXT_point_parameters = GL_TRUE;
256 ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
257 ctx->Extensions.EXT_secondary_color = GL_TRUE;
258 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
259 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
260 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
261 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
262 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
263 ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
264 if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2)
265 ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE;
266
267 ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
268
269 ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
270
271 ctx->Extensions.MESA_pack_invert = GL_TRUE;
272
273 ctx->Extensions.NV_blend_square = GL_TRUE;
274 ctx->Extensions.NV_texgen_reflection = GL_TRUE;
275 ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
276 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
277 #if 0
278 /* possibly could support the following two */
279 ctx->Extensions.NV_vertex_program = GL_TRUE;
280 ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
281 #endif
282
283 #if FEATURE_OES_EGL_image
284 ctx->Extensions.OES_EGL_image = GL_TRUE;
285 #endif
286 #if FEATURE_OES_draw_texture
287 ctx->Extensions.OES_draw_texture = GL_TRUE;
288 #endif
289
290 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
291
292 /*
293 * Extensions that depend on the driver/hardware:
294 */
295 if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) {
296 ctx->Extensions.ARB_draw_buffers = GL_TRUE;
297 }
298
299 if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) {
300 ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
301 }
302
303 if (screen->get_param(screen, PIPE_CAP_GLSL)) {
304 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
305 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
306 ctx->Extensions.ARB_shader_objects = GL_TRUE;
307 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
308 ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
309 ctx->Extensions.EXT_separate_shader_objects = GL_TRUE;
310 }
311
312 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
313 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
314 }
315
316 if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) {
317 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
318 }
319
320 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
321 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
322 ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
323 }
324
325 if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) {
326 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
327 }
328
329 if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) {
330 ctx->Extensions.ARB_multitexture = GL_TRUE;
331 }
332
333 if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) {
334 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
335 ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
336 }
337
338 if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
339 ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
340 }
341
342 if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
343 ctx->Extensions.ARB_point_sprite = GL_TRUE;
344 /* GL_NV_point_sprite is not supported by gallium because we don't
345 * support the GL_POINT_SPRITE_R_MODE_NV option.
346 */
347 }
348
349 if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
350 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
351 ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
352 }
353 if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
354 ctx->Extensions.EXT_timer_query = GL_TRUE;
355 }
356
357 if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
358 ctx->Extensions.ARB_depth_texture = GL_TRUE;
359 ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
360 ctx->Extensions.ARB_shadow = GL_TRUE;
361 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
362 /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
363 }
364
365 /* GL_EXT_packed_depth_stencil requires both the ability to render to
366 * a depth/stencil buffer and texture from depth/stencil source.
367 */
368 if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
369 PIPE_TEXTURE_2D, 0,
370 PIPE_BIND_DEPTH_STENCIL) &&
371 screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
372 PIPE_TEXTURE_2D, 0,
373 PIPE_BIND_SAMPLER_VIEW)) {
374 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
375 }
376 else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
377 PIPE_TEXTURE_2D, 0,
378 PIPE_BIND_DEPTH_STENCIL) &&
379 screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
380 PIPE_TEXTURE_2D, 0,
381 PIPE_BIND_SAMPLER_VIEW)) {
382 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
383 }
384
385 /* float support - assume nothing exclusively supports 64-bit floats */
386 if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT,
387 PIPE_TEXTURE_2D, 0,
388 PIPE_BIND_SAMPLER_VIEW |
389 PIPE_BIND_RENDER_TARGET) &&
390 screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
391 PIPE_TEXTURE_2D, 0,
392 PIPE_BIND_SAMPLER_VIEW |
393 PIPE_BIND_RENDER_TARGET)) {
394 ctx->Extensions.ARB_texture_float = GL_TRUE;
395 }
396
397 /* sRGB support */
398 if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
399 PIPE_TEXTURE_2D, 0,
400 PIPE_BIND_SAMPLER_VIEW) ||
401 screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
402 PIPE_TEXTURE_2D, 0,
403 PIPE_BIND_SAMPLER_VIEW)) {
404 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
405 ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
406 if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
407 PIPE_TEXTURE_2D, 0,
408 PIPE_BIND_RENDER_TARGET) ||
409 screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
410 PIPE_TEXTURE_2D, 0,
411 PIPE_BIND_RENDER_TARGET)) {
412 ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE;
413 ctx->Const.sRGBCapable = GL_TRUE;
414 }
415 }
416
417 if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM,
418 PIPE_TEXTURE_2D, 0,
419 PIPE_BIND_SAMPLER_VIEW)) {
420 ctx->Extensions.ARB_texture_rg = GL_TRUE;
421 }
422
423 /* s3tc support */
424 if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
425 PIPE_TEXTURE_2D, 0,
426 PIPE_BIND_SAMPLER_VIEW) &&
427 ctx->Mesa_DXTn) {
428 ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
429 ctx->Extensions.S3_s3tc = GL_TRUE;
430 }
431
432 if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM,
433 PIPE_TEXTURE_2D, 0,
434 PIPE_BIND_SAMPLER_VIEW) &&
435 screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM,
436 PIPE_TEXTURE_2D, 0,
437 PIPE_BIND_SAMPLER_VIEW) &&
438 screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM,
439 PIPE_TEXTURE_2D, 0,
440 PIPE_BIND_SAMPLER_VIEW) &&
441 screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM,
442 PIPE_TEXTURE_2D, 0,
443 PIPE_BIND_SAMPLER_VIEW)
444 ) {
445 ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
446 }
447
448 if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM,
449 PIPE_TEXTURE_2D, 0,
450 PIPE_BIND_SAMPLER_VIEW) &&
451 screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM,
452 PIPE_TEXTURE_2D, 0,
453 PIPE_BIND_SAMPLER_VIEW) &&
454 screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
455 PIPE_TEXTURE_2D, 0,
456 PIPE_BIND_SAMPLER_VIEW) &&
457 screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM,
458 PIPE_TEXTURE_2D, 0,
459 PIPE_BIND_SAMPLER_VIEW)) {
460 ctx->Extensions.EXT_texture_compression_latc = GL_TRUE;
461 }
462
463 if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
464 PIPE_TEXTURE_2D, 0,
465 PIPE_BIND_SAMPLER_VIEW)) {
466 ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
467 }
468
469 if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM,
470 PIPE_TEXTURE_2D, 0,
471 PIPE_BIND_SAMPLER_VIEW)) {
472 ctx->Extensions.EXT_texture_snorm = GL_TRUE;
473 }
474
475 /* ycbcr support */
476 if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
477 PIPE_TEXTURE_2D, 0,
478 PIPE_BIND_SAMPLER_VIEW) ||
479 screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
480 PIPE_TEXTURE_2D, 0,
481 PIPE_BIND_SAMPLER_VIEW)) {
482 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
483 }
484
485 /* GL_EXT_texture_array */
486 if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) {
487 ctx->Extensions.EXT_texture_array = GL_TRUE;
488 ctx->Extensions.MESA_texture_array = GL_TRUE;
489 }
490
491 /* GL_ARB_framebuffer_object */
492 if (ctx->Extensions.EXT_packed_depth_stencil) {
493 /* we support always support GL_EXT_framebuffer_blit */
494 ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
495 }
496
497 if (st->pipe->render_condition) {
498 ctx->Extensions.NV_conditional_render = GL_TRUE;
499 }
500
501 if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) {
502 ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
503 }
504
505 if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) {
506 ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE;
507 }
508
509 /* GL_ARB_half_float_vertex */
510 if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
511 PIPE_BUFFER, 0,
512 PIPE_BIND_VERTEX_BUFFER)) {
513 ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
514 }
515
516 if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
517 #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
518 ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
519 #endif
520 }
521
522 if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) {
523 ctx->Extensions.NV_primitive_restart = GL_TRUE;
524 }
525
526 if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) {
527 ctx->Extensions.ARB_depth_clamp = GL_TRUE;
528 }
529
530 /* This extension does not actually require support of floating point
531 * render targets, just clamping controls.
532 * Advertise this extension if either fragment color clamping is supported
533 * or no render targets having color values outside of the range [0, 1]
534 * are supported, in which case the fragment color clamping has no effect
535 * on rendering.
536 */
537 if (screen->get_param(screen, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL) ||
538 (!screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM,
539 PIPE_TEXTURE_2D, 0,
540 PIPE_BIND_RENDER_TARGET) &&
541 !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM,
542 PIPE_TEXTURE_2D, 0,
543 PIPE_BIND_RENDER_TARGET) &&
544 !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
545 PIPE_TEXTURE_2D, 0,
546 PIPE_BIND_RENDER_TARGET) &&
547 !screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT,
548 PIPE_TEXTURE_2D, 0,
549 PIPE_BIND_RENDER_TARGET) &&
550 !screen->is_format_supported(screen, PIPE_FORMAT_R11G11B10_FLOAT,
551 PIPE_TEXTURE_2D, 0,
552 PIPE_BIND_RENDER_TARGET) &&
553 !screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT,
554 PIPE_TEXTURE_2D, 0,
555 PIPE_BIND_RENDER_TARGET))) {
556 ctx->Extensions.ARB_color_buffer_float = GL_TRUE;
557 }
558
559 if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
560 ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;
561 }
562
563 if (screen->get_param(screen, PIPE_CAP_TGSI_INSTANCEID)) {
564 ctx->Extensions.ARB_draw_instanced = GL_TRUE;
565 }
566 if (screen->get_param(screen, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR)) {
567 ctx->Extensions.ARB_instanced_arrays = GL_TRUE;
568 }
569
570 if (screen->fence_finish) {
571 ctx->Extensions.ARB_sync = GL_TRUE;
572 }
573
574 if (st->pipe->texture_barrier) {
575 ctx->Extensions.NV_texture_barrier = GL_TRUE;
576 }
577 }