diff options
Diffstat (limited to 'src/mesa/main/extensions.c')
-rw-r--r-- | src/mesa/main/extensions.c | 129 |
1 files changed, 117 insertions, 12 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index ebbe28acf48..e3070b1547d 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.3 + * Version: 7.6 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. 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"), @@ -44,6 +45,7 @@ static const struct { const char *name; int flag_offset; } default_extensions[] = { + { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) }, { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, @@ -52,17 +54,20 @@ static const struct { { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, { OFF, "GL_ARB_imaging", F(ARB_imaging) }, + { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, { ON, "GL_ARB_multisample", F(ARB_multisample) }, { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) }, { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) }, { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) }, { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) }, + { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) }, { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) }, { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) }, { OFF, "GL_ARB_shadow", F(ARB_shadow) }, { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, + { OFF, "GL_ARB_sync", F(ARB_sync) }, { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) }, { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, @@ -75,6 +80,8 @@ static const struct { { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, + { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, + { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) }, @@ -106,6 +113,7 @@ static const struct { { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) }, { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, + { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) }, { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) }, @@ -183,6 +191,7 @@ static const struct { void _mesa_enable_sw_extensions(GLcontext *ctx) { + ctx->Extensions.ARB_copy_buffer = GL_TRUE; ctx->Extensions.ARB_depth_texture = GL_TRUE; /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ #if FEATURE_ARB_fragment_program @@ -197,6 +206,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #endif ctx->Extensions.ARB_half_float_pixel = GL_TRUE; ctx->Extensions.ARB_imaging = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; ctx->Extensions.ARB_multitexture = GL_TRUE; #if FEATURE_ARB_occlusion_query ctx->Extensions.ARB_occlusion_query = GL_TRUE; @@ -221,6 +231,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; #if FEATURE_ARB_vertex_program ctx->Extensions.ARB_vertex_program = GL_TRUE; #endif @@ -230,6 +241,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #if FEATURE_ARB_vertex_buffer_object /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ #endif +#if FEATURE_ARB_sync + ctx->Extensions.ARB_sync = GL_TRUE; +#endif ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; #if FEATURE_ATI_fragment_shader @@ -261,6 +275,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; #endif ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; ctx->Extensions.EXT_shadow_funcs = GL_TRUE; ctx->Extensions.EXT_secondary_color = GL_TRUE; ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; @@ -441,8 +456,9 @@ _mesa_enable_2_1_extensions(GLcontext *ctx) /** * Either enable or disable the named extension. + * \return GL_TRUE for success, GL_FALSE if invalid extension name */ -static void +static GLboolean set_extension( GLcontext *ctx, const char *name, GLboolean state ) { GLboolean *base = (GLboolean *) &ctx->Extensions; @@ -451,7 +467,7 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state ) if (ctx->Extensions.String) { /* The string was already queried - can't change it now! */ _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); - return; + return GL_FALSE; } for (i = 0 ; i < Elements(default_extensions) ; i++) { @@ -460,10 +476,10 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state ) GLboolean *enabled = base + default_extensions[i].flag_offset; *enabled = state; } - return; + return GL_TRUE; } } - _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); + return GL_FALSE; } @@ -474,7 +490,8 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state ) void _mesa_enable_extension( GLcontext *ctx, const char *name ) { - set_extension(ctx, name, GL_TRUE); + if (!set_extension(ctx, name, GL_TRUE)) + _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); } @@ -485,7 +502,8 @@ _mesa_enable_extension( GLcontext *ctx, const char *name ) void _mesa_disable_extension( GLcontext *ctx, const char *name ) { - set_extension(ctx, name, GL_FALSE); + if (!set_extension(ctx, name, GL_FALSE)) + _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); } @@ -510,6 +528,80 @@ _mesa_extension_is_enabled( GLcontext *ctx, const char *name ) /** + * Append string 'b' onto string 'a'. Free 'a' and return new string. + */ +static char * +append(const char *a, const char *b) +{ + const GLuint aLen = a ? _mesa_strlen(a) : 0; + const GLuint bLen = b ? _mesa_strlen(b) : 0; + char *s = _mesa_calloc(aLen + bLen + 1); + if (s) { + if (a) + _mesa_memcpy(s, a, aLen); + if (b) + _mesa_memcpy(s + aLen, b, bLen); + s[aLen + bLen] = '\0'; + } + if (a) + _mesa_free((void *) a); + return s; +} + + +/** + * Check the MESA_EXTENSION_OVERRIDE env var. + * For extension names that are recognized, turn them on. For extension + * names that are recognized and prefixed with '-', turn them off. + * Return a string of the unknown/leftover names. + */ +static const char * +get_extension_override( GLcontext *ctx ) +{ + const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); + char *extraExt = NULL; + char ext[1000]; + GLuint extLen = 0; + GLuint i; + GLboolean disableExt = GL_FALSE; + + if (!envExt) + return NULL; + + for (i = 0; ; i++) { + if (envExt[i] == '\0' || envExt[i] == ' ') { + /* terminate/process 'ext' if extLen > 0 */ + if (extLen > 0) { + assert(extLen < sizeof(ext)); + /* enable extension named by 'ext' */ + ext[extLen] = 0; + if (!set_extension(ctx, ext, !disableExt)) { + /* unknown extension name, append it to extraExt */ + if (extraExt) { + extraExt = append(extraExt, " "); + } + extraExt = append(extraExt, ext); + } + extLen = 0; + disableExt = GL_FALSE; + } + if (envExt[i] == '\0') + break; + } + else if (envExt[i] == '-') { + disableExt = GL_TRUE; + } + else { + /* accumulate this non-space character */ + ext[extLen++] = envExt[i]; + } + } + + return extraExt; +} + + +/** * Run through the default_extensions array above and set the * ctx->Extensions.ARB/EXT_* flags accordingly. * To be called during context initialization. @@ -537,8 +629,9 @@ GLubyte * _mesa_make_extension_string( GLcontext *ctx ) { const GLboolean *base = (const GLboolean *) &ctx->Extensions; + const char *extraExt = get_extension_override(ctx); GLuint extStrLen = 0; - GLubyte *s; + char *s; GLuint i; /* first, compute length of the extension string */ @@ -548,7 +641,14 @@ _mesa_make_extension_string( GLcontext *ctx ) extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1; } } - s = (GLubyte *) _mesa_malloc(extStrLen); + + if (extraExt) + extStrLen += _mesa_strlen(extraExt) + 1; /* +1 for space */ + + /* allocate the extension string */ + s = (char *) _mesa_malloc(extStrLen); + if (!s) + return NULL; /* second, build the extension string */ extStrLen = 0; @@ -558,13 +658,18 @@ _mesa_make_extension_string( GLcontext *ctx ) GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name); _mesa_memcpy(s + extStrLen, default_extensions[i].name, len); extStrLen += len; - s[extStrLen] = (GLubyte) ' '; + s[extStrLen] = ' '; extStrLen++; } } ASSERT(extStrLen > 0); - s[extStrLen - 1] = 0; + s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */ - return s; + if (extraExt) { + s = append(s, " "); + s = append(s, extraExt); + } + + return (GLubyte *) s; } |