Dieter Nützel wrote:
You'll even get a newer version, Alan pointed out some subtle issues
with the macro expansion (one of the reasons I don't particularly like
macros...). Instead of fixing all GET_SRC/DST_PTR macros, I got rid of
them too, since they were identical again in all drivers which use
spantmp2 (except unichrome which uses different pitches for reading and
drawing, it keeps its macros).


Sorry,

you lost spantmp_common.h in dri_span4.diff.
You're right. I really wanted to do a cvs diff to include new files, but I guess it's not possible, and hacking together the diffs manually is just asking for such errors :-).

Roland
Index: common/depthtmp.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/depthtmp.h,v
retrieving revision 1.7
diff -u -r1.7 depthtmp.h
--- common/depthtmp.h   14 Feb 2005 09:27:38 -0000      1.7
+++ common/depthtmp.h   3 Mar 2005 19:25:50 -0000
@@ -1,24 +1,19 @@
 /* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 
16:14:20 dawes Exp $ */
 
+#include "spantmp_common.h"
+
 #ifndef DBG
 #define DBG 0
 #endif
 
-
 #ifndef HAVE_HW_DEPTH_SPANS
 #define HAVE_HW_DEPTH_SPANS 0
 #endif
+
 #ifndef HAVE_HW_DEPTH_PIXELS
 #define HAVE_HW_DEPTH_PIXELS 0
 #endif
 
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK()         HW_LOCK()
-#endif
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK()       HW_UNLOCK()
-#endif
-
 static void TAG(WriteDepthSpan)( GLcontext *ctx,
                              GLuint n, GLint x, GLint y,
                                 const GLdepth *depth,
Index: common/spantmp.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/spantmp.h,v
retrieving revision 1.5
diff -u -r1.5 spantmp.h
--- common/spantmp.h    14 Feb 2005 09:27:38 -0000      1.5
+++ common/spantmp.h    3 Mar 2005 19:25:50 -0000
@@ -27,26 +27,12 @@
  *    Gareth Hughes <[EMAIL PROTECTED]>
  */
 
+#include "spantmp_common.h"
+
 #ifndef DBG
 #define DBG 0
 #endif
 
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK()                HW_LOCK()
-#endif
-
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK()      HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK()         HW_LOCK()
-#endif
-
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK()       HW_UNLOCK()
-#endif
-
 #ifndef HW_READ_CLIPLOOP
 #define HW_READ_CLIPLOOP()     HW_CLIPLOOP()
 #endif
Index: common/spantmp2.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/spantmp2.h,v
retrieving revision 1.6
diff -u -r1.6 spantmp2.h
--- common/spantmp2.h   15 Jan 2005 14:35:35 -0000      1.6
+++ common/spantmp2.h   3 Mar 2005 19:25:51 -0000
@@ -34,27 +34,12 @@
  */
 
 #include "colormac.h"
+#include "spantmp_common.h"
 
 #ifndef DBG
 #define DBG 0
 #endif
 
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK()                HW_LOCK()
-#endif
-
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK()      HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK()         HW_LOCK()
-#endif
-
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK()       HW_UNLOCK()
-#endif
-
 #ifndef HW_READ_CLIPLOOP
 #define HW_READ_CLIPLOOP()     HW_CLIPLOOP()
 #endif
@@ -65,6 +50,14 @@
 
 #if (SPANTMP_PIXEL_FMT == GL_RGB)  && (SPANTMP_PIXEL_TYPE == 
GL_UNSIGNED_SHORT_5_6_5)
 
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) (     buf + (_x) * 2 + (_y) * pitch)
+#endif
+
 #define INIT_MONO_PIXEL(p, color) \
   p = PACK_COLOR_565( color[0], color[1], color[2] )
 
@@ -92,6 +85,14 @@
 
 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == 
GL_UNSIGNED_INT_8_8_8_8_REV)
 
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * pitch)
+#endif
+
 # define INIT_MONO_PIXEL(p, color)                       \
      p = PACK_COLOR_8888(color[3], color[0], color[1], color[2]) 
     
