remove the XFree86 ID line
[mesa.git] / src / mesa / drivers / dri / common / spantmp2.h
index 01d7fea0c528cd8cd9d67cf113614c6d187c2a6c..b2b31863090b6dad884fdbdf05d35a06c2a87851 100644 (file)
                                : "=r" (p) : "r" (p) );                 \
        ((GLuint *)rgba)[0] = p;                                         \
     } while (0)
+# elif defined( MESA_BIG_ENDIAN )
+    /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
+     * rotlwi instruction.  It also produces good code on SPARC.
+     */
+#  define READ_RGBA( rgba, _x, _y )                                    \
+     do {                                                              \
+        GLuint p = *(volatile GLuint *) GET_SRC_PTR(_x, _y);            \
+        GLuint t = p;                                                   \
+        *((uint32_t *) rgba) = (t >> 24) | (p << 8);                    \
+     } while (0)
 # else
 #  define READ_RGBA( rgba, _x, _y )                                    \
      do {                                                              \
 #include "x86/common_x86_asm.h"
 #endif
 
-static void TAG(WriteRGBASpan)( const GLcontext *ctx,
+static void TAG(WriteRGBASpan)( GLcontext *ctx,
+                                struct gl_renderbuffer *rb,
                                GLuint n, GLint x, GLint y,
-                               const GLubyte rgba[][4],
-                               const GLubyte mask[] )
+                               const void *values, const GLubyte mask[] )
 {
    HW_WRITE_LOCK()
       {
+         const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
         GLint x1;
         GLint n1;
         LOCAL_VARS;
@@ -177,13 +188,14 @@ static void TAG(WriteRGBASpan)( const GLcontext *ctx,
    HW_WRITE_UNLOCK();
 }
 
-static void TAG(WriteRGBSpan)( const GLcontext *ctx,
+static void TAG(WriteRGBSpan)( GLcontext *ctx,
+                               struct gl_renderbuffer *rb,
                               GLuint n, GLint x, GLint y,
-                              const GLubyte rgb[][3],
-                              const GLubyte mask[] )
+                              const void *values, const GLubyte mask[] )
 {
    HW_WRITE_LOCK()
       {
+         const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
         GLint x1;
         GLint n1;
         LOCAL_VARS;
@@ -215,15 +227,14 @@ static void TAG(WriteRGBSpan)( const GLcontext *ctx,
    HW_WRITE_UNLOCK();
 }
 
-static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
-                              GLuint n,
-                              const GLint x[],
-                              const GLint y[],
-                              const GLubyte rgba[][4],
-                              const GLubyte mask[] )
+static void TAG(WriteRGBAPixels)( GLcontext *ctx,
+                                  struct gl_renderbuffer *rb,
+                                  GLuint n, const GLint x[], const GLint y[],
+                                  const void *values, const GLubyte mask[] )
 {
    HW_WRITE_LOCK()
       {
+         const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
         GLint i;
         LOCAL_VARS;
 
@@ -262,13 +273,14 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
 }
 
 
-static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,      
+static void TAG(WriteMonoRGBASpan)( GLcontext *ctx,    
+                                    struct gl_renderbuffer *rb,
                                    GLuint n, GLint x, GLint y, 
-                                   const GLchan color[4],
-                                   const GLubyte mask[] )
+                                   const void *value, const GLubyte mask[] )
 {
    HW_WRITE_LOCK()
       {
+         const GLubyte *color = (const GLubyte *) value;
         GLint x1;
         GLint n1;
         LOCAL_VARS;
@@ -300,14 +312,16 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
 }
 
 
-static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
+static void TAG(WriteMonoRGBAPixels)( GLcontext *ctx,
+                                      struct gl_renderbuffer *rb,
                                      GLuint n,
                                      const GLint x[], const GLint y[],
-                                     const GLchan color[],
+                                     const void *value,
                                      const GLubyte mask[] ) 
 {
    HW_WRITE_LOCK()
       {
+         const GLubyte *color = (const GLubyte *) value;
         GLint i;
         LOCAL_VARS;
         INIT_MONO_PIXEL(p, color);
@@ -340,12 +354,13 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
 }
 
 
-static void TAG(ReadRGBASpan)( const GLcontext *ctx,
-                              GLuint n, GLint x, GLint y,
-                              GLubyte rgba[][4])
+static void TAG(ReadRGBASpan)( GLcontext *ctx,
+                               struct gl_renderbuffer *rb,
+                              GLuint n, GLint x, GLint y, void *values)
 {
    HW_READ_LOCK()
       {
+         GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
         GLint x1,n1;
         LOCAL_VARS;
 
@@ -366,10 +381,14 @@ static void TAG(ReadRGBASpan)( const GLcontext *ctx,
 }
 
 
-#if defined(USE_MMX_ASM)
-static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
-                              GLuint n, GLint x, GLint y,
-                              GLubyte rgba[][4])
+#if defined(USE_MMX_ASM) && \
+   (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
+       (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
+    ((SPANTMP_PIXEL_FMT == GL_RGB) && \
+       (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
+static void TAG2(ReadRGBASpan,_MMX)( GLcontext *ctx,
+                                     struct gl_renderbuffer *rb,
+                                     GLuint n, GLint x, GLint y, void *values)
 {
 #ifndef USE_INNER_EMMS
    /* The EMMS instruction is directly in-lined here because using GCC's
@@ -378,8 +397,9 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
    __asm__ __volatile__( "emms" );
 #endif
 
-   HW_LOCK()
+   HW_READ_LOCK()
      {
+        GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
        GLint x1,n1;
        LOCAL_VARS;
 
@@ -394,12 +414,17 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
 
               {
                  const char * src = GET_SRC_PTR( x1, y );
+#if (SPANTMP_PIXEL_FMT == GL_RGB) && \
+                 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
+                 _generic_read_RGBA_span_RGB565_MMX( src, rgba[i], n1 );
+#else
                  _generic_read_RGBA_span_BGRA8888_REV_MMX( src, rgba[i], n1 );
+#endif
               }
          }
        HW_ENDCLIPLOOP();
      }
-   HW_UNLOCK();
+   HW_READ_UNLOCK();
 #ifndef USE_INNER_EMMS
    __asm__ __volatile__( "emms" );
 #endif
@@ -407,13 +432,17 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
 #endif
 
 
-#if defined(USE_SSE_ASM)
-static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
-                              GLuint n, GLint x, GLint y,
-                              GLubyte rgba[][4])
+#if defined(USE_SSE_ASM) && \
+   (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+     (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+static void TAG2(ReadRGBASpan,_SSE2)( GLcontext *ctx,
+                                      struct gl_renderbuffer *rb,
+                                      GLuint n, GLint x, GLint y,
+                                      void *values)
 {
-   HW_LOCK()
+   HW_READ_LOCK()
      {
+        GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
        GLint x1,n1;
        LOCAL_VARS;
 
@@ -433,14 +462,17 @@ static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
          }
        HW_ENDCLIPLOOP();
      }
-   HW_UNLOCK();
+   HW_READ_UNLOCK();
 }
 #endif
 
-#if defined(USE_SSE_ASM)
-static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
-                              GLuint n, GLint x, GLint y,
-                              GLubyte rgba[][4])
+#if defined(USE_SSE_ASM) && \
+   (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+     (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+static void TAG2(ReadRGBASpan,_SSE)( GLcontext *ctx,
+                                     struct gl_renderbuffer *rb,
+                                     GLuint n, GLint x, GLint y,
+                                     void *values)
 {
 #ifndef USE_INNER_EMMS
    /* The EMMS instruction is directly in-lined here because using GCC's
@@ -449,8 +481,9 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
    __asm__ __volatile__( "emms" );
 #endif
 
-   HW_LOCK()
+   HW_READ_LOCK()
      {
+        GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
        GLint x1,n1;
        LOCAL_VARS;
 
@@ -470,7 +503,7 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
          }
        HW_ENDCLIPLOOP();
      }
-   HW_UNLOCK();
+   HW_READ_UNLOCK();
 #ifndef USE_INNER_EMMS
    __asm__ __volatile__( "emms" );
 #endif
@@ -478,12 +511,15 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
 #endif
 
 
-static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
+static void TAG(ReadRGBAPixels)( GLcontext *ctx,
+                                 struct gl_renderbuffer *rb,
                                 GLuint n, const GLint x[], const GLint y[],
-                                GLubyte rgba[][4], const GLubyte mask[] )
+                                void *values )
 {
    HW_READ_LOCK()
       {
+         GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+         GLubyte *mask = NULL; /* remove someday */
         GLint i;
         LOCAL_VARS;
 
@@ -514,39 +550,47 @@ static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
    HW_READ_UNLOCK();
 }
 
-static void TAG(InitPointers)(struct swrast_device_driver *swdd)
+static void TAG(InitPointers)(struct gl_renderbuffer *rb)
 {
-   swdd->WriteRGBASpan = TAG(WriteRGBASpan);
-   swdd->WriteRGBSpan = TAG(WriteRGBSpan);
-   swdd->WriteMonoRGBASpan = TAG(WriteMonoRGBASpan);
-   swdd->WriteRGBAPixels = TAG(WriteRGBAPixels);
-   swdd->WriteMonoRGBAPixels = TAG(WriteMonoRGBAPixels);
-   swdd->ReadRGBAPixels = TAG(ReadRGBAPixels);
-
-#if defined(USE_SSE_ASM)
+   rb->PutRow = TAG(WriteRGBASpan);
+   rb->PutRowRGB = TAG(WriteRGBSpan);
+   rb->PutMonoRow = TAG(WriteMonoRGBASpan);
+   rb->PutValues = TAG(WriteRGBAPixels);
+   rb->PutMonoValues = TAG(WriteMonoRGBAPixels);
+   rb->GetValues = TAG(ReadRGBAPixels);
+
+#if defined(USE_SSE_ASM) && \
+   (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+     (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
    if ( cpu_has_xmm2 ) {
-      if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "SSE2" );
-      swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _SSE2);
+      if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE2" );
+      rb->GetRow = TAG2(ReadRGBASpan, _SSE2);
    }
    else
 #endif
-#if defined(USE_SSE_ASM)
+#if defined(USE_SSE_ASM) && \
+   (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+     (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
    if ( cpu_has_xmm ) {
-      if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "SSE" );
-      swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _SSE);
+      if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE" );
+      rb->GetRow = TAG2(ReadRGBASpan, _SSE);
    }
    else
 #endif
-#if defined(USE_MMX_ASM)
+#if defined(USE_MMX_ASM) && \
+   (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
+       (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
+    ((SPANTMP_PIXEL_FMT == GL_RGB) && \
+       (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
    if ( cpu_has_mmx ) {
-      if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "MMX" );
-      swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _MMX);
+      if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "MMX" );
+      rb->GetRow = TAG2(ReadRGBASpan, _MMX);
    }
    else
 #endif
    {
-      if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "C" );
-      swdd->ReadRGBASpan = TAG(ReadRGBASpan);
+      if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "C" );
+      rb->GetRow = TAG(ReadRGBASpan);
    }
 
 }