00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "main/imports.h"
00029 #include "main/context.h"
00030 #include "main/extensions.h"
00031 #include "main/macros.h"
00032
00033 #include "pipe/p_context.h"
00034 #include "pipe/p_defines.h"
00035 #include "pipe/p_screen.h"
00036
00037 #include "st_context.h"
00038 #include "st_extensions.h"
00039
00040
00041 static int _min(int a, int b)
00042 {
00043 return (a < b) ? a : b;
00044 }
00045
00046 static float _maxf(float a, float b)
00047 {
00048 return (a > b) ? a : b;
00049 }
00050
00051 static int _clamp(int a, int min, int max)
00052 {
00053 if (a < min)
00054 return min;
00055 else if (a > max)
00056 return max;
00057 else
00058 return a;
00059 }
00060
00061
00066 void st_init_limits(struct st_context *st)
00067 {
00068 struct pipe_screen *screen = st->pipe->screen;
00069 struct gl_constants *c = &st->ctx->Const;
00070
00071 c->MaxTextureLevels
00072 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
00073 MAX_TEXTURE_LEVELS);
00074
00075 c->Max3DTextureLevels
00076 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
00077 MAX_3D_TEXTURE_LEVELS);
00078
00079 c->MaxCubeTextureLevels
00080 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
00081 MAX_CUBE_TEXTURE_LEVELS);
00082
00083 c->MaxTextureRectSize
00084 = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
00085
00086 c->MaxTextureUnits
00087 = c->MaxTextureImageUnits
00088 = c->MaxTextureCoordUnits
00089 = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
00090 MAX_TEXTURE_IMAGE_UNITS);
00091
00092 c->MaxDrawBuffers
00093 = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
00094 1, MAX_DRAW_BUFFERS);
00095
00096 c->MaxLineWidth
00097 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH));
00098 c->MaxLineWidthAA
00099 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA));
00100
00101 c->MaxPointSize
00102 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH));
00103 c->MaxPointSizeAA
00104 = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA));
00105
00106 c->MaxTextureMaxAnisotropy
00107 = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY));
00108
00109 c->MaxTextureLodBias
00110 = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
00111
00112 c->MaxDrawBuffers
00113 = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
00114 1, MAX_DRAW_BUFFERS);
00115 }
00116
00117
00121 void st_init_extensions(struct st_context *st)
00122 {
00123 struct pipe_screen *screen = st->pipe->screen;
00124 GLcontext *ctx = st->ctx;
00125
00126
00127
00128
00129 ctx->Extensions.ARB_multisample = GL_TRUE;
00130 ctx->Extensions.ARB_fragment_program = GL_TRUE;
00131 ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
00132 ctx->Extensions.ARB_texture_compression = GL_TRUE;
00133 ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
00134 ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
00135 ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
00136 ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
00137 ctx->Extensions.ARB_vertex_program = GL_TRUE;
00138 ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
00139
00140 ctx->Extensions.EXT_blend_color = GL_TRUE;
00141 ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
00142 ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
00143 ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
00144 ctx->Extensions.EXT_blend_minmax = GL_TRUE;
00145 ctx->Extensions.EXT_blend_subtract = GL_TRUE;
00146 ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
00147 ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
00148 ctx->Extensions.EXT_fog_coord = GL_TRUE;
00149 ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
00150 ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
00151 ctx->Extensions.EXT_point_parameters = GL_TRUE;
00152 ctx->Extensions.EXT_secondary_color = GL_TRUE;
00153 ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
00154 ctx->Extensions.EXT_texture_env_add = GL_TRUE;
00155 ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
00156 ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
00157 ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
00158
00159 ctx->Extensions.NV_blend_square = GL_TRUE;
00160 ctx->Extensions.NV_texgen_reflection = GL_TRUE;
00161
00162 ctx->Extensions.SGI_color_matrix = GL_TRUE;
00163 ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
00164
00165
00166
00167
00168 if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) {
00169 ctx->Extensions.ARB_draw_buffers = GL_TRUE;
00170 }
00171
00172 if (screen->get_param(screen, PIPE_CAP_GLSL)) {
00173 ctx->Extensions.ARB_fragment_shader = GL_TRUE;
00174 ctx->Extensions.ARB_vertex_shader = GL_TRUE;
00175 ctx->Extensions.ARB_shader_objects = GL_TRUE;
00176 ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
00177 ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
00178 }
00179
00180 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
00181 ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
00182 }
00183
00184 if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
00185 ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
00186 }
00187
00188 if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) {
00189 ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
00190 ctx->Extensions.NV_texture_rectangle = GL_TRUE;
00191 }
00192
00193 if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) {
00194 ctx->Extensions.ARB_multitexture = GL_TRUE;
00195 }
00196
00197 if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) {
00198 ctx->Extensions.ATI_separate_stencil = GL_TRUE;
00199 }
00200
00201 if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
00202 ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
00203 }
00204
00205 if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
00206 ctx->Extensions.ARB_point_sprite = GL_TRUE;
00207 ctx->Extensions.NV_point_sprite = GL_TRUE;
00208 }
00209
00210 if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
00211 ctx->Extensions.ARB_occlusion_query = GL_TRUE;
00212 }
00213
00214 if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
00215 ctx->Extensions.ARB_depth_texture = GL_TRUE;
00216 ctx->Extensions.ARB_shadow = GL_TRUE;
00217 ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
00218
00219 }
00220
00221
00222
00223
00224 if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
00225 PIPE_TEXTURE_2D,
00226 PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
00227 screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
00228 PIPE_TEXTURE_2D,
00229 PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
00230 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
00231 }
00232 else if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
00233 PIPE_TEXTURE_2D,
00234 PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
00235 screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
00236 PIPE_TEXTURE_2D,
00237 PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
00238 ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
00239 }
00240
00241 if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
00242 PIPE_TEXTURE_2D,
00243 PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
00244 ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
00245 }
00246
00247 #if 01
00248 if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
00249 PIPE_TEXTURE_2D,
00250 PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
00251 ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
00252 }
00253 #endif
00254 if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR,
00255 PIPE_TEXTURE_2D,
00256 PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
00257 screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV,
00258 PIPE_TEXTURE_2D,
00259 PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
00260 ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
00261 }
00262
00263 }