Index: common/stenciltmp.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/stenciltmp.h,v
retrieving revision 1.4
diff -u -r1.4 stenciltmp.h
--- common/stenciltmp.h 14 Feb 2005 09:27:38 -0000      1.4
+++ common/stenciltmp.h 3 Mar 2005 19:25:51 -0000
@@ -1,23 +1,11 @@
 /* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 
16:14:20 dawes Exp $ */
 
+#include "spantmp_common.h"
+
 #ifndef DBG
 #define DBG 0
 #endif
 
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK()                HW_LOCK()
-#endif
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK()      HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK()         HW_LOCK()
-#endif
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK()       HW_UNLOCK()
-#endif
-
 static void TAG(WriteStencilSpan)( GLcontext *ctx,
                                   GLuint n, GLint x, GLint y,
                                   const GLstencil *stencil, 
Index: gamma/gamma_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/gamma/gamma_span.c,v
retrieving revision 1.6
diff -u -r1.6 gamma_span.c
--- gamma/gamma_span.c  20 Jan 2005 13:24:08 -0000      1.6
+++ gamma/gamma_span.c  3 Mar 2005 19:25:53 -0000
@@ -40,21 +40,6 @@
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
-
-#define CLIPPIXEL( _x, _y )                                            \
-   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP( _y )           (height - _y - 1)
 
 #define HW_LOCK()                                                      \
@@ -63,21 +48,6 @@
    gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );         \
    GAMMAHW_LOCK( gmesa );
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = gmesa->driDrawable;                        
\
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 #define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa )
 
 
Index: i810/i810span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/i810/i810span.c,v
retrieving revision 1.4
diff -u -r1.4 i810span.c
--- i810/i810span.c     20 Jan 2005 13:24:08 -0000      1.4
+++ i810/i810span.c     3 Mar 2005 19:25:53 -0000
@@ -41,39 +41,10 @@
 #define INIT_MONO_PIXEL(p, color) \
    p = PACK_COLOR_565( color[0], color[1], color[2] )
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP(_y) (height - _y - 1)
 
 #define HW_LOCK()
 
