Added support for EXT_texture_mirror_clamp and the single wrap mode

that it addes to ATI_texture_mirror_once.  This includes updating the
texwrap test to exercise the new mode.
This commit is contained in:
Ian Romanick 2003-09-02 19:25:17 +00:00
parent 886bc6f36c
commit c8363a31cf
6 changed files with 92 additions and 64 deletions

View File

@ -2210,6 +2210,18 @@ typedef void (APIENTRY * PFNGLDEPTHBOUNDSEXTPROC)(GLclampd zmin, GLclampd zmax);
/* XXX temporary until glext.h is updated! */
#ifndef GL_EXT_texture_mirror_clamp
#define GL_EXT_texture_mirror_clamp 1
#define GL_MIRROR_CLAMP_EXT 0x8742
#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
#endif /* GL_EXT_texture_mirror_clamp */
/* XXX temporary until glext.h is updated! */ /* XXX temporary until glext.h is updated! */
#ifndef GL_ARB_occlusion_query #ifndef GL_ARB_occlusion_query
#define GL_ARB_occlusion_query 1 #define GL_ARB_occlusion_query 1

View File

@ -1,4 +1,4 @@
/* $Id: texwrap.c,v 1.6 2003/05/30 15:30:17 brianp Exp $ */ /* $Id: texwrap.c,v 1.7 2003/09/02 19:25:18 idr Exp $ */
/* /*
* Test texture wrap modes. * Test texture wrap modes.
@ -24,9 +24,10 @@
#define GL_MIRRORED_REPEAT 0x8370 #define GL_MIRRORED_REPEAT 0x8370
#endif #endif
#ifndef GL_ATI_texture_mirror_once #ifndef GL_EXT_texture_mirror_clamp
#define GL_MIRROR_CLAMP_ATI 0x8742 #define GL_MIRROR_CLAMP_EXT 0x8742
#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 #define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
#endif #endif
#define BORDER_TEXTURE 1 #define BORDER_TEXTURE 1
@ -61,10 +62,13 @@ static struct wrap_mode modes[] = {
WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat", WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat",
"GL_IBM_texture_mirrored_repeat", "GL_IBM_texture_mirrored_repeat",
1.4 ), 1.4 ),
WRAP_EXT ( GL_MIRROR_CLAMP_ATI, "GL_ATI_texture_mirror_once", WRAP_EXT ( GL_MIRROR_CLAMP_EXT, "GL_ATI_texture_mirror_once",
NULL, "GL_EXT_texture_mirror_clamp",
999.0 ), 999.0 ),
WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_ATI, "GL_ATI_texture_mirror_once", WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once",
"GL_EXT_texture_mirror_clamp",
999.0 ),
WRAP_EXT ( GL_MIRROR_CLAMP_TO_BORDER_EXT, "GL_EXT_texture_mirror_clamp",
NULL, NULL,
999.0 ), 999.0 ),
{ 0 } { 0 }

View File

@ -100,8 +100,9 @@ static const struct {
{ OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, { 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_env_dot3", F(EXT_texture_env_dot3) },
{ OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, { 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_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) }, { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
{ ON, "GL_EXT_vertex_array", 0 }, { ON, "GL_EXT_vertex_array", 0 },
{ OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, { 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_add = GL_TRUE;
ctx->Extensions.EXT_texture_env_combine = GL_TRUE; ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
ctx->Extensions.EXT_texture_env_dot3 = 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.EXT_texture_lod_bias = GL_TRUE;
ctx->Extensions.HP_occlusion_test = GL_TRUE; ctx->Extensions.HP_occlusion_test = GL_TRUE;
ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE; ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;

View File

@ -1770,6 +1770,7 @@ struct gl_extensions
GLboolean EXT_texture_env_dot3; GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_filter_anisotropic; GLboolean EXT_texture_filter_anisotropic;
GLboolean EXT_texture_lod_bias; GLboolean EXT_texture_lod_bias;
GLboolean EXT_texture_mirror_clamp;
GLboolean EXT_vertex_array_set; GLboolean EXT_vertex_array_set;
GLboolean HP_occlusion_test; GLboolean HP_occlusion_test;
GLboolean IBM_rasterpos_clip; GLboolean IBM_rasterpos_clip;

View File

@ -1048,6 +1048,35 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
/* Texture Parameters */ /* 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 void
_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ) _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: case GL_TEXTURE_WRAP_S:
if (texObj->WrapS == eparam) if (texObj->WrapS == eparam)
return; return;
if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
(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 */
FLUSH_VERTICES(ctx, _NEW_TEXTURE); FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapS = eparam; texObj->WrapS = eparam;
} }
else { else {
_mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return; return;
} }
break; break;
case GL_TEXTURE_WRAP_T: case GL_TEXTURE_WRAP_T:
if (texObj->WrapT == eparam) if (texObj->WrapT == eparam)
return; return;
if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
(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 */
FLUSH_VERTICES(ctx, _NEW_TEXTURE); FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapT = eparam; texObj->WrapT = eparam;
} }
else { else {
_mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return; return;
} }
break; break;
case GL_TEXTURE_WRAP_R: case GL_TEXTURE_WRAP_R:
if (texObj->WrapR == eparam) if (texObj->WrapR == eparam)
return; return;
if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE || if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
(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 */
FLUSH_VERTICES(ctx, _NEW_TEXTURE); FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapR = eparam; texObj->WrapR = eparam;
} }
else { else {
_mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); return;
} }
break; break;
case GL_TEXTURE_BORDER_COLOR: case GL_TEXTURE_BORDER_COLOR:

