e106ce291e2ac3b68c1f3d45e9113aaf717c1c8e
2 * Depth32 functions won't compile with Glide2
3 * Optimize and check endianess for `read_R8G8B8_pixels'
6 /* $Id: fxddspan.c,v 1.23 2003/07/17 14:50:12 brianp Exp $ */
9 * Mesa 3-D graphics library
12 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
51 #include "swrast/swrast.h"
55 #pragma warning( disable : 4090 4022 )
56 /* 4101 : "different 'const' qualifier"
57 * 4022 : "pointer mistmatch for actual parameter 'n'
63 #if !defined(FXMESA_USE_ARGB)
67 #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
68 FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
72 /* KW: Rearranged the args in the call to grLfbWriteRegion().
74 #define LFB_WRITE_SPAN_MESA(dst_buffer, \
80 writeRegionClipped(fxMesa, dst_buffer, \
83 GR_LFB_SRC_FMT_8888, \
90 #else /* !defined(FXMESA_USE_RGBA) */
92 #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
93 FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
96 #define MESACOLOR_TO_ARGB(c) ( \
97 ( ((unsigned int)(c[ACOMP]))<<24 ) | \
98 ( ((unsigned int)(c[RCOMP]))<<16 ) | \
99 ( ((unsigned int)(c[GCOMP]))<<8 ) | \
100 ( (unsigned int)(c[BCOMP])) )
103 LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer
,
106 FxU32 src_width
, FxI32 src_stride
, void *src_data
)
109 GLubyte(*rgba
)[4] = src_data
;
110 GLuint argb
[MAX_WIDTH
];
113 for (i
= 0; i
< src_width
; i
++) {
114 argb
[i
] = MESACOLOR_TO_ARGB(rgba
[i
]);
116 writeRegionClipped( /*fxMesa, */ NULL
, dst_buffer
,
120 src_width
, 1, src_stride
, (void *) argb
);
123 #endif /* !defined(FXMESA_USE_RGBA) */
126 /************************************************************************/
127 /***** Span functions *****/
128 /************************************************************************/
132 fxDDWriteRGBASpan(const GLcontext
* ctx
,
133 GLuint n
, GLint x
, GLint y
,
134 const GLubyte rgba
[][4], const GLubyte mask
[])
136 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
138 GLint bottom
= fxMesa
->height
- 1;
140 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
141 fprintf(stderr
, "fxmesa: fxDDWriteRGBASpan(...)\n");
147 for (i
= 0; i
< n
; i
++) {
153 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ i
- span
,
155 /* GR_LFB_SRC_FMT_8888, */ span
, /*1, */ 0,
156 (void *) rgba
[i
- span
]);
163 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ n
- span
, bottom
- y
,
164 /* GR_LFB_SRC_FMT_8888, */ span
, /*1, */ 0,
165 (void *) rgba
[n
- span
]);
168 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
, bottom
- y
, /* GR_LFB_SRC_FMT_8888, */
169 n
, /* 1, */ 0, (void *) rgba
);
174 fxDDWriteRGBSpan(const GLcontext
* ctx
,
175 GLuint n
, GLint x
, GLint y
,
176 const GLubyte rgb
[][3], const GLubyte mask
[])
178 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
180 GLint bottom
= fxMesa
->height
- 1;
181 GLubyte rgba
[MAX_WIDTH
][4];
183 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
184 fprintf(stderr
, "fxmesa: fxDDWriteRGBSpan()\n");
190 for (i
= 0; i
< n
; i
++) {
192 rgba
[span
][RCOMP
] = rgb
[i
][0];
193 rgba
[span
][GCOMP
] = rgb
[i
][1];
194 rgba
[span
][BCOMP
] = rgb
[i
][2];
195 rgba
[span
][ACOMP
] = 255;
200 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ i
- span
,
202 /*GR_LFB_SRC_FMT_8888, */ span
, /* 1, */ 0,
210 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ n
- span
, bottom
- y
,
211 /*GR_LFB_SRC_FMT_8888, */ span
, /* 1, */ 0,
215 for (i
= 0; i
< n
; i
++) {
216 rgba
[i
][RCOMP
] = rgb
[i
][0];
217 rgba
[i
][GCOMP
] = rgb
[i
][1];
218 rgba
[i
][BCOMP
] = rgb
[i
][2];
219 rgba
[i
][ACOMP
] = 255;
222 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
, bottom
- y
, /* GR_LFB_SRC_FMT_8888, */
223 n
, /* 1, */ 0, (void *) rgba
);
229 fxDDWriteMonoRGBASpan(const GLcontext
* ctx
,
230 GLuint n
, GLint x
, GLint y
,
231 const GLchan color
[4], const GLubyte mask
[])
233 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
235 GLint bottom
= fxMesa
->height
- 1;
236 GLuint data
[MAX_WIDTH
];
237 GrColor_t gColor
= FXCOLOR4(color
);
239 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
240 fprintf(stderr
, "fxmesa: fxDDWriteMonoRGBASpan(...)\n");
246 for (i
= 0; i
< n
; i
++) {
248 data
[span
] = (GLuint
) gColor
;
253 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
+ i
- span
,
254 bottom
- y
, GR_LFB_SRC_FMT_8888
, span
, 1, 0,
262 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
+ n
- span
,
263 bottom
- y
, GR_LFB_SRC_FMT_8888
, span
, 1, 0,
267 for (i
= 0; i
< n
; i
++) {
268 data
[i
] = (GLuint
) gColor
;
271 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
, bottom
- y
,
272 GR_LFB_SRC_FMT_8888
, n
, 1, 0, (void *) data
);
279 fxDDReadRGBASpan(const GLcontext
* ctx
,
280 GLuint n
, GLint x
, GLint y
, GLubyte rgba
[][4])
282 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
283 GLushort data
[MAX_WIDTH
];
285 GLint bottom
= fxMesa
->height
- 1;
287 printf("read span %d, %d, %d\n", x
, y
, n
);
288 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
289 fprintf(stderr
, "fxmesa: fxDDReadRGBASpan(...)\n");
292 assert(n
< MAX_WIDTH
);
294 FX_grLfbReadRegion(fxMesa
->currentFB
, x
, bottom
- y
, n
, 1, 0, data
);
296 for (i
= 0; i
< n
; i
++) {
297 GLushort pixel
= data
[i
];
298 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel
];
299 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel
];
300 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel
];
301 rgba
[i
][ACOMP
] = 255;
308 * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
309 * since OpenGL says obscured pixels have undefined values.
312 read_R5G6B5_span(const GLcontext
* ctx
,
313 GLuint n
, GLint x
, GLint y
, GLubyte rgba
[][4])
315 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
318 if (grLfbLock(GR_LFB_READ_ONLY
,
320 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
321 const GLint winX
= 0;
322 const GLint winY
= fxMesa
->height
- 1;
323 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
324 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
325 + (winY
- y
) * srcStride
+ (winX
+ x
);
326 const GLuint
*data32
= (const GLuint
*) data16
;
328 GLuint extraPixel
= (n
& 1);
330 for (i
= j
= 0; i
< n
; i
+= 2, j
++) {
331 GLuint pixel
= data32
[j
];
332 GLuint pixel0
= pixel
& 0xffff;
333 GLuint pixel1
= pixel
>> 16;
334 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel0
];
335 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel0
];
336 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel0
];
337 rgba
[i
][ACOMP
] = 255;
338 rgba
[i
+ 1][RCOMP
] = FX_PixelToR
[pixel1
];
339 rgba
[i
+ 1][GCOMP
] = FX_PixelToG
[pixel1
];
340 rgba
[i
+ 1][BCOMP
] = FX_PixelToB
[pixel1
];
341 rgba
[i
+ 1][ACOMP
] = 255;
344 GLushort pixel
= data16
[n
];
345 rgba
[n
][RCOMP
] = FX_PixelToR
[pixel
];
346 rgba
[n
][GCOMP
] = FX_PixelToG
[pixel
];
347 rgba
[n
][BCOMP
] = FX_PixelToB
[pixel
];
348 rgba
[n
][ACOMP
] = 255;
351 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
357 * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
358 * since OpenGL says obscured pixels have undefined values.
360 static void read_R5G5B5_span (const GLcontext
* ctx
,
365 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
368 if (grLfbLock(GR_LFB_READ_ONLY
,
370 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
371 const GLint winX
= 0;
372 const GLint winY
= fxMesa
->height
- 1;
373 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
374 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
375 + (winY
- y
) * srcStride
+ (winX
+ x
);
376 const GLuint
*data32
= (const GLuint
*) data16
;
378 GLuint extraPixel
= (n
& 1);
380 for (i
= j
= 0; i
< n
; i
+= 2, j
++) {
381 GLuint pixel
= data32
[j
];
382 rgba
[i
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
383 rgba
[i
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
384 rgba
[i
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
385 rgba
[i
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
386 rgba
[i
+ 1][RCOMP
] = FX_rgb_scale_5
[(pixel
>> 16) & 0x1f];
387 rgba
[i
+ 1][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 21) & 0x1f];
388 rgba
[i
+ 1][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 26) & 0x1f];
389 rgba
[i
+ 1][ACOMP
] = (pixel
& 0x80000000) ? 255 : 0;
392 GLushort pixel
= data16
[n
];
393 rgba
[n
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
394 rgba
[n
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
395 rgba
[n
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
396 rgba
[n
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
399 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
405 * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
406 * since OpenGL says obscured pixels have undefined values.
408 static void read_R8G8B8_span (const GLcontext
* ctx
,
413 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
415 FX_grLfbReadRegion(fxMesa
->currentFB
, x
, fxMesa
->height
- 1 - y
, n
, 1, n
* 4, rgba
);
420 /************************************************************************/
421 /***** Pixel functions *****/
422 /************************************************************************/
425 fxDDWriteRGBAPixels(const GLcontext
* ctx
,
426 GLuint n
, const GLint x
[], const GLint y
[],
427 CONST GLubyte rgba
[][4], const GLubyte mask
[])
429 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
431 GLint bottom
= fxMesa
->height
- 1;
433 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
434 fprintf(stderr
, "fxmesa: fxDDWriteRGBAPixels(...)\n");
437 for (i
= 0; i
< n
; i
++)
439 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
[i
], bottom
- y
[i
],
440 1, 1, (void *) rgba
[i
]);
444 fxDDWriteMonoRGBAPixels(const GLcontext
* ctx
,
445 GLuint n
, const GLint x
[], const GLint y
[],
446 const GLchan color
[4], const GLubyte mask
[])
448 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
450 GLint bottom
= fxMesa
->height
- 1;
451 GrColor_t gColor
= FXCOLOR4(color
);
453 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
454 fprintf(stderr
, "fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
457 for (i
= 0; i
< n
; i
++)
459 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
[i
], bottom
- y
[i
],
460 GR_LFB_SRC_FMT_8888
, 1, 1, 0, (void *) &gColor
);
465 read_R5G6B5_pixels(const GLcontext
* ctx
,
466 GLuint n
, const GLint x
[], const GLint y
[],
467 GLubyte rgba
[][4], const GLubyte mask
[])
469 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
472 if (grLfbLock(GR_LFB_READ_ONLY
,
474 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
475 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
476 const GLint winX
= 0;
477 const GLint winY
= fxMesa
->height
- 1;
479 for (i
= 0; i
< n
; i
++) {
481 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
482 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
483 const GLushort pixel
= *data16
;
484 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel
];
485 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel
];
486 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel
];
487 rgba
[i
][ACOMP
] = 255;
490 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
496 static void read_R5G5B5_pixels (const GLcontext
* ctx
,
498 const GLint x
[], const GLint y
[],
500 const GLubyte mask
[])
502 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
505 if (grLfbLock(GR_LFB_READ_ONLY
,
507 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
508 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
509 const GLint winX
= 0;
510 const GLint winY
= fxMesa
->height
- 1;
512 for (i
= 0; i
< n
; i
++) {
514 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
515 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
516 const GLushort pixel
= *data16
;
517 rgba
[i
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
518 rgba
[i
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
519 rgba
[i
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
520 rgba
[i
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
523 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
530 read_R8G8B8_pixels(const GLcontext
* ctx
,
531 GLuint n
, const GLint x
[], const GLint y
[],
532 GLubyte rgba
[][4], const GLubyte mask
[])
534 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
537 if (grLfbLock(GR_LFB_READ_ONLY
,
539 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
540 const GLint srcStride
= info
.strideInBytes
/ 4; /* stride in GLuints */
541 const GLint winX
= 0;
542 const GLint winY
= fxMesa
->height
- 1;
544 for (i
= 0; i
< n
; i
++) {
546 const GLuint
*data32
= (const GLuint
*) info
.lfbPtr
547 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
548 const GLuint pixel
= *data32
;
549 *(GLuint
*)&rgba
[i
][0] = pixel
;
552 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
559 /************************************************************************/
560 /***** Depth functions *****/
561 /************************************************************************/
564 fxDDWriteDepthSpan(GLcontext
* ctx
,
565 GLuint n
, GLint x
, GLint y
, const GLdepth depth
[],
566 const GLubyte mask
[])
568 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
569 GLint bottom
= fxMesa
->height
- 1;
571 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
572 fprintf(stderr
, "fxmesa: fxDDWriteDepthSpan(...)\n");
578 for (i
= 0; i
< n
; i
++) {
580 GLshort d
= depth
[i
];
581 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
+ i
, bottom
- y
,
582 GR_LFB_SRC_FMT_ZA16
, 1, 1, 0, (void *) &d
);
587 GLushort depth16
[MAX_WIDTH
];
589 for (i
= 0; i
< n
; i
++) {
590 depth16
[i
] = depth
[i
];
592 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
, bottom
- y
,
593 GR_LFB_SRC_FMT_ZA16
, n
, 1, 0, (void *) depth16
);
599 fxDDWriteDepth32Span(GLcontext
* ctx
,
600 GLuint n
, GLint x
, GLint y
, const GLdepth depth
[],
601 const GLubyte mask
[])
603 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
604 GLint bottom
= fxMesa
->height
- 1;
606 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
607 fprintf(stderr
, "fxmesa: fxDDWriteDepth32Span(...)\n");
613 for (i
= 0; i
< n
; i
++) {
615 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
+ i
, bottom
- y
,
616 GR_LFBWRITEMODE_Z32
, 1, 1, 0, (void *) &depth
[i
]);
621 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
, bottom
- y
,
622 GR_LFBWRITEMODE_Z32
, n
, 1, 0, (void *) depth
);
628 fxDDReadDepthSpan(GLcontext
* ctx
,
629 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
631 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
632 GLint bottom
= fxMesa
->height
- 1;
633 GLushort depth16
[MAX_WIDTH
];
636 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
637 fprintf(stderr
, "fxmesa: fxDDReadDepthSpan(...)\n");
640 FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER
, x
, bottom
- y
, n
, 1, 0, depth16
);
641 for (i
= 0; i
< n
; i
++) {
642 depth
[i
] = depth16
[i
];
648 fxDDReadDepth32Span(GLcontext
* ctx
,
649 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
651 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
652 GLint bottom
= fxMesa
->height
- 1;
654 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
655 fprintf(stderr
, "fxmesa: fxDDReadDepth32Span(...)\n");
658 FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER
, x
, bottom
- y
, n
, 1, 0, depth
);
664 fxDDWriteDepthPixels(GLcontext
* ctx
,
665 GLuint n
, const GLint x
[], const GLint y
[],
666 const GLdepth depth
[], const GLubyte mask
[])
668 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
669 GLint bottom
= fxMesa
->height
- 1;
672 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
673 fprintf(stderr
, "fxmesa: fxDDWriteDepthPixels(...)\n");
676 for (i
= 0; i
< n
; i
++) {
679 int ypos
= bottom
- y
[i
];
680 GLushort d
= depth
[i
];
681 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, xpos
, ypos
,
682 GR_LFB_SRC_FMT_ZA16
, 1, 1, 0, (void *) &d
);
689 fxDDWriteDepth32Pixels(GLcontext
* ctx
,
690 GLuint n
, const GLint x
[], const GLint y
[],
691 const GLdepth depth
[], const GLubyte mask
[])
693 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
694 GLint bottom
= fxMesa
->height
- 1;
697 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
698 fprintf(stderr
, "fxmesa: fxDDWriteDepth32Pixels(...)\n");
701 for (i
= 0; i
< n
; i
++) {
704 int ypos
= bottom
- y
[i
];
705 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, xpos
, ypos
,
706 GR_LFBWRITEMODE_Z32
, 1, 1, 0, (void *) &depth
[i
]);
713 fxDDReadDepthPixels(GLcontext
* ctx
, GLuint n
,
714 const GLint x
[], const GLint y
[], GLdepth depth
[])
716 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
717 GLint bottom
= fxMesa
->height
- 1;
720 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
721 fprintf(stderr
, "fxmesa: fxDDReadDepthPixels(...)\n");
724 for (i
= 0; i
< n
; i
++) {
726 int ypos
= bottom
- y
[i
];
728 FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER
, xpos
, ypos
, 1, 1, 0, &d
);
735 fxDDReadDepth32Pixels(GLcontext
* ctx
, GLuint n
,
736 const GLint x
[], const GLint y
[], GLdepth depth
[])
738 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
739 GLint bottom
= fxMesa
->height
- 1;
742 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
743 fprintf(stderr
, "fxmesa: fxDDReadDepth32Pixels(...)\n");
746 for (i
= 0; i
< n
; i
++) {
748 int ypos
= bottom
- y
[i
];
749 FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER
, xpos
, ypos
, 1, 1, 0, &depth
[i
]);
755 /* Set the buffer used for reading */
756 /* XXX support for separate read/draw buffers hasn't been tested */
758 fxDDSetBuffer(GLcontext
* ctx
, GLframebuffer
* buffer
, GLuint bufferBit
)
760 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
763 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
764 fprintf(stderr
, "fxmesa: fxDDSetBuffer(%x)\n", (int) bufferBit
);
767 if (bufferBit
== FRONT_LEFT_BIT
) {
768 fxMesa
->currentFB
= GR_BUFFER_FRONTBUFFER
;
769 FX_grRenderBuffer(fxMesa
->currentFB
);
771 else if (bufferBit
== BACK_LEFT_BIT
) {
772 fxMesa
->currentFB
= GR_BUFFER_BACKBUFFER
;
773 FX_grRenderBuffer(fxMesa
->currentFB
);
778 /************************************************************************/
783 fxSetupDDSpanPointers(GLcontext
* ctx
)
785 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference( ctx
);
787 swdd
->SetBuffer
= fxDDSetBuffer
;
789 swdd
->WriteRGBASpan
= fxDDWriteRGBASpan
;
790 swdd
->WriteRGBSpan
= fxDDWriteRGBSpan
;
791 swdd
->WriteMonoRGBASpan
= fxDDWriteMonoRGBASpan
;
792 swdd
->WriteRGBAPixels
= fxDDWriteRGBAPixels
;
793 swdd
->WriteMonoRGBAPixels
= fxDDWriteMonoRGBAPixels
;
795 /* swdd->ReadRGBASpan =fxDDReadRGBASpan; */
797 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
798 switch (fxMesa
->colDepth
) {
800 swdd
->ReadRGBASpan
= read_R5G5B5_span
;
801 swdd
->ReadRGBAPixels
= read_R5G5B5_pixels
;
802 swdd
->WriteDepthSpan
= fxDDWriteDepthSpan
;
803 swdd
->WriteDepthPixels
= fxDDWriteDepthPixels
;
804 swdd
->ReadDepthSpan
= fxDDReadDepthSpan
;
805 swdd
->ReadDepthPixels
= fxDDReadDepthPixels
;
808 swdd
->ReadRGBASpan
= read_R5G6B5_span
;
809 swdd
->ReadRGBAPixels
= read_R5G6B5_pixels
;
810 swdd
->WriteDepthSpan
= fxDDWriteDepthSpan
;
811 swdd
->WriteDepthPixels
= fxDDWriteDepthPixels
;
812 swdd
->ReadDepthSpan
= fxDDReadDepthSpan
;
813 swdd
->ReadDepthPixels
= fxDDReadDepthPixels
;
816 swdd
->ReadRGBASpan
= read_R8G8B8_span
;
817 swdd
->ReadRGBAPixels
= read_R8G8B8_pixels
;
818 swdd
->WriteDepthSpan
= fxDDWriteDepth32Span
;
819 swdd
->WriteDepthPixels
= fxDDWriteDepth32Pixels
;
820 swdd
->ReadDepthSpan
= fxDDReadDepth32Span
;
821 swdd
->ReadDepthPixels
= fxDDReadDepth32Pixels
;
832 * Need this to provide at least one external definition.
835 extern int gl_fx_dummy_function_span(void);
837 gl_fx_dummy_function_span(void)