-#define HW_CLIPLOOP()                                          \
-  do {                                                         \
-    __DRIdrawablePrivate *dPriv = imesa->driDrawable;          \
-    int _nc = dPriv->numClipRects;                             \
-    while (_nc--) {                                            \
-       int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                \
-       int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;        \
-       int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                \
-       int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-
-#define HW_ENDCLIPLOOP()                       \
-    }                                          \
-  } while (0)
-
 #define HW_UNLOCK()
 
 /* 16 bit, 565 rgb color spanline and pixel functions
Index: i830/i830_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/i830/i830_span.c,v
retrieving revision 1.3
diff -u -r1.3 i830_span.c
--- i830/i830_span.c    7 May 2004 22:46:37 -0000       1.3
+++ i830/i830_span.c    3 Mar 2005 19:25:53 -0000
@@ -81,39 +81,11 @@
 #define INIT_MONO_PIXEL(p,color)\
         p = PACK_COLOR_565(color[0],color[1],color[2])
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                \
-   } else {                                                            \
-      _n1 = _n;                                                        \
-      _x1 = _x;                                                        \
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                \
-   }
 
 #define Y_FLIP(_y) (height - _y - 1)
 
-
 #define HW_LOCK()
 
-#define HW_CLIPLOOP()                                          \
-  do {                                                         \
-    __DRIdrawablePrivate *dPriv = imesa->driDrawable;          \
-    int _nc = dPriv->numClipRects;                             \
-    while (_nc--) {                                            \
-       int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                \
-       int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;        \
-       int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                \
-       int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-
-#define HW_ENDCLIPLOOP()                       \
-    }                                          \
-  } while (0)
-
 #define HW_UNLOCK()
 
 /* 16 bit, 565 rgb color spanline and pixel functions
Index: i915/intel_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/i915/intel_span.c,v
retrieving revision 1.4
diff -u -r1.4 intel_span.c
--- i915/intel_span.c   20 Jan 2005 13:24:08 -0000      1.4
+++ i915/intel_span.c   3 Mar 2005 19:25:53 -0000
@@ -69,39 +69,10 @@
 #define INIT_MONO_PIXEL(p,color)\
         p = INTEL_PACKCOLOR565(color[0],color[1],color[2])
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                \
-   } else {                                                            \
-      _n1 = _n;                                                        \
-      _x1 = _x;                                                        \
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                \
-   }
-
 #define Y_FLIP(_y) (height - _y - 1)
 
-
 #define HW_LOCK()
 
-#define HW_CLIPLOOP()                                          \
-  do {                                                         \
-    __DRIdrawablePrivate *dPriv = intel->driDrawable;          \
-    int _nc = dPriv->numClipRects;                             \
-    while (_nc--) {                                            \
-       int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                \
-       int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;        \
-       int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                \
-       int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-
-#define HW_ENDCLIPLOOP()                       \
-    }                                          \
-  } while (0)
-
 #define HW_UNLOCK()
 
 /* 16 bit, 565 rgb color spanline and pixel functions
Index: mach64/mach64_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/mach64/mach64_span.c,v
retrieving revision 1.2
diff -u -r1.2 mach64_span.c
--- mach64/mach64_span.c        21 Mar 2004 17:05:03 -0000      1.2
+++ mach64/mach64_span.c        3 Mar 2005 19:25:53 -0000
@@ -26,7 +26,6 @@
 #include "mach64_ioctl.h"
 #include "mach64_state.h"
 #include "mach64_span.h"
-#include "mach64_tex.h"
 
 #include "swrast/swrast.h"
 
@@ -70,19 +69,6 @@
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
-#define CLIPPIXEL( _x, _y )                                            \
-   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if (( _y < miny) || (_y >= maxy)) {                                 \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if (_x1 < minx) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx;  \
-      if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx);                  \
-   }
 
 #define Y_FLIP( _y )   (height - _y - 1)
 
@@ -117,58 +103,24 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
-  p = MACH64PACKCOLOR565( color[0], color[1], color[2] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
-   *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) |    \
-                                          (((int)g & 0xfc) << 3) |     \
-                                          (((int)b & 0xf8) >> 3))
-
-#define WRITE_PIXEL( _x, _y, p )                                       \
-    *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y )                                      \
-    do {                                                               \
-       GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);         \
-       rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8;                       \
-       rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc;                       \
-       rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8;                       \
-       rgba[3] = 0xff;                                                 \
-    } while (0)
-
-#define TAG(x) mach64##x##_RGB565
-#include "spantmp.h"
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
+#define TAG(x)    mach64##x##_RGB565
+#define TAG2(x,y) mach64##x##_RGB565##y
+#include "spantmp2.h"
 
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
-  p = MACH64PACKCOLOR8888( color[0], color[1], color[2], color[3] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = ((b <<  0) |                   \
-                                        (g <<  8) |                    \
-                                        (r << 16) |                    \
-                                        (a << 24) )
-
-#define WRITE_PIXEL( _x, _y, p )                                       \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y )                                      \
-do {                                                                   \
-   GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch);                 \
-   rgba[0] = (p >> 16) & 0xff;                                         \
-   rgba[1] = (p >>  8) & 0xff;                                         \
-   rgba[2] = (p >>  0) & 0xff;                                         \
-   rgba[3] = 0xff; /*(p >> 24) & 0xff;*/                               \
-} while (0)
-
-#define TAG(x) mach64##x##_ARGB8888
-#include "spantmp.h"
+/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
+   Was there a reason to do so ? If so that'll won't work with that 
template... */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x)    mach64##x##_ARGB8888
+#define TAG2(x,y) mach64##x##_ARGB8888##y
+#include "spantmp2.h"
 
 
 
