1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright (c) 2008 VMware, Inc.
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:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
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.
27 **************************************************************************/
29 #include "main/imports.h"
30 #include "main/context.h"
31 #include "main/macros.h"
32 #include "main/mfeatures.h"
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_screen.h"
38 #include "st_context.h"
39 #include "st_extensions.h"
42 static int _min(int a
, int b
)
44 return (a
< b
) ? a
: b
;
47 static float _maxf(float a
, float b
)
49 return (a
> b
) ? a
: b
;
52 static int _clamp(int a
, int min
, int max
)
64 * Query driver to get implementation limits.
65 * Note that we have to limit/clamp against Mesa's internal limits too.
67 void st_init_limits(struct st_context
*st
)
69 struct pipe_screen
*screen
= st
->pipe
->screen
;
70 struct gl_constants
*c
= &st
->ctx
->Const
;
74 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
),
78 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
),
79 MAX_3D_TEXTURE_LEVELS
);
81 c
->MaxCubeTextureLevels
82 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
),
83 MAX_CUBE_TEXTURE_LEVELS
);
86 = _min(1 << (c
->MaxTextureLevels
- 1), MAX_TEXTURE_RECT_SIZE
);
88 c
->MaxArrayTextureLayers
89 = screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
);
91 c
->MaxTextureImageUnits
92 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
),
93 MAX_TEXTURE_IMAGE_UNITS
);
95 c
->MaxVertexTextureImageUnits
96 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
),
97 MAX_VERTEX_TEXTURE_IMAGE_UNITS
);
99 c
->MaxCombinedTextureImageUnits
100 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_COMBINED_SAMPLERS
),
101 MAX_COMBINED_TEXTURE_IMAGE_UNITS
);
103 c
->MaxTextureCoordUnits
104 = _min(c
->MaxTextureImageUnits
, MAX_TEXTURE_COORD_UNITS
);
106 c
->MaxTextureUnits
= _min(c
->MaxTextureImageUnits
, c
->MaxTextureCoordUnits
);
109 = _clamp(screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
),
110 1, MAX_DRAW_BUFFERS
);
113 = _maxf(1.0f
, screen
->get_paramf(screen
, PIPE_CAP_MAX_LINE_WIDTH
));
115 = _maxf(1.0f
, screen
->get_paramf(screen
, PIPE_CAP_MAX_LINE_WIDTH_AA
));
118 = _maxf(1.0f
, screen
->get_paramf(screen
, PIPE_CAP_MAX_POINT_WIDTH
));
120 = _maxf(1.0f
, screen
->get_paramf(screen
, PIPE_CAP_MAX_POINT_WIDTH_AA
));
121 /* called after _mesa_create_context/_mesa_init_point, fix default user
122 * settable max point size up
124 st
->ctx
->Point
.MaxSize
= MAX2(c
->MaxPointSize
, c
->MaxPointSizeAA
);
125 /* these are not queryable. Note that GL basically mandates a 1.0 minimum
126 * for non-aa sizes, but we can go down to 0.0 for aa points.
128 c
->MinPointSize
= 1.0f
;
129 c
->MinPointSizeAA
= 0.0f
;
131 c
->MaxTextureMaxAnisotropy
132 = _maxf(2.0f
, screen
->get_paramf(screen
, PIPE_CAP_MAX_TEXTURE_ANISOTROPY
));
135 = screen
->get_paramf(screen
, PIPE_CAP_MAX_TEXTURE_LOD_BIAS
);
138 = CLAMP(screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
),
139 1, MAX_DRAW_BUFFERS
);
141 /* Quads always follow GL provoking rules. */
142 c
->QuadsFollowProvokingVertexConvention
= GL_FALSE
;
144 for (sh
= 0; sh
< MESA_SHADER_TYPES
; ++sh
) {
145 struct gl_shader_compiler_options
*options
=
146 &st
->ctx
->ShaderCompilerOptions
[sh
];
147 struct gl_program_constants
*pc
;
150 case PIPE_SHADER_FRAGMENT
:
151 pc
= &c
->FragmentProgram
;
153 case PIPE_SHADER_VERTEX
:
154 pc
= &c
->VertexProgram
;
156 case PIPE_SHADER_GEOMETRY
:
157 pc
= &c
->GeometryProgram
;
164 pc
->MaxNativeInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
165 pc
->MaxNativeAluInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
);
166 pc
->MaxNativeTexInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
);
167 pc
->MaxNativeTexIndirections
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
);
168 pc
->MaxNativeAttribs
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INPUTS
);
169 pc
->MaxNativeTemps
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEMPS
);
170 pc
->MaxNativeAddressRegs
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_ADDRS
);
171 pc
->MaxNativeParameters
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONSTS
);
172 pc
->MaxUniformComponents
= 4 * MIN2(pc
->MaxNativeParameters
, MAX_UNIFORMS
);
173 /* raise MaxParameters if native support is higher */
174 pc
->MaxParameters
= MAX2(pc
->MaxParameters
, pc
->MaxNativeParameters
);
176 /* Gallium doesn't really care about local vs. env parameters so use the
179 pc
->MaxLocalParams
= MIN2(pc
->MaxParameters
, MAX_PROGRAM_LOCAL_PARAMS
);
180 pc
->MaxEnvParams
= MIN2(pc
->MaxParameters
, MAX_PROGRAM_ENV_PARAMS
);
182 options
->EmitNoNoise
= TRUE
;
184 /* TODO: make these more fine-grained if anyone needs it */
185 options
->MaxIfDepth
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
186 options
->EmitNoLoops
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
187 options
->EmitNoFunctions
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_SUBROUTINES
);
188 options
->EmitNoMainReturn
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_SUBROUTINES
);
190 options
->EmitNoCont
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
);
192 options
->EmitNoIndirectInput
= !screen
->get_shader_param(screen
, sh
,
193 PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
);
194 options
->EmitNoIndirectOutput
= !screen
->get_shader_param(screen
, sh
,
195 PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
);
196 options
->EmitNoIndirectTemp
= !screen
->get_shader_param(screen
, sh
,
197 PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
);
198 options
->EmitNoIndirectUniform
= !screen
->get_shader_param(screen
, sh
,
199 PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
);
201 if (options
->EmitNoLoops
)
202 options
->MaxUnrollIterations
= MIN2(screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
), 65536);
205 /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
206 * and is set in MaxNativeAttribs. It's always 2 colors + N generic
207 * attributes. The GLSL compiler never uses COLORn for varyings, so we
208 * subtract the 2 colors to get the maximum number of varyings (generic
209 * attributes) supported by a driver. */
210 c
->MaxVarying
= screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_INPUTS
) - 2;
211 c
->MaxVarying
= MIN2(c
->MaxVarying
, MAX_VARYING
);
213 /* XXX we'll need a better query here someday */
214 if (screen
->get_param(screen
, PIPE_CAP_GLSL
)) {
215 c
->MinProgramTexelOffset
= screen
->get_param(screen
, PIPE_CAP_MIN_TEXEL_OFFSET
);
216 c
->MaxProgramTexelOffset
= screen
->get_param(screen
, PIPE_CAP_MAX_TEXEL_OFFSET
);
218 c
->GLSLVersion
= 120;
219 c
->UniformBooleanTrue
= ~0;
224 static GLboolean
st_get_s3tc_override(void)
226 const char *override
= _mesa_getenv("force_s3tc_enable");
227 if (override
&& !strcmp(override
, "true"))
234 * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
235 * which GL extensions are supported.
236 * Quite a few extensions are always supported because they are standard
237 * features or can be built on top of other gallium features.
238 * Some fine tuning may still be needed.
240 void st_init_extensions(struct st_context
*st
)
242 struct pipe_screen
*screen
= st
->pipe
->screen
;
243 struct gl_context
*ctx
= st
->ctx
;
247 * Extensions that are supported by all Gallium drivers:
249 ctx
->Extensions
.ARB_copy_buffer
= GL_TRUE
;
250 ctx
->Extensions
.ARB_draw_elements_base_vertex
= GL_TRUE
;
251 ctx
->Extensions
.ARB_fragment_coord_conventions
= GL_TRUE
;
252 ctx
->Extensions
.ARB_fragment_program
= GL_TRUE
;
253 ctx
->Extensions
.ARB_half_float_pixel
= GL_TRUE
;
254 ctx
->Extensions
.ARB_map_buffer_range
= GL_TRUE
;
255 ctx
->Extensions
.ARB_multisample
= GL_TRUE
;
256 ctx
->Extensions
.ARB_sampler_objects
= GL_TRUE
;
257 ctx
->Extensions
.ARB_texture_border_clamp
= GL_TRUE
; /* XXX temp */
258 ctx
->Extensions
.ARB_texture_compression
= GL_TRUE
;
259 ctx
->Extensions
.ARB_texture_cube_map
= GL_TRUE
;
260 ctx
->Extensions
.ARB_texture_env_combine
= GL_TRUE
;
261 ctx
->Extensions
.ARB_texture_env_crossbar
= GL_TRUE
;
262 ctx
->Extensions
.ARB_texture_env_dot3
= GL_TRUE
;
263 ctx
->Extensions
.ARB_vertex_array_object
= GL_TRUE
;
264 ctx
->Extensions
.ARB_vertex_buffer_object
= GL_TRUE
;
265 ctx
->Extensions
.ARB_vertex_program
= GL_TRUE
;
266 ctx
->Extensions
.ARB_window_pos
= GL_TRUE
;
268 ctx
->Extensions
.EXT_blend_color
= GL_TRUE
;
269 ctx
->Extensions
.EXT_blend_func_separate
= GL_TRUE
;
270 ctx
->Extensions
.EXT_blend_minmax
= GL_TRUE
;
271 ctx
->Extensions
.EXT_blend_subtract
= GL_TRUE
;
272 ctx
->Extensions
.EXT_framebuffer_blit
= GL_TRUE
;
273 ctx
->Extensions
.EXT_framebuffer_object
= GL_TRUE
;
274 ctx
->Extensions
.EXT_framebuffer_multisample
= GL_TRUE
;
275 ctx
->Extensions
.EXT_fog_coord
= GL_TRUE
;
276 ctx
->Extensions
.EXT_gpu_program_parameters
= GL_TRUE
;
277 ctx
->Extensions
.EXT_multi_draw_arrays
= GL_TRUE
;
278 ctx
->Extensions
.EXT_pixel_buffer_object
= GL_TRUE
;
279 ctx
->Extensions
.EXT_point_parameters
= GL_TRUE
;
280 ctx
->Extensions
.EXT_provoking_vertex
= GL_TRUE
;
281 ctx
->Extensions
.EXT_secondary_color
= GL_TRUE
;
282 ctx
->Extensions
.EXT_stencil_wrap
= GL_TRUE
;
283 ctx
->Extensions
.EXT_texture_env_add
= GL_TRUE
;
284 ctx
->Extensions
.EXT_texture_env_combine
= GL_TRUE
;
285 ctx
->Extensions
.EXT_texture_env_dot3
= GL_TRUE
;
286 ctx
->Extensions
.EXT_texture_lod_bias
= GL_TRUE
;
287 ctx
->Extensions
.EXT_vertex_array_bgra
= GL_TRUE
;
288 if (ctx
->API
== API_OPENGLES
|| ctx
->API
== API_OPENGLES2
)
289 ctx
->Extensions
.EXT_texture_format_BGRA8888
= GL_TRUE
;
291 ctx
->Extensions
.APPLE_vertex_array_object
= GL_TRUE
;
293 ctx
->Extensions
.ATI_texture_env_combine3
= GL_TRUE
;
295 ctx
->Extensions
.MESA_pack_invert
= GL_TRUE
;
297 ctx
->Extensions
.NV_blend_square
= GL_TRUE
;
298 ctx
->Extensions
.NV_texgen_reflection
= GL_TRUE
;
299 ctx
->Extensions
.NV_texture_env_combine4
= GL_TRUE
;
300 ctx
->Extensions
.NV_texture_rectangle
= GL_TRUE
;
302 /* possibly could support the following two */
303 ctx
->Extensions
.NV_vertex_program
= GL_TRUE
;
304 ctx
->Extensions
.NV_vertex_program1_1
= GL_TRUE
;
307 #if FEATURE_OES_EGL_image
308 ctx
->Extensions
.OES_EGL_image
= GL_TRUE
;
310 #if FEATURE_OES_draw_texture
311 ctx
->Extensions
.OES_draw_texture
= GL_TRUE
;
314 ctx
->Extensions
.SGIS_generate_mipmap
= GL_TRUE
;
317 * Extensions that depend on the driver/hardware:
319 if (screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
) > 0) {
320 ctx
->Extensions
.ARB_draw_buffers
= GL_TRUE
;
323 if (screen
->get_param(screen
, PIPE_CAP_TEXTURE_SWIZZLE
) > 0) {
324 ctx
->Extensions
.EXT_texture_swizzle
= GL_TRUE
;
327 if (screen
->get_param(screen
, PIPE_CAP_GLSL
)) {
328 ctx
->Extensions
.ARB_fragment_shader
= GL_TRUE
;
329 ctx
->Extensions
.ARB_vertex_shader
= GL_TRUE
;
330 ctx
->Extensions
.ARB_shader_objects
= GL_TRUE
;
331 ctx
->Extensions
.ARB_shading_language_100
= GL_TRUE
;
332 ctx
->Extensions
.ARB_explicit_attrib_location
= GL_TRUE
;
333 ctx
->Extensions
.EXT_separate_shader_objects
= GL_TRUE
;
336 if (screen
->get_param(screen
, PIPE_CAP_TEXTURE_MIRROR_REPEAT
) > 0) {
337 ctx
->Extensions
.ARB_texture_mirrored_repeat
= GL_TRUE
;
340 if (screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
)) {
341 ctx
->Extensions
.EXT_blend_equation_separate
= GL_TRUE
;
344 if (screen
->get_param(screen
, PIPE_CAP_TEXTURE_MIRROR_CLAMP
) > 0) {
345 ctx
->Extensions
.EXT_texture_mirror_clamp
= GL_TRUE
;
346 ctx
->Extensions
.ATI_texture_mirror_once
= GL_TRUE
;
349 if (screen
->get_param(screen
, PIPE_CAP_NPOT_TEXTURES
)) {
350 ctx
->Extensions
.ARB_texture_non_power_of_two
= GL_TRUE
;
353 if (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
) > 1) {
354 ctx
->Extensions
.ARB_multitexture
= GL_TRUE
;
357 if (screen
->get_param(screen
, PIPE_CAP_TWO_SIDED_STENCIL
)) {
358 ctx
->Extensions
.ATI_separate_stencil
= GL_TRUE
;
359 ctx
->Extensions
.EXT_stencil_two_side
= GL_TRUE
;
362 if (screen
->get_param(screen
, PIPE_CAP_ANISOTROPIC_FILTER
)) {
363 ctx
->Extensions
.EXT_texture_filter_anisotropic
= GL_TRUE
;
366 if (screen
->get_param(screen
, PIPE_CAP_POINT_SPRITE
)) {
367 ctx
->Extensions
.ARB_point_sprite
= GL_TRUE
;
368 /* GL_NV_point_sprite is not supported by gallium because we don't
369 * support the GL_POINT_SPRITE_R_MODE_NV option.
373 if (screen
->get_param(screen
, PIPE_CAP_OCCLUSION_QUERY
)) {
374 ctx
->Extensions
.ARB_occlusion_query
= GL_TRUE
;
375 ctx
->Extensions
.ARB_occlusion_query2
= GL_TRUE
;
377 if (screen
->get_param(screen
, PIPE_CAP_TIMER_QUERY
)) {
378 ctx
->Extensions
.EXT_timer_query
= GL_TRUE
;
381 if (screen
->get_param(screen
, PIPE_CAP_TEXTURE_SHADOW_MAP
)) {
382 ctx
->Extensions
.ARB_depth_texture
= GL_TRUE
;
383 ctx
->Extensions
.ARB_fragment_program_shadow
= GL_TRUE
;
384 ctx
->Extensions
.ARB_shadow
= GL_TRUE
;
385 ctx
->Extensions
.EXT_shadow_funcs
= GL_TRUE
;
386 /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
389 /* GL_EXT_packed_depth_stencil requires both the ability to render to
390 * a depth/stencil buffer and texture from depth/stencil source.
392 if (screen
->is_format_supported(screen
, PIPE_FORMAT_S8_USCALED_Z24_UNORM
,
394 PIPE_BIND_DEPTH_STENCIL
) &&
395 screen
->is_format_supported(screen
, PIPE_FORMAT_S8_USCALED_Z24_UNORM
,
397 PIPE_BIND_SAMPLER_VIEW
)) {
398 ctx
->Extensions
.EXT_packed_depth_stencil
= GL_TRUE
;
400 else if (screen
->is_format_supported(screen
, PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
402 PIPE_BIND_DEPTH_STENCIL
) &&
403 screen
->is_format_supported(screen
, PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
405 PIPE_BIND_SAMPLER_VIEW
)) {
406 ctx
->Extensions
.EXT_packed_depth_stencil
= GL_TRUE
;
409 /* float support - assume nothing exclusively supports 64-bit floats */
410 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
412 PIPE_BIND_SAMPLER_VIEW
|
413 PIPE_BIND_RENDER_TARGET
) &&
414 screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_FLOAT
,
416 PIPE_BIND_SAMPLER_VIEW
|
417 PIPE_BIND_RENDER_TARGET
)) {
418 ctx
->Extensions
.ARB_texture_float
= GL_TRUE
;
422 if (screen
->is_format_supported(screen
, PIPE_FORMAT_A8B8G8R8_SRGB
,
424 PIPE_BIND_SAMPLER_VIEW
) ||
425 screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_SRGB
,
427 PIPE_BIND_SAMPLER_VIEW
)) {
428 ctx
->Extensions
.EXT_texture_sRGB
= GL_TRUE
;
429 ctx
->Extensions
.EXT_texture_sRGB_decode
= GL_TRUE
;
430 if (screen
->is_format_supported(screen
, PIPE_FORMAT_A8B8G8R8_SRGB
,
432 PIPE_BIND_RENDER_TARGET
) ||
433 screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_SRGB
,
435 PIPE_BIND_RENDER_TARGET
)) {
436 ctx
->Extensions
.EXT_framebuffer_sRGB
= GL_TRUE
;
437 ctx
->Const
.sRGBCapable
= GL_TRUE
;
441 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R8G8_UNORM
,
443 PIPE_BIND_SAMPLER_VIEW
)) {
444 ctx
->Extensions
.ARB_texture_rg
= GL_TRUE
;
448 if (screen
->is_format_supported(screen
, PIPE_FORMAT_DXT5_RGBA
,
450 PIPE_BIND_SAMPLER_VIEW
) &&
451 (ctx
->Mesa_DXTn
|| st_get_s3tc_override())) {
452 ctx
->Extensions
.EXT_texture_compression_s3tc
= GL_TRUE
;
453 ctx
->Extensions
.S3_s3tc
= GL_TRUE
;
456 if (screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC1_UNORM
,
458 PIPE_BIND_SAMPLER_VIEW
) &&
459 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC1_SNORM
,
461 PIPE_BIND_SAMPLER_VIEW
) &&
462 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC2_UNORM
,
464 PIPE_BIND_SAMPLER_VIEW
) &&
465 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC2_SNORM
,
467 PIPE_BIND_SAMPLER_VIEW
)
469 ctx
->Extensions
.ARB_texture_compression_rgtc
= GL_TRUE
;
472 if (screen
->is_format_supported(screen
, PIPE_FORMAT_LATC1_UNORM
,
474 PIPE_BIND_SAMPLER_VIEW
) &&
475 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC1_SNORM
,
477 PIPE_BIND_SAMPLER_VIEW
) &&
478 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_UNORM
,
480 PIPE_BIND_SAMPLER_VIEW
) &&
481 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_SNORM
,
483 PIPE_BIND_SAMPLER_VIEW
)) {
484 ctx
->Extensions
.EXT_texture_compression_latc
= GL_TRUE
;
487 if (screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_UNORM
,
489 PIPE_BIND_SAMPLER_VIEW
)) {
490 ctx
->Extensions
.ATI_texture_compression_3dc
= GL_TRUE
;
493 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R8G8B8A8_SNORM
,
495 PIPE_BIND_SAMPLER_VIEW
)) {
496 ctx
->Extensions
.EXT_texture_snorm
= GL_TRUE
;
500 if (screen
->is_format_supported(screen
, PIPE_FORMAT_UYVY
,
502 PIPE_BIND_SAMPLER_VIEW
) ||
503 screen
->is_format_supported(screen
, PIPE_FORMAT_YUYV
,
505 PIPE_BIND_SAMPLER_VIEW
)) {
506 ctx
->Extensions
.MESA_ycbcr_texture
= GL_TRUE
;
509 /* GL_EXT_texture_array */
510 if (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
) > 1) {
511 ctx
->Extensions
.EXT_texture_array
= GL_TRUE
;
512 ctx
->Extensions
.MESA_texture_array
= GL_TRUE
;
515 /* GL_ARB_framebuffer_object */
516 if (ctx
->Extensions
.EXT_packed_depth_stencil
) {
517 /* we support always support GL_EXT_framebuffer_blit */
518 ctx
->Extensions
.ARB_framebuffer_object
= GL_TRUE
;
521 if (st
->pipe
->render_condition
) {
522 ctx
->Extensions
.NV_conditional_render
= GL_TRUE
;
525 if (screen
->get_param(screen
, PIPE_CAP_INDEP_BLEND_ENABLE
)) {
526 ctx
->Extensions
.EXT_draw_buffers2
= GL_TRUE
;
529 if (screen
->get_param(screen
, PIPE_CAP_INDEP_BLEND_FUNC
)) {
530 ctx
->Extensions
.ARB_draw_buffers_blend
= GL_TRUE
;
533 /* GL_ARB_half_float_vertex */
534 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_FLOAT
,
536 PIPE_BIND_VERTEX_BUFFER
)) {
537 ctx
->Extensions
.ARB_half_float_vertex
= GL_TRUE
;
540 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_FIXED
,
542 PIPE_BIND_VERTEX_BUFFER
)) {
543 ctx
->Extensions
.ARB_ES2_compatibility
= GL_TRUE
;
546 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_UNORM
,
548 PIPE_BIND_VERTEX_BUFFER
) &&
549 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_UNORM
,
551 PIPE_BIND_VERTEX_BUFFER
) &&
552 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_SNORM
,
554 PIPE_BIND_VERTEX_BUFFER
) &&
555 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_SNORM
,
557 PIPE_BIND_VERTEX_BUFFER
) &&
558 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_USCALED
,
560 PIPE_BIND_VERTEX_BUFFER
) &&
561 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_USCALED
,
563 PIPE_BIND_VERTEX_BUFFER
) &&
564 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_SSCALED
,
566 PIPE_BIND_VERTEX_BUFFER
) &&
567 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_SSCALED
,
569 PIPE_BIND_VERTEX_BUFFER
)) {
570 ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
= GL_TRUE
;
573 if (screen
->get_shader_param(screen
, PIPE_SHADER_GEOMETRY
, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
) > 0) {
574 #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
575 ctx
->Extensions
.ARB_geometry_shader4
= GL_TRUE
;
579 if (screen
->get_param(screen
, PIPE_CAP_PRIMITIVE_RESTART
)) {
580 ctx
->Extensions
.NV_primitive_restart
= GL_TRUE
;
583 if (screen
->get_param(screen
, PIPE_CAP_DEPTH_CLAMP
)) {
584 ctx
->Extensions
.ARB_depth_clamp
= GL_TRUE
;
587 /* This extension does not actually require support of floating point
588 * render targets, just clamping controls.
589 * Advertise this extension if either fragment color clamping is supported
590 * or no render targets having color values outside of the range [0, 1]
591 * are supported, in which case the fragment color clamping has no effect
594 if (screen
->get_param(screen
, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL
) ||
595 (!screen
->is_format_supported(screen
, PIPE_FORMAT_R8G8B8A8_SNORM
,
597 PIPE_BIND_RENDER_TARGET
) &&
598 !screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_SNORM
,
600 PIPE_BIND_RENDER_TARGET
) &&
601 !screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_FLOAT
,
603 PIPE_BIND_RENDER_TARGET
) &&
604 !screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
606 PIPE_BIND_RENDER_TARGET
) &&
607 !screen
->is_format_supported(screen
, PIPE_FORMAT_R11G11B10_FLOAT
,
609 PIPE_BIND_RENDER_TARGET
) &&
610 !screen
->is_format_supported(screen
, PIPE_FORMAT_R9G9B9E5_FLOAT
,
612 PIPE_BIND_RENDER_TARGET
))) {
613 ctx
->Extensions
.ARB_color_buffer_float
= GL_TRUE
;
616 if (screen
->get_param(screen
, PIPE_CAP_SHADER_STENCIL_EXPORT
)) {
617 ctx
->Extensions
.ARB_shader_stencil_export
= GL_TRUE
;
620 if (screen
->get_param(screen
, PIPE_CAP_TGSI_INSTANCEID
)) {
621 ctx
->Extensions
.ARB_draw_instanced
= GL_TRUE
;
623 if (screen
->get_param(screen
, PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR
)) {
624 ctx
->Extensions
.ARB_instanced_arrays
= GL_TRUE
;
627 if (screen
->fence_finish
) {
628 ctx
->Extensions
.ARB_sync
= GL_TRUE
;
631 if (st
->pipe
->texture_barrier
) {
632 ctx
->Extensions
.NV_texture_barrier
= GL_TRUE
;
635 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R9G9B9E5_FLOAT
,
637 PIPE_BIND_SAMPLER_VIEW
)) {
638 ctx
->Extensions
.EXT_texture_shared_exponent
= GL_TRUE
;
641 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R11G11B10_FLOAT
,
643 PIPE_BIND_RENDER_TARGET
|
644 PIPE_BIND_SAMPLER_VIEW
)) {
645 ctx
->Extensions
.EXT_packed_float
= GL_TRUE
;
648 /* Maximum sample count. */
649 for (i
= 16; i
> 0; --i
) {
650 if (screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_UNORM
,
652 PIPE_BIND_RENDER_TARGET
)) {
653 ctx
->Const
.MaxSamples
= i
;
658 if (screen
->get_param(screen
, PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE
)) {
659 ctx
->Extensions
.ARB_seamless_cube_map
= GL_TRUE
;
660 ctx
->Extensions
.AMD_seamless_cubemap_per_texture
= GL_TRUE
;
662 else if (screen
->get_param(screen
, PIPE_CAP_SEAMLESS_CUBE_MAP
)) {
663 ctx
->Extensions
.ARB_seamless_cube_map
= GL_TRUE
;
666 if (screen
->get_param(screen
, PIPE_CAP_SM3
)) {
667 ctx
->Extensions
.ARB_shader_texture_lod
= GL_TRUE
;
670 if (screen
->is_format_supported(screen
, PIPE_FORMAT_Z32_FLOAT
,
672 PIPE_BIND_DEPTH_STENCIL
|
673 PIPE_BIND_SAMPLER_VIEW
) &&
674 screen
->is_format_supported(screen
, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED
,
676 PIPE_BIND_DEPTH_STENCIL
|
677 PIPE_BIND_SAMPLER_VIEW
)) {
678 ctx
->Extensions
.ARB_depth_buffer_float
= GL_TRUE
;