View File

@ -122,7 +122,7 @@ repeat_remainder(GLint a, GLint b)
if (I1 >= (GLint) SIZE) \ if (I1 >= (GLint) SIZE) \
I1 = SIZE - 1; \ I1 = SIZE - 1; \
} \ } \
else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
U = (GLfloat) fabs(S); \ U = (GLfloat) fabs(S); \
if (U >= 1.0F) \ if (U >= 1.0F) \
U = (GLfloat) SIZE; \ U = (GLfloat) SIZE; \
@ -132,7 +132,7 @@ repeat_remainder(GLint a, GLint b)
I0 = IFLOOR(U); \ I0 = IFLOOR(U); \
I1 = I0 + 1; \ 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); \ U = (GLfloat) fabs(S); \
if (U >= 1.0F) \ if (U >= 1.0F) \
U = (GLfloat) SIZE; \ U = (GLfloat) SIZE; \
@ -146,6 +146,20 @@ repeat_remainder(GLint a, GLint b)
if (I1 >= (GLint) SIZE) \ if (I1 >= (GLint) SIZE) \
I1 = SIZE - 1; \ 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 { \ else { \
ASSERT(wrapMode == GL_CLAMP); \ ASSERT(wrapMode == GL_CLAMP); \
if (S <= 0.0F) \ if (S <= 0.0F) \
@ -215,7 +229,7 @@ repeat_remainder(GLint a, GLint b)
else \ else \
I = IFLOOR(u * SIZE); \ I = IFLOOR(u * SIZE); \
} \ } \
else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
/* s limited to [0,1] */ \ /* s limited to [0,1] */ \
/* i limited to [0,size-1] */ \ /* i limited to [0,size-1] */ \
const GLfloat u = (GLfloat) fabs(S); \ const GLfloat u = (GLfloat) fabs(S); \
@ -226,7 +240,7 @@ repeat_remainder(GLint a, GLint b)
else \ else \
I = IFLOOR(u * SIZE); \ 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] */ \ /* s limited to [min,max] */ \
/* i limited to [0, size-1] */ \ /* i limited to [0, size-1] */ \
const GLfloat min = 1.0F / (2.0F * SIZE); \ const GLfloat min = 1.0F / (2.0F * SIZE); \
@ -239,6 +253,19 @@ repeat_remainder(GLint a, GLint b)
else \ else \
I = IFLOOR(u * SIZE); \ 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 { \ else { \
ASSERT(wrapMode == GL_CLAMP); \ ASSERT(wrapMode == GL_CLAMP); \
/* s limited to [0,1] */ \ /* s limited to [0,1] */ \