@@ -228,24 +180,11 @@
 
    switch ( mmesa->mach64Screen->cpp ) {
    case 2:
-      swdd->WriteRGBASpan      = mach64WriteRGBASpan_RGB565;
-      swdd->WriteRGBSpan       = mach64WriteRGBSpan_RGB565;
-      swdd->WriteMonoRGBASpan  = mach64WriteMonoRGBASpan_RGB565;
-      swdd->WriteRGBAPixels    = mach64WriteRGBAPixels_RGB565;
-      swdd->WriteMonoRGBAPixels        = mach64WriteMonoRGBAPixels_RGB565;
-      swdd->ReadRGBASpan       = mach64ReadRGBASpan_RGB565;
-      swdd->ReadRGBAPixels     = mach64ReadRGBAPixels_RGB565;
+      mach64InitPointers_RGB565( swdd );
       break;
 
    case 4:
-      swdd->WriteRGBASpan      = mach64WriteRGBASpan_ARGB8888;
-      swdd->WriteRGBSpan       = mach64WriteRGBSpan_ARGB8888;
-      swdd->WriteMonoRGBASpan  = mach64WriteMonoRGBASpan_ARGB8888;
-      swdd->WriteRGBAPixels    = mach64WriteRGBAPixels_ARGB8888;
-      swdd->WriteMonoRGBAPixels        = mach64WriteMonoRGBAPixels_ARGB8888;
-      swdd->ReadRGBASpan       = mach64ReadRGBASpan_ARGB8888;
-      swdd->ReadRGBAPixels     = mach64ReadRGBAPixels_ARGB8888;
-
+      mach64InitPointers_ARGB8888( swdd );
       break;
 
    default:
Index: mga/mgaspan.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/mga/mgaspan.c,v
retrieving revision 1.8
diff -u -r1.8 mgaspan.c
--- mga/mgaspan.c       20 Jan 2005 13:24:08 -0000      1.8
+++ mga/mgaspan.c       3 Mar 2005 19:25:53 -0000
@@ -67,19 +67,6 @@
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 
 #define HW_LOCK()                              \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);     \
@@ -112,9 +99,6 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 2 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 2 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -124,9 +108,6 @@
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 4 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
Index: r128/r128_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r128/r128_span.c,v
retrieving revision 1.4
diff -u -r1.4 r128_span.c
--- r128/r128_span.c    20 Jan 2005 13:24:08 -0000      1.4
+++ r128/r128_span.c    3 Mar 2005 19:25:53 -0000
@@ -75,21 +75,6 @@
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
-
-#define CLIPPIXEL( _x, _y )                                            \
-   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP( _y )           (height - _y - 1)
 
 
@@ -99,21 +84,6 @@
    LOCK_HARDWARE( rmesa );                                             \
    r128WaitForIdleLocked( rmesa );
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                        
\
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 #define HW_UNLOCK()                                                    \
    UNLOCK_HARDWARE( rmesa )
 
@@ -125,8 +95,6 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 2 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 2 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -137,8 +105,6 @@
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 4 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
Index: r200/r200_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_span.c,v
retrieving revision 1.7
diff -u -r1.7 r200_span.c
--- r200/r200_span.c    26 Jan 2005 18:05:03 -0000      1.7
+++ r200/r200_span.c    3 Mar 2005 19:25:54 -0000
@@ -77,41 +77,10 @@
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
-
-#define CLIPPIXEL( _x, _y )                                            \
-   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP( _y )           (height - _y - 1)
 
-
 #define HW_LOCK() 
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;               \
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 #define HW_UNLOCK()                                                    
 
 
@@ -122,9 +91,6 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 2 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 2 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -134,9 +100,6 @@
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 4 + _y * pitch)
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
Index: radeon/radeon_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/radeon/radeon_span.c,v
retrieving revision 1.4
diff -u -r1.4 radeon_span.c
--- radeon/radeon_span.c        26 Jan 2005 18:05:03 -0000      1.4
+++ radeon/radeon_span.c        3 Mar 2005 19:25:55 -0000
@@ -78,41 +78,10 @@
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
-
-#define CLIPPIXEL( _x, _y )                                            \
-   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP( _y )           (height - _y - 1)
 
