1 /* -*- mode: c; c-basic-offset: 3 -*-
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
30 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
33 * Gareth Hughes <gareth@valinux.com>
34 * Brian Paul <brianp@valinux.com>
35 * Keith Whitwell <keith@tungstengraphics.com>
39 #include "tdfx_context.h"
40 #include "tdfx_lock.h"
41 #include "tdfx_span.h"
42 #include "tdfx_render.h"
43 #include "swrast/swrast.h"
50 __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \
51 tdfxScreenPrivate *fxPriv = fxMesa->fxScreen; \
52 GLuint pitch = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) \
53 ? (fxMesa->screen_width * BYTESPERPIXEL) : \
54 (info.strideInBytes); \
55 GLuint height = fxMesa->height; \
56 char *buf = (char *)((char *)info.lfbPtr + \
57 dPriv->x * fxPriv->cpp + \
63 #define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \
64 _y >= miny && _y < maxy )
66 #define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
67 if ( _y < miny || _y >= maxy ) { \
72 if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
73 if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
76 #define Y_FLIP(_y) (height - _y - 1)
79 #define HW_WRITE_LOCK() \
80 tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
82 FLUSH_BATCH( fxMesa ); \
83 UNLOCK_HARDWARE( fxMesa ); \
84 LOCK_HARDWARE( fxMesa ); \
85 info.size = sizeof(GrLfbInfo_t); \
86 if ( fxMesa->Glide.grLfbLock( GR_LFB_WRITE_ONLY, \
87 fxMesa->DrawBuffer, LFB_MODE, \
88 GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
91 #define HW_WRITE_UNLOCK() \
92 fxMesa->Glide.grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer );\
96 #define HW_READ_LOCK() \
97 tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
99 FLUSH_BATCH( fxMesa ); \
100 UNLOCK_HARDWARE( fxMesa ); \
101 LOCK_HARDWARE( fxMesa ); \
102 info.size = sizeof(GrLfbInfo_t); \
103 if ( fxMesa->Glide.grLfbLock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer, \
104 LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
107 #define HW_READ_UNLOCK() \
108 fxMesa->Glide.grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer );\
112 #define HW_WRITE_CLIPLOOP() \
114 int _nc = fxMesa->numClipRects; \
116 int minx = fxMesa->pClipRects[_nc].x1 - fxMesa->x_offset; \
117 int miny = fxMesa->pClipRects[_nc].y1 - fxMesa->y_offset; \
118 int maxx = fxMesa->pClipRects[_nc].x2 - fxMesa->x_offset; \
119 int maxy = fxMesa->pClipRects[_nc].y2 - fxMesa->y_offset;
121 #define HW_READ_CLIPLOOP() \
123 const __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \
124 XF86DRIClipRectPtr rect = dPriv->pClipRects; \
125 int _nc = dPriv->numClipRects; \
127 const int minx = rect->x1 - fxMesa->x_offset; \
128 const int miny = rect->y1 - fxMesa->y_offset; \
129 const int maxx = rect->x2 - fxMesa->x_offset; \
130 const int maxy = rect->y2 - fxMesa->y_offset; \
133 #define HW_ENDCLIPLOOP() \
139 #define LFB_MODE GR_LFBWRITEMODE_565
142 /* 16 bit, RGB565 color spanline and pixel functions */ \
144 #undef INIT_MONO_PIXEL
145 #define INIT_MONO_PIXEL(p, color) \
146 p = TDFXPACKCOLOR565( color[0], color[1], color[2] )
149 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
150 *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
151 (((int)g & 0xfc) << 3) | \
152 (((int)b & 0xf8) >> 3))
154 #define WRITE_PIXEL( _x, _y, p ) \
155 *(GLushort *)(buf + _x*2 + _y*pitch) = p
157 #define READ_RGBA( rgba, _x, _y ) \
159 GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
160 rgba[0] = (((p >> 11) & 0x1f) * 255) / 31; \
161 rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \
162 rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \
166 #define TAG(x) tdfx##x##_RGB565
167 #define BYTESPERPIXEL 2
172 /* 16 bit, BGR565 color spanline and pixel functions */ \
175 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
176 *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)b & 0xf8) << 8) | \
177 (((int)g & 0xfc) << 3) | \
178 (((int)r & 0xf8) >> 3))
180 #define WRITE_PIXEL( _x, _y, p ) \
181 *(GLushort *)(buf + _x*2 + _y*pitch) = p
183 #define READ_RGBA( rgba, _x, _y ) \
185 GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
186 rgba[0] = (p << 3) & 0xf8; \
187 rgba[1] = (p >> 3) & 0xfc; \
188 rgba[2] = (p >> 8) & 0xf8; \
192 #define TAG(x) tdfx##x##_BGR565
193 #define BYTESPERPIXEL 2
200 #define LFB_MODE GR_LFBWRITEMODE_888
203 /* 24 bit, RGB888 color spanline and pixel functions */
204 #undef INIT_MONO_PIXEL
205 #define INIT_MONO_PIXEL(p, color) \
206 p = TDFXPACKCOLOR888( color[0], color[1], color[2] )
208 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
209 *(GLuint *)(buf + _x*3 + _y*pitch) = ((b << 0) | \
213 #define WRITE_PIXEL( _x, _y, p ) \
214 *(GLuint *)(buf + _x*3 + _y*pitch) = p
216 #define READ_RGBA( rgba, _x, _y ) \
218 GLuint p = *(GLuint *)(buf + _x*3 + _y*pitch); \
219 rgba[0] = (p >> 16) & 0xff; \
220 rgba[1] = (p >> 8) & 0xff; \
221 rgba[2] = (p >> 0) & 0xff; \
225 #define TAG(x) tdfx##x##_RGB888
226 #define BYTESPERPIXEL 4
232 #define LFB_MODE GR_LFBWRITEMODE_8888
235 /* 32 bit, ARGB8888 color spanline and pixel functions */
236 #undef INIT_MONO_PIXEL
237 #define INIT_MONO_PIXEL(p, color) \
238 p = TDFXPACKCOLOR8888( color[0], color[1], color[2], color[3] )
240 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
241 *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
246 #define WRITE_PIXEL( _x, _y, p ) \
247 *(GLuint *)(buf + _x*4 + _y*pitch) = p
249 #define READ_RGBA( rgba, _x, _y ) \
251 GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \
252 rgba[0] = (p >> 16) & 0xff; \
253 rgba[1] = (p >> 8) & 0xff; \
254 rgba[2] = (p >> 0) & 0xff; \
255 rgba[3] = (p >> 24) & 0xff; \
258 #define TAG(x) tdfx##x##_ARGB8888
259 #define BYTESPERPIXEL 4
265 /* ================================================================
266 * Old span functions below...
271 * Examine the cliprects to generate an array of flags to indicate
272 * which pixels in a span are visible. Note: (x,y) is a screen
276 generate_vismask(const tdfxContextPtr fxMesa
, GLint x
, GLint y
, GLint n
,
279 GLboolean initialized
= GL_FALSE
;
282 /* Ensure we clear the visual mask */
283 MEMSET(vismask
, 0, n
);
285 /* turn on flags for all visible pixels */
286 for (i
= 0; i
< fxMesa
->numClipRects
; i
++) {
287 const XF86DRIClipRectPtr rect
= &fxMesa
->pClipRects
[i
];
289 if (y
>= rect
->y1
&& y
< rect
->y2
) {
290 if (x
>= rect
->x1
&& x
+ n
<= rect
->x2
) {
291 /* common case, whole span inside cliprect */
292 MEMSET(vismask
, 1, n
);
295 if (x
< rect
->x2
&& x
+ n
>= rect
->x1
) {
296 /* some of the span is inside the rect */
299 MEMSET(vismask
, 0, n
);
300 initialized
= GL_TRUE
;
303 start
= rect
->x1
- x
;
306 if (x
+ n
> rect
->x2
)
312 for (j
= start
; j
< end
; j
++)
320 * Examine cliprects and determine if the given screen pixel is visible.
323 visible_pixel(const tdfxContextPtr fxMesa
, int scrX
, int scrY
)
326 for (i
= 0; i
< fxMesa
->numClipRects
; i
++) {
327 const XF86DRIClipRectPtr rect
= &fxMesa
->pClipRects
[i
];
328 if (scrX
>= rect
->x1
&&
330 scrY
>= rect
->y1
&& scrY
< rect
->y2
) return GL_TRUE
;
338 * Depth buffer read/write functions.
341 * To read the frame buffer, we need to lock and unlock it. The
342 * four macros {READ,WRITE}_FB_SPAN_{LOCK,UNLOCK}
345 * Note that the lock must be matched with an unlock. These
346 * macros include a spare curly brace, so they must
347 * be syntactically matched.
349 * Note, also, that you can't lock a buffer twice with different
350 * modes. That is to say, you can't lock a buffer in both read
351 * and write modes. The strideInBytes and LFB pointer will be
352 * the same with read and write locks, so you can use either.
353 * o The HW has different state for reads and writes, so
354 * locking it twice may give screwy results.
355 * o The DRM won't let you lock twice. It hangs. This is probably
356 * because of the LOCK_HARDWARE IN THE *_FB_SPAN_LOCK macros,
357 * and could be eliminated with nonlocking lock routines. But
358 * what's the point after all.
360 #define READ_FB_SPAN_LOCK(fxMesa, info, target_buffer) \
361 UNLOCK_HARDWARE(fxMesa); \
362 LOCK_HARDWARE(fxMesa); \
363 (info).size=sizeof(info); \
364 if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, \
366 GR_LFBWRITEMODE_ANY, \
367 GR_ORIGIN_UPPER_LEFT, \
371 #define READ_FB_SPAN_UNLOCK(fxMesa, target_buffer) \
372 fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, target_buffer); \
374 fprintf(stderr, "tdfxDriver: Can't get %s (%d) read lock\n", \
375 (target_buffer == GR_BUFFER_BACKBUFFER) \
377 : ((target_buffer == GR_BUFFER_AUXBUFFER) \
379 : "unknown buffer"), \
383 #define WRITE_FB_SPAN_LOCK(fxMesa, info, target_buffer, write_mode) \
384 UNLOCK_HARDWARE(fxMesa); \
385 LOCK_HARDWARE(fxMesa); \
386 info.size=sizeof(info); \
387 if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY, \
390 GR_ORIGIN_UPPER_LEFT, \
394 #define WRITE_FB_SPAN_UNLOCK(fxMesa, target_buffer) \
395 fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, target_buffer); \
397 fprintf(stderr, "tdfxDriver: Can't get %s (%d) write lock\n", \
398 (target_buffer == GR_BUFFER_BACKBUFFER) \
400 : ((target_buffer == GR_BUFFER_AUXBUFFER) \
402 : "unknown buffer"), \
407 * Because the Linear Frame Buffer is not necessarily aligned
408 * with the depth buffer, we have to do some fiddling
409 * around to get the right addresses.
411 * Perhaps a picture is in order. The Linear Frame Buffer
414 * |<----------------------info.strideInBytes------------->|
415 * |<-----physicalStrideInBytes------->|
416 * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
418 * | Legal Memory | Forbidden Zone |
420 * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
422 * You can only reliably read and write legal locations. Reads
423 * and writes from the Forbidden Zone will return undefined values,
424 * and may cause segmentation faults.
426 * Now, the depth buffer may not end up in a location such each
427 * scan line is an LFB line. For example, the depth buffer may
431 * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
432 * |0000000000000000000000 | | back
433 * |1111111111111111111111 | | buffer
434 * |2222222222222222222222 | |
435 * |4096b align. padxx00000000000000000| Forbidden Zone | depth
436 * |0000 11111111111111111| | buffer
437 * |1111 22222222222222222| |
439 * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
440 * where each number is the scan line number. We know it will
441 * be aligned on 128 byte boundaries, at least. Aligning this
442 * on a scanline boundary causes the back and depth buffers to
443 * thrash in the SST1 cache. (Note that the back buffer is always
444 * allocated at the beginning of LFB memory, and so it is always
445 * properly aligned with the LFB stride.)
447 * We call the beginning of the line (which is the rightmost
448 * part of the depth line in the picture above) the *ordinary* part
449 * of the scanline, and the end of the line (which is the
450 * leftmost part, one line below) the *wrapped* part of the scanline.
451 * a.) We need to know what x value to subtract from the screen
452 * x coordinate to index into the wrapped part.
453 * b.) We also need to figure out if we need to read from the ordinary
454 * part scan line, or from the wrapped part of the scan line.
457 * The first wrapped x coordinate is that coordinate such that
458 * depthBufferOffset&(info.strideInBytes) + x*elmentSize {*}
459 * > physicalStrideInBytes
460 * where depthBufferOffset is the LFB distance in bytes
461 * from the back buffer to the depth buffer. The expression
462 * depthBufferOffset&(info.strideInBytes)
463 * is then the offset (in bytes) from the beginining of (any)
464 * depth buffer line to first element in the line.
465 * Simplifying inequation {*} above we see that x is the smallest
467 * x*elementSize > physicalStrideInBytes {**}
468 * - depthBufferOffset&(info.strideInBytes)
469 * Now, we know that both the summands on the right are multiples of
470 * 128, and elementSize <= 4, so if equality holds in {**}, x would
471 * be a multiple of 32. Thus we can set x to
472 * xwrapped = (physicalStrideInBytes
473 * - depthBufferOffset&(info.strideInBytes))/elementSize
477 * Question b is now simple. We read from the wrapped scan line if
478 * x is greater than xwrapped.
480 #define TILE_WIDTH_IN_BYTES 128
481 #define TILE_WIDTH_IN_ZOXELS(bpz) (TILE_WIDTH_IN_BYTES/(bpz))
482 #define TILE_HEIGHT_IN_LINES 32
487 FxU32 LFBStrideInElts
;
493 * We need information about the back buffer. Note that
494 * this function *cannot be called* while the aux buffer
495 * is locked, or the caller will hang.
497 * Only Glide knows the LFB address of the back and depth
498 * offsets. The upper levels of Mesa know the depth offset,
499 * but that is not in LFB space, it is tiled memory space,
500 * and is not useable for us.
503 GetBackBufferInfo(tdfxContextPtr fxMesa
, GrLfbInfo_t
* backBufferInfo
)
505 READ_FB_SPAN_LOCK(fxMesa
, *backBufferInfo
, GR_BUFFER_BACKBUFFER
);
506 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_BACKBUFFER
);
510 GetFbParams(tdfxContextPtr fxMesa
,
512 GrLfbInfo_t
* backBufferInfo
,
513 LFBParameters
* ReadParamsp
, FxU32 elementSize
)
515 FxU32 physicalStrideInBytes
, bufferOffset
;
516 FxU32 strideInBytes
= info
->strideInBytes
;
517 char *lfbPtr
= (char *) (info
->lfbPtr
); /* For arithmetic, use char * */
520 * These two come directly from the info structure.
522 ReadParamsp
->lfbPtr
= (void *) lfbPtr
;
523 ReadParamsp
->LFBStrideInElts
= strideInBytes
/ elementSize
;
525 * Now, calculate the value of firstWrappedX.
527 * The physical stride is the screen width in bytes rounded up to
528 * the next highest multiple of 128 bytes. Note that this fails
529 * when TILE_WIDTH_IN_BYTES is not a power of two.
531 * The buffer Offset is the distance between the beginning of
532 * the LFB space, which is the beginning of the back buffer,
533 * and the buffer we are gathering information about.
534 * We want to make this routine usable for operations on the
535 * back buffer, though we don't actually use it on the back
536 * buffer. Note, then, that if bufferOffset == 0, the firstWrappedX
537 * is in the forbidden zone, and is therefore never reached.
540 * physicalStrideInBytes
541 * < bufferOffset&(info->strideInBytes-1)
542 * the buffer begins in the forbidden zone. We assert for this.
544 bufferOffset
= (FxU32
)(lfbPtr
- (char *) backBufferInfo
->lfbPtr
);
545 physicalStrideInBytes
546 = (fxMesa
->screen_width
* elementSize
+ TILE_WIDTH_IN_BYTES
- 1)
547 & ~(TILE_WIDTH_IN_BYTES
- 1);
548 assert(physicalStrideInBytes
> (bufferOffset
& (strideInBytes
- 1)));
549 ReadParamsp
->firstWrappedX
550 = (physicalStrideInBytes
551 - (bufferOffset
& (strideInBytes
- 1))) / elementSize
;
553 * This is the address of the next physical line.
555 ReadParamsp
->lfbWrapPtr
556 = (void *) ((char *) backBufferInfo
->lfbPtr
557 + (bufferOffset
& ~(strideInBytes
- 1))
558 + (TILE_HEIGHT_IN_LINES
) * strideInBytes
);
562 * These macros fetch data from the frame buffer. The type is
563 * the type of data we want to fetch. It should match the type
564 * whose size was used with GetFbParams to fill in the structure
565 * in *ReadParamsp. We have a macro to read the ordinary
566 * part, a second macro to read the wrapped part, and one which
567 * will do either. When we are reading a span, we will know
568 * when the ordinary part ends, so there's no need to test for
569 * it. However, when reading and writing pixels, we don't
570 * necessarily know. I suppose it's a matter of taste whether
571 * it's better in the macro or in the call.
573 * Recall that x and y are screen coordinates.
575 #define GET_FB_DATA(ReadParamsp, type, x, y) \
576 (((x) < (ReadParamsp)->firstWrappedX) \
577 ? (((type *)((ReadParamsp)->lfbPtr)) \
578 [(y) * ((ReadParamsp)->LFBStrideInElts) \
580 : (((type *)((ReadParamsp)->lfbWrapPtr)) \
581 [((y)) * ((ReadParamsp)->LFBStrideInElts) \
582 + ((x) - (ReadParamsp)->firstWrappedX)]))
583 #define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \
584 (((type *)((ReadParamsp)->lfbPtr)) \
585 [(y) * ((ReadParamsp)->LFBStrideInElts) \
587 #define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \
588 (((type *)((ReadParamsp)->lfbWrapPtr)) \
589 [((y)) * ((ReadParamsp)->LFBStrideInElts) \
590 + ((x) - (ReadParamsp)->firstWrappedX)])
591 #define PUT_FB_DATA(ReadParamsp, type, x, y, value) \
592 (GET_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
593 #define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \
594 (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
595 #define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \
596 (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
599 tdfxDDWriteDepthSpan(GLcontext
* ctx
,
600 GLuint n
, GLint x
, GLint y
, const GLdepth depth
[],
601 const GLubyte mask
[])
603 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
604 GLint bottom
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
605 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
606 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
608 GLubyte visMask
[MAX_WIDTH
];
610 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
611 fprintf(stderr
, "tdfxmesa: tdfxDDWriteDepthSpan(...)\n");
614 assert((depth_size
== 16) || (depth_size
== 24) || (depth_size
== 32));
616 * Convert x and y to screen coordinates.
618 x
+= fxMesa
->x_offset
;
623 GrLfbInfo_t backBufferInfo
;
625 switch (depth_size
) {
627 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
629 * Note that the _LOCK macro adds a curly brace,
630 * and the UNLOCK macro removes it.
632 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
,
633 GR_LFBWRITEMODE_ANY
);
634 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
636 LFBParameters ReadParams
;
637 int wrappedPartStart
;
638 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
639 &ReadParams
, sizeof(GLushort
));
640 if (ReadParams
.firstWrappedX
<= x
) {
641 wrappedPartStart
= 0;
643 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
644 wrappedPartStart
= n
;
647 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
649 for (i
= 0; i
< wrappedPartStart
; i
++) {
650 if (mask
[i
] && visMask
[i
]) {
652 PUT_ORDINARY_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
, d16
);
656 if (mask
[i
] && visMask
[i
]) {
658 PUT_WRAPPED_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
, d16
);
662 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
666 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
668 * Note that the _LOCK macro adds a curly brace,
669 * and the UNLOCK macro removes it.
671 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
,
672 GR_LFBWRITEMODE_ANY
);
673 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
675 LFBParameters ReadParams
;
676 int wrappedPartStart
;
677 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
678 &ReadParams
, sizeof(GLuint
));
679 if (ReadParams
.firstWrappedX
<= x
) {
680 wrappedPartStart
= 0;
682 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
683 wrappedPartStart
= n
;
686 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
688 for (i
= 0; i
< wrappedPartStart
; i
++) {
690 if (mask
[i
] && visMask
[i
]) {
691 if (stencil_size
> 0) {
693 GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
696 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
701 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
706 if (mask
[i
] && visMask
[i
]) {
707 if (stencil_size
> 0) {
709 GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
712 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
717 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
721 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
729 GrLfbInfo_t backBufferInfo
;
731 switch (depth_size
) {
733 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
735 * Note that the _LOCK macro adds a curly brace,
736 * and the UNLOCK macro removes it.
738 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
739 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
740 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
742 LFBParameters ReadParams
;
743 GLuint wrappedPartStart
;
744 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
745 &ReadParams
, sizeof(GLushort
));
746 if (ReadParams
.firstWrappedX
<= x
) {
747 wrappedPartStart
= 0;
749 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
750 wrappedPartStart
= n
;
753 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
755 for (i
= 0; i
< wrappedPartStart
; i
++) {
758 PUT_ORDINARY_FB_DATA(&ReadParams
,
767 PUT_WRAPPED_FB_DATA(&ReadParams
,
774 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
778 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
780 * Note that the _LOCK macro adds a curly brace,
781 * and the UNLOCK macro removes it.
783 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
784 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
785 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
787 LFBParameters ReadParams
;
788 GLuint wrappedPartStart
;
790 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
791 &ReadParams
, sizeof(GLuint
));
792 if (ReadParams
.firstWrappedX
<= x
) {
793 wrappedPartStart
= 0;
795 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
796 wrappedPartStart
= n
;
799 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
801 for (i
= 0; i
< wrappedPartStart
; i
++) {
803 if (stencil_size
> 0) {
804 d32
= GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
806 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
811 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
816 if (stencil_size
> 0) {
817 d32
= GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
819 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
824 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
828 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
835 tdfxDDReadDepthSpan(GLcontext
* ctx
,
836 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
838 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
839 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
841 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
844 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
845 fprintf(stderr
, "tdfxmesa: tdfxDDReadDepthSpan(...)\n");
849 * Convert to screen coordinates.
851 x
+= fxMesa
->x_offset
;
853 switch (depth_size
) {
856 LFBParameters ReadParams
;
857 GrLfbInfo_t backBufferInfo
;
858 int wrappedPartStart
;
859 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
861 * Note that the _LOCK macro adds a curly brace,
862 * and the UNLOCK macro removes it.
864 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
865 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
866 &ReadParams
, sizeof(GLushort
));
867 if (ReadParams
.firstWrappedX
<= x
) {
868 wrappedPartStart
= 0;
870 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
871 wrappedPartStart
= n
;
874 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
879 for (i
= 0; i
< wrappedPartStart
; i
++) {
881 GET_ORDINARY_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
);
884 depth
[i
] = GET_WRAPPED_FB_DATA(&ReadParams
, GLushort
,
887 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
893 LFBParameters ReadParams
;
894 GrLfbInfo_t backBufferInfo
;
895 int wrappedPartStart
;
896 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
897 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
899 * Note that the _LOCK macro adds a curly brace,
900 * and the UNLOCK macro removes it.
902 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
903 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
904 &ReadParams
, sizeof(GLuint
));
905 if (ReadParams
.firstWrappedX
<= x
) {
906 wrappedPartStart
= 0;
908 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
909 wrappedPartStart
= n
;
912 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
917 for (i
= 0; i
< wrappedPartStart
; i
++) {
919 (stencil_size
> 0) ? 0x00FFFFFF : 0xFFFFFFFF;
921 GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
926 (stencil_size
> 0) ? 0x00FFFFFF : 0xFFFFFFFF;
927 depth
[i
] = GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
930 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
938 tdfxDDWriteDepthPixels(GLcontext
* ctx
,
939 GLuint n
, const GLint x
[], const GLint y
[],
940 const GLdepth depth
[], const GLubyte mask
[])
942 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
943 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
947 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
948 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
952 GrLfbInfo_t backBufferInfo
;
954 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
955 fprintf(stderr
, "tdfxmesa: tdfxDDWriteDepthPixels(...)\n");
958 switch (depth_size
) {
960 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
962 * Note that the _LOCK macro adds a curly brace,
963 * and the UNLOCK macro removes it.
965 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
966 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
968 LFBParameters ReadParams
;
969 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
970 &ReadParams
, sizeof(GLushort
));
971 for (i
= 0; i
< n
; i
++) {
972 if (mask
[i
] && visible_pixel(fxMesa
, x
[i
], y
[i
])) {
973 xpos
= x
[i
] + fxMesa
->x_offset
;
974 ypos
= bottom
- y
[i
];
976 PUT_FB_DATA(&ReadParams
, GLushort
, xpos
, ypos
, d16
);
980 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
984 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
986 * Note that the _LOCK macro adds a curly brace,
987 * and the UNLOCK macro removes it.
989 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
990 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
992 LFBParameters ReadParams
;
993 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
994 &ReadParams
, sizeof(GLuint
));
995 for (i
= 0; i
< n
; i
++) {
997 if (visible_pixel(fxMesa
, x
[i
], y
[i
])) {
998 xpos
= x
[i
] + fxMesa
->x_offset
;
999 ypos
= bottom
- y
[i
];
1000 if (stencil_size
> 0) {
1002 GET_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
);
1003 d32
= (d32
& 0xFF000000) | (depth
[i
] & 0xFFFFFF);
1008 PUT_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
, d32
);
1013 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1020 tdfxDDReadDepthPixels(GLcontext
* ctx
, GLuint n
,
1021 const GLint x
[], const GLint y
[], GLdepth depth
[])
1023 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
1024 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
1026 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
1031 GLuint stencil_size
;
1032 GrLfbInfo_t backBufferInfo
;
1034 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
1035 fprintf(stderr
, "tdfxmesa: tdfxDDReadDepthPixels(...)\n");
1038 assert((depth_size
== 16) || (depth_size
== 24) || (depth_size
== 32));
1039 switch (depth_size
) {
1041 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1043 * Note that the _LOCK macro adds a curly brace,
1044 * and the UNLOCK macro removes it.
1046 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1048 LFBParameters ReadParams
;
1049 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
1050 &ReadParams
, sizeof(GLushort
));
1051 for (i
= 0; i
< n
; i
++) {
1053 * Convert to screen coordinates.
1055 xpos
= x
[i
] + fxMesa
->x_offset
;
1056 ypos
= bottom
- y
[i
];
1057 d16
= GET_FB_DATA(&ReadParams
, GLushort
, xpos
, ypos
);
1061 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1065 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1067 * Note that the _LOCK macro adds a curly brace,
1068 * and the UNLOCK macro removes it.
1070 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1071 stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
1073 LFBParameters ReadParams
;
1074 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
1075 &ReadParams
, sizeof(GLuint
));
1076 for (i
= 0; i
< n
; i
++) {
1080 * Convert to screen coordinates.
1082 xpos
= x
[i
] + fxMesa
->x_offset
;
1083 ypos
= bottom
- y
[i
];
1084 d32
= GET_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
);
1085 if (stencil_size
> 0) {
1091 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1099 * Stencil buffer read/write functions.
1101 #define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF)
1102 #define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff)
1103 #define BUILD_ZS(z, s) (((s) << 24) | (z))
1106 write_stencil_span(GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
,
1107 const GLstencil stencil
[], const GLubyte mask
[])
1109 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1111 GrLfbInfo_t backBufferInfo
;
1113 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1115 * Note that the _LOCK macro adds a curly brace,
1116 * and the UNLOCK macro removes it.
1118 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
1120 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1121 const GLint winX
= fxMesa
->x_offset
;
1122 const GLint scrX
= winX
+ x
;
1123 const GLint scrY
= winY
- y
;
1124 LFBParameters ReadParams
;
1125 GLubyte visMask
[MAX_WIDTH
];
1127 int wrappedPartStart
;
1129 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1131 if (ReadParams
.firstWrappedX
<= x
) {
1132 wrappedPartStart
= 0;
1134 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
1135 wrappedPartStart
= n
;
1138 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
1140 generate_vismask(fxMesa
, scrX
, scrY
, n
, visMask
);
1141 for (i
= 0; i
< wrappedPartStart
; i
++) {
1142 if (visMask
[i
] && (!mask
|| mask
[i
])) {
1143 GLuint z
= GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
1144 scrX
+ i
, scrY
) & 0x00FFFFFF;
1145 z
|= (stencil
[i
] & 0xFF) << 24;
1146 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, scrX
+ i
, scrY
, z
);
1149 for (; i
< n
; i
++) {
1150 if (visMask
[i
] && (!mask
|| mask
[i
])) {
1151 GLuint z
= GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
1152 scrX
+ i
, scrY
) & 0x00FFFFFF;
1153 z
|= (stencil
[i
] & 0xFF) << 24;
1154 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, scrX
+ i
, scrY
, z
);
1158 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1163 read_stencil_span(GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
,
1164 GLstencil stencil
[])
1166 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1168 GrLfbInfo_t backBufferInfo
;
1170 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1172 * Note that the _LOCK macro adds a curly brace,
1173 * and the UNLOCK macro removes it.
1175 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1177 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1178 const GLint winX
= fxMesa
->x_offset
;
1180 LFBParameters ReadParams
;
1181 int wrappedPartStart
;
1184 * Convert to screen coordinates.
1188 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1190 if (ReadParams
.firstWrappedX
<= x
) {
1191 wrappedPartStart
= 0;
1193 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
1194 wrappedPartStart
= n
;
1197 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
1199 for (i
= 0; i
< wrappedPartStart
; i
++) {
1200 stencil
[i
] = (GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
1201 x
+ i
, y
) >> 24) & 0xFF;
1203 for (; i
< n
; i
++) {
1204 stencil
[i
] = (GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
1205 x
+ i
, y
) >> 24) & 0xFF;
1208 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1213 write_stencil_pixels(GLcontext
* ctx
, GLuint n
,
1214 const GLint x
[], const GLint y
[],
1215 const GLstencil stencil
[], const GLubyte mask
[])
1217 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1219 GrLfbInfo_t backBufferInfo
;
1221 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1223 * Note that the _LOCK macro adds a curly brace,
1224 * and the UNLOCK macro removes it.
1226 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
1228 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1229 const GLint winX
= fxMesa
->x_offset
;
1230 LFBParameters ReadParams
;
1233 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1235 for (i
= 0; i
< n
; i
++) {
1236 const GLint scrX
= winX
+ x
[i
];
1237 const GLint scrY
= winY
- y
[i
];
1238 if ((!mask
|| mask
[i
]) && visible_pixel(fxMesa
, scrX
, scrY
)) {
1240 GET_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
) & 0x00FFFFFF;
1241 z
|= (stencil
[i
] & 0xFF) << 24;
1242 PUT_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
, z
);
1246 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1251 read_stencil_pixels(GLcontext
* ctx
, GLuint n
, const GLint x
[],
1252 const GLint y
[], GLstencil stencil
[])
1254 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1256 GrLfbInfo_t backBufferInfo
;
1258 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1260 * Note that the _LOCK macro adds a curly brace,
1261 * and the UNLOCK macro removes it.
1263 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1265 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1266 const GLint winX
= fxMesa
->x_offset
;
1268 LFBParameters ReadParams
;
1270 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1272 for (i
= 0; i
< n
; i
++) {
1273 const GLint scrX
= winX
+ x
[i
];
1274 const GLint scrY
= winY
- y
[i
];
1276 (GET_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
) >> 24) & 0xFF;
1279 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1282 #define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
1283 ((vis.redBits == r) && \
1284 (vis.greenBits == g) && \
1285 (vis.blueBits == b) && \
1286 (vis.alphaBits == a))
1291 /**********************************************************************/
1292 /* Locking for swrast */
1293 /**********************************************************************/
1296 static void tdfxSpanRenderStart( GLcontext
*ctx
)
1298 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1299 LOCK_HARDWARE(fxMesa
);
1302 static void tdfxSpanRenderFinish( GLcontext
*ctx
)
1304 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1305 _swrast_flush( ctx
);
1306 UNLOCK_HARDWARE(fxMesa
);
1309 /* Set the buffer used for reading */
1310 static void tdfxDDSetBuffer( GLcontext
*ctx
,
1311 GLframebuffer
*buffer
, GLuint bufferBit
)
1313 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1316 switch ( bufferBit
) {
1317 case FRONT_LEFT_BIT
:
1318 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_FRONTBUFFER
;
1321 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_BACKBUFFER
;
1328 /**********************************************************************/
1329 /* Initialize swrast device driver */
1330 /**********************************************************************/
1332 void tdfxDDInitSpanFuncs( GLcontext
*ctx
)
1334 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1335 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference( ctx
);
1337 swdd
->SetBuffer
= tdfxDDSetBuffer
;
1339 if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 5, 6, 5, 0) )
1342 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_RGB565
;
1343 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_RGB565
;
1344 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_RGB565
;
1345 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_RGB565
;
1346 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_RGB565
;
1347 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_RGB565
;
1348 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_RGB565
;
1350 else if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 8, 8, 8, 0) )
1353 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_RGB888
;
1354 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_RGB888
;
1355 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_RGB888
;
1356 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_RGB888
;
1357 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_RGB888
;
1358 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_RGB888
;
1359 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_RGB888
;
1361 else if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 8, 8, 8, 8) )
1364 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_ARGB8888
;
1365 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_ARGB8888
;
1366 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_ARGB8888
;
1367 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_ARGB8888
;
1368 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_ARGB8888
;
1369 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_ARGB8888
;
1370 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_ARGB8888
;
1377 if ( fxMesa
->haveHwStencil
) {
1378 swdd
->WriteStencilSpan
= write_stencil_span
;
1379 swdd
->ReadStencilSpan
= read_stencil_span
;
1380 swdd
->WriteStencilPixels
= write_stencil_pixels
;
1381 swdd
->ReadStencilPixels
= read_stencil_pixels
;
1384 swdd
->WriteDepthSpan
= tdfxDDWriteDepthSpan
;
1385 swdd
->WriteDepthPixels
= tdfxDDWriteDepthPixels
;
1386 swdd
->ReadDepthSpan
= tdfxDDReadDepthSpan
;
1387 swdd
->ReadDepthPixels
= tdfxDDReadDepthPixels
;
1389 swdd
->WriteCI8Span
= NULL
;
1390 swdd
->WriteCI32Span
= NULL
;
1391 swdd
->WriteMonoCISpan
= NULL
;
1392 swdd
->WriteCI32Pixels
= NULL
;
1393 swdd
->WriteMonoCIPixels
= NULL
;
1394 swdd
->ReadCI32Span
= NULL
;
1395 swdd
->ReadCI32Pixels
= NULL
;
1397 swdd
->SpanRenderStart
= tdfxSpanRenderStart
;
1398 swdd
->SpanRenderFinish
= tdfxSpanRenderFinish
;