2007-11-05 18:04:30 -07:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
2008-12-12 05:09:56 +01:00
|
|
|
* Copyright (c) 2008 VMware, Inc.
|
2007-11-05 18:04:30 -07:00
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include "main/imports.h"
|
|
|
|
#include "main/context.h"
|
|
|
|
#include "main/extensions.h"
|
|
|
|
#include "main/macros.h"
|
|
|
|
|
|
|
|
#include "pipe/p_context.h"
|
|
|
|
#include "pipe/p_defines.h"
|
2008-02-27 11:24:35 -07:00
|
|
|
#include "pipe/p_screen.h"
|
2007-11-05 18:04:30 -07:00
|
|
|
|
|
|
|
#include "st_context.h"
|
|
|
|
#include "st_extensions.h"
|
|
|
|
|
|
|
|
|
2008-05-02 10:08:03 +00:00
|
|
|
static int _min(int a, int b)
|
2007-11-06 09:41:45 -07:00
|
|
|
{
|
|
|
|
return (a < b) ? a : b;
|
|
|
|
}
|
|
|
|
|
2008-06-24 11:34:46 +09:00
|
|
|
static float _maxf(float a, float b)
|
2007-11-08 08:22:42 -07:00
|
|
|
{
|
|
|
|
return (a > b) ? a : b;
|
|
|
|
}
|
|
|
|
|
2008-05-02 10:08:03 +00:00
|
|
|
static int _clamp(int a, int min, int max)
|
2007-11-05 18:04:30 -07:00
|
|
|
{
|
2007-11-06 09:41:45 -07:00
|
|
|
if (a < min)
|
|
|
|
return min;
|
|
|
|
else if (a > max)
|
|
|
|
return max;
|
|
|
|
else
|
|
|
|
return a;
|
2007-11-05 18:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-06 09:41:45 -07:00
|
|
|
/**
|
|
|
|
* Query driver to get implementation limits.
|
|
|
|
* Note that we have to limit/clamp against Mesa's internal limits too.
|
|
|
|
*/
|
2007-11-05 18:04:30 -07:00
|
|
|
void st_init_limits(struct st_context *st)
|
|
|
|
{
|
2008-02-27 11:24:35 -07:00
|
|
|
struct pipe_screen *screen = st->pipe->screen;
|
2007-11-06 09:41:45 -07:00
|
|
|
struct gl_constants *c = &st->ctx->Const;
|
|
|
|
|
|
|
|
c->MaxTextureLevels
|
2008-05-02 10:08:03 +00:00
|
|
|
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
|
2007-11-06 09:41:45 -07:00
|
|
|
MAX_TEXTURE_LEVELS);
|
2007-11-05 18:04:30 -07:00
|
|
|
|
2007-11-06 09:41:45 -07:00
|
|
|
c->Max3DTextureLevels
|
2008-05-02 10:08:03 +00:00
|
|
|
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
|
2007-11-06 09:41:45 -07:00
|
|
|
MAX_3D_TEXTURE_LEVELS);
|
2007-11-05 18:04:30 -07:00
|
|
|
|
2007-11-06 09:41:45 -07:00
|
|
|
c->MaxCubeTextureLevels
|
2008-05-02 10:08:03 +00:00
|
|
|
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
|
2007-11-06 09:41:45 -07:00
|
|
|
MAX_CUBE_TEXTURE_LEVELS);
|
2007-11-05 18:04:30 -07:00
|
|
|
|
2007-11-06 09:41:45 -07:00
|
|
|
c->MaxTextureRectSize
|
2008-05-02 10:08:03 +00:00
|
|
|
= _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
|
2007-11-05 18:04:30 -07:00
|
|
|
|
2009-01-02 16:54:11 -07:00
|
|
|
c->MaxTextureImageUnits
|
2008-05-02 10:08:03 +00:00
|
|
|
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
|
2007-11-06 09:41:45 -07:00
|
|
|
MAX_TEXTURE_IMAGE_UNITS);
|
2007-11-05 18:04:30 -07:00
|
|
|
|
2008-12-02 22:37:35 -07:00
|
|
|
c->MaxVertexTextureImageUnits
|
2009-01-02 16:15:43 -07:00
|
|
|
= _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
|
|
|
|
MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
2008-12-02 22:37:35 -07:00
|
|
|
|
2009-01-04 10:04:44 -07:00
|
|
|
c->MaxTextureCoordUnits
|
|
|
|
= _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);
|
2009-01-02 16:54:11 -07:00
|
|
|
|
2009-01-04 10:04:44 -07:00
|
|
|
c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits);
|
2009-01-02 16:54:11 -07:00
|
|
|
|
2007-11-06 09:41:45 -07:00
|
|
|
c->MaxDrawBuffers
|
2008-05-02 10:08:03 +00:00
|
|
|
= _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
|
2007-11-06 09:41:45 -07:00
|
|
|
1, MAX_DRAW_BUFFERS);
|
2007-11-08 08:22:42 -07:00
|
|
|
|
|
|
|
c->MaxLineWidth
|
2008-06-24 11:34:46 +09:00
|
|
|
= _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH));
|
2007-11-08 08:22:42 -07:00
|
|
|
c->MaxLineWidthAA
|
2008-06-24 11:34:46 +09:00
|
|
|
= _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA));
|
2007-11-08 08:22:42 -07:00
|
|
|
|
|
|
|
c->MaxPointSize
|
2008-06-24 11:34:46 +09:00
|
|
|
= _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH));
|
2007-11-08 08:22:42 -07:00
|
|
|
c->MaxPointSizeAA
|
2008-06-24 11:34:46 +09:00
|
|
|
= _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA));
|
2007-11-08 08:22:42 -07:00
|
|
|
|
|
|
|
c->MaxTextureMaxAnisotropy
|
2008-06-24 11:34:46 +09:00
|
|
|
= _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY));
|
2007-11-08 08:22:42 -07:00
|
|
|
|
|
|
|
c->MaxTextureLodBias
|
2008-02-27 11:24:35 -07:00
|
|
|
= screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
|
2008-02-05 16:32:15 -07:00
|
|
|
|
2008-04-14 20:56:08 -06:00
|
|
|
c->MaxDrawBuffers
|
|
|
|
= CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
|
|
|
|
1, MAX_DRAW_BUFFERS);
|
2007-11-05 18:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-01-26 12:31:02 -07:00
|
|
|
* Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
|
|
|
|
* which GL extensions are supported.
|
|
|
|
* Quite a few extensions are always supported because they are standard
|
|
|
|
* features or can be built on top of other gallium features.
|
|
|
|
* Some fine tuning may still be needed.
|
2007-11-05 18:04:30 -07:00
|
|
|
*/
|
|
|
|
void st_init_extensions(struct st_context *st)
|
|
|
|
{
|
2008-02-27 11:24:35 -07:00
|
|
|
struct pipe_screen *screen = st->pipe->screen;
|
2007-11-05 18:04:30 -07:00
|
|
|
GLcontext *ctx = st->ctx;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extensions that are supported by all Gallium drivers:
|
|
|
|
*/
|
2009-01-26 12:31:02 -07:00
|
|
|
ctx->Extensions.ARB_multisample = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_fragment_program = GL_TRUE;
|
2007-11-07 08:18:34 -07:00
|
|
|
ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
|
2009-01-26 12:31:02 -07:00
|
|
|
ctx->Extensions.ARB_texture_compression = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_vertex_program = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
|
|
|
|
|
|
|
|
ctx->Extensions.EXT_blend_color = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_blend_minmax = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_blend_subtract = GL_TRUE;
|
2008-03-18 17:16:23 -06:00
|
|
|
ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_fog_coord = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_point_parameters = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_secondary_color = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_texture_env_add = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
|
|
|
|
ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
|
|
|
|
|
2009-05-13 11:15:00 -06:00
|
|
|
ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
|
|
|
|
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.NV_blend_square = GL_TRUE;
|
|
|
|
ctx->Extensions.NV_texgen_reflection = GL_TRUE;
|
|
|
|
|
2008-04-16 09:09:08 -06:00
|
|
|
ctx->Extensions.SGI_color_matrix = GL_TRUE;
|
2009-01-26 12:31:02 -07:00
|
|
|
ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Extensions that depend on the driver/hardware:
|
|
|
|
*/
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_draw_buffers = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_GLSL)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_fragment_shader = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_vertex_shader = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_shader_objects = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-06 17:22:29 -06:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
|
|
|
|
ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
|
|
|
|
ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
|
|
|
|
ctx->Extensions.NV_texture_rectangle = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_multitexture = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ATI_separate_stencil = GL_TRUE;
|
2009-02-19 14:37:43 -07:00
|
|
|
ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_point_sprite = GL_TRUE;
|
2007-11-07 15:57:19 -07:00
|
|
|
ctx->Extensions.NV_point_sprite = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_occlusion_query = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 11:24:35 -07:00
|
|
|
if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
|
2007-11-05 18:04:30 -07:00
|
|
|
ctx->Extensions.ARB_depth_texture = GL_TRUE;
|
|
|
|
ctx->Extensions.ARB_shadow = GL_TRUE;
|
2007-11-08 09:33:33 -07:00
|
|
|
ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
|
2007-11-05 18:04:30 -07:00
|
|
|
/*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
|
|
|
|
}
|
|
|
|
|
2008-08-14 10:53:59 -06:00
|
|
|
/* GL_EXT_packed_depth_stencil requires both the ability to render to
|
|
|
|
* a depth/stencil buffer and texture from depth/stencil source.
|
|
|
|
*/
|
|
|
|
if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
|
|
|
|
screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
|
|
|
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
|
|
|
|
}
|
|
|
|
else if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
|
|
|
|
screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
|
|
|
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
2009-01-26 12:31:02 -07:00
|
|
|
/* sRGB support */
|
2008-03-21 10:51:21 -06:00
|
|
|
if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
|
2008-12-12 05:09:56 +01:00
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
|
|
|
|
screen->is_format_supported(screen, PIPE_FORMAT_A8R8G8B8_SRGB,
|
2008-07-19 12:04:37 +09:00
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
2008-03-21 10:51:21 -06:00
|
|
|
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
|
|
|
|
}
|
2008-03-21 11:05:02 -06:00
|
|
|
|
2009-01-26 12:31:02 -07:00
|
|
|
/* s3tc support */
|
2008-03-21 11:05:02 -06:00
|
|
|
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
|
2008-07-19 12:04:37 +09:00
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
2008-03-21 11:05:02 -06:00
|
|
|
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
|
|
|
|
}
|
2009-01-26 12:31:02 -07:00
|
|
|
|
|
|
|
/* ycbcr support */
|
2008-07-19 12:04:37 +09:00
|
|
|
if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
|
|
|
|
screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV,
|
|
|
|
PIPE_TEXTURE_2D,
|
|
|
|
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
2008-04-03 16:37:30 -06:00
|
|
|
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
|
|
|
|
}
|
2007-11-05 18:04:30 -07:00
|
|
|
}
|