-
 #define HW_LOCK() 
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;               \
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 #define HW_UNLOCK()                                                    
 
 
@@ -123,61 +92,21 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-#define INIT_MONO_PIXEL(p, color) \
-  p = PACK_COLOR_565( color[0], color[1], color[2] )
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
-#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
-   *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) |    \
-                                          (((int)g & 0xfc) << 3) |     \
-                                          (((int)b & 0xf8) >> 3))
-
-#define WRITE_PIXEL( _x, _y, p )                                       \
-   *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y )                                      \
-   do {                                                                        
\
-      GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);          \
-      rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8;                                
\
-      rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc;                                
\
-      rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8;                                
\
-      rgba[3] = 0xff;                                                  \
-   } while (0)
-
-#define TAG(x) radeon##x##_RGB565
-#include "spantmp.h"
+#define TAG(x)    radeon##x##_RGB565
+#define TAG2(x,y) radeon##x##_RGB565##y
+#include "spantmp2.h"
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
-  p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a )                       \
-do {                                                           \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = ((b <<  0) |           \
-                                        (g <<  8) |            \
-                                        (r << 16) |            \
-                                        (a << 24) );           \
-} while (0)
-
-#define WRITE_PIXEL( _x, _y, p )                       \
-do {                                                   \
-   *(GLuint *)(buf + _x*4 + _y*pitch) = p;             \
-} while (0)
-
-#define READ_RGBA( rgba, _x, _y )                              \
-do {                                                           \
-   volatile GLuint *ptr = (volatile GLuint *)(read_buf + _x*4 + _y*pitch); \
-   GLuint p = *ptr;                                    \
-   rgba[0] = (p >> 16) & 0xff;                                 \
-   rgba[1] = (p >>  8) & 0xff;                                 \
-   rgba[2] = (p >>  0) & 0xff;                                 \
-   rgba[3] = (p >> 24) & 0xff;                                 \
-} while (0)
-
-#define TAG(x) radeon##x##_ARGB8888
-#include "spantmp.h"
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
+#define TAG(x)    radeon##x##_ARGB8888
+#define TAG2(x,y) radeon##x##_ARGB8888##y
+#include "spantmp2.h"
 
 
 /* ================================================================
@@ -375,23 +304,11 @@
 
    switch ( rmesa->radeonScreen->cpp ) {
    case 2:
-      swdd->WriteRGBASpan      = radeonWriteRGBASpan_RGB565;
-      swdd->WriteRGBSpan       = radeonWriteRGBSpan_RGB565;
-      swdd->WriteMonoRGBASpan  = radeonWriteMonoRGBASpan_RGB565;
-      swdd->WriteRGBAPixels    = radeonWriteRGBAPixels_RGB565;
-      swdd->WriteMonoRGBAPixels        = radeonWriteMonoRGBAPixels_RGB565;
-      swdd->ReadRGBASpan       = radeonReadRGBASpan_RGB565;
-      swdd->ReadRGBAPixels      = radeonReadRGBAPixels_RGB565;
+      radeonInitPointers_RGB565( swdd );
       break;
 
    case 4:
-      swdd->WriteRGBASpan      = radeonWriteRGBASpan_ARGB8888;
-      swdd->WriteRGBSpan       = radeonWriteRGBSpan_ARGB8888;
-      swdd->WriteMonoRGBASpan   = radeonWriteMonoRGBASpan_ARGB8888;
-      swdd->WriteRGBAPixels     = radeonWriteRGBAPixels_ARGB8888;
-      swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_ARGB8888;
-      swdd->ReadRGBASpan       = radeonReadRGBASpan_ARGB8888;
-      swdd->ReadRGBAPixels      = radeonReadRGBAPixels_ARGB8888;
+      radeonInitPointers_ARGB8888( swdd );
       break;
 
    default:
Index: s3v/s3v_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/s3v/s3v_span.c,v
retrieving revision 1.2
diff -u -r1.2 s3v_span.c
--- s3v/s3v_span.c      27 Dec 2004 20:31:56 -0000      1.2
+++ s3v/s3v_span.c      3 Mar 2005 19:25:56 -0000
@@ -46,22 +46,6 @@
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
 
-#define CLIPPIXEL( _x, _y ) \
-       ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
-       if ( _y < miny || _y >= maxy ) { \
-               _n1 = 0, _x1 = x; \
-       } else { \
-               _n1 = _n; \
-               _x1 = _x; \
-               if ( _x1 < minx ) \
-                       _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-               if ( _x1 + _n1 >= maxx ) \
-                       n1 -= (_x1 + n1 - maxx); \
-       }
-
 #define Y_FLIP( _y )   (height - _y - 1)
 
 #if _SPANLOCK  /* OK, we lock */
