6e847acce4ecf510e76cbc8486eb6cfddc0c56a7
2 * The performance hit is disastruous for SPAN functions.
3 * Should we use SpanRenderStart / SpanRenderFinish in `swrast.h'
4 * for locking / unlocking the LFB?
5 * Optimize and check endianess for `read_R8G8B8_pixels'
8 /* $Id: fxddspan.c,v 1.24 2003/08/19 15:52:53 brianp Exp $ */
11 * Mesa 3-D graphics library
14 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files (the "Software"),
18 * to deal in the Software without restriction, including without limitation
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 * and/or sell copies of the Software, and to permit persons to whom the
21 * Software is furnished to do so, subject to the following conditions:
23 * The above copyright notice and this permission notice shall be included
24 * in all copies or substantial portions of the Software.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
30 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
55 #include "swrast/swrast.h"
59 #pragma warning( disable : 4090 4022 )
60 /* 4101 : "different 'const' qualifier"
61 * 4022 : "pointer mistmatch for actual parameter 'n'
68 #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
69 FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
73 /* KW: Rearranged the args in the call to grLfbWriteRegion().
75 #define LFB_WRITE_SPAN_MESA(dst_buffer, \
81 writeRegionClipped(fxMesa, dst_buffer, \
84 GR_LFB_SRC_FMT_8888, \
91 /************************************************************************/
92 /***** Span functions *****/
93 /************************************************************************/
97 fxDDWriteRGBASpan(const GLcontext
* ctx
,
98 GLuint n
, GLint x
, GLint y
,
99 const GLubyte rgba
[][4], const GLubyte mask
[])
101 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
103 GLint bottom
= fxMesa
->height
- 1;
105 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
106 fprintf(stderr
, "fxmesa: fxDDWriteRGBASpan(...)\n");
112 for (i
= 0; i
< n
; i
++) {
118 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ i
- span
,
120 /* GR_LFB_SRC_FMT_8888, */ span
, /*1, */ 0,
121 (void *) rgba
[i
- span
]);
128 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ n
- span
, bottom
- y
,
129 /* GR_LFB_SRC_FMT_8888, */ span
, /*1, */ 0,
130 (void *) rgba
[n
- span
]);
133 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
, bottom
- y
, /* GR_LFB_SRC_FMT_8888, */
134 n
, /* 1, */ 0, (void *) rgba
);
139 fxDDWriteRGBSpan(const GLcontext
* ctx
,
140 GLuint n
, GLint x
, GLint y
,
141 const GLubyte rgb
[][3], const GLubyte mask
[])
143 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
145 GLint bottom
= fxMesa
->height
- 1;
146 GLubyte rgba
[MAX_WIDTH
][4];
148 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
149 fprintf(stderr
, "fxmesa: fxDDWriteRGBSpan()\n");
155 for (i
= 0; i
< n
; i
++) {
157 rgba
[span
][RCOMP
] = rgb
[i
][0];
158 rgba
[span
][GCOMP
] = rgb
[i
][1];
159 rgba
[span
][BCOMP
] = rgb
[i
][2];
160 rgba
[span
][ACOMP
] = 255;
165 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ i
- span
,
167 /*GR_LFB_SRC_FMT_8888, */ span
, /* 1, */ 0,
175 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
+ n
- span
, bottom
- y
,
176 /*GR_LFB_SRC_FMT_8888, */ span
, /* 1, */ 0,
180 for (i
= 0; i
< n
; i
++) {
181 rgba
[i
][RCOMP
] = rgb
[i
][0];
182 rgba
[i
][GCOMP
] = rgb
[i
][1];
183 rgba
[i
][BCOMP
] = rgb
[i
][2];
184 rgba
[i
][ACOMP
] = 255;
187 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
, bottom
- y
, /* GR_LFB_SRC_FMT_8888, */
188 n
, /* 1, */ 0, (void *) rgba
);
194 fxDDWriteMonoRGBASpan(const GLcontext
* ctx
,
195 GLuint n
, GLint x
, GLint y
,
196 const GLchan color
[4], const GLubyte mask
[])
198 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
200 GLint bottom
= fxMesa
->height
- 1;
201 GLuint data
[MAX_WIDTH
];
202 GrColor_t gColor
= FXCOLOR4(color
);
204 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
205 fprintf(stderr
, "fxmesa: fxDDWriteMonoRGBASpan(...)\n");
211 for (i
= 0; i
< n
; i
++) {
213 data
[span
] = (GLuint
) gColor
;
218 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
+ i
- span
,
219 bottom
- y
, GR_LFB_SRC_FMT_8888
, span
, 1, 0,
227 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
+ n
- span
,
228 bottom
- y
, GR_LFB_SRC_FMT_8888
, span
, 1, 0,
232 for (i
= 0; i
< n
; i
++) {
233 data
[i
] = (GLuint
) gColor
;
236 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
, bottom
- y
,
237 GR_LFB_SRC_FMT_8888
, n
, 1, 0, (void *) data
);
244 fxDDReadRGBASpan(const GLcontext
* ctx
,
245 GLuint n
, GLint x
, GLint y
, GLubyte rgba
[][4])
247 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
248 GLushort data
[MAX_WIDTH
];
250 GLint bottom
= fxMesa
->height
- 1;
252 printf("read span %d, %d, %d\n", x
, y
, n
);
253 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
254 fprintf(stderr
, "fxmesa: fxDDReadRGBASpan(...)\n");
257 assert(n
< MAX_WIDTH
);
259 FX_grLfbReadRegion(fxMesa
->currentFB
, x
, bottom
- y
, n
, 1, 0, data
);
261 for (i
= 0; i
< n
; i
++) {
262 GLushort pixel
= data
[i
];
263 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel
];
264 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel
];
265 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel
];
266 rgba
[i
][ACOMP
] = 255;
273 * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
274 * since OpenGL says obscured pixels have undefined values.
277 read_R5G6B5_span(const GLcontext
* ctx
,
278 GLuint n
, GLint x
, GLint y
, GLubyte rgba
[][4])
280 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
283 if (grLfbLock(GR_LFB_READ_ONLY
,
285 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
286 const GLint winX
= 0;
287 const GLint winY
= fxMesa
->height
- 1;
288 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
289 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
290 + (winY
- y
) * srcStride
+ (winX
+ x
);
291 const GLuint
*data32
= (const GLuint
*) data16
;
293 GLuint extraPixel
= (n
& 1);
295 for (i
= j
= 0; i
< n
; i
+= 2, j
++) {
296 GLuint pixel
= data32
[j
];
297 GLuint pixel0
= pixel
& 0xffff;
298 GLuint pixel1
= pixel
>> 16;
299 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel0
];
300 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel0
];
301 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel0
];
302 rgba
[i
][ACOMP
] = 255;
303 rgba
[i
+ 1][RCOMP
] = FX_PixelToR
[pixel1
];
304 rgba
[i
+ 1][GCOMP
] = FX_PixelToG
[pixel1
];
305 rgba
[i
+ 1][BCOMP
] = FX_PixelToB
[pixel1
];
306 rgba
[i
+ 1][ACOMP
] = 255;
309 GLushort pixel
= data16
[n
];
310 rgba
[n
][RCOMP
] = FX_PixelToR
[pixel
];
311 rgba
[n
][GCOMP
] = FX_PixelToG
[pixel
];
312 rgba
[n
][BCOMP
] = FX_PixelToB
[pixel
];
313 rgba
[n
][ACOMP
] = 255;
316 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
322 * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
323 * since OpenGL says obscured pixels have undefined values.
325 static void read_R5G5B5_span (const GLcontext
* ctx
,
330 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
333 if (grLfbLock(GR_LFB_READ_ONLY
,
335 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
336 const GLint winX
= 0;
337 const GLint winY
= fxMesa
->height
- 1;
338 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
339 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
340 + (winY
- y
) * srcStride
+ (winX
+ x
);
341 const GLuint
*data32
= (const GLuint
*) data16
;
343 GLuint extraPixel
= (n
& 1);
345 for (i
= j
= 0; i
< n
; i
+= 2, j
++) {
346 GLuint pixel
= data32
[j
];
347 rgba
[i
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
348 rgba
[i
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
349 rgba
[i
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
350 rgba
[i
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
351 rgba
[i
+ 1][RCOMP
] = FX_rgb_scale_5
[(pixel
>> 16) & 0x1f];
352 rgba
[i
+ 1][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 21) & 0x1f];
353 rgba
[i
+ 1][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 26) & 0x1f];
354 rgba
[i
+ 1][ACOMP
] = (pixel
& 0x80000000) ? 255 : 0;
357 GLushort pixel
= data16
[n
];
358 rgba
[n
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
359 rgba
[n
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
360 rgba
[n
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
361 rgba
[n
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
364 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
370 * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
371 * since OpenGL says obscured pixels have undefined values.
373 static void read_R8G8B8_span (const GLcontext
* ctx
,
378 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
380 grLfbReadRegion(fxMesa
->currentFB
, x
, fxMesa
->height
- 1 - y
, n
, 1, n
* 4, rgba
);
385 /************************************************************************/
386 /***** Pixel functions *****/
387 /************************************************************************/
390 fxDDWriteRGBAPixels(const GLcontext
* ctx
,
391 GLuint n
, const GLint x
[], const GLint y
[],
392 CONST GLubyte rgba
[][4], const GLubyte mask
[])
394 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
396 GLint bottom
= fxMesa
->height
- 1;
398 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
399 fprintf(stderr
, "fxmesa: fxDDWriteRGBAPixels(...)\n");
402 for (i
= 0; i
< n
; i
++)
404 LFB_WRITE_SPAN_MESA(fxMesa
->currentFB
, x
[i
], bottom
- y
[i
],
405 1, 1, (void *) rgba
[i
]);
409 fxDDWriteMonoRGBAPixels(const GLcontext
* ctx
,
410 GLuint n
, const GLint x
[], const GLint y
[],
411 const GLchan color
[4], const GLubyte mask
[])
413 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
415 GLint bottom
= fxMesa
->height
- 1;
416 GrColor_t gColor
= FXCOLOR4(color
);
418 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
419 fprintf(stderr
, "fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
422 for (i
= 0; i
< n
; i
++)
424 writeRegionClipped(fxMesa
, fxMesa
->currentFB
, x
[i
], bottom
- y
[i
],
425 GR_LFB_SRC_FMT_8888
, 1, 1, 0, (void *) &gColor
);
430 read_R5G6B5_pixels(const GLcontext
* ctx
,
431 GLuint n
, const GLint x
[], const GLint y
[],
432 GLubyte rgba
[][4], const GLubyte mask
[])
434 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
437 if (grLfbLock(GR_LFB_READ_ONLY
,
439 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
440 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
441 const GLint winX
= 0;
442 const GLint winY
= fxMesa
->height
- 1;
444 for (i
= 0; i
< n
; i
++) {
446 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
447 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
448 const GLushort pixel
= *data16
;
449 rgba
[i
][RCOMP
] = FX_PixelToR
[pixel
];
450 rgba
[i
][GCOMP
] = FX_PixelToG
[pixel
];
451 rgba
[i
][BCOMP
] = FX_PixelToB
[pixel
];
452 rgba
[i
][ACOMP
] = 255;
455 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
461 static void read_R5G5B5_pixels (const GLcontext
* ctx
,
463 const GLint x
[], const GLint y
[],
465 const GLubyte mask
[])
467 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
470 if (grLfbLock(GR_LFB_READ_ONLY
,
472 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
473 const GLint srcStride
= info
.strideInBytes
/ 2; /* stride in GLushorts */
474 const GLint winX
= 0;
475 const GLint winY
= fxMesa
->height
- 1;
477 for (i
= 0; i
< n
; i
++) {
479 const GLushort
*data16
= (const GLushort
*) info
.lfbPtr
480 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
481 const GLushort pixel
= *data16
;
482 rgba
[i
][RCOMP
] = FX_rgb_scale_5
[ pixel
& 0x1f];
483 rgba
[i
][GCOMP
] = FX_rgb_scale_5
[(pixel
>> 5) & 0x1f];
484 rgba
[i
][BCOMP
] = FX_rgb_scale_5
[(pixel
>> 10) & 0x1f];
485 rgba
[i
][ACOMP
] = (pixel
& 0x8000) ? 255 : 0;
488 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
495 read_R8G8B8_pixels(const GLcontext
* ctx
,
496 GLuint n
, const GLint x
[], const GLint y
[],
497 GLubyte rgba
[][4], const GLubyte mask
[])
499 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
502 if (grLfbLock(GR_LFB_READ_ONLY
,
504 GR_LFBWRITEMODE_ANY
, GR_ORIGIN_UPPER_LEFT
, FXFALSE
, &info
)) {
505 const GLint srcStride
= info
.strideInBytes
/ 4; /* stride in GLuints */
506 const GLint winX
= 0;
507 const GLint winY
= fxMesa
->height
- 1;
509 for (i
= 0; i
< n
; i
++) {
511 const GLuint
*data32
= (const GLuint
*) info
.lfbPtr
512 + (winY
- y
[i
]) * srcStride
+ (winX
+ x
[i
]);
513 const GLuint pixel
= *data32
;
514 *(GLuint
*)&rgba
[i
][0] = pixel
;
517 grLfbUnlock(GR_LFB_READ_ONLY
, fxMesa
->currentFB
);
524 /************************************************************************/
525 /***** Depth functions *****/
526 /************************************************************************/
529 fxDDWriteDepthSpan(GLcontext
* ctx
,
530 GLuint n
, GLint x
, GLint y
, const GLdepth depth
[],
531 const GLubyte mask
[])
533 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
534 GLint bottom
= fxMesa
->height
- 1;
536 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
537 fprintf(stderr
, "fxmesa: fxDDWriteDepthSpan(...)\n");
543 for (i
= 0; i
< n
; i
++) {
545 GLshort d
= depth
[i
];
546 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
+ i
, bottom
- y
,
547 GR_LFB_SRC_FMT_ZA16
, 1, 1, 0, (void *) &d
);
552 GLushort depth16
[MAX_WIDTH
];
554 for (i
= 0; i
< n
; i
++) {
555 depth16
[i
] = depth
[i
];
557 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
, bottom
- y
,
558 GR_LFB_SRC_FMT_ZA16
, n
, 1, 0, (void *) depth16
);
564 fxDDWriteDepth32Span(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;
572 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
573 fprintf(stderr
, "fxmesa: fxDDWriteDepth32Span(...)\n");
578 for (i
= 0; i
< n
; i
++) {
580 GLuint d
= depth
[i
] << 8;
581 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
+ i
, bottom
- y
,
582 GR_LFBWRITEMODE_Z32
, 1, 1, 0, (void *) &d
);
587 GLuint depth32
[MAX_WIDTH
];
588 for (i
= 0; i
< n
; i
++) {
589 depth32
[i
] = depth
[i
] << 8;
591 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, x
, bottom
- y
,
592 GR_LFBWRITEMODE_Z32
, n
, 1, 0, (void *) depth32
);
598 fxDDReadDepthSpan(GLcontext
* ctx
,
599 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
601 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
602 GLint bottom
= fxMesa
->height
- 1;
603 GLushort depth16
[MAX_WIDTH
];
606 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
607 fprintf(stderr
, "fxmesa: fxDDReadDepthSpan(...)\n");
610 grLfbReadRegion(GR_BUFFER_AUXBUFFER
, x
, bottom
- y
, n
, 1, 0, depth16
);
611 for (i
= 0; i
< n
; i
++) {
612 depth
[i
] = depth16
[i
];
618 fxDDReadDepth32Span(GLcontext
* ctx
,
619 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
621 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
622 GLint bottom
= fxMesa
->height
- 1;
624 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
625 fprintf(stderr
, "fxmesa: fxDDReadDepth32Span(...)\n");
628 grLfbReadRegion(GR_BUFFER_AUXBUFFER
, x
, bottom
- y
, n
, 1, 0, depth
);
634 fxDDWriteDepthPixels(GLcontext
* ctx
,
635 GLuint n
, const GLint x
[], const GLint y
[],
636 const GLdepth depth
[], const GLubyte mask
[])
638 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
639 GLint bottom
= fxMesa
->height
- 1;
642 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
643 fprintf(stderr
, "fxmesa: fxDDWriteDepthPixels(...)\n");
646 for (i
= 0; i
< n
; i
++) {
649 int ypos
= bottom
- y
[i
];
650 GLushort d
= depth
[i
];
651 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, xpos
, ypos
,
652 GR_LFB_SRC_FMT_ZA16
, 1, 1, 0, (void *) &d
);
659 fxDDWriteDepth32Pixels(GLcontext
* ctx
,
660 GLuint n
, const GLint x
[], const GLint y
[],
661 const GLdepth depth
[], const GLubyte mask
[])
663 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
664 GLint bottom
= fxMesa
->height
- 1;
667 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
668 fprintf(stderr
, "fxmesa: fxDDWriteDepth32Pixels(...)\n");
671 for (i
= 0; i
< n
; i
++) {
674 int ypos
= bottom
- y
[i
];
675 GLuint d
= depth
[i
] << 8;
676 writeRegionClipped(fxMesa
, GR_BUFFER_AUXBUFFER
, xpos
, ypos
,
677 GR_LFBWRITEMODE_Z32
, 1, 1, 0, (void *) &d
);
684 fxDDReadDepthPixels(GLcontext
* ctx
, GLuint n
,
685 const GLint x
[], const GLint y
[], GLdepth depth
[])
687 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
688 GLint bottom
= fxMesa
->height
- 1;
691 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
692 fprintf(stderr
, "fxmesa: fxDDReadDepthPixels(...)\n");
695 for (i
= 0; i
< n
; i
++) {
697 int ypos
= bottom
- y
[i
];
699 grLfbReadRegion(GR_BUFFER_AUXBUFFER
, xpos
, ypos
, 1, 1, 0, &d
);
706 fxDDReadDepth32Pixels(GLcontext
* ctx
, GLuint n
,
707 const GLint x
[], const GLint y
[], GLdepth depth
[])
709 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
710 GLint bottom
= fxMesa
->height
- 1;
713 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
714 fprintf(stderr
, "fxmesa: fxDDReadDepth32Pixels(...)\n");
717 for (i
= 0; i
< n
; i
++) {
719 int ypos
= bottom
- y
[i
];
720 grLfbReadRegion(GR_BUFFER_AUXBUFFER
, xpos
, ypos
, 1, 1, 0, &depth
[i
]);
726 /* Set the buffer used for reading */
727 /* XXX support for separate read/draw buffers hasn't been tested */
729 fxDDSetBuffer(GLcontext
* ctx
, GLframebuffer
* buffer
, GLuint bufferBit
)
731 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
734 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
735 fprintf(stderr
, "fxmesa: fxDDSetBuffer(%x)\n", (int) bufferBit
);
738 if (bufferBit
== FRONT_LEFT_BIT
) {
739 fxMesa
->currentFB
= GR_BUFFER_FRONTBUFFER
;
740 grRenderBuffer(fxMesa
->currentFB
);
742 else if (bufferBit
== BACK_LEFT_BIT
) {
743 fxMesa
->currentFB
= GR_BUFFER_BACKBUFFER
;
744 grRenderBuffer(fxMesa
->currentFB
);
749 /************************************************************************/
754 fxSetupDDSpanPointers(GLcontext
* ctx
)
756 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference( ctx
);
758 swdd
->SetBuffer
= fxDDSetBuffer
;
760 swdd
->WriteRGBASpan
= fxDDWriteRGBASpan
;
761 swdd
->WriteRGBSpan
= fxDDWriteRGBSpan
;
762 swdd
->WriteMonoRGBASpan
= fxDDWriteMonoRGBASpan
;
763 swdd
->WriteRGBAPixels
= fxDDWriteRGBAPixels
;
764 swdd
->WriteMonoRGBAPixels
= fxDDWriteMonoRGBAPixels
;
766 /* swdd->ReadRGBASpan =fxDDReadRGBASpan; */
768 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
769 switch (fxMesa
->colDepth
) {
771 swdd
->ReadRGBASpan
= read_R5G5B5_span
;
772 swdd
->ReadRGBAPixels
= read_R5G5B5_pixels
;
773 swdd
->WriteDepthSpan
= fxDDWriteDepthSpan
;
774 swdd
->WriteDepthPixels
= fxDDWriteDepthPixels
;
775 swdd
->ReadDepthSpan
= fxDDReadDepthSpan
;
776 swdd
->ReadDepthPixels
= fxDDReadDepthPixels
;
779 swdd
->ReadRGBASpan
= read_R5G6B5_span
;
780 swdd
->ReadRGBAPixels
= read_R5G6B5_pixels
;
781 swdd
->WriteDepthSpan
= fxDDWriteDepthSpan
;
782 swdd
->WriteDepthPixels
= fxDDWriteDepthPixels
;
783 swdd
->ReadDepthSpan
= fxDDReadDepthSpan
;
784 swdd
->ReadDepthPixels
= fxDDReadDepthPixels
;
787 swdd
->ReadRGBASpan
= read_R8G8B8_span
;
788 swdd
->ReadRGBAPixels
= read_R8G8B8_pixels
;
789 swdd
->WriteDepthSpan
= fxDDWriteDepth32Span
;
790 swdd
->WriteDepthPixels
= fxDDWriteDepth32Pixels
;
791 swdd
->ReadDepthSpan
= fxDDReadDepth32Span
;
792 swdd
->ReadDepthPixels
= fxDDReadDepth32Pixels
;
803 * Need this to provide at least one external definition.
806 extern int gl_fx_dummy_function_span(void);
808 gl_fx_dummy_function_span(void)