GL_ATI_texture_mirror_once extension (Ian Romanick)
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 21 Oct 2002 15:52:34 +0000 (15:52 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 21 Oct 2002 15:52:34 +0000 (15:52 +0000)
src/mesa/main/extensions.c
src/mesa/main/mtypes.h
src/mesa/main/texstate.c
src/mesa/swrast/s_texture.c

index ec4422d..f37c07d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.82 2002/10/16 17:57:52 brianp Exp $ */
+/* $Id: extensions.c,v 1.83 2002/10/21 15:52:34 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -73,6 +73,7 @@ static struct {
    { OFF, "GL_ARB_texture_mirrored_repeat",    F(ARB_texture_mirrored_repeat)},
    { ON,  "GL_ARB_transpose_matrix",           0 },
    { ON,  "GL_ARB_window_pos",                 F(ARB_window_pos) },
+   { OFF, "GL_ATI_texture_mirror_once",        F(ATI_texture_mirror_once)},
    { ON,  "GL_EXT_abgr",                       0 },
    { ON,  "GL_EXT_bgra",                       0 },
    { OFF, "GL_EXT_blend_color",                F(EXT_blend_color) },
@@ -160,6 +161,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
       "GL_ARB_texture_env_crossbar",
       "GL_ARB_texture_env_dot3",
       "GL_ARB_texture_mirrored_repeat",
+      "GL_ATI_texture_mirror_once",
       "GL_EXT_blend_color",
       "GL_EXT_blend_func_separate",
       "GL_EXT_blend_logic_op",
index 10f8e2b..fde7e3f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.96 2002/10/11 17:41:04 brianp Exp $ */
+/* $Id: mtypes.h,v 1.97 2002/10/21 15:52:34 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1367,6 +1367,7 @@ struct gl_extensions {
    GLboolean ARB_texture_env_dot3;
    GLboolean ARB_texture_mirrored_repeat;
    GLboolean ARB_window_pos;
+   GLboolean ATI_texture_mirror_once;
    GLboolean EXT_blend_color;
    GLboolean EXT_blend_func_separate;
    GLboolean EXT_blend_logic_op;
index 0da2134..ce40c56 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.81 2002/10/17 22:26:06 kschultz Exp $ */
+/* $Id: texstate.c,v 1.82 2002/10/21 15:52:34 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1093,7 +1093,11 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
          else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
                   (eparam == GL_REPEAT ||
                    (eparam == GL_MIRRORED_REPEAT_ARB &&
-                    ctx->Extensions.ARB_texture_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);
             texObj->WrapS = eparam;
@@ -1116,7 +1120,11 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
          else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
                   (eparam == GL_REPEAT ||
                    (eparam == GL_MIRRORED_REPEAT_ARB &&
-                    ctx->Extensions.ARB_texture_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);
             texObj->WrapT = eparam;
@@ -1139,7 +1147,11 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
          else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
                   (eparam == GL_REPEAT ||
                    (eparam == GL_MIRRORED_REPEAT_ARB &&
-                    ctx->Extensions.ARB_texture_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);
             texObj->WrapR = eparam;
index db2e9e0..6929a3c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.71 2002/10/18 17:02:01 kschultz Exp $ */
+/* $Id: s_texture.c,v 1.72 2002/10/21 15:52:35 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
          U = 1.0F - (S - (GLfloat) flr);       /* flr is odd */        \
       else                                                             \
          U = S - (GLfloat) flr;                /* flr is even */               \
-      U = (U * SIZE) - 0.5F;                                           \
+      U = (U * SIZE) - 0.5;                                            \
+      I0 = IFLOOR(U);                                                  \
+      I1 = I0 + 1;                                                     \
+      if (I0 < 0)                                                      \
+         I0 = 0;                                                       \
+      if (I1 >= (GLint) SIZE)                                          \
+         I1 = SIZE - 1;                                                        \
+   }                                                                   \
+   else if (wrapMode == GL_MIRROR_CLAMP_ATI) {                         \
+      U = fabs(S);                                                     \
+      if (U >= 1.0F)                                                   \
+         U = (GLfloat) SIZE;                                           \
+      else                                                             \
+         U *= SIZE;                                                    \
+      U -= 0.5F;                                                       \
+      I0 = IFLOOR(U);                                                  \
+      I1 = I0 + 1;                                                     \
+   }                                                                   \
+   else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) {                 \
+      U = fabs(S);                                                     \
+      if (U >= 1.0F)                                                   \
+         U = (GLfloat) SIZE;                                           \
+      else                                                             \
+         U *= SIZE;                                                    \
+      U -= 0.5F;                                                       \
       I0 = IFLOOR(U);                                                  \
       I1 = I0 + 1;                                                     \
       if (I0 < 0)                                                      \
       else                                                             \
          I = IFLOOR(u * SIZE);                                         \
    }                                                                   \
+   else if (wrapMode == GL_MIRROR_CLAMP_ATI) {                         \
+      /* s limited to [0,1] */                                         \
+      /* i limited to [0,size-1] */                                    \
+      const GLfloat u = fabs(S);                                       \
+      if (u <= 0.0F)                                                   \
+         I = 0;                                                                \
+      else if (u >= 1.0F)                                              \
+         I = SIZE - 1;                                                 \
+      else                                                             \
+         I = IFLOOR(u * SIZE);                                         \
+   }                                                                   \
+   else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) {                 \
+      /* 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 = fabs(S);                                       \
+      if (u < min)                                                     \
+         I = 0;                                                                \
+      else if (u > max)                                                        \
+         I = SIZE - 1;                                                 \
+      else                                                             \
+         I = IFLOOR(u * SIZE);                                         \
+   }                                                                   \
    else {                                                              \
       ASSERT(wrapMode == GL_CLAMP);                                    \
       /* s limited to [0,1] */                                         \