@@ -83,21 +67,6 @@
 
 #endif
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = vmesa->driDrawable;                        
\
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 
 /* ================================================================
  * Color buffer
Index: savage/savagespan.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/savage/savagespan.c,v
retrieving revision 1.7
diff -u -r1.7 savagespan.c
--- savage/savagespan.c 21 Jan 2005 01:39:09 -0000      1.7
+++ savage/savagespan.c 3 Mar 2005 19:25:56 -0000
@@ -42,6 +42,7 @@
    char *buf = (char *)(map +                          \
                        dPriv->x * cpp +                \
                        dPriv->y * pitch);              \
+   char *read_buf = buf;                                       \
    GLuint p;                                           \
    (void) p
 
@@ -58,20 +59,6 @@
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP(_y) (height - _y - 1)
 
 #define HW_LOCK()
@@ -86,26 +73,9 @@
        savageContextPtr imesa = SAVAGE_CONTEXT(ctx);   \
        char *map = imesa->readMap;
 
-#define HW_CLIPLOOP()                                          \
-  do {                                                         \
-    __DRIdrawablePrivate *dPriv = imesa->driDrawable;          \
-    int _nc = dPriv->numClipRects;                             \
-    while (_nc--) {                                            \
-       int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                \
-       int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;        \
-       int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                \
-       int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-
-#define HW_ENDCLIPLOOP()                       \
-    }                                          \
-  } while (0)
-
 
 /* 16 bit, 565 rgb color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (buf + (_x<<1) + _y*pitch)
-#define GET_DST_PTR(_x, _y) GET_SRC_PTR(_x, _y)
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -116,8 +86,6 @@
 
 /* 32 bit, 8888 ARGB color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (buf + (_x<<2) + _y*pitch)
-#define GET_DST_PTR(_x, _y) GET_SRC_PTR(_x, _y)
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
Index: sis/sis_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/sis/sis_span.c,v
retrieving revision 1.6
diff -u -r1.6 sis_span.c
--- sis/sis_span.c      20 Jan 2005 13:24:08 -0000      1.6
+++ sis/sis_span.c      3 Mar 2005 19:25:56 -0000
@@ -43,6 +43,8 @@
 
 #define LOCAL_VARS                                                     \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                             \
+   __DRIdrawablePrivate *dPriv = smesa->driDrawable;                   \
+   GLuint pitch = smesa->drawPitch;                                    \
    char *buf = (char *)(smesa->FbBase + smesa->drawOffset);            \
    char *read_buf = (char *)(smesa->FbBase + smesa->readOffset);       \
    GLuint p;                                                           \
@@ -50,94 +52,34 @@
 
 #define LOCAL_DEPTH_VARS                                               \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                             \
+   __DRIdrawablePrivate *dPriv = smesa->driDrawable;                   \
    char *buf = smesa->depthbuffer;                                     \
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
-                         _y >= miny && _y < maxy)
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
 
 #define HW_LOCK() do {} while(0);
 
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        
\
-      __DRIdrawablePrivate *dPriv = smesa->driDrawable;                        
\
-      int _nc = dPriv->numClipRects;                                   \
-                                                                       \
-      while ( _nc-- ) {                                                        
\
-        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
-        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
-        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
-        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
-
-#define HW_ENDCLIPLOOP()                                               \
-      }                                                                        
\
-   } while (0)
-
 #define HW_UNLOCK() do {} while(0);
 
 /* RGB565 */
-#define INIT_MONO_PIXEL(p, color) \
-  p = SISPACKCOLOR565( color[0], color[1], color[2] )
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
-#define WRITE_RGBA( _x, _y, r, g, b, a )                               \
-   *(GLushort *)(buf + _x*2 + _y*smesa->drawPitch) =                   \
-                                            (((r & 0xf8) << 8) |       \
-                                            ((g & 0xfc) << 3) |        \
-                                            (b >> 3))
-
-#define WRITE_PIXEL( _x, _y, p )  \
-   *(GLushort *)(buf + _x*2 + _y*smesa->drawPitch) = p
-
-#define READ_RGBA( rgba, _x, _y )                      \
-do {                                                   \
-   GLushort p = *(GLushort *)(read_buf + _x*2 + _y*smesa->readPitch);  \
-   rgba[0] = (p & 0xf800) >> 8;                                \
-   rgba[1] = (p & 0x07e0) >> 3;                                \
-   rgba[2] = (p & 0x001f) << 3;                                \
-   rgba[3] = 0xff;                                     \
-} while(0)
-
-#define TAG(x) sis##x##_565
-#include "spantmp.h"
+#define TAG(x)    sis##x##_RGB565
+#define TAG2(x,y) sis##x##_RGB565##y
+#include "spantmp2.h"
 
 
 /* ARGB8888 */
