diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2010-04-22 11:41:41 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2010-04-22 12:42:23 -0400 |
commit | ade150d66724259119012420068fa930807311c2 (patch) | |
tree | b74d89dfa00a924b85b3f2b33b13a18509fef435 /src | |
parent | 18f7e118a5c6dfc04502e6e91ae492bfa33d3cc9 (diff) |
mesa: Compute extension string according to API
We can now stop special casing glGetString() and drop specials_es*.c.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/es/main/APIspec.xml | 4 | ||||
-rw-r--r-- | src/mesa/es/main/specials_es1.c | 168 | ||||
-rw-r--r-- | src/mesa/es/main/specials_es2.c | 137 | ||||
-rw-r--r-- | src/mesa/es/sources.mak | 2 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 126 |
5 files changed, 113 insertions, 324 deletions
diff --git a/src/mesa/es/main/APIspec.xml b/src/mesa/es/main/APIspec.xml index 17665d8df5..7e77eb74d5 100644 --- a/src/mesa/es/main/APIspec.xml +++ b/src/mesa/es/main/APIspec.xml @@ -3955,7 +3955,7 @@ <function name="GetMaterialfv" template="GetMaterial" gltype="GLfloat"/> <function name="GetMaterialxv" template="GetMaterial" gltype="GLfixed"/> - <function name="GetString" external="true" template="GetString"/> + <function name="GetString" template="GetString"/> <function name="GetTexEnvfv" template="GetTexEnv" gltype="GLfloat"/> <function name="GetTexEnviv" template="GetTexEnv" gltype="GLint"/> @@ -4178,7 +4178,7 @@ <function name="GetFloatv" template="GetState" gltype="GLfloat"/> <function name="GetIntegerv" template="GetState" gltype="GLint"/> - <function name="GetString" external="true" template="GetString"/> + <function name="GetString" template="GetString"/> <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/> <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/> diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c deleted file mode 100644 index 37a5943490..0000000000 --- a/src/mesa/es/main/specials_es1.c +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS 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/mtypes.h" -#include "main/context.h" -#include "main/imports.h" -#include "main/get.h" - - -extern const GLubyte * GLAPIENTRY _es_GetString(GLenum name); - - -static size_t -append_extension(char **str, const char *ext) -{ - char *s = *str; - size_t len = strlen(ext); - - if (s) { - memcpy(s, ext, len); - s[len++] = ' '; - s[len] = '\0'; - - *str += len; - } - else { - len++; - } - - return len; -} - - -static size_t -make_extension_string(const GLcontext *ctx, char *str) -{ - size_t len = 0; - - /* Core additions */ - len += append_extension(&str, "GL_OES_byte_coordinates"); - len += append_extension(&str, "GL_OES_fixed_point"); - len += append_extension(&str, "GL_OES_single_precision"); - len += append_extension(&str, "GL_OES_matrix_get"); - - /* 1.1 required extensions */ - len += append_extension(&str, "GL_OES_read_format"); - len += append_extension(&str, "GL_OES_compressed_paletted_texture"); - len += append_extension(&str, "GL_OES_point_size_array"); - len += append_extension(&str, "GL_OES_point_sprite"); - - /* 1.1 deprecated extensions */ - len += append_extension(&str, "GL_OES_query_matrix"); - -#if FEATURE_OES_draw_texture - if (ctx->Extensions.OES_draw_texture) - len += append_extension(&str, "GL_OES_draw_texture"); -#endif - - if (ctx->Extensions.EXT_blend_equation_separate) - len += append_extension(&str, "GL_OES_blend_equation_separate"); - if (ctx->Extensions.EXT_blend_func_separate) - len += append_extension(&str, "GL_OES_blend_func_separate"); - if (ctx->Extensions.EXT_blend_subtract) - len += append_extension(&str, "GL_OES_blend_subtract"); - - if (ctx->Extensions.EXT_stencil_wrap) - len += append_extension(&str, "GL_OES_stencil_wrap"); - - if (ctx->Extensions.ARB_texture_cube_map) - len += append_extension(&str, "GL_OES_texture_cube_map"); - if (ctx->Extensions.ARB_texture_env_crossbar) - len += append_extension(&str, "GL_OES_texture_env_crossbar"); - if (ctx->Extensions.ARB_texture_mirrored_repeat) - len += append_extension(&str, "GL_OES_texture_mirrored_repeat"); - - if (ctx->Extensions.ARB_framebuffer_object) { - len += append_extension(&str, "GL_OES_framebuffer_object"); - len += append_extension(&str, "GL_OES_depth24"); - len += append_extension(&str, "GL_OES_depth32"); - len += append_extension(&str, "GL_OES_fbo_render_mipmap"); - len += append_extension(&str, "GL_OES_rgb8_rgba8"); - len += append_extension(&str, "GL_OES_stencil1"); - len += append_extension(&str, "GL_OES_stencil4"); - len += append_extension(&str, "GL_OES_stencil8"); - } - - if (ctx->Extensions.EXT_vertex_array) - len += append_extension(&str, "GL_OES_element_index_uint"); - if (ctx->Extensions.ARB_vertex_buffer_object) - len += append_extension(&str, "GL_OES_mapbuffer"); - if (ctx->Extensions.EXT_texture_filter_anisotropic) - len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); - - /* some applications check this for NPOT support */ - if (ctx->Extensions.ARB_texture_non_power_of_two) - len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); - - if (ctx->Extensions.EXT_texture_compression_s3tc) - len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); - if (ctx->Extensions.EXT_texture_lod_bias) - len += append_extension(&str, "GL_EXT_texture_lod_bias"); - if (ctx->Extensions.EXT_blend_minmax) - len += append_extension(&str, "GL_EXT_blend_minmax"); - if (ctx->Extensions.EXT_multi_draw_arrays) - len += append_extension(&str, "GL_EXT_multi_draw_arrays"); - -#if FEATURE_OES_EGL_image - if (ctx->Extensions.OES_EGL_image) - len += append_extension(&str, "GL_OES_EGL_image"); -#endif - - return len; -} - - -static const GLubyte * -compute_es_extensions(void) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.String) { - char *s; - unsigned int len; - - len = make_extension_string(ctx, NULL); - s = (char *) malloc(len + 1); - if (!s) - return NULL; - make_extension_string(ctx, s); - ctx->Extensions.String = (const GLubyte *) s; - } - - return ctx->Extensions.String; -} - - -const GLubyte * GLAPIENTRY -_es_GetString(GLenum name) -{ - switch (name) { - case GL_EXTENSIONS: - return compute_es_extensions(); - default: - return _mesa_GetString(name); - } -} diff --git a/src/mesa/es/main/specials_es2.c b/src/mesa/es/main/specials_es2.c deleted file mode 100644 index ac499473a3..0000000000 --- a/src/mesa/es/main/specials_es2.c +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS 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/mtypes.h" -#include "main/context.h" -#include "main/imports.h" -#include "main/get.h" - - -const GLubyte * GLAPIENTRY _es_GetString(GLenum name); - - -static size_t -append_extension(char **str, const char *ext) -{ - char *s = *str; - size_t len = strlen(ext); - - if (s) { - memcpy(s, ext, len); - s[len++] = ' '; - s[len] = '\0'; - - *str += len; - } - else { - len++; - } - - return len; -} - - -static size_t -make_extension_string(const GLcontext *ctx, char *str) -{ - size_t len = 0; - - len += append_extension(&str, "GL_OES_compressed_paletted_texture"); - - if (ctx->Extensions.ARB_framebuffer_object) { - len += append_extension(&str, "GL_OES_depth24"); - len += append_extension(&str, "GL_OES_depth32"); - len += append_extension(&str, "GL_OES_fbo_render_mipmap"); - len += append_extension(&str, "GL_OES_rgb8_rgba8"); - len += append_extension(&str, "GL_OES_stencil1"); - len += append_extension(&str, "GL_OES_stencil4"); - } - - if (ctx->Extensions.EXT_vertex_array) - len += append_extension(&str, "GL_OES_element_index_uint"); - if (ctx->Extensions.ARB_vertex_buffer_object) - len += append_extension(&str, "GL_OES_mapbuffer"); - - if (ctx->Extensions.EXT_texture3D) - len += append_extension(&str, "GL_OES_texture_3D"); - if (ctx->Extensions.ARB_texture_non_power_of_two) - len += append_extension(&str, "GL_OES_texture_npot"); - if (ctx->Extensions.EXT_texture_filter_anisotropic) - len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); - - len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV"); - if (ctx->Extensions.ARB_depth_texture) - len += append_extension(&str, "GL_OES_depth_texture"); - if (ctx->Extensions.EXT_packed_depth_stencil) - len += append_extension(&str, "GL_OES_packed_depth_stencil"); - if (ctx->Extensions.ARB_fragment_shader) - len += append_extension(&str, "GL_OES_standard_derivatives"); - - if (ctx->Extensions.EXT_texture_compression_s3tc) - len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); - if (ctx->Extensions.EXT_blend_minmax) - len += append_extension(&str, "GL_EXT_blend_minmax"); - if (ctx->Extensions.EXT_multi_draw_arrays) - len += append_extension(&str, "GL_EXT_multi_draw_arrays"); - -#if FEATURE_OES_EGL_image - if (ctx->Extensions.OES_EGL_image) - len += append_extension(&str, "GL_OES_EGL_image"); -#endif - - return len; -} - - -static const GLubyte * -compute_es_extensions(void) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.String) { - char *s; - unsigned int len; - - len = make_extension_string(ctx, NULL); - s = (char *) malloc(len + 1); - if (!s) - return NULL; - make_extension_string(ctx, s); - ctx->Extensions.String = (const GLubyte *) s; - } - - return ctx->Extensions.String; -} - -const GLubyte * GLAPIENTRY -_es_GetString(GLenum name) -{ - switch (name) { - case GL_EXTENSIONS: - return compute_es_extensions(); - default: - return _mesa_GetString(name); - } -} diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index 55bb31b80d..b08069bce5 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -5,7 +5,6 @@ include $(MESA)/sources.mak LOCAL_ES1_SOURCES := \ main/api_exec_es1.c \ main/get_es1.c \ - main/specials_es1.c \ main/drawtex.c \ main/es_cpaltex.c \ main/es_enable.c \ @@ -31,7 +30,6 @@ LOCAL_ES1_INCLUDES := \ LOCAL_ES2_SOURCES := \ main/api_exec_es2.c \ main/get_es2.c \ - main/specials_es2.c \ main/es_cpaltex.c \ main/es_fbo.c \ main/stubs.c \ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 30a51abbe7..4c8d4ccfa2 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -727,9 +727,9 @@ compute_extensions( GLcontext *ctx ) } static size_t -append_extension(char **str, const char *ext) +append_extension(GLubyte **str, const char *ext) { - char *s = *str; + GLubyte *s = *str; size_t len = strlen(ext); if (s) { @@ -748,7 +748,104 @@ append_extension(char **str, const char *ext) static size_t -make_extension_string_es2(const GLcontext *ctx, char *str) +make_extension_string_es1(const GLcontext *ctx, GLubyte *str) +{ + size_t len = 0; + + /* Core additions */ + len += append_extension(&str, "GL_OES_byte_coordinates"); + len += append_extension(&str, "GL_OES_fixed_point"); + len += append_extension(&str, "GL_OES_single_precision"); + len += append_extension(&str, "GL_OES_matrix_get"); + + /* 1.1 required extensions */ + len += append_extension(&str, "GL_OES_read_format"); + len += append_extension(&str, "GL_OES_compressed_paletted_texture"); + len += append_extension(&str, "GL_OES_point_size_array"); + len += append_extension(&str, "GL_OES_point_sprite"); + + /* 1.1 deprecated extensions */ + len += append_extension(&str, "GL_OES_query_matrix"); + +#if FEATURE_OES_draw_texture + if (ctx->Extensions.OES_draw_texture) + len += append_extension(&str, "GL_OES_draw_texture"); +#endif + + if (ctx->Extensions.EXT_blend_equation_separate) + len += append_extension(&str, "GL_OES_blend_equation_separate"); + if (ctx->Extensions.EXT_blend_func_separate) + len += append_extension(&str, "GL_OES_blend_func_separate"); + if (ctx->Extensions.EXT_blend_subtract) + len += append_extension(&str, "GL_OES_blend_subtract"); + + if (ctx->Extensions.EXT_stencil_wrap) + len += append_extension(&str, "GL_OES_stencil_wrap"); + + if (ctx->Extensions.ARB_texture_cube_map) + len += append_extension(&str, "GL_OES_texture_cube_map"); + if (ctx->Extensions.ARB_texture_env_crossbar) + len += append_extension(&str, "GL_OES_texture_env_crossbar"); + if (ctx->Extensions.ARB_texture_mirrored_repeat) + len += append_extension(&str, "GL_OES_texture_mirrored_repeat"); + + if (ctx->Extensions.ARB_framebuffer_object) { + len += append_extension(&str, "GL_OES_framebuffer_object"); + len += append_extension(&str, "GL_OES_depth24"); + len += append_extension(&str, "GL_OES_depth32"); + len += append_extension(&str, "GL_OES_fbo_render_mipmap"); + len += append_extension(&str, "GL_OES_rgb8_rgba8"); + len += append_extension(&str, "GL_OES_stencil1"); + len += append_extension(&str, "GL_OES_stencil4"); + len += append_extension(&str, "GL_OES_stencil8"); + } + + if (ctx->Extensions.EXT_vertex_array) + len += append_extension(&str, "GL_OES_element_index_uint"); + if (ctx->Extensions.ARB_vertex_buffer_object) + len += append_extension(&str, "GL_OES_mapbuffer"); + if (ctx->Extensions.EXT_texture_filter_anisotropic) + len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + + /* some applications check this for NPOT support */ + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); + + if (ctx->Extensions.EXT_texture_compression_s3tc) + len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); + if (ctx->Extensions.EXT_texture_lod_bias) + len += append_extension(&str, "GL_EXT_texture_lod_bias"); + if (ctx->Extensions.EXT_blend_minmax) + len += append_extension(&str, "GL_EXT_blend_minmax"); + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + +#if FEATURE_OES_EGL_image + if (ctx->Extensions.OES_EGL_image) + len += append_extension(&str, "GL_OES_EGL_image"); +#endif + + return len; +} + + +static GLubyte * +compute_extensions_es1(const GLcontext *ctx) +{ + GLubyte *s; + unsigned int len; + + len = make_extension_string_es1(ctx, NULL); + s = malloc(len + 1); + if (!s) + return NULL; + make_extension_string_es1(ctx, s); + + return s; +} + +static size_t +make_extension_string_es2(const GLcontext *ctx, GLubyte *str) { size_t len = 0; @@ -801,21 +898,19 @@ make_extension_string_es2(const GLcontext *ctx, char *str) static GLubyte * compute_extensions_es2(GLcontext *ctx) { - if (!ctx->Extensions.String) { - char *s; - unsigned int len; - - len = make_extension_string_es2(ctx, NULL); - s = (char *) malloc(len + 1); - if (!s) - return NULL; - make_extension_string_es2(ctx, s); - ctx->Extensions.String = (const GLubyte *) s; - } + GLubyte *s; + unsigned int len; - return ctx->Extensions.String; + len = make_extension_string_es2(ctx, NULL); + s = malloc(len + 1); + if (!s) + return NULL; + make_extension_string_es2(ctx, s); + + return s; } + GLubyte * _mesa_make_extension_string(GLcontext *ctx) { @@ -825,6 +920,7 @@ _mesa_make_extension_string(GLcontext *ctx) case API_OPENGLES2: return compute_extensions_es2(ctx); case API_OPENGLES: + return compute_extensions_es1(ctx); default: assert(0); return NULL; |