From bfa66bd6f941920cf32ce79fb103c3755b4dd8fb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 21 Sep 2009 17:57:57 +0800 Subject: mesa/es: Add OpenGL ES overlay. This is primitive support for OpenGL ES. It uses a subset of mesa sources to build libesXgallium.a and libesXapi.a, where X is 1 for OpenGL ES 1.x, 2 for OpenGL ES 2.x. The static libraries serve the same purpose as libmesagallium.a and libglapi.a do for OpenGL. This is based on the work of opengl-es branch. Signed-off-by: Chia-I Wu --- src/mesa/es/main/specials_es1.c | 186 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 src/mesa/es/main/specials_es1.c (limited to 'src/mesa/es/main/specials_es1.c') diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c new file mode 100644 index 0000000000..84d339ebf6 --- /dev/null +++ b/src/mesa/es/main/specials_es1.c @@ -0,0 +1,186 @@ +/************************************************************************** + * + * 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 const GLubyte * +compute_es_version(void) +{ + GET_CURRENT_CONTEXT(ctx); + static const char es_1_0[] = "OpenGL ES-CM 1.0"; + static const char es_1_1[] = "OpenGL ES-CM 1.1"; + /* OpenGL ES 1.0 is derived from OpenGL 1.3 */ + const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.EXT_texture_env_add && + ctx->Extensions.ARB_texture_env_combine && + ctx->Extensions.ARB_texture_env_dot3); + /* OpenGL ES 1.1 is derived from OpenGL 1.5 */ + const GLboolean ver_1_1 = (ver_1_0 && + ctx->Extensions.EXT_point_parameters && + ctx->Extensions.SGIS_generate_mipmap && + ctx->Extensions.ARB_vertex_buffer_object); + if (ver_1_1) + return (const GLubyte *) es_1_1; + + if (!ver_1_0) + _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support."); + return (const GLubyte *) es_1_0; +} + + +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 (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"); + + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + + 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 *) _mesa_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_VERSION: + return compute_es_version(); + case GL_EXTENSIONS: + return compute_es_extensions(); + default: + return _mesa_GetString(name); + } +} + + +void +_mesa_initialize_context_extra(GLcontext *ctx) +{ + /* nothing here */ +} -- cgit v1.2.3 From 34064756a5e2c8952c9de26eaebafddabd562540 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 22 Sep 2009 15:00:24 +0800 Subject: mesa/es: Add support for GL_OES_draw_texture. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.txt | 77 ++++++++ src/mesa/es/main/drawtex.c | 148 +++++++++++++++ src/mesa/es/main/drawtex.h | 77 ++++++++ src/mesa/es/main/mfeatures_es1.h | 1 + src/mesa/es/main/mfeatures_es2.h | 1 + src/mesa/es/main/specials_es1.c | 5 + src/mesa/es/sources.mak | 4 +- src/mesa/es/state_tracker/st_cb_drawtex.c | 297 ++++++++++++++++++++++++++++++ src/mesa/es/state_tracker/st_cb_drawtex.h | 18 ++ src/mesa/main/dd.h | 10 + src/mesa/main/extensions.c | 3 + src/mesa/main/mtypes.h | 3 + src/mesa/state_tracker/st_context.c | 9 +- src/mesa/state_tracker/st_extensions.c | 4 + 14 files changed, 654 insertions(+), 3 deletions(-) create mode 100644 src/mesa/es/main/drawtex.c create mode 100644 src/mesa/es/main/drawtex.h create mode 100644 src/mesa/es/state_tracker/st_cb_drawtex.c create mode 100644 src/mesa/es/state_tracker/st_cb_drawtex.h (limited to 'src/mesa/es/main/specials_es1.c') diff --git a/src/mesa/es/main/APIspec.txt b/src/mesa/es/main/APIspec.txt index 86dd546f63..6d18ae67d9 100644 --- a/src/mesa/es/main/APIspec.txt +++ b/src/mesa/es/main/APIspec.txt @@ -412,6 +412,8 @@ checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OE dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT # OES_texture_3D checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES2.0 name TexParameteri @@ -457,6 +459,8 @@ checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OE dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT # OES_texture_3D checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES2.0 name TexParameterx @@ -498,6 +502,8 @@ checkdependentparam pname GL_TEXTURE_MAG_FILTER params GL_NEAREST GL_LINEAR checkdependentparam pname GL_GENERATE_MIPMAP params GL_TRUE GL_FALSE convertalias TexParameterfv convertparams GLfloat params +# OES_draw_texture +dependentvector params 4 pname GL_TEXTURE_CROP_RECT_OES # OES_texture_cube_map checkparam target GL_TEXTURE_CUBE_MAP_OES # OES_texture_mirrored_repeat @@ -1352,6 +1358,8 @@ param pname GLenum param params GLfloat * dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP props get +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES # OES_texture_cube_map checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES category GLES1.1 GLES2.0 @@ -1366,6 +1374,8 @@ dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MI props get # OES_texture_cube_map checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES # OES_texture_3D checkparam target GLES2.0:GL_TEXTURE_3D_OES category GLES1.1 GLES2.0 @@ -1383,6 +1393,8 @@ dependentnovalueconvert params pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXT props get # OES_texture_cube_map checkparam target GL_TEXTURE_CUBE_MAP_OES +# OES_draw_texture +dependentvector params 4 pname GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES1.1:OES_fixed_point # GLES1.1 and GLES2.0 have different capabilities @@ -2867,6 +2879,71 @@ vector exponent 16 props get category GLES1.1:OES_query_matrix +# OES_draw_texture +name DrawTexf +return void +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +param h GLfloat +category GLES1.1:OES_draw_texture + +name DrawTexi +return void +param x GLint +param y GLint +param z GLint +param w GLint +param h GLint +category GLES1.1:OES_draw_texture + +name DrawTexs +return void +param x GLshort +param y GLshort +param z GLshort +param w GLshort +param h GLshort +category GLES1.1:OES_draw_texture + +name DrawTexx +return void +param x GLfixed +param y GLfixed +param z GLfixed +param w GLfixed +param h GLfixed +convertalias DrawTexf +convertparams GLfloat x y z w h +category GLES1.1:OES_draw_texture + +name DrawTexfv +return void +param coords const GLfloat * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexiv +return void +param coords const GLint * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexsv +return void +param coords const GLshort * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexxv +return void +param coords const GLfixed * +vector coords 5 +convertalias DrawTexfv +convertparams GLfloat coords +category GLES1.1:OES_draw_texture + # We don't support OES_get_program_binary yet either #name GetProgramBinary #return void diff --git a/src/mesa/es/main/drawtex.c b/src/mesa/es/main/drawtex.c new file mode 100644 index 0000000000..cbd41ca975 --- /dev/null +++ b/src/mesa/es/main/drawtex.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 "drawtex.h" +#include "main/state.h" +#include "main/imports.h" + +#include "glapi/dispatch.h" + + +#if FEATURE_OES_draw_texture + + +static void +draw_texture(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + if (!ctx->Extensions.OES_draw_texture) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawTex(unsupported)"); + return; + } + if (width <= 0.0f || height <= 0.0f) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + ASSERT(ctx->Driver.DrawTex); + ctx->Driver.DrawTex(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) x / 65536.0f, + (GLfloat) y / 65536.0f, + (GLfloat) z / 65536.0f, + (GLfloat) width / 65536.0f, + (GLfloat) height / 65536.0f); +} + + +void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) coords[0] / 65536.0f, + (GLfloat) coords[1] / 65536.0f, + (GLfloat) coords[2] / 65536.0f, + (GLfloat) coords[3] / 65536.0f, + (GLfloat) coords[4] / 65536.0f); +} + + +void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ + SET_DrawTexfOES(disp, _mesa_DrawTexf); + SET_DrawTexfvOES(disp, _mesa_DrawTexfv); + SET_DrawTexiOES(disp, _mesa_DrawTexi); + SET_DrawTexivOES(disp, _mesa_DrawTexiv); + SET_DrawTexsOES(disp, _mesa_DrawTexs); + SET_DrawTexsvOES(disp, _mesa_DrawTexsv); + SET_DrawTexxOES(disp, _mesa_DrawTexx); + SET_DrawTexxvOES(disp, _mesa_DrawTexxv); +} + + +#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/es/main/drawtex.h b/src/mesa/es/main/drawtex.h new file mode 100644 index 0000000000..0f3bac38c7 --- /dev/null +++ b/src/mesa/es/main/drawtex.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + */ + +#ifndef DRAWTEX_H +#define DRAWTEX_H + + +#include "main/mtypes.h" + + +#if FEATURE_OES_draw_texture + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) \ + do { \ + (driver)->DrawTex = impl ## DrawTex; \ + } while (0) + +extern void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); + +extern void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords); + +extern void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); + +extern void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords); + +extern void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); + +extern void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords); + +extern void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); + +extern void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords); + +extern void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_OES_draw_texture */ + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) do { } while (0) + +static INLINE void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_OES_draw_texture */ + + +#endif /* DRAWTEX_H */ diff --git a/src/mesa/es/main/mfeatures_es1.h b/src/mesa/es/main/mfeatures_es1.h index 9c65596089..6c2ece2608 100644 --- a/src/mesa/es/main/mfeatures_es1.h +++ b/src/mesa/es/main/mfeatures_es1.h @@ -103,6 +103,7 @@ #define FEATURE_NV_vertex_program 0 #define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_draw_texture 1 #define FEATURE_OES_mapbuffer 1 #define FEATURE_extra_context_init 1 diff --git a/src/mesa/es/main/mfeatures_es2.h b/src/mesa/es/main/mfeatures_es2.h index 6ed7b678dc..f34782fedb 100644 --- a/src/mesa/es/main/mfeatures_es2.h +++ b/src/mesa/es/main/mfeatures_es2.h @@ -103,6 +103,7 @@ #define FEATURE_NV_vertex_program 0 #define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_draw_texture 0 #define FEATURE_OES_mapbuffer 1 #define FEATURE_extra_context_init 1 diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 84d339ebf6..548fb0f029 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -100,6 +100,11 @@ make_extension_string(const GLcontext *ctx, char *str) /* 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) diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index d12acaae80..11f735d52a 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -4,6 +4,7 @@ include $(MESA)/sources.mak LOCAL_ES1_SOURCES := \ main/api_exec_es1.c \ + main/drawtex.c \ main/get_es1.c \ main/specials_es1.c \ main/drawtex.c \ @@ -14,7 +15,8 @@ LOCAL_ES1_SOURCES := \ glapi/glapi-es1/main/enums.c LOCAL_ES1_GALLIUM_SOURCES := \ - $(LOCAL_ES1_SOURCES) + $(LOCAL_ES1_SOURCES) \ + state_tracker/st_cb_drawtex.c # always use local version of GLAPI_ASM_SOURCES LOCAL_ES1_API_ASM := $(addprefix glapi/glapi-es1/, $(GLAPI_ASM_SOURCES)) diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.c b/src/mesa/es/state_tracker/st_cb_drawtex.c new file mode 100644 index 0000000000..3b98b9c40b --- /dev/null +++ b/src/mesa/es/state_tracker/st_cb_drawtex.c @@ -0,0 +1,297 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Implementation of glDrawTex() for GL_OES_draw_tex + */ + + + +#include "main/imports.h" +#include "main/image.h" +#include "main/bufferobj.h" +#include "main/drawtex.h" +#include "main/macros.h" +#include "main/state.h" +#include "main/texformat.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" + +#include "st_context.h" +#include "st_atom.h" +#include "st_atom_constbuf.h" +#include "st_draw.h" +#include "st_cb_drawtex.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_inlines.h" +#include "pipe/p_shader_tokens.h" +#include "util/u_tile.h" +#include "util/u_draw_quad.h" +#include "util/u_simple_shaders.h" + +#include "cso_cache/cso_context.h" + + +struct cached_shader +{ + //struct pipe_shader_state shader; + void *handle; + + uint num_attribs; + uint semantic_names[2 + MAX_TEXTURE_UNITS]; + uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; +}; + +#define MAX_SHADERS (2 * MAX_TEXTURE_UNITS) + +/** + * Simple linear list cache. + * Most of the time there'll only be one cached shader. + */ +static struct cached_shader CachedShaders[MAX_SHADERS]; +static GLuint NumCachedShaders = 0; + + +#if FEATURE_OES_draw_texture + + +static void * +lookup_shader(struct pipe_context *pipe, + uint num_attribs, + const uint *semantic_names, + const uint *semantic_indexes) +{ + GLuint i, j; + + /* look for existing shader with same attributes */ + for (i = 0; i < NumCachedShaders; i++) { + if (CachedShaders[i].num_attribs == num_attribs) { + GLboolean match = GL_TRUE; + for (j = 0; j < num_attribs; j++) { + if (semantic_names[j] != CachedShaders[i].semantic_names[j] || + semantic_indexes[j] != CachedShaders[i].semantic_indexes[j]) { + match = GL_FALSE; + break; + } + } + if (match) + return CachedShaders[i].handle; + } + } + + /* not found - create new one now */ + if (NumCachedShaders >= MAX_SHADERS) { + return NULL; + } + + CachedShaders[i].num_attribs = num_attribs; + for (j = 0; j < num_attribs; j++) { + CachedShaders[i].semantic_names[j] = semantic_names[j]; + CachedShaders[i].semantic_indexes[j] = semantic_indexes[j]; + } + + CachedShaders[i].handle = + util_make_vertex_passthrough_shader(pipe, + num_attribs, + semantic_names, + semantic_indexes); + NumCachedShaders++; + + return CachedShaders[i].handle; +} + +static void +st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct cso_context *cso = ctx->st->cso_context; + struct pipe_buffer *vbuffer; + GLuint i, numTexCoords, numAttribs; + GLboolean emitColor; + uint semantic_names[2 + MAX_TEXTURE_UNITS]; + uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; + GLbitfield inputs = VERT_BIT_POS; + + /* determine if we need vertex color */ + if (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL0) + emitColor = GL_TRUE; + else + emitColor = GL_FALSE; + + /* determine how many enabled sets of texcoords */ + numTexCoords = 0; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) { + inputs |= VERT_BIT_TEX(i); + numTexCoords++; + } + } + + /* total number of attributes per vertex */ + numAttribs = 1 + emitColor + numTexCoords; + + + /* create the vertex buffer */ + vbuffer = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, + numAttribs * 4 * 4 * sizeof(GLfloat)); + + /* load vertex buffer */ + { +#define SET_ATTRIB(VERT, ATTR, X, Y, Z, W) \ + do { \ + GLuint k = (((VERT) * numAttribs + (ATTR)) * 4); \ + assert(k < 4 * 4 * numAttribs); \ + vbuf[k + 0] = X; \ + vbuf[k + 1] = Y; \ + vbuf[k + 2] = Z; \ + vbuf[k + 3] = W; \ + } while (0) + + const GLfloat x0 = x, y0 = y, x1 = x + width, y1 = y + height; + GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe->screen, vbuffer, + PIPE_BUFFER_USAGE_CPU_WRITE); + GLuint attr; + + z = CLAMP(z, 0.0f, 1.0f); + + /* positions (in clip coords) */ + { + const struct gl_framebuffer *fb = st->ctx->DrawBuffer; + const GLfloat fb_width = (GLfloat)fb->Width; + const GLfloat fb_height = (GLfloat)fb->Height; + + const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0); + const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0); + const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0); + const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0); + + SET_ATTRIB(0, 0, clip_x0, clip_y0, z, 1.0f); /* lower left */ + SET_ATTRIB(1, 0, clip_x1, clip_y0, z, 1.0f); /* lower right */ + SET_ATTRIB(2, 0, clip_x1, clip_y1, z, 1.0f); /* upper right */ + SET_ATTRIB(3, 0, clip_x0, clip_y1, z, 1.0f); /* upper left */ + + semantic_names[0] = TGSI_SEMANTIC_POSITION; + semantic_indexes[0] = 0; + } + + /* colors */ + if (emitColor) { + const GLfloat *c = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + SET_ATTRIB(0, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(1, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(2, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(3, 1, c[0], c[1], c[2], c[3]); + semantic_names[1] = TGSI_SEMANTIC_COLOR; + semantic_indexes[1] = 0; + attr = 2; + } + else { + attr = 1; + } + + /* texcoords */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) { + struct gl_texture_object *obj = ctx->Texture.Unit[i]._Current; + struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const GLfloat wt = (GLfloat) img->Width; + const GLfloat ht = (GLfloat) img->Height; + const GLfloat s0 = obj->CropRect[0] / wt; + const GLfloat t0 = obj->CropRect[1] / ht; + const GLfloat s1 = (obj->CropRect[0] + obj->CropRect[2]) / wt; + const GLfloat t1 = (obj->CropRect[1] + obj->CropRect[3]) / ht; + + /*printf("crop texcoords: %g, %g .. %g, %g\n", s0, t0, s1, t1);*/ + SET_ATTRIB(0, attr, s0, t0, 0.0f, 1.0f); /* lower left */ + SET_ATTRIB(1, attr, s1, t0, 0.0f, 1.0f); /* lower right */ + SET_ATTRIB(2, attr, s1, t1, 0.0f, 1.0f); /* upper right */ + SET_ATTRIB(3, attr, s0, t1, 0.0f, 1.0f); /* upper left */ + + semantic_names[attr] = TGSI_SEMANTIC_GENERIC; + semantic_indexes[attr] = 0; + + attr++; + } + } + + pipe_buffer_unmap(pipe->screen, vbuffer); + +#undef SET_ATTRIB + } + + + cso_save_viewport(cso); + cso_save_vertex_shader(cso); + + { + void *vs = lookup_shader(pipe, numAttribs, + semantic_names, semantic_indexes); + cso_set_vertex_shader_handle(cso, vs); + } + + /* viewport state: viewport matching window dims */ + { + const struct gl_framebuffer *fb = st->ctx->DrawBuffer; + const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); + const GLfloat width = (GLfloat)fb->Width; + const GLfloat height = (GLfloat)fb->Height; + struct pipe_viewport_state vp; + vp.scale[0] = 0.5f * width; + vp.scale[1] = height * (invert ? -0.5f : 0.5f); + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * width; + vp.translate[1] = 0.5f * height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; + cso_set_viewport(cso, &vp); + } + + + util_draw_vertex_buffer(pipe, vbuffer, + 0, /* offset */ + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + numAttribs); /* attribs/vert */ + + + pipe_buffer_reference(&vbuffer, NULL); + + /* restore state */ + cso_restore_viewport(cso); + cso_restore_vertex_shader(cso); +} + + +#endif /* FEATURE_OES_draw_texture */ + + +void +st_init_drawtex_functions(struct dd_function_table *functions) +{ + _MESA_INIT_DRAWTEX_FUNCTIONS(functions, st_); +} + + +/** + * Free any cached shaders + */ +void +st_destroy_drawtex(struct st_context *st) +{ + GLuint i; + for (i = 0; i < NumCachedShaders; i++) { + cso_delete_vertex_shader(st->cso_context, CachedShaders[i].handle); + } + NumCachedShaders = 0; +} diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.h b/src/mesa/es/state_tracker/st_cb_drawtex.h new file mode 100644 index 0000000000..7b0da70279 --- /dev/null +++ b/src/mesa/es/state_tracker/st_cb_drawtex.h @@ -0,0 +1,18 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +#ifndef ST_CB_DRAWTEX_H +#define ST_CB_DRAWTEX_H + +extern void +st_init_drawtex_functions(struct dd_function_table *functions); + +extern void +st_destroy_drawtex(struct st_context *st); + +#endif /* ST_CB_DRAWTEX_H */ diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 99f2cad402..0488a693b2 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1046,6 +1046,16 @@ struct dd_function_table { GLbitfield, GLuint64); /*@}*/ #endif + +#if FEATURE_OES_draw_texture + /** + * \name GL_OES_draw_texture interface + */ + /*@{*/ + void (*DrawTex)(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height); + /*@}*/ +#endif }; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 54cf37c5f4..7a8184ffc8 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -185,6 +185,9 @@ static const struct { { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, { OFF, "GL_S3_s3tc", F(S3_s3tc) }, +#if FEATURE_OES_draw_texture + { OFF, "GL_OES_draw_texture", F(OES_draw_texture) }, +#endif /* FEATURE_OES_draw_texture */ }; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 94d29a7dbb..e91c7e5ac1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2485,6 +2485,9 @@ struct gl_extensions GLboolean SGIS_texture_lod; GLboolean TDFX_texture_compression_FXT1; GLboolean S3_s3tc; +#if FEATURE_OES_draw_texture + GLboolean OES_draw_texture; +#endif /* FEATURE_OES_draw_texture */ /** The extension string */ const GLubyte *String; }; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index f0eddafd33..e82598c8e7 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -47,7 +47,7 @@ #include "st_cb_drawpixels.h" #include "st_cb_rasterpos.h" #endif -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture #include "st_cb_drawtex.h" #endif #include "st_cb_fbo.h" @@ -209,7 +209,7 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_bitmap(st); st_destroy_drawpix(st); #endif -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture st_destroy_drawtex(st); #endif @@ -330,6 +330,11 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_drawpixels_functions(functions); st_init_rasterpos_functions(functions); #endif + +#if FEATURE_OES_draw_texture + st_init_drawtex_functions(functions); +#endif + st_init_fbo_functions(functions); st_init_get_functions(functions); #if FEATURE_feedback diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 3f835d38dd..ce3c302e48 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -183,6 +183,10 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.NV_texgen_reflection = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; +#if FEATURE_OES_draw_texture + ctx->Extensions.OES_draw_texture = GL_TRUE; +#endif + ctx->Extensions.SGI_color_matrix = GL_TRUE; ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; -- cgit v1.2.3 From 3a4d0811b43295519d771fa192bd3d28bd5312d5 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 23 Nov 2009 17:10:12 +0800 Subject: mesa/es: Clean up extension string. Add some new extensions and remove those that do not belong to OpenGL ES 2.0. Signed-off-by: Chia-I Wu --- src/mesa/es/main/specials_es1.c | 8 ++++++++ src/mesa/es/main/specials_es2.c | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/mesa/es/main/specials_es1.c') diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 548fb0f029..0ace2924b3 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -140,8 +140,16 @@ make_extension_string(const GLcontext *ctx, char *str) 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"); diff --git a/src/mesa/es/main/specials_es2.c b/src/mesa/es/main/specials_es2.c index ef8c581618..e11ade9b94 100644 --- a/src/mesa/es/main/specials_es2.c +++ b/src/mesa/es/main/specials_es2.c @@ -86,21 +86,15 @@ make_extension_string(const GLcontext *ctx, char *str) { size_t len = 0; - /* Core additions */ - len += append_extension(&str, "GL_OES_single_precision"); - - /* Required extensions */ len += append_extension(&str, "GL_OES_compressed_paletted_texture"); 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) @@ -123,6 +117,10 @@ make_extension_string(const GLcontext *ctx, char *str) 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"); -- cgit v1.2.3 From b80ec33f3559e9a14d08f84c8e369a0dc81b46d7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 24 Nov 2009 10:28:27 +0800 Subject: mesa/es: Fix GL_OES_texture_cube_map support. Unlike in OpenGL, GL_OES_texture_cube_map says that all coordinates are changed the same time by the token GL_TEXTURE_GEN_STR_OES, and the initial mode is GL_REFLECTION_MAP_OES. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.xml | 25 ++++++----- src/mesa/es/main/es_enable.c | 91 +++++++++++++++++++++++++++++++++++++++++ src/mesa/es/main/es_texgen.c | 73 +++++++++++++++++++++++++++++++++ src/mesa/es/main/get_gen.py | 11 ++--- src/mesa/es/main/specials_es1.c | 16 +++++++- src/mesa/es/sources.mak | 2 + 6 files changed, 199 insertions(+), 19 deletions(-) create mode 100644 src/mesa/es/main/es_enable.c create mode 100644 src/mesa/es/main/es_texgen.c (limited to 'src/mesa/es/main/specials_es1.c') diff --git a/src/mesa/es/main/APIspec.xml b/src/mesa/es/main/APIspec.xml index 8926007f8d..a7dbdc4249 100644 --- a/src/mesa/es/main/APIspec.xml +++ b/src/mesa/es/main/APIspec.xml @@ -3546,7 +3546,6 @@ - @@ -3873,12 +3872,12 @@ - - - - - - + + + + + + @@ -3892,8 +3891,8 @@ - - + + @@ -3932,15 +3931,15 @@ - - - + + + - + diff --git a/src/mesa/es/main/es_enable.c b/src/mesa/es/main/es_enable.c new file mode 100644 index 0000000000..351caacd77 --- /dev/null +++ b/src/mesa/es/main/es_enable.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 "GLES/gl.h" +#include "GLES/glext.h" + +#include "main/compiler.h" /* for ASSERT */ + + +#ifndef GL_TEXTURE_GEN_S +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#endif + + +extern void GL_APIENTRY _es_Disable(GLenum cap); +extern void GL_APIENTRY _es_Enable(GLenum cap); +extern GLboolean GL_APIENTRY _es_IsEnabled(GLenum cap); + +extern void GL_APIENTRY _mesa_Disable(GLenum cap); +extern void GL_APIENTRY _mesa_Enable(GLenum cap); +extern GLboolean GL_APIENTRY _mesa_IsEnabled(GLenum cap); + + +void GL_APIENTRY +_es_Disable(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + /* disable S, T, and R at the same time */ + _mesa_Disable(GL_TEXTURE_GEN_S); + _mesa_Disable(GL_TEXTURE_GEN_T); + _mesa_Disable(GL_TEXTURE_GEN_R); + break; + default: + _mesa_Disable(cap); + break; + } +} + + +void GL_APIENTRY +_es_Enable(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + /* enable S, T, and R at the same time */ + _mesa_Enable(GL_TEXTURE_GEN_S); + _mesa_Enable(GL_TEXTURE_GEN_T); + _mesa_Enable(GL_TEXTURE_GEN_R); + break; + default: + _mesa_Enable(cap); + break; + } +} + + +GLboolean GL_APIENTRY +_es_IsEnabled(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + cap = GL_TEXTURE_GEN_S; + default: + break; + } + + return _mesa_IsEnabled(cap); +} diff --git a/src/mesa/es/main/es_texgen.c b/src/mesa/es/main/es_texgen.c new file mode 100644 index 0000000000..c29a0a7f13 --- /dev/null +++ b/src/mesa/es/main/es_texgen.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 "GLES/gl.h" +#include "GLES/glext.h" + +#include "main/compiler.h" /* for ASSERT */ + + +#ifndef GL_S +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#endif + + +extern void GL_APIENTRY _es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); +extern void GL_APIENTRY _es_TexGenf(GLenum coord, GLenum pname, GLfloat param); +extern void GL_APIENTRY _es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); + +extern void GL_APIENTRY _mesa_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); +extern void GL_APIENTRY _mesa_TexGenf(GLenum coord, GLenum pname, GLfloat param); +extern void GL_APIENTRY _mesa_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); + + +void GL_APIENTRY +_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + _mesa_GetTexGenfv(GL_S, pname, params); +} + + +void GL_APIENTRY +_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenf(GL_S, pname, param); + _mesa_TexGenf(GL_T, pname, param); + _mesa_TexGenf(GL_R, pname, param); +} + + +void GL_APIENTRY +_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenfv(GL_S, pname, params); + _mesa_TexGenfv(GL_T, pname, params); + _mesa_TexGenfv(GL_R, pname, params); +} diff --git a/src/mesa/es/main/get_gen.py b/src/mesa/es/main/get_gen.py index 9da0b6b742..fee6670104 100644 --- a/src/mesa/es/main/get_gen.py +++ b/src/mesa/es/main/get_gen.py @@ -391,12 +391,9 @@ StateVars_es1 = [ # OES_texture_cube_map ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", None), - ( "GL_TEXTURE_GEN_S", GLboolean, + ( "GL_TEXTURE_GEN_STR_OES", GLboolean, + # S, T, and R are always set at the same time ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None), - ( "GL_TEXTURE_GEN_T", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None), - ( "GL_TEXTURE_GEN_R", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None), # ARB_multisample ( "GL_MULTISAMPLE_ARB", GLboolean, ["ctx->Multisample.Enabled"], "", ["ARB_multisample"] ), @@ -695,6 +692,10 @@ def EmitHeader(): #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \\ diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 0ace2924b3..a4f14490f3 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -195,5 +195,19 @@ _es_GetString(GLenum name) void _mesa_initialize_context_extra(GLcontext *ctx) { - /* nothing here */ + GLuint i; + + /** + * GL_OES_texture_cube_map says + * "Initially all texture generation modes are set to REFLECTION_MAP_OES" + */ + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + texUnit->GenS.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenT.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenR.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV; + } } diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index f00e41b011..84fad26773 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -8,8 +8,10 @@ LOCAL_ES1_SOURCES := \ main/specials_es1.c \ main/drawtex.c \ main/es_cpaltex.c \ + main/es_enable.c \ main/es_fbo.c \ main/es_query_matrix.c \ + main/es_texgen.c \ main/stubs.c \ glapi/glapi-es1/main/enums.c -- cgit v1.2.3