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[0] == 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 drm_clip_rect_t *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 drm_clip_rect_t
*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 drm_clip_rect_t
*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_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \
576 (((type *)((ReadParamsp)->lfbPtr)) \
577 [(y) * ((ReadParamsp)->LFBStrideInElts) \
579 #define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \
580 (((type *)((ReadParamsp)->lfbWrapPtr)) \
581 [((y)) * ((ReadParamsp)->LFBStrideInElts) \
582 + ((x) - (ReadParamsp)->firstWrappedX)])
583 #define GET_FB_DATA(ReadParamsp, type, x, y) \
584 (((x) < (ReadParamsp)->firstWrappedX) \
585 ? GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \
586 : GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y))
587 #define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \
588 (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
589 #define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \
590 (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
591 #define PUT_FB_DATA(ReadParamsp, type, x, y, value) \
593 if ((x) < (ReadParamsp)->firstWrappedX) \
594 PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value); \
596 PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value); \
600 tdfxDDWriteDepthSpan(GLcontext
* ctx
,
601 GLuint n
, GLint x
, GLint y
, const GLdepth depth
[],
602 const GLubyte mask
[])
604 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
605 GLint bottom
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
606 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
607 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
609 GLubyte visMask
[MAX_WIDTH
];
611 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
612 fprintf(stderr
, "tdfxmesa: tdfxDDWriteDepthSpan(...)\n");
615 assert((depth_size
== 16) || (depth_size
== 24) || (depth_size
== 32));
617 * Convert x and y to screen coordinates.
619 x
+= fxMesa
->x_offset
;
624 GrLfbInfo_t backBufferInfo
;
626 switch (depth_size
) {
628 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
630 * Note that the _LOCK macro adds a curly brace,
631 * and the UNLOCK macro removes it.
633 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
,
634 GR_LFBWRITEMODE_ANY
);
635 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
637 LFBParameters ReadParams
;
638 int wrappedPartStart
;
639 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
640 &ReadParams
, sizeof(GLushort
));
641 if (ReadParams
.firstWrappedX
<= x
) {
642 wrappedPartStart
= 0;
644 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
645 wrappedPartStart
= n
;
648 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
650 for (i
= 0; i
< wrappedPartStart
; i
++) {
651 if (mask
[i
] && visMask
[i
]) {
653 PUT_ORDINARY_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
, d16
);
657 if (mask
[i
] && visMask
[i
]) {
659 PUT_WRAPPED_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
, d16
);
663 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
667 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
669 * Note that the _LOCK macro adds a curly brace,
670 * and the UNLOCK macro removes it.
672 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
,
673 GR_LFBWRITEMODE_ANY
);
674 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
676 LFBParameters ReadParams
;
677 int wrappedPartStart
;
678 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
679 &ReadParams
, sizeof(GLuint
));
680 if (ReadParams
.firstWrappedX
<= x
) {
681 wrappedPartStart
= 0;
683 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
684 wrappedPartStart
= n
;
687 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
689 for (i
= 0; i
< wrappedPartStart
; i
++) {
691 if (mask
[i
] && visMask
[i
]) {
692 if (stencil_size
> 0) {
694 GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
697 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
702 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
707 if (mask
[i
] && visMask
[i
]) {
708 if (stencil_size
> 0) {
710 GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
713 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
718 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
722 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
730 GrLfbInfo_t backBufferInfo
;
732 switch (depth_size
) {
734 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
736 * Note that the _LOCK macro adds a curly brace,
737 * and the UNLOCK macro removes it.
739 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
740 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
741 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
743 LFBParameters ReadParams
;
744 GLuint wrappedPartStart
;
745 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
746 &ReadParams
, sizeof(GLushort
));
747 if (ReadParams
.firstWrappedX
<= x
) {
748 wrappedPartStart
= 0;
750 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
751 wrappedPartStart
= n
;
754 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
756 for (i
= 0; i
< wrappedPartStart
; i
++) {
759 PUT_ORDINARY_FB_DATA(&ReadParams
,
768 PUT_WRAPPED_FB_DATA(&ReadParams
,
775 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
779 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
781 * Note that the _LOCK macro adds a curly brace,
782 * and the UNLOCK macro removes it.
784 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
785 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
786 generate_vismask(fxMesa
, x
, y
, n
, visMask
);
788 LFBParameters ReadParams
;
789 GLuint wrappedPartStart
;
791 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
792 &ReadParams
, sizeof(GLuint
));
793 if (ReadParams
.firstWrappedX
<= x
) {
794 wrappedPartStart
= 0;
796 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
797 wrappedPartStart
= n
;
800 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
802 for (i
= 0; i
< wrappedPartStart
; i
++) {
804 if (stencil_size
> 0) {
805 d32
= GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
807 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
812 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
817 if (stencil_size
> 0) {
818 d32
= GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
820 (d32
& 0xFF000000) | (depth
[i
] & 0x00FFFFFF);
825 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
, d32
);
829 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
836 tdfxDDReadDepthSpan(GLcontext
* ctx
,
837 GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
839 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
840 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
842 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
845 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
846 fprintf(stderr
, "tdfxmesa: tdfxDDReadDepthSpan(...)\n");
850 * Convert to screen coordinates.
852 x
+= fxMesa
->x_offset
;
854 switch (depth_size
) {
857 LFBParameters ReadParams
;
858 GrLfbInfo_t backBufferInfo
;
859 int wrappedPartStart
;
860 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
862 * Note that the _LOCK macro adds a curly brace,
863 * and the UNLOCK macro removes it.
865 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
866 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
867 &ReadParams
, sizeof(GLushort
));
868 if (ReadParams
.firstWrappedX
<= x
) {
869 wrappedPartStart
= 0;
871 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
872 wrappedPartStart
= n
;
875 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
880 for (i
= 0; i
< wrappedPartStart
; i
++) {
882 GET_ORDINARY_FB_DATA(&ReadParams
, GLushort
, x
+ i
, y
);
885 depth
[i
] = GET_WRAPPED_FB_DATA(&ReadParams
, GLushort
,
888 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
894 LFBParameters ReadParams
;
895 GrLfbInfo_t backBufferInfo
;
896 int wrappedPartStart
;
897 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
898 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
900 * Note that the _LOCK macro adds a curly brace,
901 * and the UNLOCK macro removes it.
903 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
904 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
905 &ReadParams
, sizeof(GLuint
));
906 if (ReadParams
.firstWrappedX
<= x
) {
907 wrappedPartStart
= 0;
909 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
910 wrappedPartStart
= n
;
913 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
918 for (i
= 0; i
< wrappedPartStart
; i
++) {
920 (stencil_size
> 0) ? 0x00FFFFFF : 0xFFFFFFFF;
922 GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
927 (stencil_size
> 0) ? 0x00FFFFFF : 0xFFFFFFFF;
928 depth
[i
] = GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
, x
+ i
, y
);
931 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
939 tdfxDDWriteDepthPixels(GLcontext
* ctx
,
940 GLuint n
, const GLint x
[], const GLint y
[],
941 const GLdepth depth
[], const GLubyte mask
[])
943 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
944 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
948 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
949 GLuint stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
953 GrLfbInfo_t backBufferInfo
;
955 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
956 fprintf(stderr
, "tdfxmesa: tdfxDDWriteDepthPixels(...)\n");
959 switch (depth_size
) {
961 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
963 * Note that the _LOCK macro adds a curly brace,
964 * and the UNLOCK macro removes it.
966 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
967 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
969 LFBParameters ReadParams
;
970 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
971 &ReadParams
, sizeof(GLushort
));
972 for (i
= 0; i
< n
; i
++) {
973 if (mask
[i
] && visible_pixel(fxMesa
, x
[i
], y
[i
])) {
974 xpos
= x
[i
] + fxMesa
->x_offset
;
975 ypos
= bottom
- y
[i
];
977 PUT_FB_DATA(&ReadParams
, GLushort
, xpos
, ypos
, d16
);
981 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
985 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
987 * Note that the _LOCK macro adds a curly brace,
988 * and the UNLOCK macro removes it.
990 WRITE_FB_SPAN_LOCK(fxMesa
, info
,
991 GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
993 LFBParameters ReadParams
;
994 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
995 &ReadParams
, sizeof(GLuint
));
996 for (i
= 0; i
< n
; i
++) {
998 if (visible_pixel(fxMesa
, x
[i
], y
[i
])) {
999 xpos
= x
[i
] + fxMesa
->x_offset
;
1000 ypos
= bottom
- y
[i
];
1001 if (stencil_size
> 0) {
1003 GET_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
);
1004 d32
= (d32
& 0xFF000000) | (depth
[i
] & 0xFFFFFF);
1009 PUT_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
, d32
);
1014 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1021 tdfxDDReadDepthPixels(GLcontext
* ctx
, GLuint n
,
1022 const GLint x
[], const GLint y
[], GLdepth depth
[])
1024 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
1025 GLint bottom
= fxMesa
->height
+ fxMesa
->y_offset
- 1;
1027 GLuint depth_size
= fxMesa
->glCtx
->Visual
.depthBits
;
1032 GLuint stencil_size
;
1033 GrLfbInfo_t backBufferInfo
;
1035 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
1036 fprintf(stderr
, "tdfxmesa: tdfxDDReadDepthPixels(...)\n");
1039 assert((depth_size
== 16) || (depth_size
== 24) || (depth_size
== 32));
1040 switch (depth_size
) {
1042 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1044 * Note that the _LOCK macro adds a curly brace,
1045 * and the UNLOCK macro removes it.
1047 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1049 LFBParameters ReadParams
;
1050 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
1051 &ReadParams
, sizeof(GLushort
));
1052 for (i
= 0; i
< n
; i
++) {
1054 * Convert to screen coordinates.
1056 xpos
= x
[i
] + fxMesa
->x_offset
;
1057 ypos
= bottom
- y
[i
];
1058 d16
= GET_FB_DATA(&ReadParams
, GLushort
, xpos
, ypos
);
1062 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1066 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1068 * Note that the _LOCK macro adds a curly brace,
1069 * and the UNLOCK macro removes it.
1071 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1072 stencil_size
= fxMesa
->glCtx
->Visual
.stencilBits
;
1074 LFBParameters ReadParams
;
1075 GetFbParams(fxMesa
, &info
, &backBufferInfo
,
1076 &ReadParams
, sizeof(GLuint
));
1077 for (i
= 0; i
< n
; i
++) {
1081 * Convert to screen coordinates.
1083 xpos
= x
[i
] + fxMesa
->x_offset
;
1084 ypos
= bottom
- y
[i
];
1085 d32
= GET_FB_DATA(&ReadParams
, GLuint
, xpos
, ypos
);
1086 if (stencil_size
> 0) {
1092 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1100 * Stencil buffer read/write functions.
1102 #define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF)
1103 #define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff)
1104 #define BUILD_ZS(z, s) (((s) << 24) | (z))
1107 write_stencil_span(GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
,
1108 const GLstencil stencil
[], const GLubyte mask
[])
1110 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1112 GrLfbInfo_t backBufferInfo
;
1114 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1116 * Note that the _LOCK macro adds a curly brace,
1117 * and the UNLOCK macro removes it.
1119 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
1121 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1122 const GLint winX
= fxMesa
->x_offset
;
1123 const GLint scrX
= winX
+ x
;
1124 const GLint scrY
= winY
- y
;
1125 LFBParameters ReadParams
;
1126 GLubyte visMask
[MAX_WIDTH
];
1128 int wrappedPartStart
;
1130 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1132 if (ReadParams
.firstWrappedX
<= x
) {
1133 wrappedPartStart
= 0;
1135 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
1136 wrappedPartStart
= n
;
1139 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
1141 generate_vismask(fxMesa
, scrX
, scrY
, n
, visMask
);
1142 for (i
= 0; i
< wrappedPartStart
; i
++) {
1143 if (visMask
[i
] && (!mask
|| mask
[i
])) {
1144 GLuint z
= GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
1145 scrX
+ i
, scrY
) & 0x00FFFFFF;
1146 z
|= (stencil
[i
] & 0xFF) << 24;
1147 PUT_ORDINARY_FB_DATA(&ReadParams
, GLuint
, scrX
+ i
, scrY
, z
);
1150 for (; i
< n
; i
++) {
1151 if (visMask
[i
] && (!mask
|| mask
[i
])) {
1152 GLuint z
= GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
1153 scrX
+ i
, scrY
) & 0x00FFFFFF;
1154 z
|= (stencil
[i
] & 0xFF) << 24;
1155 PUT_WRAPPED_FB_DATA(&ReadParams
, GLuint
, scrX
+ i
, scrY
, z
);
1159 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1164 read_stencil_span(GLcontext
* ctx
, GLuint n
, GLint x
, GLint y
,
1165 GLstencil stencil
[])
1167 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1169 GrLfbInfo_t backBufferInfo
;
1171 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1173 * Note that the _LOCK macro adds a curly brace,
1174 * and the UNLOCK macro removes it.
1176 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1178 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1179 const GLint winX
= fxMesa
->x_offset
;
1181 LFBParameters ReadParams
;
1182 int wrappedPartStart
;
1185 * Convert to screen coordinates.
1189 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1191 if (ReadParams
.firstWrappedX
<= x
) {
1192 wrappedPartStart
= 0;
1194 else if (n
<= (ReadParams
.firstWrappedX
- x
)) {
1195 wrappedPartStart
= n
;
1198 wrappedPartStart
= (ReadParams
.firstWrappedX
- x
);
1200 for (i
= 0; i
< wrappedPartStart
; i
++) {
1201 stencil
[i
] = (GET_ORDINARY_FB_DATA(&ReadParams
, GLuint
,
1202 x
+ i
, y
) >> 24) & 0xFF;
1204 for (; i
< n
; i
++) {
1205 stencil
[i
] = (GET_WRAPPED_FB_DATA(&ReadParams
, GLuint
,
1206 x
+ i
, y
) >> 24) & 0xFF;
1209 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1214 write_stencil_pixels(GLcontext
* ctx
, GLuint n
,
1215 const GLint x
[], const GLint y
[],
1216 const GLstencil stencil
[], const GLubyte mask
[])
1218 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1220 GrLfbInfo_t backBufferInfo
;
1222 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1224 * Note that the _LOCK macro adds a curly brace,
1225 * and the UNLOCK macro removes it.
1227 WRITE_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
, GR_LFBWRITEMODE_ANY
);
1229 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1230 const GLint winX
= fxMesa
->x_offset
;
1231 LFBParameters ReadParams
;
1234 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1236 for (i
= 0; i
< n
; i
++) {
1237 const GLint scrX
= winX
+ x
[i
];
1238 const GLint scrY
= winY
- y
[i
];
1239 if ((!mask
|| mask
[i
]) && visible_pixel(fxMesa
, scrX
, scrY
)) {
1241 GET_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
) & 0x00FFFFFF;
1242 z
|= (stencil
[i
] & 0xFF) << 24;
1243 PUT_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
, z
);
1247 WRITE_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1252 read_stencil_pixels(GLcontext
* ctx
, GLuint n
, const GLint x
[],
1253 const GLint y
[], GLstencil stencil
[])
1255 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1257 GrLfbInfo_t backBufferInfo
;
1259 GetBackBufferInfo(fxMesa
, &backBufferInfo
);
1261 * Note that the _LOCK macro adds a curly brace,
1262 * and the UNLOCK macro removes it.
1264 READ_FB_SPAN_LOCK(fxMesa
, info
, GR_BUFFER_AUXBUFFER
);
1266 const GLint winY
= fxMesa
->y_offset
+ fxMesa
->height
- 1;
1267 const GLint winX
= fxMesa
->x_offset
;
1269 LFBParameters ReadParams
;
1271 GetFbParams(fxMesa
, &info
, &backBufferInfo
, &ReadParams
,
1273 for (i
= 0; i
< n
; i
++) {
1274 const GLint scrX
= winX
+ x
[i
];
1275 const GLint scrY
= winY
- y
[i
];
1277 (GET_FB_DATA(&ReadParams
, GLuint
, scrX
, scrY
) >> 24) & 0xFF;
1280 READ_FB_SPAN_UNLOCK(fxMesa
, GR_BUFFER_AUXBUFFER
);
1283 #define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
1284 ((vis.redBits == r) && \
1285 (vis.greenBits == g) && \
1286 (vis.blueBits == b) && \
1287 (vis.alphaBits == a))
1292 /**********************************************************************/
1293 /* Locking for swrast */
1294 /**********************************************************************/
1297 static void tdfxSpanRenderStart( GLcontext
*ctx
)
1299 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1300 LOCK_HARDWARE(fxMesa
);
1303 static void tdfxSpanRenderFinish( GLcontext
*ctx
)
1305 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1306 _swrast_flush( ctx
);
1307 UNLOCK_HARDWARE(fxMesa
);
1310 /* Set the buffer used for reading */
1311 static void tdfxDDSetBuffer( GLcontext
*ctx
,
1312 GLframebuffer
*buffer
, GLuint bufferBit
)
1314 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1317 switch ( bufferBit
) {
1318 case DD_FRONT_LEFT_BIT
:
1319 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_FRONTBUFFER
;
1321 case DD_BACK_LEFT_BIT
:
1322 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_BACKBUFFER
;
1329 /**********************************************************************/
1330 /* Initialize swrast device driver */
1331 /**********************************************************************/
1333 void tdfxDDInitSpanFuncs( GLcontext
*ctx
)
1335 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1336 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference( ctx
);
1338 swdd
->SetBuffer
= tdfxDDSetBuffer
;
1340 if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 5, 6, 5, 0) )
1343 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_RGB565
;
1344 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_RGB565
;
1345 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_RGB565
;
1346 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_RGB565
;
1347 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_RGB565
;
1348 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_RGB565
;
1349 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_RGB565
;
1351 else if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 8, 8, 8, 0) )
1354 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_RGB888
;
1355 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_RGB888
;
1356 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_RGB888
;
1357 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_RGB888
;
1358 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_RGB888
;
1359 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_RGB888
;
1360 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_RGB888
;
1362 else if ( VISUAL_EQUALS_RGBA(ctx
->Visual
, 8, 8, 8, 8) )
1365 swdd
->WriteRGBASpan
= tdfxWriteRGBASpan_ARGB8888
;
1366 swdd
->WriteRGBSpan
= tdfxWriteRGBSpan_ARGB8888
;
1367 swdd
->WriteMonoRGBASpan
= tdfxWriteMonoRGBASpan_ARGB8888
;
1368 swdd
->WriteRGBAPixels
= tdfxWriteRGBAPixels_ARGB8888
;
1369 swdd
->WriteMonoRGBAPixels
= tdfxWriteMonoRGBAPixels_ARGB8888
;
1370 swdd
->ReadRGBAPixels
= tdfxReadRGBAPixels_ARGB8888
;
1371 swdd
->ReadRGBASpan
= tdfxReadRGBASpan_ARGB8888
;
1378 if ( fxMesa
->haveHwStencil
) {
1379 swdd
->WriteStencilSpan
= write_stencil_span
;
1380 swdd
->ReadStencilSpan
= read_stencil_span
;
1381 swdd
->WriteStencilPixels
= write_stencil_pixels
;
1382 swdd
->ReadStencilPixels
= read_stencil_pixels
;
1385 swdd
->WriteDepthSpan
= tdfxDDWriteDepthSpan
;
1386 swdd
->WriteDepthPixels
= tdfxDDWriteDepthPixels
;
1387 swdd
->ReadDepthSpan
= tdfxDDReadDepthSpan
;
1388 swdd
->ReadDepthPixels
= tdfxDDReadDepthPixels
;
1390 swdd
->WriteCI8Span
= NULL
;
1391 swdd
->WriteCI32Span
= NULL
;
1392 swdd
->WriteMonoCISpan
= NULL
;
1393 swdd
->WriteCI32Pixels
= NULL
;
1394 swdd
->WriteMonoCIPixels
= NULL
;
1395 swdd
->ReadCI32Span
= NULL
;
1396 swdd
->ReadCI32Pixels
= NULL
;
1398 swdd
->SpanRenderStart
= tdfxSpanRenderStart
;
1399 swdd
->SpanRenderFinish
= tdfxSpanRenderFinish
;