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"
33 #include "main/version.h"
35 #include "pipe/p_context.h"
36 #include "pipe/p_defines.h"
37 #include "pipe/p_screen.h"
39 #include "st_context.h"
40 #include "st_extensions.h"
43 static int _min(int a
, int b
)
45 return (a
< b
) ? a
: b
;
48 static float _maxf(float a
, float b
)
50 return (a
> b
) ? a
: b
;
53 static int _clamp(int a
, int min
, int max
)
65 * Query driver to get implementation limits.
66 * Note that we have to limit/clamp against Mesa's internal limits too.
68 void st_init_limits(struct st_context
*st
)
70 struct pipe_screen
*screen
= st
->pipe
->screen
;
71 struct gl_constants
*c
= &st
->ctx
->Const
;
75 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
),
79 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
),
80 MAX_3D_TEXTURE_LEVELS
);
82 c
->MaxCubeTextureLevels
83 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
),
84 MAX_CUBE_TEXTURE_LEVELS
);
87 = _min(1 << (c
->MaxTextureLevels
- 1), MAX_TEXTURE_RECT_SIZE
);
89 c
->MaxArrayTextureLayers
90 = screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
);
92 c
->MaxTextureImageUnits
93 = _min(screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
94 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
),
95 MAX_TEXTURE_IMAGE_UNITS
);
97 c
->MaxVertexTextureImageUnits
98 = _min(screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
99 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
),
100 MAX_VERTEX_TEXTURE_IMAGE_UNITS
);
102 c
->MaxCombinedTextureImageUnits
103 = _min(screen
->get_param(screen
, PIPE_CAP_MAX_COMBINED_SAMPLERS
),
104 MAX_COMBINED_TEXTURE_IMAGE_UNITS
);
106 c
->MaxTextureCoordUnits
107 = _min(c
->MaxTextureImageUnits
, MAX_TEXTURE_COORD_UNITS
);
109 c
->MaxTextureUnits
= _min(c
->MaxTextureImageUnits
, c
->MaxTextureCoordUnits
);
112 = _clamp(screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
),
113 1, MAX_DRAW_BUFFERS
);
116 = _maxf(1.0f
, screen
->get_paramf(screen
,
117 PIPE_CAPF_MAX_LINE_WIDTH
));
119 = _maxf(1.0f
, screen
->get_paramf(screen
,
120 PIPE_CAPF_MAX_LINE_WIDTH_AA
));
123 = _maxf(1.0f
, screen
->get_paramf(screen
,
124 PIPE_CAPF_MAX_POINT_WIDTH
));
126 = _maxf(1.0f
, screen
->get_paramf(screen
,
127 PIPE_CAPF_MAX_POINT_WIDTH_AA
));
128 /* called after _mesa_create_context/_mesa_init_point, fix default user
129 * settable max point size up
131 st
->ctx
->Point
.MaxSize
= MAX2(c
->MaxPointSize
, c
->MaxPointSizeAA
);
132 /* these are not queryable. Note that GL basically mandates a 1.0 minimum
133 * for non-aa sizes, but we can go down to 0.0 for aa points.
135 c
->MinPointSize
= 1.0f
;
136 c
->MinPointSizeAA
= 0.0f
;
138 c
->MaxTextureMaxAnisotropy
139 = _maxf(2.0f
, screen
->get_paramf(screen
,
140 PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
));
143 = screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS
);
146 = CLAMP(screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
),
147 1, MAX_DRAW_BUFFERS
);
149 /* Quads always follow GL provoking rules. */
150 c
->QuadsFollowProvokingVertexConvention
= GL_FALSE
;
152 for (sh
= 0; sh
< MESA_SHADER_TYPES
; ++sh
) {
153 struct gl_shader_compiler_options
*options
=
154 &st
->ctx
->ShaderCompilerOptions
[sh
];
155 struct gl_program_constants
*pc
;
158 case PIPE_SHADER_FRAGMENT
:
159 pc
= &c
->FragmentProgram
;
161 case PIPE_SHADER_VERTEX
:
162 pc
= &c
->VertexProgram
;
164 case PIPE_SHADER_GEOMETRY
:
165 pc
= &c
->GeometryProgram
;
172 pc
->MaxNativeInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
173 pc
->MaxNativeAluInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
);
174 pc
->MaxNativeTexInstructions
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
);
175 pc
->MaxNativeTexIndirections
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
);
176 pc
->MaxNativeAttribs
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INPUTS
);
177 pc
->MaxNativeTemps
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_TEMPS
);
178 pc
->MaxNativeAddressRegs
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_ADDRS
);
179 pc
->MaxNativeParameters
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONSTS
);
180 pc
->MaxUniformComponents
= 4 * MIN2(pc
->MaxNativeParameters
, MAX_UNIFORMS
);
181 /* raise MaxParameters if native support is higher */
182 pc
->MaxParameters
= MAX2(pc
->MaxParameters
, pc
->MaxNativeParameters
);
184 /* Gallium doesn't really care about local vs. env parameters so use the
187 pc
->MaxLocalParams
= MIN2(pc
->MaxParameters
, MAX_PROGRAM_LOCAL_PARAMS
);
188 pc
->MaxEnvParams
= MIN2(pc
->MaxParameters
, MAX_PROGRAM_ENV_PARAMS
);
190 options
->EmitNoNoise
= TRUE
;
192 /* TODO: make these more fine-grained if anyone needs it */
193 options
->MaxIfDepth
= screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
194 options
->EmitNoLoops
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
195 options
->EmitNoFunctions
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_SUBROUTINES
);
196 options
->EmitNoMainReturn
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_SUBROUTINES
);
198 options
->EmitNoCont
= !screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
);
200 options
->EmitNoIndirectInput
= !screen
->get_shader_param(screen
, sh
,
201 PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
);
202 options
->EmitNoIndirectOutput
= !screen
->get_shader_param(screen
, sh
,
203 PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
);
204 options
->EmitNoIndirectTemp
= !screen
->get_shader_param(screen
, sh
,
205 PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
);
206 options
->EmitNoIndirectUniform
= !screen
->get_shader_param(screen
, sh
,
207 PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
);
209 if (options
->EmitNoLoops
)
210 options
->MaxUnrollIterations
= MIN2(screen
->get_shader_param(screen
, sh
, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
), 65536);
213 /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
214 * of inputs. It's always 2 colors + N generic inputs. */
215 c
->MaxVarying
= screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
216 PIPE_SHADER_CAP_MAX_INPUTS
);
217 c
->MaxVarying
= MIN2(c
->MaxVarying
, MAX_VARYING
);
219 c
->MinProgramTexelOffset
= screen
->get_param(screen
, PIPE_CAP_MIN_TEXEL_OFFSET
);
220 c
->MaxProgramTexelOffset
= screen
->get_param(screen
, PIPE_CAP_MAX_TEXEL_OFFSET
);
222 c
->UniformBooleanTrue
= ~0;
224 c
->MaxTransformFeedbackSeparateAttribs
=
225 screen
->get_param(screen
, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS
);
226 c
->MaxTransformFeedbackSeparateComponents
=
227 screen
->get_param(screen
, PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS
);
228 c
->MaxTransformFeedbackInterleavedComponents
=
229 screen
->get_param(screen
, PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS
);
231 c
->StripTextureBorder
= GL_TRUE
;
233 c
->GLSLSkipStrictMaxUniformLimitCheck
=
234 screen
->get_param(screen
, PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS
);
236 c
->GLSLSkipStrictMaxVaryingLimitCheck
=
237 screen
->get_param(screen
, PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS
);
241 static GLboolean
st_get_s3tc_override(void)
243 const char *override
= _mesa_getenv("force_s3tc_enable");
244 if (override
&& !strcmp(override
, "true"))
250 * Given a member \c x of struct gl_extensions, return offset of
253 #define o(x) offsetof(struct gl_extensions, x)
256 struct st_extension_cap_mapping
{
257 int extension_offset
;
263 * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
264 * which GL extensions are supported.
265 * Quite a few extensions are always supported because they are standard
266 * features or can be built on top of other gallium features.
267 * Some fine tuning may still be needed.
269 void st_init_extensions(struct st_context
*st
)
271 struct pipe_screen
*screen
= st
->pipe
->screen
;
272 struct gl_context
*ctx
= st
->ctx
;
273 int i
, glsl_feature_level
;
274 GLboolean
*extensions
= (GLboolean
*) &ctx
->Extensions
;
276 static const struct st_extension_cap_mapping cap_mapping
[] = {
277 { o(ARB_depth_clamp
), PIPE_CAP_DEPTH_CLIP_DISABLE
},
278 { o(ARB_depth_texture
), PIPE_CAP_TEXTURE_SHADOW_MAP
},
279 { o(ARB_draw_buffers_blend
), PIPE_CAP_INDEP_BLEND_FUNC
},
280 { o(ARB_draw_instanced
), PIPE_CAP_TGSI_INSTANCEID
},
281 { o(ARB_fragment_program_shadow
), PIPE_CAP_TEXTURE_SHADOW_MAP
},
282 { o(ARB_instanced_arrays
), PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR
},
283 { o(ARB_occlusion_query
), PIPE_CAP_OCCLUSION_QUERY
},
284 { o(ARB_occlusion_query2
), PIPE_CAP_OCCLUSION_QUERY
},
285 { o(ARB_point_sprite
), PIPE_CAP_POINT_SPRITE
},
286 { o(ARB_seamless_cube_map
), PIPE_CAP_SEAMLESS_CUBE_MAP
},
287 { o(ARB_shader_stencil_export
), PIPE_CAP_SHADER_STENCIL_EXPORT
},
288 { o(ARB_shader_texture_lod
), PIPE_CAP_SM3
},
289 { o(ARB_shadow
), PIPE_CAP_TEXTURE_SHADOW_MAP
},
290 { o(ARB_texture_non_power_of_two
), PIPE_CAP_NPOT_TEXTURES
},
291 { o(ARB_transform_feedback2
), PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME
},
293 { o(EXT_blend_equation_separate
), PIPE_CAP_BLEND_EQUATION_SEPARATE
},
294 { o(EXT_draw_buffers2
), PIPE_CAP_INDEP_BLEND_ENABLE
},
295 { o(EXT_shadow_funcs
), PIPE_CAP_TEXTURE_SHADOW_MAP
},
296 { o(EXT_stencil_two_side
), PIPE_CAP_TWO_SIDED_STENCIL
},
297 { o(EXT_texture_array
), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
},
298 { o(EXT_texture_filter_anisotropic
), PIPE_CAP_ANISOTROPIC_FILTER
},
299 { o(EXT_texture_mirror_clamp
), PIPE_CAP_TEXTURE_MIRROR_CLAMP
},
300 { o(EXT_texture_swizzle
), PIPE_CAP_TEXTURE_SWIZZLE
},
301 { o(EXT_timer_query
), PIPE_CAP_TIMER_QUERY
},
302 { o(EXT_transform_feedback
), PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS
},
304 { o(AMD_seamless_cubemap_per_texture
), PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE
},
305 { o(ATI_separate_stencil
), PIPE_CAP_TWO_SIDED_STENCIL
},
306 { o(ATI_texture_mirror_once
), PIPE_CAP_TEXTURE_MIRROR_CLAMP
},
307 { o(NV_conditional_render
), PIPE_CAP_CONDITIONAL_RENDER
},
308 { o(NV_texture_barrier
), PIPE_CAP_TEXTURE_BARRIER
},
309 /* GL_NV_point_sprite is not supported by gallium because we don't
310 * support the GL_POINT_SPRITE_R_MODE_NV option. */
311 { o(MESA_texture_array
), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS
},
315 * Extensions that are supported by all Gallium drivers:
317 ctx
->Extensions
.ARB_copy_buffer
= GL_TRUE
;
318 ctx
->Extensions
.ARB_draw_elements_base_vertex
= GL_TRUE
;
319 ctx
->Extensions
.ARB_explicit_attrib_location
= GL_TRUE
;
320 ctx
->Extensions
.ARB_fragment_coord_conventions
= GL_TRUE
;
321 ctx
->Extensions
.ARB_fragment_program
= GL_TRUE
;
322 ctx
->Extensions
.ARB_fragment_shader
= GL_TRUE
;
323 ctx
->Extensions
.ARB_half_float_pixel
= GL_TRUE
;
324 ctx
->Extensions
.ARB_map_buffer_range
= GL_TRUE
;
325 ctx
->Extensions
.ARB_sampler_objects
= GL_TRUE
;
326 ctx
->Extensions
.ARB_shader_objects
= GL_TRUE
;
327 ctx
->Extensions
.ARB_shading_language_100
= GL_TRUE
;
328 ctx
->Extensions
.ARB_texture_border_clamp
= GL_TRUE
; /* XXX temp */
329 ctx
->Extensions
.ARB_texture_cube_map
= GL_TRUE
;
330 ctx
->Extensions
.ARB_texture_env_combine
= GL_TRUE
;
331 ctx
->Extensions
.ARB_texture_env_crossbar
= GL_TRUE
;
332 ctx
->Extensions
.ARB_texture_env_dot3
= GL_TRUE
;
333 ctx
->Extensions
.ARB_texture_storage
= GL_TRUE
;
334 ctx
->Extensions
.ARB_vertex_array_object
= GL_TRUE
;
335 ctx
->Extensions
.ARB_vertex_program
= GL_TRUE
;
336 ctx
->Extensions
.ARB_vertex_shader
= GL_TRUE
;
337 ctx
->Extensions
.ARB_window_pos
= GL_TRUE
;
339 ctx
->Extensions
.EXT_blend_color
= GL_TRUE
;
340 ctx
->Extensions
.EXT_blend_func_separate
= GL_TRUE
;
341 ctx
->Extensions
.EXT_blend_minmax
= GL_TRUE
;
342 ctx
->Extensions
.EXT_framebuffer_blit
= GL_TRUE
;
343 ctx
->Extensions
.EXT_framebuffer_object
= GL_TRUE
;
344 ctx
->Extensions
.EXT_framebuffer_multisample
= GL_TRUE
;
345 ctx
->Extensions
.EXT_fog_coord
= GL_TRUE
;
346 ctx
->Extensions
.EXT_gpu_program_parameters
= GL_TRUE
;
347 ctx
->Extensions
.EXT_pixel_buffer_object
= GL_TRUE
;
348 ctx
->Extensions
.EXT_point_parameters
= GL_TRUE
;
349 ctx
->Extensions
.EXT_provoking_vertex
= GL_TRUE
;
350 ctx
->Extensions
.EXT_secondary_color
= GL_TRUE
;
351 ctx
->Extensions
.EXT_separate_shader_objects
= GL_TRUE
;
352 ctx
->Extensions
.EXT_texture_env_dot3
= GL_TRUE
;
353 ctx
->Extensions
.EXT_vertex_array_bgra
= GL_TRUE
;
355 ctx
->Extensions
.APPLE_vertex_array_object
= GL_TRUE
;
357 ctx
->Extensions
.ATI_texture_env_combine3
= GL_TRUE
;
359 ctx
->Extensions
.MESA_pack_invert
= GL_TRUE
;
361 ctx
->Extensions
.NV_blend_square
= GL_TRUE
;
362 ctx
->Extensions
.NV_fog_distance
= GL_TRUE
;
363 ctx
->Extensions
.NV_texgen_reflection
= GL_TRUE
;
364 ctx
->Extensions
.NV_texture_env_combine4
= GL_TRUE
;
365 ctx
->Extensions
.NV_texture_rectangle
= GL_TRUE
;
367 /* possibly could support the following two */
368 ctx
->Extensions
.NV_vertex_program
= GL_TRUE
;
369 ctx
->Extensions
.NV_vertex_program1_1
= GL_TRUE
;
372 #if FEATURE_OES_EGL_image
373 ctx
->Extensions
.OES_EGL_image
= GL_TRUE
;
374 if (ctx
->API
!= API_OPENGL
)
375 ctx
->Extensions
.OES_EGL_image_external
= GL_TRUE
;
377 #if FEATURE_OES_draw_texture
378 ctx
->Extensions
.OES_draw_texture
= GL_TRUE
;
381 /* Expose the extensions which directly correspond to gallium caps. */
382 for (i
= 0; i
< Elements(cap_mapping
); i
++) {
383 if (screen
->get_param(screen
, cap_mapping
[i
].cap
)) {
384 extensions
[cap_mapping
[i
].extension_offset
] = GL_TRUE
;
388 /* Figure out GLSL support. */
389 glsl_feature_level
= screen
->get_param(screen
, PIPE_CAP_GLSL_FEATURE_LEVEL
);
391 if (glsl_feature_level
>= 130) {
392 ctx
->Const
.GLSLVersion
= 130;
394 ctx
->Const
.GLSLVersion
= 120;
397 _mesa_override_glsl_version(st
->ctx
);
399 if (ctx
->Const
.GLSLVersion
>= 130) {
400 ctx
->Const
.NativeIntegers
= GL_TRUE
;
401 ctx
->Const
.MaxClipPlanes
= 8;
403 /* Extensions that only depend on GLSL 1.3. */
404 ctx
->Extensions
.ARB_conservative_depth
= GL_TRUE
;
406 /* Optional integer support for GLSL 1.2. */
407 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
408 PIPE_SHADER_CAP_INTEGERS
) &&
409 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
410 PIPE_SHADER_CAP_INTEGERS
)) {
411 ctx
->Const
.NativeIntegers
= GL_TRUE
;
416 * Extensions that depend on the driver/hardware:
418 /* GL_EXT_packed_depth_stencil requires both the ability to render to
419 * a depth/stencil buffer and texture from depth/stencil source.
421 if (screen
->is_format_supported(screen
, PIPE_FORMAT_S8_UINT_Z24_UNORM
,
423 PIPE_BIND_DEPTH_STENCIL
|
424 PIPE_BIND_SAMPLER_VIEW
) ||
425 screen
->is_format_supported(screen
, PIPE_FORMAT_Z24_UNORM_S8_UINT
,
427 PIPE_BIND_DEPTH_STENCIL
|
428 PIPE_BIND_SAMPLER_VIEW
)) {
429 ctx
->Extensions
.EXT_packed_depth_stencil
= GL_TRUE
;
430 ctx
->Extensions
.ARB_framebuffer_object
= GL_TRUE
;
433 /* float support - assume nothing exclusively supports 64-bit floats */
434 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
436 PIPE_BIND_SAMPLER_VIEW
|
437 PIPE_BIND_RENDER_TARGET
) &&
438 screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_FLOAT
,
440 PIPE_BIND_SAMPLER_VIEW
|
441 PIPE_BIND_RENDER_TARGET
)) {
442 ctx
->Extensions
.ARB_texture_float
= GL_TRUE
;
446 if (screen
->is_format_supported(screen
, PIPE_FORMAT_A8B8G8R8_SRGB
,
448 PIPE_BIND_SAMPLER_VIEW
) ||
449 screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_SRGB
,
451 PIPE_BIND_SAMPLER_VIEW
)) {
452 ctx
->Extensions
.EXT_texture_sRGB
= GL_TRUE
;
453 ctx
->Extensions
.EXT_texture_sRGB_decode
= GL_TRUE
;
454 if (screen
->is_format_supported(screen
, PIPE_FORMAT_A8B8G8R8_SRGB
,
456 PIPE_BIND_RENDER_TARGET
) ||
457 screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_SRGB
,
459 PIPE_BIND_RENDER_TARGET
)) {
460 ctx
->Extensions
.EXT_framebuffer_sRGB
= GL_TRUE
;
464 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R8G8_UNORM
,
466 PIPE_BIND_SAMPLER_VIEW
)) {
467 ctx
->Extensions
.ARB_texture_rg
= GL_TRUE
;
471 if (screen
->is_format_supported(screen
, PIPE_FORMAT_DXT1_RGB
,
473 PIPE_BIND_SAMPLER_VIEW
) &&
474 screen
->is_format_supported(screen
, PIPE_FORMAT_DXT1_RGBA
,
476 PIPE_BIND_SAMPLER_VIEW
) &&
477 screen
->is_format_supported(screen
, PIPE_FORMAT_DXT3_RGBA
,
479 PIPE_BIND_SAMPLER_VIEW
) &&
480 screen
->is_format_supported(screen
, PIPE_FORMAT_DXT5_RGBA
,
482 PIPE_BIND_SAMPLER_VIEW
) &&
483 (ctx
->Mesa_DXTn
|| st_get_s3tc_override())) {
484 ctx
->Extensions
.EXT_texture_compression_s3tc
= GL_TRUE
;
485 ctx
->Extensions
.S3_s3tc
= GL_TRUE
;
488 if (screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC1_UNORM
,
490 PIPE_BIND_SAMPLER_VIEW
) &&
491 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC1_SNORM
,
493 PIPE_BIND_SAMPLER_VIEW
) &&
494 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC2_UNORM
,
496 PIPE_BIND_SAMPLER_VIEW
) &&
497 screen
->is_format_supported(screen
, PIPE_FORMAT_RGTC2_SNORM
,
499 PIPE_BIND_SAMPLER_VIEW
)
501 ctx
->Extensions
.ARB_texture_compression_rgtc
= GL_TRUE
;
504 if (screen
->is_format_supported(screen
, PIPE_FORMAT_LATC1_UNORM
,
506 PIPE_BIND_SAMPLER_VIEW
) &&
507 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC1_SNORM
,
509 PIPE_BIND_SAMPLER_VIEW
) &&
510 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_UNORM
,
512 PIPE_BIND_SAMPLER_VIEW
) &&
513 screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_SNORM
,
515 PIPE_BIND_SAMPLER_VIEW
)) {
516 ctx
->Extensions
.EXT_texture_compression_latc
= GL_TRUE
;
519 if (screen
->is_format_supported(screen
, PIPE_FORMAT_LATC2_UNORM
,
521 PIPE_BIND_SAMPLER_VIEW
)) {
522 ctx
->Extensions
.ATI_texture_compression_3dc
= GL_TRUE
;
525 if (ctx
->API
!= API_OPENGL
) {
526 if (screen
->is_format_supported(screen
, PIPE_FORMAT_ETC1_RGB8
,
528 PIPE_BIND_SAMPLER_VIEW
)) {
529 ctx
->Extensions
.OES_compressed_ETC1_RGB8_texture
= GL_TRUE
;
533 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R8G8B8A8_SNORM
,
535 PIPE_BIND_SAMPLER_VIEW
)) {
536 ctx
->Extensions
.EXT_texture_snorm
= GL_TRUE
;
540 if (screen
->is_format_supported(screen
, PIPE_FORMAT_UYVY
,
542 PIPE_BIND_SAMPLER_VIEW
) ||
543 screen
->is_format_supported(screen
, PIPE_FORMAT_YUYV
,
545 PIPE_BIND_SAMPLER_VIEW
)) {
546 ctx
->Extensions
.MESA_ycbcr_texture
= GL_TRUE
;
549 /* GL_ARB_half_float_vertex */
550 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R16G16B16A16_FLOAT
,
552 PIPE_BIND_VERTEX_BUFFER
)) {
553 ctx
->Extensions
.ARB_half_float_vertex
= GL_TRUE
;
556 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_FIXED
,
558 PIPE_BIND_VERTEX_BUFFER
)) {
559 ctx
->Extensions
.ARB_ES2_compatibility
= GL_TRUE
;
562 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_UNORM
,
564 PIPE_BIND_VERTEX_BUFFER
) &&
565 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_UNORM
,
567 PIPE_BIND_VERTEX_BUFFER
) &&
568 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_SNORM
,
570 PIPE_BIND_VERTEX_BUFFER
) &&
571 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_SNORM
,
573 PIPE_BIND_VERTEX_BUFFER
) &&
574 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_USCALED
,
576 PIPE_BIND_VERTEX_BUFFER
) &&
577 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_USCALED
,
579 PIPE_BIND_VERTEX_BUFFER
) &&
580 screen
->is_format_supported(screen
, PIPE_FORMAT_R10G10B10A2_SSCALED
,
582 PIPE_BIND_VERTEX_BUFFER
) &&
583 screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_SSCALED
,
585 PIPE_BIND_VERTEX_BUFFER
)) {
586 ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
= GL_TRUE
;
589 if (screen
->get_shader_param(screen
, PIPE_SHADER_GEOMETRY
,
590 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
) > 0) {
591 #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
592 ctx
->Extensions
.ARB_geometry_shader4
= GL_TRUE
;
596 ctx
->Extensions
.NV_primitive_restart
= GL_TRUE
;
597 if (!screen
->get_param(screen
, PIPE_CAP_PRIMITIVE_RESTART
)) {
598 st
->sw_primitive_restart
= GL_TRUE
;
601 if (screen
->get_param(screen
, PIPE_CAP_VERTEX_COLOR_UNCLAMPED
)) {
602 ctx
->Extensions
.ARB_color_buffer_float
= GL_TRUE
;
604 if (!screen
->get_param(screen
, PIPE_CAP_VERTEX_COLOR_CLAMPED
)) {
605 st
->clamp_vert_color_in_shader
= TRUE
;
608 if (!screen
->get_param(screen
, PIPE_CAP_FRAGMENT_COLOR_CLAMPED
)) {
609 st
->clamp_frag_color_in_shader
= TRUE
;
613 if (screen
->fence_finish
) {
614 ctx
->Extensions
.ARB_sync
= GL_TRUE
;
617 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R9G9B9E5_FLOAT
,
619 PIPE_BIND_SAMPLER_VIEW
)) {
620 ctx
->Extensions
.EXT_texture_shared_exponent
= GL_TRUE
;
623 if (screen
->is_format_supported(screen
, PIPE_FORMAT_R11G11B10_FLOAT
,
625 PIPE_BIND_RENDER_TARGET
|
626 PIPE_BIND_SAMPLER_VIEW
)) {
627 ctx
->Extensions
.EXT_packed_float
= GL_TRUE
;
630 /* Maximum sample count. */
631 for (i
= 16; i
> 0; --i
) {
632 if (screen
->is_format_supported(screen
, PIPE_FORMAT_B8G8R8A8_UNORM
,
634 PIPE_BIND_RENDER_TARGET
)) {
635 ctx
->Const
.MaxSamples
= i
;
640 if (screen
->is_format_supported(screen
, PIPE_FORMAT_Z32_FLOAT
,
642 PIPE_BIND_DEPTH_STENCIL
|
643 PIPE_BIND_SAMPLER_VIEW
) &&
644 screen
->is_format_supported(screen
, PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
,
646 PIPE_BIND_DEPTH_STENCIL
|
647 PIPE_BIND_SAMPLER_VIEW
)) {
648 ctx
->Extensions
.ARB_depth_buffer_float
= GL_TRUE
;
651 if (screen
->is_format_supported(screen
, PIPE_FORMAT_B10G10R10A2_UINT
,
653 PIPE_BIND_SAMPLER_VIEW
))
654 ctx
->Extensions
.ARB_texture_rgb10_a2ui
= GL_TRUE
;
656 if (ctx
->Const
.NativeIntegers
&&
657 screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_UINT
, PIPE_TEXTURE_2D
, 0,
658 PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
) &&
659 screen
->is_format_supported(screen
, PIPE_FORMAT_R32G32B32A32_SINT
, PIPE_TEXTURE_2D
, 0,
660 PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
))
661 ctx
->Extensions
.EXT_texture_integer
= GL_TRUE
;