Changed escaping of double quotes.
[mesa.git] / src / mesa / drivers / dri / common / spantmp2.h
index 01d7fea0c528cd8cd9d67cf113614c6d187c2a6c..fa737a9623f0d032a7303a1b0df68d6ca6c1642e 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 {                                                              \
@@ -366,7 +376,11 @@ static void TAG(ReadRGBASpan)( const GLcontext *ctx,
 }
 
 
-#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)))
 static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
                               GLuint n, GLint x, GLint y,
                               GLubyte rgba[][4])
@@ -378,7 +392,7 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
    __asm__ __volatile__( "emms" );
 #endif
 
-   HW_LOCK()
+   HW_READ_LOCK()
      {
        GLint x1,n1;
        LOCAL_VARS;
@@ -394,12 +408,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,12 +426,14 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
 #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)
 static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
                               GLuint n, GLint x, GLint y,
                               GLubyte rgba[][4])
 {
-   HW_LOCK()
+   HW_READ_LOCK()
      {
        GLint x1,n1;
        LOCAL_VARS;
@@ -433,11 +454,13 @@ static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
          }
        HW_ENDCLIPLOOP();
      }
-   HW_UNLOCK();
+   HW_READ_UNLOCK();
 }
 #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)
 static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
                               GLuint n, GLint x, GLint y,
                               GLubyte rgba[][4])
@@ -449,7 +472,7 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
    __asm__ __volatile__( "emms" );
 #endif
 
-   HW_LOCK()
+   HW_READ_LOCK()
      {
        GLint x1,n1;
        LOCAL_VARS;
@@ -470,7 +493,7 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
          }
        HW_ENDCLIPLOOP();
      }
-   HW_UNLOCK();
+   HW_READ_UNLOCK();
 #ifndef USE_INNER_EMMS
    __asm__ __volatile__( "emms" );
 #endif
@@ -523,21 +546,29 @@ static void TAG(InitPointers)(struct swrast_device_driver *swdd)
    swdd->WriteMonoRGBAPixels = TAG(WriteMonoRGBAPixels);
    swdd->ReadRGBAPixels = TAG(ReadRGBAPixels);
 
-#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_xmm2 ) {
       if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "SSE2" );
       swdd->ReadRGBASpan = 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);
    }
    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);