-#undef INIT_MONO_PIXEL
-#define INIT_MONO_PIXEL(p, color) \
-  p = SISPACKCOLOR8888( color[0], color[1], color[2], color[3] )
-
-#define WRITE_RGBA( _x, _y, r, g, b, a )                       \
-   *(GLuint *)(buf + _x*4 + _y*smesa->drawPitch) =             \
-                                          (((a) << 24) |       \
-                                          ((r) << 16) |        \
-                                          ((g) << 8) |         \
-                                          ((b)))
-
-#define WRITE_PIXEL( _x, _y, p )  \
-   *(GLuint *)(buf + _x*4 + _y*smesa->drawPitch)  = p
-
-#define READ_RGBA( rgba, _x, _y )                      \
-do {                                                   \
-   GLuint p = *(GLuint *)(read_buf + _x*4 + _y*smesa->readPitch);      \
-   rgba[0] = (p >> 16) & 0xff;                         \
-   rgba[1] = (p >> 8) & 0xff;                          \
-   rgba[2] = (p >> 0) & 0xff;                          \
-   rgba[3] = 0xff;                                     \
-} while(0)
-
-#define TAG(x) sis##x##_8888
-#include "spantmp.h"
+/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
+   Was there a reason to do so ? If so that'll won't work with that 
template... */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x)    sis##x##_ARGB8888
+#define TAG2(x,y) sis##x##_ARGB8888##y
+#include "spantmp2.h"
 
 
 /* 16 bit depthbuffer functions.
@@ -283,22 +225,10 @@
    switch ( smesa->bytesPerPixel )
    {
    case 2:
-      swdd->WriteRGBASpan = sisWriteRGBASpan_565;
-      swdd->WriteRGBSpan = sisWriteRGBSpan_565;
-      swdd->WriteMonoRGBASpan = sisWriteMonoRGBASpan_565;
-      swdd->WriteRGBAPixels = sisWriteRGBAPixels_565;
-      swdd->WriteMonoRGBAPixels = sisWriteMonoRGBAPixels_565;
-      swdd->ReadRGBASpan = sisReadRGBASpan_565;
-      swdd->ReadRGBAPixels = sisReadRGBAPixels_565;
+      sisInitPointers_RGB565( swdd );
       break;
    case 4:
-      swdd->WriteRGBASpan = sisWriteRGBASpan_8888;
-      swdd->WriteRGBSpan = sisWriteRGBSpan_8888;
-      swdd->WriteMonoRGBASpan = sisWriteMonoRGBASpan_8888;
-      swdd->WriteRGBAPixels = sisWriteRGBAPixels_8888;
-      swdd->WriteMonoRGBAPixels = sisWriteMonoRGBAPixels_8888;
-      swdd->ReadRGBASpan = sisReadRGBASpan_8888;
-      swdd->ReadRGBAPixels = sisReadRGBAPixels_8888;
+      sisInitPointers_ARGB8888( swdd );
       break;
     default:
       sis_fatal_error("Bad bytesPerPixel.\n");
Index: tdfx/tdfx_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c,v
retrieving revision 1.5
diff -u -r1.5 tdfx_span.c
--- tdfx/tdfx_span.c    2 Oct 2004 16:39:11 -0000       1.5
+++ tdfx/tdfx_span.c    3 Mar 2005 19:25:57 -0000
@@ -60,19 +60,6 @@
    (void) buf; (void) p;
 
 
-#define CLIPPIXEL( _x, _y )    ( _x >= minx && _x < maxx &&            \
-                                 _y >= miny && _y < maxy )
-
-#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
-   if ( _y < miny || _y >= maxy ) {                                    \
-      _n1 = 0, _x1 = x;                                                        
\
-   } else {                                                            \
-      _n1 = _n;                                                                
\
-      _x1 = _x;                                                                
\
-      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
-      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
-   }
-
 #define Y_FLIP(_y)             (height - _y - 1)
 
 
Index: unichrome/via_span.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/unichrome/via_span.c,v
retrieving revision 1.17
diff -u -r1.17 via_span.c
--- unichrome/via_span.c        20 Jan 2005 13:24:08 -0000      1.17
+++ unichrome/via_span.c        3 Mar 2005 19:25:57 -0000
@@ -33,38 +33,9 @@
 
 #define DBG 0
 
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx &&    \
-                          _y >= miny && _y < maxy)
-
-
-#define CLIPSPAN(_x, _y, _n, _x1, _n1, _i)                                  \
-    if (_y < miny || _y >= maxy) {                                          \
-        _n1 = 0, _x1 = x;                                                   \
-    }                                                                       \
-    else {                                                                  \
-        _n1 = _n;                                                           \
-        _x1 = _x;                                                           \
-        if (_x1 < minx) _i += (minx -_x1), n1 -= (minx -_x1), _x1 = minx;   \
-        if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx);                     \
-   }
-
 #define Y_FLIP(_y) (height - _y - 1)
 
 #define HW_LOCK() 
-#define HW_CLIPLOOP()                                                          
\
-    do {                                                                       
\
-        __DRIdrawablePrivate *dPriv = vmesa->driDrawable;                      
\
-        int _nc = dPriv->numClipRects;                                         
\
-        while (_nc--) {                                                        
        \
-               int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                
\
-               int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;                
\
-               int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                
\
-               int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;        
-
-
-#define HW_ENDCLIPLOOP()                                            \
-        }                                                           \
-    } while (0)
 
 #define HW_UNLOCK()
 
@@ -86,8 +57,8 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 2 + _y * read_pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 2 + _y * draw_pitch)
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * read_pitch)
+#define GET_DST_PTR(_x, _y) (     buf + (_x) * 2 + (_y) * draw_pitch)
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -98,8 +69,8 @@
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * read_pitch)
-#define GET_DST_PTR(_x, _y) (     buf + _x * 4 + _y * draw_pitch)
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * read_pitch)
+#define GET_DST_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * draw_pitch)
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
Index: common/spantmp_common.h
===================================================================
+++ common/spantmp_common.h     2005-03-02 22:15:18.000000000 +0100
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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.
+ */
+
+/**
+ * \file spantmp_common.h
+ *
+ * common macros for span read / write functions to be used in the depth,
+ * stencil and pixel span templates.
+ */
+
+#ifndef HW_WRITE_LOCK
+#define HW_WRITE_LOCK()                HW_LOCK()
+#endif
+
+#ifndef HW_WRITE_UNLOCK
+#define HW_WRITE_UNLOCK()      HW_UNLOCK()
+#endif
+
+#ifndef HW_READ_LOCK
+#define HW_READ_LOCK()         HW_LOCK()
+#endif
+
+#ifndef HW_READ_UNLOCK
+#define HW_READ_UNLOCK()       HW_UNLOCK()
+#endif
+
+#ifndef HW_CLIPLOOP
+#define HW_CLIPLOOP()                                                  \
+   do {                                                                        
\
+      int _nc = dPriv->numClipRects;                                   \
+      while ( _nc-- ) {                                                        
\
+        int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
+        int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
+        int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
+        int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+#endif
+
+#ifndef HW_ENDCLIPLOOP
+#define HW_ENDCLIPLOOP()                                               \
+      }                                                                        
\
+   } while (0)
+#endif
+
+#ifndef CLIPPIXEL
+#define CLIPPIXEL( _x, _y )                                            \
+   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+#endif
+
+#ifndef CLIPSPAN
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                           \
+   if ( _y < miny || _y >= maxy || _x + n < minx || _x >=maxx ) {      \
+      _n1 = 0, _x1 = x;                                                        
\
+   } else {                                                            \
+      _n1 = _n;                                                                
\
+      _x1 = _x;                                                                
\
+      if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
+      if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                        
\
+   }
+#endif

Reply via email to