6030ca18a7e302c36f693ad5531fdeaaf003d217
2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * (C) Copyright IBM Corporation 2004
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * on the rights to use, copy, modify, merge, publish, distribute, sub
10 * license, and/or sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Template file of span read / write functions.
31 * \author Keith Whitwell <keithw@tungstengraphics.com>
32 * \author Gareth Hughes <gareth@nvidia.com>
33 * \author Ian Romanick <idr@us.ibm.com>
36 #include "main/colormac.h"
37 #include "spantmp_common.h"
43 #ifndef HW_READ_CLIPLOOP
44 #define HW_READ_CLIPLOOP() HW_CLIPLOOP()
47 #ifndef HW_WRITE_CLIPLOOP
48 #define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
51 #if (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
54 ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5
59 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
62 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
63 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
64 #endif /* GET_VALUE */
66 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
67 PUT_VALUE(_x, _y, ((((int)r & 0xf8) << 8) | \
68 (((int)g & 0xfc) << 3) | \
69 (((int)b & 0xf8) >> 3))) \
71 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
73 #define READ_RGBA( rgba, _x, _y ) \
75 GLushort p = GET_VALUE(_x, _y); \
76 rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
77 rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
78 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
82 #elif (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5_REV)
85 ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV
90 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
93 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
94 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
95 #endif /* GET_VALUE */
97 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
98 PUT_VALUE(_x, _y, PACK_COLOR_565_REV( r, g, b ))
100 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
102 #define READ_RGBA( rgba, _x, _y ) \
104 GLushort p = GET_VALUE(_x, _y); \
105 p = p << 8 | p >> 8; \
106 rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
107 rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
108 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
112 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4)
115 ** GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4
120 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
123 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
124 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
125 #endif /* GET_VALUE */
127 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
128 PUT_VALUE(_x, _y, PACK_COLOR_4444_REV(a, r, g, b)) \
130 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
132 #define READ_RGBA( rgba, _x, _y ) \
134 GLushort p = GET_VALUE(_x, _y); \
135 rgba[0] = ((p >> 0) & 0xf) * 0x11; \
136 rgba[1] = ((p >> 12) & 0xf) * 0x11; \
137 rgba[2] = ((p >> 4) & 0xf) * 0x11; \
138 rgba[3] = ((p >> 8) & 0xf) * 0x11; \
142 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_4_4_4_4_REV)
145 ** GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV
150 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
153 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
154 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
155 #endif /* GET_VALUE */
157 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
158 PUT_VALUE(_x, _y, PACK_COLOR_4444(a, r, g, b)) \
160 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
162 #define READ_RGBA( rgba, _x, _y ) \
164 GLushort p = GET_VALUE(_x, _y); \
165 rgba[0] = ((p >> 8) & 0xf) * 0x11; \
166 rgba[1] = ((p >> 4) & 0xf) * 0x11; \
167 rgba[2] = ((p >> 0) & 0xf) * 0x11; \
168 rgba[3] = ((p >> 12) & 0xf) * 0x11; \
172 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_1_5_5_5_REV)
175 ** GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV
180 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
183 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
184 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
185 #endif /* GET_VALUE */
187 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
188 PUT_VALUE(_x, _y, PACK_COLOR_1555(a, r, g, b)) \
190 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
192 #define READ_RGBA( rgba, _x, _y ) \
194 GLushort p = GET_VALUE(_x, _y); \
195 rgba[0] = ((p >> 7) & 0xf8) * 255 / 0xf8; \
196 rgba[1] = ((p >> 2) & 0xf8) * 255 / 0xf8; \
197 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
198 rgba[3] = ((p >> 15) & 0x1) * 0xff; \
201 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_1_5_5_5)
204 ** GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5
209 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
212 #define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
213 #define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
214 #endif /* GET_VALUE */
216 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
217 PUT_VALUE(_x, _y, PACK_COLOR_1555_REV(a, r, g, b)) \
219 #define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
221 #define READ_RGBA( rgba, _x, _y ) \
223 GLushort p = GET_VALUE(_x, _y); \
224 p = p << 8 | p >> 8; \
225 rgba[0] = ((p >> 7) & 0xf8) * 255 / 0xf8; \
226 rgba[1] = ((p >> 2) & 0xf8) * 255 / 0xf8; \
227 rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
228 rgba[3] = ((p >> 15) & 0x1) * 0xff; \
231 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
234 ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV
239 #define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch)
242 #define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
243 #define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
244 #endif /* GET_VALUE */
246 # define WRITE_RGBA(_x, _y, r, g, b, a) \
247 PUT_VALUE(_x, _y, ((r << 16) | \
252 #define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
254 # if defined( USE_X86_ASM )
255 # define READ_RGBA(rgba, _x, _y) \
257 GLuint p = GET_VALUE(_x, _y); \
258 __asm__ __volatile__( "bswap %0; rorl $8, %0" \
259 : "=r" (p) : "0" (p) ); \
260 ((GLuint *)rgba)[0] = p; \
262 # elif defined( MESA_BIG_ENDIAN )
263 /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
264 * rotlwi instruction. It also produces good code on SPARC.
266 # define READ_RGBA( rgba, _x, _y ) \
268 GLuint p = GET_VALUE(_x, _y); \
270 *((uint32_t *) rgba) = (t >> 24) | (p << 8); \
273 # define READ_RGBA( rgba, _x, _y ) \
275 GLuint p = GET_VALUE(_x, _y); \
276 rgba[0] = (p >> 16) & 0xff; \
277 rgba[1] = (p >> 8) & 0xff; \
278 rgba[2] = (p >> 0) & 0xff; \
279 rgba[3] = (p >> 24) & 0xff; \
283 #elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8)
286 ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8
291 #define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch)
294 #define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
295 #define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
296 #endif /* GET_VALUE */
298 # define WRITE_RGBA(_x, _y, r, g, b, a) \
299 PUT_VALUE(_x, _y, ((r << 8) | \
304 #define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
306 # if defined( USE_X86_ASM )
307 # define READ_RGBA(rgba, _x, _y) \
309 GLuint p = GET_VALUE(_x, _y); \
310 __asm__ __volatile__( "rorl $8, %0" \
311 : "=r" (p) : "0" (p) ); \
312 ((GLuint *)rgba)[0] = p; \
314 # elif defined( MESA_BIG_ENDIAN )
315 /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
316 * rotlwi instruction. It also produces good code on SPARC.
318 # define READ_RGBA( rgba, _x, _y ) \
320 GLuint p = CPU_TO_LE32(GET_VALUE(_x, _y)); \
322 *((uint32_t *) rgba) = (t >> 24) | (p << 8); \
325 # define READ_RGBA( rgba, _x, _y ) \
327 GLuint p = GET_VALUE(_x, _y); \
328 rgba[0] = (p >> 8) & 0xff; \
329 rgba[1] = (p >> 16) & 0xff; \
330 rgba[2] = (p >> 24) & 0xff; \
331 rgba[3] = (p >> 0) & 0xff; \
335 #elif (SPANTMP_PIXEL_FMT == GL_BGR) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
338 ** GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV
340 ** This is really for MESA_FORMAT_XRGB8888. The spantmp code needs to be
341 ** kicked to the curb, and we need to just code-gen this.
346 #define GET_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch)
349 #define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
350 #define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
351 #endif /* GET_VALUE */
353 # define WRITE_RGBA(_x, _y, r, g, b, a) \
354 PUT_VALUE(_x, _y, ((r << 16) | \
359 #define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
361 # if defined( USE_X86_ASM )
362 # define READ_RGBA(rgba, _x, _y) \
364 GLuint p = GET_VALUE(_x, _y); \
365 __asm__ __volatile__( "bswap %0; rorl $8, %0" \
366 : "=r" (p) : "0" (p) ); \
367 ((GLuint *)rgba)[0] = p | 0xff000000; \
369 # elif defined( MESA_BIG_ENDIAN )
370 /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
371 * rotlwi instruction. It also produces good code on SPARC.
373 # define READ_RGBA( rgba, _x, _y ) \
375 GLuint p = GET_VALUE(_x, _y); \
376 *((uint32_t *) rgba) = (p << 8) | 0xff; \
379 # define READ_RGBA( rgba, _x, _y ) \
381 GLuint p = GET_VALUE(_x, _y); \
382 rgba[0] = (p >> 16) & 0xff; \
383 rgba[1] = (p >> 8) & 0xff; \
384 rgba[2] = (p >> 0) & 0xff; \
389 #elif (SPANTMP_PIXEL_FMT == GL_ALPHA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_BYTE)
392 ** GL_ALPHA, GL_UNSIGNED_BYTE
397 #define GET_PTR(_x, _y) ( buf + (_x) + (_y) * pitch)
400 #define GET_VALUE(_x, _y) *(volatile GLubyte *)(GET_PTR(_x, _y))
401 #define PUT_VALUE(_x, _y, _v) *(volatile GLubyte *)(GET_PTR(_x, _y)) = (_v)
402 #endif /* GET_VALUE */
404 # define WRITE_RGBA(_x, _y, r, g, b, a) \
405 PUT_VALUE(_x, _y, a | (r & 0 /* quiet warnings */))
407 #define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
409 #define READ_RGBA( rgba, _x, _y ) \
411 GLubyte p = GET_VALUE(_x, _y); \
419 #error SPANTMP_PIXEL_FMT must be set to a valid value!
425 ** Assembly routines.
428 #if defined( USE_MMX_ASM ) || defined( USE_SSE_ASM )
429 #include "x86/read_rgba_span_x86.h"
430 #include "x86/common_x86_asm.h"
433 static void TAG(WriteRGBASpan
)( struct gl_context
*ctx
,
434 struct gl_renderbuffer
*rb
,
435 GLuint n
, GLint x
, GLint y
,
436 const void *values
, const GLubyte mask
[] )
442 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
452 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
454 if (DBG
) fprintf(stderr
, "WriteRGBASpan %d..%d (x1 %d)\n",
455 (int)i
, (int)n1
, (int)x1
);
459 for (;n1
>0;i
++,x1
++,n1
--)
462 rgba
[i
][0], rgba
[i
][1],
463 rgba
[i
][2], rgba
[i
][3] );
467 for (;n1
>0;i
++,x1
++,n1
--)
469 rgba
[i
][0], rgba
[i
][1],
470 rgba
[i
][2], rgba
[i
][3] );
478 static void TAG(WriteRGBSpan
)( struct gl_context
*ctx
,
479 struct gl_renderbuffer
*rb
,
480 GLuint n
, GLint x
, GLint y
,
481 const void *values
, const GLubyte mask
[] )
487 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
497 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
499 if (DBG
) fprintf(stderr
, "WriteRGBSpan %d..%d (x1 %d)\n",
500 (int)i
, (int)n1
, (int)x1
);
504 for (;n1
>0;i
++,x1
++,n1
--)
506 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
510 for (;n1
>0;i
++,x1
++,n1
--)
511 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
519 static void TAG(WriteRGBAPixels
)( struct gl_context
*ctx
,
520 struct gl_renderbuffer
*rb
,
521 GLuint n
, const GLint x
[], const GLint y
[],
522 const void *values
, const GLubyte mask
[] )
528 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
532 if (DBG
) fprintf(stderr
, "WriteRGBAPixels\n");
541 const int fy
= Y_FLIP(y
[i
]);
542 if (CLIPPIXEL(x
[i
],fy
))
543 WRITE_RGBA( x
[i
], fy
,
544 rgba
[i
][0], rgba
[i
][1],
545 rgba
[i
][2], rgba
[i
][3] );
553 const int fy
= Y_FLIP(y
[i
]);
554 if (CLIPPIXEL(x
[i
],fy
))
555 WRITE_RGBA( x
[i
], fy
,
556 rgba
[i
][0], rgba
[i
][1],
557 rgba
[i
][2], rgba
[i
][3] );
567 static void TAG(ReadRGBASpan
)( struct gl_context
*ctx
,
568 struct gl_renderbuffer
*rb
,
569 GLuint n
, GLint x
, GLint y
, void *values
)
575 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
581 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
586 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
587 for (;n1
>0;i
++,x1
++,n1
--)
588 READ_RGBA( rgba
[i
], x1
, y
);
596 #if defined(GET_PTR) && \
597 defined(USE_MMX_ASM) && \
598 (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
599 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
600 ((SPANTMP_PIXEL_FMT == GL_RGB) && \
601 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
602 static void TAG2(ReadRGBASpan
,_MMX
)( struct gl_context
*ctx
,
603 struct gl_renderbuffer
*rb
,
604 GLuint n
, GLint x
, GLint y
, void *values
)
606 #ifndef USE_INNER_EMMS
607 /* The EMMS instruction is directly in-lined here because using GCC's
608 * built-in _mm_empty function was found to utterly destroy performance.
610 __asm__
__volatile__( "emms" );
617 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
623 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
628 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
631 const void * src
= GET_PTR( x1
, y
);
632 #if (SPANTMP_PIXEL_FMT == GL_RGB) && \
633 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
634 _generic_read_RGBA_span_RGB565_MMX( src
, rgba
[i
], n1
);
636 _generic_read_RGBA_span_BGRA8888_REV_MMX( src
, rgba
[i
], n1
);
643 #ifndef USE_INNER_EMMS
644 __asm__
__volatile__( "emms" );
650 #if defined(GET_PTR) && \
651 defined(USE_SSE_ASM) && \
652 (SPANTMP_PIXEL_FMT == GL_BGRA) && \
653 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
654 static void TAG2(ReadRGBASpan
,_SSE2
)( struct gl_context
*ctx
,
655 struct gl_renderbuffer
*rb
,
656 GLuint n
, GLint x
, GLint y
,
663 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
669 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
674 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
677 const void * src
= GET_PTR( x1
, y
);
678 _generic_read_RGBA_span_BGRA8888_REV_SSE2( src
, rgba
[i
], n1
);
687 #if defined(GET_PTR) && \
688 defined(USE_SSE_ASM) && \
689 (SPANTMP_PIXEL_FMT == GL_BGRA) && \
690 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
691 static void TAG2(ReadRGBASpan
,_SSE
)( struct gl_context
*ctx
,
692 struct gl_renderbuffer
*rb
,
693 GLuint n
, GLint x
, GLint y
,
696 #ifndef USE_INNER_EMMS
697 /* The EMMS instruction is directly in-lined here because using GCC's
698 * built-in _mm_empty function was found to utterly destroy performance.
700 __asm__
__volatile__( "emms" );
707 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
713 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
718 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
721 const void * src
= GET_PTR( x1
, y
);
722 _generic_read_RGBA_span_BGRA8888_REV_SSE( src
, rgba
[i
], n1
);
728 #ifndef USE_INNER_EMMS
729 __asm__
__volatile__( "emms" );
735 static void TAG(ReadRGBAPixels
)( struct gl_context
*ctx
,
736 struct gl_renderbuffer
*rb
,
737 GLuint n
, const GLint x
[], const GLint y
[],
744 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
748 if (DBG
) fprintf(stderr
, "ReadRGBAPixels\n");
753 int fy
= Y_FLIP( y
[i
] );
754 if (CLIPPIXEL( x
[i
], fy
))
755 READ_RGBA( rgba
[i
], x
[i
], fy
);
763 static void TAG(InitPointers
)(struct gl_renderbuffer
*rb
)
765 rb
->PutRow
= TAG(WriteRGBASpan
);
766 rb
->PutRowRGB
= TAG(WriteRGBSpan
);
767 rb
->PutValues
= TAG(WriteRGBAPixels
);
768 rb
->GetValues
= TAG(ReadRGBAPixels
);
771 #if defined(USE_SSE_ASM) && \
772 (SPANTMP_PIXEL_FMT == GL_BGRA) && \
773 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
774 if ( cpu_has_xmm2
) {
775 if (DBG
) fprintf( stderr
, "Using %s version of GetRow\n", "SSE2" );
776 rb
->GetRow
= TAG2(ReadRGBASpan
, _SSE2
);
780 #if defined(USE_SSE_ASM) && \
781 (SPANTMP_PIXEL_FMT == GL_BGRA) && \
782 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
784 if (DBG
) fprintf( stderr
, "Using %s version of GetRow\n", "SSE" );
785 rb
->GetRow
= TAG2(ReadRGBASpan
, _SSE
);
789 #if defined(USE_MMX_ASM) && \
790 (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
791 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
792 ((SPANTMP_PIXEL_FMT == GL_RGB) && \
793 (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
795 if (DBG
) fprintf( stderr
, "Using %s version of GetRow\n", "MMX" );
796 rb
->GetRow
= TAG2(ReadRGBASpan
, _MMX
);
802 if (DBG
) fprintf( stderr
, "Using %s version of GetRow\n", "C" );
803 rb
->GetRow
= TAG(ReadRGBASpan
);
817 #undef SPANTMP_PIXEL_FMT
818 #undef SPANTMP_PIXEL_TYPE