dri: Fix write/read depth buffer issue under 16bpp mode. See bug #16646
[mesa.git] / src / mesa / drivers / glide / fxddspan.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 4.0
4 *
5 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /* Authors:
26 * David Bucciarelli
27 * Brian Paul
28 * Daryll Strauss
29 * Keith Whitwell
30 * Daniel Borca
31 * Hiroshi Morii
32 */
33
34
35 /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
36
37
38 #ifdef HAVE_CONFIG_H
39 #include "conf.h"
40 #endif
41
42 #if defined(FX)
43
44 #include "fxdrv.h"
45 #include "fxglidew.h"
46 #include "swrast/swrast.h"
47
48
49 /************************************************************************/
50 /***** Span functions *****/
51 /************************************************************************/
52
53 #define DBG 0
54
55
56 #define LOCAL_VARS \
57 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; \
58 GLuint pitch = info.strideInBytes; \
59 GLuint height = fxMesa->height; \
60 char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
61 GLuint p; \
62 (void) buf; (void) p;
63
64 #define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \
65 _y >= miny && _y < maxy )
66
67 #define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
68 if ( _y < miny || _y >= maxy ) { \
69 _n1 = 0, _x1 = x; \
70 } else { \
71 _n1 = _n; \
72 _x1 = _x; \
73 if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx;\
74 if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
75 }
76
77 #define Y_FLIP(_y) (height - _y - 1)
78
79 #define HW_WRITE_LOCK() \
80 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
81 GrLfbInfo_t info; \
82 info.size = sizeof(GrLfbInfo_t); \
83 if ( grLfbLock( GR_LFB_WRITE_ONLY, \
84 currentFB, LFB_MODE, \
85 GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
86
87 #define HW_WRITE_UNLOCK() \
88 grLfbUnlock( GR_LFB_WRITE_ONLY, currentFB ); \
89 }
90
91 #define HW_READ_LOCK() \
92 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
93 GrLfbInfo_t info; \
94 info.size = sizeof(GrLfbInfo_t); \
95 if ( grLfbLock( GR_LFB_READ_ONLY, currentFB, \
96 LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
97
98 #define HW_READ_UNLOCK() \
99 grLfbUnlock( GR_LFB_READ_ONLY, currentFB ); \
100 }
101
102 #define HW_WRITE_CLIPLOOP() \
103 do { \
104 /* remember, we need to flip the scissor, too */ \
105 /* is it better to do it inside fxDDScissor? */ \
106 const int minx = fxMesa->clipMinX; \
107 const int maxy = Y_FLIP(fxMesa->clipMinY); \
108 const int maxx = fxMesa->clipMaxX; \
109 const int miny = Y_FLIP(fxMesa->clipMaxY);
110
111 #define HW_READ_CLIPLOOP() \
112 do { \
113 /* remember, we need to flip the scissor, too */ \
114 /* is it better to do it inside fxDDScissor? */ \
115 const int minx = fxMesa->clipMinX; \
116 const int maxy = Y_FLIP(fxMesa->clipMinY); \
117 const int maxx = fxMesa->clipMaxX; \
118 const int miny = Y_FLIP(fxMesa->clipMaxY);
119
120 #define HW_ENDCLIPLOOP() \
121 } while (0)
122
123
124 /* 16 bit, ARGB1555 color spanline and pixel functions */
125
126 #undef LFB_MODE
127 #define LFB_MODE GR_LFBWRITEMODE_1555
128
129 #undef BYTESPERPIXEL
130 #define BYTESPERPIXEL 2
131
132 #undef INIT_MONO_PIXEL
133 #define INIT_MONO_PIXEL(p, color) \
134 p = TDFXPACKCOLOR1555( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
135
136 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
137 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
138 TDFXPACKCOLOR1555( r, g, b, a )
139
140 #define WRITE_PIXEL( _x, _y, p ) \
141 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
142
143 #define READ_RGBA( rgba, _x, _y ) \
144 do { \
145 GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
146 rgba[0] = FX_rgb_scale_5[(p >> 10) & 0x1F]; \
147 rgba[1] = FX_rgb_scale_5[(p >> 5) & 0x1F]; \
148 rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
149 rgba[3] = (p & 0x8000) ? 255 : 0; \
150 } while (0)
151
152 #define TAG(x) tdfx##x##_ARGB1555
153 #include "../dri/common/spantmp.h"
154
155
156 /* 16 bit, RGB565 color spanline and pixel functions */
157 /* [dBorca] Hack alert:
158 * This is wrong. The alpha value is lost, even when we provide
159 * HW alpha (565 w/o depth buffering). To really update alpha buffer,
160 * we would need to do the 565 writings via 8888 colorformat and rely
161 * on the Voodoo to perform color scaling. In which case our 565 span
162 * would look nicer! But this violates FSAA rules...
163 */
164
165 #undef LFB_MODE
166 #define LFB_MODE GR_LFBWRITEMODE_565
167
168 #undef BYTESPERPIXEL
169 #define BYTESPERPIXEL 2
170
171 #undef INIT_MONO_PIXEL
172 #define INIT_MONO_PIXEL(p, color) \
173 p = TDFXPACKCOLOR565( color[RCOMP], color[GCOMP], color[BCOMP] )
174
175 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
176 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
177 TDFXPACKCOLOR565( r, g, b )
178
179 #define WRITE_PIXEL( _x, _y, p ) \
180 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
181
182 #define READ_RGBA( rgba, _x, _y ) \
183 do { \
184 GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
185 rgba[0] = FX_rgb_scale_5[(p >> 11) & 0x1F]; \
186 rgba[1] = FX_rgb_scale_6[(p >> 5) & 0x3F]; \
187 rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
188 rgba[3] = 0xff; \
189 } while (0)
190
191 #define TAG(x) tdfx##x##_RGB565
192 #include "../dri/common/spantmp.h"
193
194
195 /* 32 bit, ARGB8888 color spanline and pixel functions */
196
197 #undef LFB_MODE
198 #define LFB_MODE GR_LFBWRITEMODE_8888
199
200 #undef BYTESPERPIXEL
201 #define BYTESPERPIXEL 4
202
203 #undef INIT_MONO_PIXEL
204 #define INIT_MONO_PIXEL(p, color) \
205 p = TDFXPACKCOLOR8888( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
206
207 #define WRITE_RGBA( _x, _y, r, g, b, a ) \
208 *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
209 TDFXPACKCOLOR8888( r, g, b, a )
210
211 #define WRITE_PIXEL( _x, _y, p ) \
212 *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
213
214 #define READ_RGBA( rgba, _x, _y ) \
215 do { \
216 GLuint p = *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
217 rgba[0] = (p >> 16) & 0xff; \
218 rgba[1] = (p >> 8) & 0xff; \
219 rgba[2] = (p >> 0) & 0xff; \
220 rgba[3] = (p >> 24) & 0xff; \
221 } while (0)
222
223 #define TAG(x) tdfx##x##_ARGB8888
224 #include "../dri/common/spantmp.h"
225
226
227 /************************************************************************/
228 /***** Depth functions *****/
229 /************************************************************************/
230
231 #define DBG 0
232
233 #undef HW_WRITE_LOCK
234 #undef HW_WRITE_UNLOCK
235 #undef HW_READ_LOCK
236 #undef HW_READ_UNLOCK
237
238 #define HW_CLIPLOOP HW_WRITE_CLIPLOOP
239
240 #define LOCAL_DEPTH_VARS \
241 GLuint pitch = info.strideInBytes; \
242 GLuint height = fxMesa->height; \
243 char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
244 (void) buf;
245
246 #define HW_WRITE_LOCK() \
247 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
248 GrLfbInfo_t info; \
249 info.size = sizeof(GrLfbInfo_t); \
250 if ( grLfbLock( GR_LFB_WRITE_ONLY, \
251 GR_BUFFER_AUXBUFFER, LFB_MODE, \
252 GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
253
254 #define HW_WRITE_UNLOCK() \
255 grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER); \
256 }
257
258 #define HW_READ_LOCK() \
259 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
260 GrLfbInfo_t info; \
261 info.size = sizeof(GrLfbInfo_t); \
262 if ( grLfbLock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER, \
263 LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
264
265 #define HW_READ_UNLOCK() \
266 grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER); \
267 }
268
269
270 /* 16 bit, depth spanline and pixel functions */
271
272 #undef LFB_MODE
273 #define LFB_MODE GR_LFBWRITEMODE_ZA16
274
275 #undef BYTESPERPIXEL
276 #define BYTESPERPIXEL 2
277
278 #define VALUE_TYPE GLushort
279
280 #define WRITE_DEPTH( _x, _y, d ) \
281 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
282
283 #define READ_DEPTH( d, _x, _y ) \
284 d = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch)
285
286 #define TAG(x) tdfx##x##_Z16
287 #include "../dri/common/depthtmp.h"
288
289
290 /* 24 bit, depth spanline and pixel functions (for use w/ stencil) */
291 /* [dBorca] Hack alert:
292 * This is evil. The incoming Mesa's 24bit depth value
293 * is shifted left 8 bits, to obtain a full 32bit value,
294 * which will be thrown into the framebuffer. We rely on
295 * the fact that Voodoo hardware transforms a 32bit value
296 * into 24bit value automatically and, MOST IMPORTANT, won't
297 * alter the upper 8bits of the value already existing in the
298 * framebuffer (where stencil resides).
299 */
300
301 #undef LFB_MODE
302 #define LFB_MODE GR_LFBWRITEMODE_Z32
303
304 #undef BYTESPERPIXEL
305 #define BYTESPERPIXEL 4
306
307 #define VALUE_TYPE GLuint
308
309 #define WRITE_DEPTH( _x, _y, d ) \
310 *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
311
312 #define READ_DEPTH( d, _x, _y ) \
313 d = (*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch)) & 0xffffff
314
315 #define TAG(x) tdfx##x##_Z24
316 #include "../dri/common/depthtmp.h"
317
318
319 /* 32 bit, depth spanline and pixel functions (for use w/o stencil) */
320 /* [dBorca] Hack alert:
321 * This is more evil. We make Mesa run in 32bit depth, but
322 * tha Voodoo HW can only handle 24bit depth. Well, exploiting
323 * the pixel pipeline, we can achieve 24:8 format for greater
324 * precision...
325 * If anyone tells me how to really store 32bit values into the
326 * depth buffer, I'll write the *_Z32 routines. Howver, bear in
327 * mind that means running without stencil!
328 */
329
330 /************************************************************************/
331 /***** Span functions (optimized) *****/
332 /************************************************************************/
333
334 /*
335 * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
336 * since OpenGL says obscured pixels have undefined values.
337 */
338 static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
339 struct gl_renderbuffer *rb,
340 GLuint n,
341 GLint x, GLint y,
342 GLubyte rgba[][4])
343 {
344 fxMesaContext fxMesa = FX_CONTEXT(ctx);
345 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
346 GrLfbInfo_t info;
347 info.size = sizeof(GrLfbInfo_t);
348 if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
349 GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
350 const GLint winX = 0;
351 const GLint winY = fxMesa->height - 1;
352 const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
353 (winY - y) * info.strideInBytes +
354 (winX + x) * 2);
355 const GLuint *data32 = (const GLuint *) data16;
356 GLuint i, j;
357 GLuint extraPixel = (n & 1);
358 n -= extraPixel;
359
360 for (i = j = 0; i < n; i += 2, j++) {
361 GLuint pixel = data32[j];
362 rgba[i][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
363 rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
364 rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
365 rgba[i][3] = (pixel & 0x8000) ? 255 : 0;
366 rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F];
367 rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F];
368 rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
369 rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0;
370 }
371 if (extraPixel) {
372 GLushort pixel = data16[n];
373 rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
374 rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
375 rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
376 rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
377 }
378
379 grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
380 }
381 }
382
383 /*
384 * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
385 * since OpenGL says obscured pixels have undefined values.
386 */
387 static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
388 struct gl_renderbuffer *rb,
389 GLuint n,
390 GLint x, GLint y,
391 GLubyte rgba[][4])
392 {
393 fxMesaContext fxMesa = FX_CONTEXT(ctx);
394 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
395 GrLfbInfo_t info;
396 info.size = sizeof(GrLfbInfo_t);
397 if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
398 GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
399 const GLint winX = 0;
400 const GLint winY = fxMesa->height - 1;
401 const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
402 (winY - y) * info.strideInBytes +
403 (winX + x) * 2);
404 const GLuint *data32 = (const GLuint *) data16;
405 GLuint i, j;
406 GLuint extraPixel = (n & 1);
407 n -= extraPixel;
408
409 for (i = j = 0; i < n; i += 2, j++) {
410 GLuint pixel = data32[j];
411 rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
412 rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
413 rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
414 rgba[i][3] = 255;
415 rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F];
416 rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F];
417 rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
418 rgba[i+1][3] = 255;
419 }
420 if (extraPixel) {
421 GLushort pixel = data16[n];
422 rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
423 rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
424 rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
425 rgba[n][3] = 255;
426 }
427
428 grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
429 }
430 }
431
432 /*
433 * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
434 * since OpenGL says obscured pixels have undefined values.
435 */
436 static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
437 struct gl_renderbuffer *rb,
438 GLuint n,
439 GLint x, GLint y,
440 GLubyte rgba[][4])
441 {
442 fxMesaContext fxMesa = FX_CONTEXT(ctx);
443 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
444 GLuint i;
445 grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
446 for (i = 0; i < n; i++) {
447 GLubyte c = rgba[i][0];
448 rgba[i][0] = rgba[i][2];
449 rgba[i][2] = c;
450 }
451 }
452
453
454 /************************************************************************/
455 /***** Depth functions (optimized) *****/
456 /************************************************************************/
457
458 static void
459 fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
460 GLuint n, GLint x, GLint y, GLuint depth[])
461 {
462 fxMesaContext fxMesa = FX_CONTEXT(ctx);
463 GLint bottom = fxMesa->height - 1;
464 GLushort depth16[MAX_WIDTH];
465 GLuint i;
466
467 if (TDFX_DEBUG & VERBOSE_DRIVER) {
468 fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
469 }
470
471 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
472 for (i = 0; i < n; i++) {
473 depth[i] = depth16[i];
474 }
475 }
476
477
478 static void
479 fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
480 GLuint n, GLint x, GLint y, GLuint depth[])
481 {
482 fxMesaContext fxMesa = FX_CONTEXT(ctx);
483 GLint bottom = fxMesa->height - 1;
484 GLuint i;
485
486 if (TDFX_DEBUG & VERBOSE_DRIVER) {
487 fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
488 }
489
490 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
491 for (i = 0; i < n; i++) {
492 depth[i] &= 0xffffff;
493 }
494 }
495
496
497 /************************************************************************/
498 /***** Stencil functions (optimized) *****/
499 /************************************************************************/
500
501 static void
502 fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
503 GLuint n, GLint x, GLint y,
504 const GLstencil stencil[], const GLubyte mask[])
505 {
506 /*
507 * XXX todo
508 */
509 }
510
511 static void
512 fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
513 GLuint n, GLint x, GLint y, GLstencil stencil[])
514 {
515 fxMesaContext fxMesa = FX_CONTEXT(ctx);
516 GLint bottom = fxMesa->height - 1;
517 GLuint zs32[MAX_WIDTH];
518 GLuint i;
519
520 if (TDFX_DEBUG & VERBOSE_DRIVER) {
521 fprintf(stderr, "fxReadStencilSpan(...)\n");
522 }
523
524 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
525 for (i = 0; i < n; i++) {
526 stencil[i] = zs32[i] >> 24;
527 }
528 }
529
530 static void
531 fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
532 const GLint x[], const GLint y[],
533 const GLstencil stencil[],
534 const GLubyte mask[])
535 {
536 /*
537 * XXX todo
538 */
539 }
540
541 static void
542 fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
543 const GLint x[], const GLint y[],
544 GLstencil stencil[])
545 {
546 /*
547 * XXX todo
548 */
549 }
550
551
552 void
553 fxSetupDDSpanPointers(GLcontext * ctx)
554 {
555 struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
556 fxMesaContext fxMesa = FX_CONTEXT(ctx);
557
558 switch (fxMesa->colDepth) {
559 case 15:
560 swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;
561 swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555;
562 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555;
563 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555;
564 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555;
565 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555;
566 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555;
567
568 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
569 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
570 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
571 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
572 break;
573 case 16:
574 swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
575 swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
576 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
577 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
578 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
579 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565;
580 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
581
582 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
583 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
584 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
585 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
586 break;
587 case 32:
588 swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
589 swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
590 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
591 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
592 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
593 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB8888;
594 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
595
596 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z24;
597 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z24;
598 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z24;
599 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z24;
600 break;
601 }
602
603 if (fxMesa->haveHwStencil) {
604 swdd->WriteStencilSpan = fxWriteStencilSpan;
605 swdd->ReadStencilSpan = fxReadStencilSpan;
606 swdd->WriteStencilPixels = fxWriteStencilPixels;
607 swdd->ReadStencilPixels = fxReadStencilPixels;
608 }
609 #if 0
610 swdd->WriteCI8Span = NULL;
611 swdd->WriteCI32Span = NULL;
612 swdd->WriteMonoCISpan = NULL;
613 swdd->WriteCI32Pixels = NULL;
614 swdd->WriteMonoCIPixels = NULL;
615 swdd->ReadCI32Span = NULL;
616 swdd->ReadCI32Pixels = NULL;
617
618 swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */
619 swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */
620 #endif
621 }
622
623
624 #else
625
626
627 /*
628 * Need this to provide at least one external definition.
629 */
630
631 extern int gl_fx_dummy_function_span(void);
632 int
633 gl_fx_dummy_function_span(void)
634 {
635 return 0;
636 }
637
638 #endif /* FX */