diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/extensions.c | 4 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 84 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 35 |
4 files changed, 68 insertions, 56 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 886311e0f1c..9928a5244e6 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -100,8 +100,9 @@ static const struct { { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, - { ON, "GL_EXT_texture_object", 0 }, { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, + { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, + { ON, "GL_EXT_texture_object", 0 }, { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, { ON, "GL_EXT_vertex_array", 0 }, { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, @@ -196,6 +197,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) 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_mirror_clamp = GL_TRUE; ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; ctx->Extensions.HP_occlusion_test = GL_TRUE; ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 47cb19b6259..a51a463602c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1770,6 +1770,7 @@ struct gl_extensions GLboolean EXT_texture_env_dot3; GLboolean EXT_texture_filter_anisotropic; GLboolean EXT_texture_lod_bias; + GLboolean EXT_texture_mirror_clamp; GLboolean EXT_vertex_array_set; GLboolean HP_occlusion_test; GLboolean IBM_rasterpos_clip; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index a62106aa491..133b957aa56 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1048,6 +1048,35 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) /* Texture Parameters */ /**********************************************************************/ +static GLboolean +_mesa_validate_texture_wrap_mode(GLcontext * ctx, + GLenum target, GLenum eparam) +{ + const struct gl_extensions * const e = & ctx->Extensions; + + if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || + (eparam == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) { + /* any texture target */ + return GL_TRUE; + } + else if (target != GL_TEXTURE_RECTANGLE_NV && + (eparam == GL_REPEAT || + (eparam == GL_MIRRORED_REPEAT && + e->ARB_texture_mirrored_repeat) || + (eparam == GL_MIRROR_CLAMP_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (eparam == GL_MIRROR_CLAMP_TO_EDGE_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (eparam == GL_MIRROR_CLAMP_TO_BORDER_EXT && + (e->EXT_texture_mirror_clamp)))) { + /* non-rectangle texture */ + return GL_TRUE; + } + + _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return GL_FALSE; +} + void _mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ) @@ -1141,81 +1170,34 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) case GL_TEXTURE_WRAP_S: if (texObj->WrapS == eparam) return; - if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || - (eparam == GL_CLAMP_TO_BORDER && - ctx->Extensions.ARB_texture_border_clamp)) { - /* any texture target */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->WrapS = eparam; - } - else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV && - (eparam == GL_REPEAT || - (eparam == GL_MIRRORED_REPEAT && - ctx->Extensions.ARB_texture_mirrored_repeat) || - (eparam == GL_MIRROR_CLAMP_ATI && - ctx->Extensions.ATI_texture_mirror_once) || - (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI && - ctx->Extensions.ATI_texture_mirror_once))) { - /* non-rectangle texture */ + if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->WrapS = eparam; } else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); return; } break; case GL_TEXTURE_WRAP_T: if (texObj->WrapT == eparam) return; - if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || - (eparam == GL_CLAMP_TO_BORDER && - ctx->Extensions.ARB_texture_border_clamp)) { - /* any texture target */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->WrapT = eparam; - } - else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV && - (eparam == GL_REPEAT || - (eparam == GL_MIRRORED_REPEAT && - ctx->Extensions.ARB_texture_mirrored_repeat) || - (eparam == GL_MIRROR_CLAMP_ATI && - ctx->Extensions.ATI_texture_mirror_once) || - (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI && - ctx->Extensions.ATI_texture_mirror_once))) { - /* non-rectangle texture */ + if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->WrapT = eparam; } else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); return; } break; case GL_TEXTURE_WRAP_R: if (texObj->WrapR == eparam) return; - if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || - (eparam == GL_CLAMP_TO_BORDER && - ctx->Extensions.ARB_texture_border_clamp)) { - /* any texture target */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->WrapR = eparam; - } - else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV && - (eparam == GL_REPEAT || - (eparam == GL_MIRRORED_REPEAT && - ctx->Extensions.ARB_texture_mirrored_repeat) || - (eparam == GL_MIRROR_CLAMP_ATI && - ctx->Extensions.ATI_texture_mirror_once) || - (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI && - ctx->Extensions.ATI_texture_mirror_once))) { - /* non-rectangle texture */ + if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->WrapR = eparam; } else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return; } break; case GL_TEXTURE_BORDER_COLOR: diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 6f38aab7f0a..a196f34c275 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -122,7 +122,7 @@ repeat_remainder(GLint a, GLint b) if (I1 >= (GLint) SIZE) \ I1 = SIZE - 1; \ } \ - else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ + else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \ U = (GLfloat) fabs(S); \ if (U >= 1.0F) \ U = (GLfloat) SIZE; \ @@ -132,7 +132,7 @@ repeat_remainder(GLint a, GLint b) I0 = IFLOOR(U); \ I1 = I0 + 1; \ } \ - else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \ U = (GLfloat) fabs(S); \ if (U >= 1.0F) \ U = (GLfloat) SIZE; \ @@ -146,6 +146,20 @@ repeat_remainder(GLint a, GLint b) if (I1 >= (GLint) SIZE) \ I1 = SIZE - 1; \ } \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \ + const GLfloat min = -1.0F / (2.0F * SIZE); \ + const GLfloat max = 1.0F - min; \ + U = (GLfloat) fabs(S); \ + if (U <= min) \ + U = min * SIZE; \ + else if (U >= max) \ + U = max * SIZE; \ + else \ + U *= SIZE; \ + U -= 0.5F; \ + I0 = IFLOOR(U); \ + I1 = I0 + 1; \ + } \ else { \ ASSERT(wrapMode == GL_CLAMP); \ if (S <= 0.0F) \ @@ -215,7 +229,7 @@ repeat_remainder(GLint a, GLint b) else \ I = IFLOOR(u * SIZE); \ } \ - else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ + else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \ /* s limited to [0,1] */ \ /* i limited to [0,size-1] */ \ const GLfloat u = (GLfloat) fabs(S); \ @@ -226,7 +240,7 @@ repeat_remainder(GLint a, GLint b) else \ I = IFLOOR(u * SIZE); \ } \ - else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \ /* s limited to [min,max] */ \ /* i limited to [0, size-1] */ \ const GLfloat min = 1.0F / (2.0F * SIZE); \ @@ -239,6 +253,19 @@ repeat_remainder(GLint a, GLint b) else \ I = IFLOOR(u * SIZE); \ } \ + else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \ + /* s limited to [min,max] */ \ + /* i limited to [0, size-1] */ \ + const GLfloat min = -1.0F / (2.0F * SIZE); \ + const GLfloat max = 1.0F - min; \ + const GLfloat u = (GLfloat) fabs(S); \ + if (u < min) \ + I = -1; \ + else if (u > max) \ + I = SIZE; \ + else \ + I = IFLOOR(u * SIZE); \ + } \ else { \ ASSERT(wrapMode == GL_CLAMP); \ /* s limited to [0,1] */ \ |