gallium: fix refcount bug introduced in eb20e2984
[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 WRITE_DEPTH( _x, _y, d ) \
279 *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
280
281 #define READ_DEPTH( d, _x, _y ) \
282 d = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch)
283
284 #define TAG(x) tdfx##x##_Z16
285 #include "../dri/common/depthtmp.h"
286
287
288 /* 24 bit, depth spanline and pixel functions (for use w/ stencil) */
289 /* [dBorca] Hack alert:
290 * This is evil. The incoming Mesa's 24bit depth value
291 * is shifted left 8 bits, to obtain a full 32bit value,
292 * which will be thrown into the framebuffer. We rely on
293 * the fact that Voodoo hardware transforms a 32bit value
294 * into 24bit value automatically and, MOST IMPORTANT, won't
295 * alter the upper 8bits of the value already existing in the
296 * framebuffer (where stencil resides).
297 */
298
299 #undef LFB_MODE
300 #define LFB_MODE GR_LFBWRITEMODE_Z32
301
302 #undef BYTESPERPIXEL
303 #define BYTESPERPIXEL 4
304
305 #define WRITE_DEPTH( _x, _y, d ) \
306 *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
307
308 #define READ_DEPTH( d, _x, _y ) \
309 d = (*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch)) & 0xffffff
310
311 #define TAG(x) tdfx##x##_Z24
312 #include "../dri/common/depthtmp.h"
313
314
315 /* 32 bit, depth spanline and pixel functions (for use w/o stencil) */
316 /* [dBorca] Hack alert:
317 * This is more evil. We make Mesa run in 32bit depth, but
318 * tha Voodoo HW can only handle 24bit depth. Well, exploiting
319 * the pixel pipeline, we can achieve 24:8 format for greater
320 * precision...
321 * If anyone tells me how to really store 32bit values into the
322 * depth buffer, I'll write the *_Z32 routines. Howver, bear in
323 * mind that means running without stencil!
324 */
325
326 /************************************************************************/
327 /***** Span functions (optimized) *****/
328 /************************************************************************/
329
330 /*
331 * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
332 * since OpenGL says obscured pixels have undefined values.
333 */
334 static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
335 struct gl_renderbuffer *rb,
336 GLuint n,
337 GLint x, GLint y,
338 GLubyte rgba[][4])
339 {
340 fxMesaContext fxMesa = FX_CONTEXT(ctx);
341 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
342 GrLfbInfo_t info;
343 info.size = sizeof(GrLfbInfo_t);
344 if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
345 GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
346 const GLint winX = 0;
347 const GLint winY = fxMesa->height - 1;
348 const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
349 (winY - y) * info.strideInBytes +
350 (winX + x) * 2);
351 const GLuint *data32 = (const GLuint *) data16;
352 GLuint i, j;
353 GLuint extraPixel = (n & 1);
354 n -= extraPixel;
355
356 for (i = j = 0; i < n; i += 2, j++) {
357 GLuint pixel = data32[j];
358 rgba[i][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
359 rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
360 rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
361 rgba[i][3] = (pixel & 0x8000) ? 255 : 0;
362 rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F];
363 rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F];
364 rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
365 rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0;
366 }
367 if (extraPixel) {
368 GLushort pixel = data16[n];
369 rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
370 rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
371 rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
372 rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
373 }
374
375 grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
376 }
377 }
378
379 /*
380 * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
381 * since OpenGL says obscured pixels have undefined values.
382 */
383 static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
384 struct gl_renderbuffer *rb,
385 GLuint n,
386 GLint x, GLint y,
387 GLubyte rgba[][4])
388 {
389 fxMesaContext fxMesa = FX_CONTEXT(ctx);
390 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
391 GrLfbInfo_t info;
392 info.size = sizeof(GrLfbInfo_t);
393 if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
394 GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
395 const GLint winX = 0;
396 const GLint winY = fxMesa->height - 1;
397 const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
398 (winY - y) * info.strideInBytes +
399 (winX + x) * 2);
400 const GLuint *data32 = (const GLuint *) data16;
401 GLuint i, j;
402 GLuint extraPixel = (n & 1);
403 n -= extraPixel;
404
405 for (i = j = 0; i < n; i += 2, j++) {
406 GLuint pixel = data32[j];
407 rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
408 rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
409 rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
410 rgba[i][3] = 255;
411 rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F];
412 rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F];
413 rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
414 rgba[i+1][3] = 255;
415 }
416 if (extraPixel) {
417 GLushort pixel = data16[n];
418 rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
419 rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
420 rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
421 rgba[n][3] = 255;
422 }
423
424 grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
425 }
426 }
427
428 /*
429 * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
430 * since OpenGL says obscured pixels have undefined values.
431 */
432 static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
433 struct gl_renderbuffer *rb,
434 GLuint n,
435 GLint x, GLint y,
436 GLubyte rgba[][4])
437 {
438 fxMesaContext fxMesa = FX_CONTEXT(ctx);
439 GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
440 GLuint i;
441 grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
442 for (i = 0; i < n; i++) {
443 GLubyte c = rgba[i][0];
444 rgba[i][0] = rgba[i][2];
445 rgba[i][2] = c;
446 }
447 }
448
449
450 /************************************************************************/
451 /***** Depth functions (optimized) *****/
452 /************************************************************************/
453
454 static void
455 fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
456 GLuint n, GLint x, GLint y, GLuint depth[])
457 {
458 fxMesaContext fxMesa = FX_CONTEXT(ctx);
459 GLint bottom = fxMesa->height - 1;
460 GLushort depth16[MAX_WIDTH];
461 GLuint i;
462
463 if (TDFX_DEBUG & VERBOSE_DRIVER) {
464 fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
465 }
466
467 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
468 for (i = 0; i < n; i++) {
469 depth[i] = depth16[i];
470 }
471 }
472
473
474 static void
475 fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
476 GLuint n, GLint x, GLint y, GLuint depth[])
477 {
478 fxMesaContext fxMesa = FX_CONTEXT(ctx);
479 GLint bottom = fxMesa->height - 1;
480 GLuint i;
481
482 if (TDFX_DEBUG & VERBOSE_DRIVER) {
483 fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
484 }
485
486 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
487 for (i = 0; i < n; i++) {
488 depth[i] &= 0xffffff;
489 }
490 }
491
492
493 /************************************************************************/
494 /***** Stencil functions (optimized) *****/
495 /************************************************************************/
496
497 static void
498 fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
499 GLuint n, GLint x, GLint y,
500 const GLstencil stencil[], const GLubyte mask[])
501 {
502 /*
503 * XXX todo
504 */
505 }
506
507 static void
508 fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
509 GLuint n, GLint x, GLint y, GLstencil stencil[])
510 {
511 fxMesaContext fxMesa = FX_CONTEXT(ctx);
512 GLint bottom = fxMesa->height - 1;
513 GLuint zs32[MAX_WIDTH];
514 GLuint i;
515
516 if (TDFX_DEBUG & VERBOSE_DRIVER) {
517 fprintf(stderr, "fxReadStencilSpan(...)\n");
518 }
519
520 grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
521 for (i = 0; i < n; i++) {
522 stencil[i] = zs32[i] >> 24;
523 }
524 }
525
526 static void
527 fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
528 const GLint x[], const GLint y[],
529 const GLstencil stencil[],
530 const GLubyte mask[])
531 {
532 /*
533 * XXX todo
534 */
535 }
536
537 static void
538 fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
539 const GLint x[], const GLint y[],
540 GLstencil stencil[])
541 {
542 /*
543 * XXX todo
544 */
545 }
546
547
548 void
549 fxSetupDDSpanPointers(GLcontext * ctx)
550 {
551 struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
552 fxMesaContext fxMesa = FX_CONTEXT(ctx);
553
554 switch (fxMesa->colDepth) {
555 case 15:
556 swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;
557 swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555;
558 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555;
559 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555;
560 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555;
561 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555;
562 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555;
563
564 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
565 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
566 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
567 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
568 break;
569 case 16:
570 swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
571 swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
572 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
573 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
574 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
575 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565;
576 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
577
578 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
579 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
580 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
581 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
582 break;
583 case 32:
584 swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
585 swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
586 swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
587 swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
588 swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
589 swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB8888;
590 swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
591
592 swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z24;
593 swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z24;
594 swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z24;
595 swdd->ReadDepthPixels = tdfxReadDepthPixels_Z24;
596 break;
597 }
598
599 if (fxMesa->haveHwStencil) {
600 swdd->WriteStencilSpan = fxWriteStencilSpan;
601 swdd->ReadStencilSpan = fxReadStencilSpan;
602 swdd->WriteStencilPixels = fxWriteStencilPixels;
603 swdd->ReadStencilPixels = fxReadStencilPixels;
604 }
605 #if 0
606 swdd->WriteCI8Span = NULL;
607 swdd->WriteCI32Span = NULL;
608 swdd->WriteMonoCISpan = NULL;
609 swdd->WriteCI32Pixels = NULL;
610 swdd->WriteMonoCIPixels = NULL;
611 swdd->ReadCI32Span = NULL;
612 swdd->ReadCI32Pixels = NULL;
613
614 swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */
615 swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */
616 #endif
617 }
618
619
620 #else
621
622
623 /*
624 * Need this to provide at least one external definition.
625 */
626
627 extern int gl_fx_dummy_function_span(void);
628 int
629 gl_fx_dummy_function_span(void)
630 {
631 return 0;
632 }
633
634 #endif /* FX */