Remove get_buffer_size()
[mesa.git] / src / mesa / drivers / x11 / xm_dd.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.2
4 *
5 * Copyright (C) 1999-2006 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
26 /**
27 * \file xm_dd.h
28 * General device driver functions for Xlib driver.
29 */
30
31 #include "glxheader.h"
32 #include "bufferobj.h"
33 #include "buffers.h"
34 #include "context.h"
35 #include "colormac.h"
36 #include "depth.h"
37 #include "drawpix.h"
38 #include "extensions.h"
39 #include "framebuffer.h"
40 #include "macros.h"
41 #include "image.h"
42 #include "imports.h"
43 #include "mtypes.h"
44 #include "state.h"
45 #include "texobj.h"
46 #include "teximage.h"
47 #include "texstore.h"
48 #include "texformat.h"
49 #include "xmesaP.h"
50 #include "array_cache/acache.h"
51 #include "swrast/swrast.h"
52 #include "swrast/s_context.h"
53 #include "swrast_setup/swrast_setup.h"
54 #include "tnl/tnl.h"
55 #include "tnl/t_context.h"
56
57 #ifdef XFree86Server
58 #include <GL/glxtokens.h>
59 #endif
60
61
62
63 /*
64 * Dithering kernels and lookup tables.
65 */
66
67 const int xmesa_kernel8[DITH_DY * DITH_DX] = {
68 0 * MAXC, 8 * MAXC, 2 * MAXC, 10 * MAXC,
69 12 * MAXC, 4 * MAXC, 14 * MAXC, 6 * MAXC,
70 3 * MAXC, 11 * MAXC, 1 * MAXC, 9 * MAXC,
71 15 * MAXC, 7 * MAXC, 13 * MAXC, 5 * MAXC,
72 };
73
74 const short xmesa_HPCR_DRGB[3][2][16] = {
75 {
76 { 16, -4, 1,-11, 14, -6, 3, -9, 15, -5, 2,-10, 13, -7, 4, -8},
77 {-15, 5, 0, 12,-13, 7, -2, 10,-14, 6, -1, 11,-12, 8, -3, 9}
78 },
79 {
80 {-11, 15, -7, 3, -8, 14, -4, 2,-10, 16, -6, 4, -9, 13, -5, 1},
81 { 12,-14, 8, -2, 9,-13, 5, -1, 11,-15, 7, -3, 10,-12, 6, 0}
82 },
83 {
84 { 6,-18, 26,-14, 2,-22, 30,-10, 8,-16, 28,-12, 4,-20, 32, -8},
85 { -4, 20,-24, 16, 0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10}
86 }
87 };
88
89 const int xmesa_kernel1[16] = {
90 0*47, 9*47, 4*47, 12*47, /* 47 = (255*3)/16 */
91 6*47, 2*47, 14*47, 8*47,
92 10*47, 1*47, 5*47, 11*47,
93 7*47, 13*47, 3*47, 15*47
94 };
95
96
97 static void
98 finish_or_flush( GLcontext *ctx )
99 {
100 #ifdef XFree86Server
101 /* NOT_NEEDED */
102 #else
103 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
104 if (xmesa) {
105 _glthread_LOCK_MUTEX(_xmesa_lock);
106 XSync( xmesa->display, False );
107 _glthread_UNLOCK_MUTEX(_xmesa_lock);
108 }
109 #endif
110 }
111
112
113 static void
114 clear_index( GLcontext *ctx, GLuint index )
115 {
116 if (ctx->DrawBuffer->Name == 0) {
117 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
118 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
119 xmesa->clearpixel = (unsigned long) index;
120 XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index );
121 }
122 }
123
124
125 static void
126 clear_color( GLcontext *ctx, const GLfloat color[4] )
127 {
128 if (ctx->DrawBuffer->Name == 0) {
129 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
130 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
131
132 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
133 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
134 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
135 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
136 xmesa->clearpixel = xmesa_color_to_pixel( ctx,
137 xmesa->clearcolor[0],
138 xmesa->clearcolor[1],
139 xmesa->clearcolor[2],
140 xmesa->clearcolor[3],
141 xmesa->xm_visual->undithered_pf );
142 _glthread_LOCK_MUTEX(_xmesa_lock);
143 XMesaSetForeground( xmesa->display, xmbuf->cleargc,
144 xmesa->clearpixel );
145 _glthread_UNLOCK_MUTEX(_xmesa_lock);
146 }
147 }
148
149
150
151 /* Set index mask ala glIndexMask */
152 static void
153 index_mask( GLcontext *ctx, GLuint mask )
154 {
155 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
156 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
157 /* not sure this conditional is really needed */
158 if (xmbuf->backxrb && xmbuf->backxrb->pixmap) {
159 unsigned long m;
160 if (mask==0xffffffff) {
161 m = ((unsigned long)~0L);
162 }
163 else {
164 m = (unsigned long) mask;
165 }
166 XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
167 XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
168 }
169 }
170
171
172 /* Implements glColorMask() */
173 static void
174 color_mask(GLcontext *ctx,
175 GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
176 {
177 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
178 XMesaBuffer xmbuf;
179 const int xclass = xmesa->xm_visual->mesa_visual.visualType;
180 (void) amask;
181
182 if (ctx->DrawBuffer->Name != 0)
183 return;
184
185 xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
186
187 if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
188 unsigned long m;
189 if (rmask && gmask && bmask) {
190 m = ((unsigned long)~0L);
191 }
192 else {
193 m = 0;
194 if (rmask) m |= GET_REDMASK(xmesa->xm_visual);
195 if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
196 if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
197 }
198 XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
199 XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
200 }
201 }
202
203
204
205 /**********************************************************************/
206 /*** glClear implementations ***/
207 /**********************************************************************/
208
209
210 /**
211 * Clear the front or back color buffer, if it's implemented with a pixmap.
212 */
213 static void
214 clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLboolean all,
215 GLint x, GLint y, GLint width, GLint height)
216 {
217 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
218 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
219
220 assert(xmbuf);
221 assert(xrb->pixmap);
222 assert(xmesa);
223 assert(xmesa->display);
224 assert(xrb->pixmap);
225 assert(xmbuf->cleargc);
226
227 if (all) {
228 XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
229 0, 0, xrb->Base.Width + 1, xrb->Base.Height + 1 );
230 }
231 else {
232 XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
233 x, xrb->Base.Height - y - height,
234 width, height );
235 }
236 }
237
238
239 static void
240 clear_8bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
241 GLboolean all, GLint x, GLint y, GLint width, GLint height )
242 {
243 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
244
245 if (all) {
246 const size_t n = xrb->ximage->bytes_per_line * xrb->Base.Height;
247 MEMSET( xrb->ximage->data, xmesa->clearpixel, n );
248 }
249 else {
250 GLint i;
251 for (i=0;i<height;i++) {
252 GLubyte *ptr = PIXEL_ADDR1(xrb, x, y + i);
253 MEMSET( ptr, xmesa->clearpixel, width );
254 }
255 }
256 }
257
258
259 static void
260 clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
261 GLboolean all, GLint x, GLint y, GLint width, GLint height )
262 {
263 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
264
265 if (all) {
266 const GLuint c16 = xrb->ximage->bytes_per_line & ~0xf;
267 GLuint i;
268 GLubyte *ptr = (GLubyte *) xrb->ximage->data;
269 for (i = 0; i < xrb->Base.Height; i++) {
270 GLuint j;
271 const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
272 if (i&1) {
273 sptr += 16;
274 }
275 for (j=0; j<c16; j+=16) {
276 ptr[0] = sptr[0];
277 ptr[1] = sptr[1];
278 ptr[2] = sptr[2];
279 ptr[3] = sptr[3];
280 ptr[4] = sptr[4];
281 ptr[5] = sptr[5];
282 ptr[6] = sptr[6];
283 ptr[7] = sptr[7];
284 ptr[8] = sptr[8];
285 ptr[9] = sptr[9];
286 ptr[10] = sptr[10];
287 ptr[11] = sptr[11];
288 ptr[12] = sptr[12];
289 ptr[13] = sptr[13];
290 ptr[14] = sptr[14];
291 ptr[15] = sptr[15];
292 ptr += 16;
293 }
294 for (; j < (GLuint) xrb->ximage->bytes_per_line; j++) {
295 *ptr = sptr[j&15];
296 ptr++;
297 }
298 }
299 }
300 else {
301 GLint i;
302 for (i=y; i<y+height; i++) {
303 GLubyte *ptr = PIXEL_ADDR1( xrb, x, i );
304 int j;
305 const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
306 if (i&1) {
307 sptr += 16;
308 }
309 for (j=x; j<x+width; j++) {
310 *ptr = sptr[j&15];
311 ptr++;
312 }
313 }
314 }
315 }
316
317
318 static void
319 clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
320 GLboolean all, GLint x, GLint y, GLint width, GLint height)
321 {
322 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
323 register GLuint pixel = (GLuint) xmesa->clearpixel;
324
325 if (xmesa->swapbytes) {
326 pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
327 }
328
329 if (all) {
330 GLuint *ptr4 = (GLuint *) xrb->ximage->data;
331 if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
332 /* low and high bytes are equal so use memset() */
333 const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height;
334 MEMSET( ptr4, pixel & 0xff, n );
335 }
336 else {
337 const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height / 4;
338 GLuint i;
339 pixel = pixel | (pixel<<16);
340 for (i = 0; i < n; i++) {
341 ptr4[i] = pixel;
342 }
343 ptr4 += n;
344 /* might be one last GLushort to set */
345 if ((xrb->ximage->bytes_per_line * xrb->Base.Height) & 0x2)
346 *(GLushort *)ptr4 = pixel & 0xffff;
347 }
348 }
349 else {
350 GLint i, j;
351 for (j=0;j<height;j++) {
352 GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y + j);
353 for (i=0;i<width;i++) {
354 *ptr2++ = pixel;
355 }
356 }
357 }
358 }
359
360
361 /* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
362 static void
363 clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
364 GLboolean all, GLint x, GLint y, GLint width, GLint height)
365 {
366 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
367 const GLubyte r = xmesa->clearcolor[0];
368 const GLubyte g = xmesa->clearcolor[1];
369 const GLubyte b = xmesa->clearcolor[2];
370
371 if (all) {
372 if (r == g && g == b) {
373 /* same value for all three components (gray) */
374 const GLint w3 = xrb->Base.Width * 3;
375 const GLint h = xrb->Base.Height;
376 GLint i;
377 for (i = 0; i < h; i++) {
378 bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
379 MEMSET(ptr3, r, w3);
380 }
381 }
382 else {
383 /* the usual case */
384 const GLint w = xrb->Base.Width;
385 const GLint h = xrb->Base.Height;
386 GLint i, j;
387 for (i = 0; i < h; i++) {
388 bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
389 for (j = 0; j < w; j++) {
390 ptr3->r = r;
391 ptr3->g = g;
392 ptr3->b = b;
393 ptr3++;
394 }
395 }
396 }
397 }
398 else {
399 /* only clear subrect of color buffer */
400 if (r == g && g == b) {
401 /* same value for all three components (gray) */
402 GLint j;
403 for (j=0;j<height;j++) {
404 bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
405 MEMSET(ptr3, r, 3 * width);
406 }
407 }
408 else {
409 /* non-gray clear color */
410 GLint i, j;
411 for (j = 0; j < height; j++) {
412 bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
413 for (i = 0; i < width; i++) {
414 ptr3->r = r;
415 ptr3->g = g;
416 ptr3->b = b;
417 ptr3++;
418 }
419 }
420 }
421 }
422 }
423
424
425 static void
426 clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
427 GLboolean all, GLint x, GLint y, GLint width, GLint height)
428 {
429 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
430 register GLuint pixel = (GLuint) xmesa->clearpixel;
431
432 if (!xrb->ximage)
433 return;
434
435 if (xmesa->swapbytes) {
436 pixel = ((pixel >> 24) & 0x000000ff)
437 | ((pixel >> 8) & 0x0000ff00)
438 | ((pixel << 8) & 0x00ff0000)
439 | ((pixel << 24) & 0xff000000);
440 }
441
442 if (all) {
443 const GLuint n = xrb->Base.Width * xrb->Base.Height;
444 GLuint *ptr4 = (GLuint *) xrb->ximage->data;
445 if (pixel == 0) {
446 _mesa_memset(ptr4, pixel, 4 * n);
447 }
448 else {
449 GLuint i;
450 for (i = 0; i < n; i++)
451 ptr4[i] = pixel;
452 }
453 }
454 else {
455 GLint i, j;
456 for (j = 0; j < height; j++) {
457 GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y + j);
458 for (i = 0; i < width; i++) {
459 ptr4[i] = pixel;
460 }
461 }
462 }
463 }
464
465
466 static void
467 clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
468 GLboolean all, GLint x, GLint y, GLint width, GLint height)
469 {
470 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
471 XMesaImage *img = xrb->ximage;
472 GLint i, j;
473
474 /* We can ignore 'all' here - x, y, width, height are always right */
475 (void) all;
476
477 /* TODO: optimize this */
478 y = YFLIP(xrb, y);
479 for (j = 0; j < height; j++) {
480 for (i = 0; i < width; i++) {
481 XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
482 }
483 }
484 }
485
486
487
488 static void
489 clear_buffers( GLcontext *ctx, GLbitfield mask,
490 GLboolean all, GLint x, GLint y, GLint width, GLint height )
491 {
492 if (ctx->DrawBuffer->Name == 0) {
493 /* this is a window system framebuffer */
494 const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
495 XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
496
497 /* we can't handle color or index masking */
498 if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
499 if (mask & BUFFER_BIT_FRONT_LEFT) {
500 /* clear front color buffer */
501 struct gl_renderbuffer *frontRb
502 = ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
503 if (b->frontxrb == xmesa_renderbuffer(frontRb)) {
504 /* renderbuffer is not wrapped - great! */
505 b->frontxrb->clearFunc(ctx, b->frontxrb, all, x, y,
506 width, height);
507 mask &= ~BUFFER_BIT_FRONT_LEFT;
508 }
509 else {
510 /* we can't directly clear an alpha-wrapped color buffer */
511 }
512 }
513 if (mask & BUFFER_BIT_BACK_LEFT) {
514 /* clear back color buffer */
515 struct gl_renderbuffer *backRb
516 = ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
517 if (b->backxrb == xmesa_renderbuffer(backRb)) {
518 /* renderbuffer is not wrapped - great! */
519 b->backxrb->clearFunc(ctx, b->backxrb, all, x, y,
520 width, height);
521 mask &= ~BUFFER_BIT_BACK_LEFT;
522 }
523 }
524 }
525 }
526 if (mask)
527 _swrast_Clear( ctx, mask, all, x, y, width, height );
528 }
529
530
531 #ifndef XFree86Server
532 /* XXX this was never tested in the Xserver environment */
533
534 /**
535 * This function implements glDrawPixels() with an XPutImage call when
536 * drawing to the front buffer (X Window drawable).
537 * The image format must be GL_BGRA to match the PF_8R8G8B pixel format.
538 */
539 static void
540 xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
541 GLint x, GLint y, GLsizei width, GLsizei height,
542 GLenum format, GLenum type,
543 const struct gl_pixelstore_attrib *unpack,
544 const GLvoid *pixels )
545 {
546 const SWcontext *swrast = SWRAST_CONTEXT( ctx );
547 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
548 struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb->Wrapped;
549
550 if (swrast->NewState)
551 _swrast_validate_derived( ctx );
552
553 if (ctx->DrawBuffer->Name == 0 &&
554 format == GL_BGRA &&
555 type == GL_UNSIGNED_BYTE &&
556 (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
557 ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
558 ctx->Pixel.ZoomX == 1.0 && /* no zooming */
559 ctx->Pixel.ZoomY == 1.0 &&
560 xrb->pixmap &&
561 xrb->Base.AlphaBits == 0)
562 {
563 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
564 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
565 XMesaDisplay *dpy = xmesa->xm_visual->display;
566 const XMesaGC gc = xmbuf->gc;
567 int dstX = x;
568 int dstY = y;
569 int w = width;
570 int h = height;
571 struct gl_pixelstore_attrib clippedUnpack = *unpack;
572
573 ASSERT(xmesa->xm_visual->dithered_pf == PF_8R8G8B);
574 ASSERT(xmesa->xm_visual->undithered_pf == PF_8R8G8B);
575 ASSERT(dpy);
576 ASSERT(gc);
577
578 if (unpack->BufferObj->Name) {
579 /* unpack from PBO */
580 GLubyte *buf;
581 if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
582 format, type, pixels)) {
583 _mesa_error(ctx, GL_INVALID_OPERATION,
584 "glDrawPixels(invalid PBO access)");
585 return;
586 }
587 buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
588 GL_PIXEL_UNPACK_BUFFER_EXT,
589 GL_READ_ONLY_ARB,
590 unpack->BufferObj);
591 if (!buf) {
592 /* buffer is already mapped - that's an error */
593 _mesa_error(ctx, GL_INVALID_OPERATION,
594 "glDrawPixels(PBO is mapped)");
595 return;
596 }
597 pixels = ADD_POINTERS(buf, pixels);
598 }
599
600 if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
601 /* This is a little tricky since all coordinates up to now have
602 * been in the OpenGL bottom-to-top orientation. X is top-to-bottom
603 * so we have to carefully compute the Y coordinates/addresses here.
604 */
605 int srcX = clippedUnpack.SkipPixels;
606 int srcY = clippedUnpack.SkipRows;
607 int rowLength = clippedUnpack.RowLength;
608 XMesaImage ximage;
609 MEMSET(&ximage, 0, sizeof(XMesaImage));
610 ximage.width = width;
611 ximage.height = height;
612 ximage.format = ZPixmap;
613 ximage.data = (char *) pixels
614 + ((srcY + h - 1) * rowLength + srcX) * 4;
615 ximage.byte_order = LSBFirst;
616 ximage.bitmap_unit = 32;
617 ximage.bitmap_bit_order = LSBFirst;
618 ximage.bitmap_pad = 32;
619 ximage.depth = 24;
620 ximage.bytes_per_line = -rowLength * 4; /* negative to flip image */
621 ximage.bits_per_pixel = 32;
622 /* it seems we don't need to set the ximage.red/green/blue_mask fields */
623 /* flip Y axis for dest position */
624 dstY = YFLIP(xrb, dstY) - h + 1;
625 XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
626 }
627
628 if (unpack->BufferObj->Name) {
629 ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
630 unpack->BufferObj);
631 }
632 }
633 else {
634 /* software fallback */
635 _swrast_DrawPixels(ctx, x, y, width, height,
636 format, type, unpack, pixels);
637 }
638 }
639
640
641
642 /**
643 * This function implements glDrawPixels() with an XPutImage call when
644 * drawing to the front buffer (X Window drawable). The image format
645 * must be GL_RGB and image type must be GL_UNSIGNED_SHORT_5_6_5 to
646 * match the PF_5R6G5B pixel format.
647 */
648 static void
649 xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
650 GLint x, GLint y, GLsizei width, GLsizei height,
651 GLenum format, GLenum type,
652 const struct gl_pixelstore_attrib *unpack,
653 const GLvoid *pixels )
654 {
655 struct xmesa_renderbuffer *xrb
656 = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
657 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
658 const SWcontext *swrast = SWRAST_CONTEXT( ctx );
659 XMesaDisplay *dpy = xmesa->xm_visual->display;
660 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
661 const XMesaGC gc = xmbuf->gc;
662
663 ASSERT(dpy);
664 ASSERT(gc);
665 ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
666
667 if (swrast->NewState)
668 _swrast_validate_derived( ctx );
669
670 if (xrb->pixmap &&
671 format == GL_RGB &&
672 type == GL_UNSIGNED_SHORT_5_6_5 &&
673 !ctx->Color.DitherFlag && /* no dithering */
674 (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
675 ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
676 ctx->Pixel.ZoomX == 1.0 && /* no zooming */
677 ctx->Pixel.ZoomY == 1.0) {
678 int dstX = x;
679 int dstY = y;
680 int w = width;
681 int h = height;
682 struct gl_pixelstore_attrib clippedUnpack = *unpack;
683
684 if (unpack->BufferObj->Name) {
685 /* unpack from PBO */
686 GLubyte *buf;
687 if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
688 format, type, pixels)) {
689 _mesa_error(ctx, GL_INVALID_OPERATION,
690 "glDrawPixels(invalid PBO access)");
691 return;
692 }
693 buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
694 GL_PIXEL_UNPACK_BUFFER_EXT,
695 GL_READ_ONLY_ARB,
696 unpack->BufferObj);
697 if (!buf) {
698 /* buffer is already mapped - that's an error */
699 _mesa_error(ctx, GL_INVALID_OPERATION,
700 "glDrawPixels(PBO is mapped)");
701 return;
702 }
703 pixels = ADD_POINTERS(buf, pixels);
704 }
705
706 if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
707 /* This is a little tricky since all coordinates up to now have
708 * been in the OpenGL bottom-to-top orientation. X is top-to-bottom
709 * so we have to carefully compute the Y coordinates/addresses here.
710 */
711 int srcX = clippedUnpack.SkipPixels;
712 int srcY = clippedUnpack.SkipRows;
713 int rowLength = clippedUnpack.RowLength;
714 XMesaImage ximage;
715 MEMSET(&ximage, 0, sizeof(XMesaImage));
716 ximage.width = width;
717 ximage.height = height;
718 ximage.format = ZPixmap;
719 ximage.data = (char *) pixels
720 + ((srcY + h - 1) * rowLength + srcX) * 2;
721 ximage.byte_order = LSBFirst;
722 ximage.bitmap_unit = 16;
723 ximage.bitmap_bit_order = LSBFirst;
724 ximage.bitmap_pad = 16;
725 ximage.depth = 16;
726 ximage.bytes_per_line = -rowLength * 2; /* negative to flip image */
727 ximage.bits_per_pixel = 16;
728 /* it seems we don't need to set the ximage.red/green/blue_mask fields */
729 /* flip Y axis for dest position */
730 dstY = YFLIP(xrb, dstY) - h + 1;
731 XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
732 }
733
734 if (unpack->BufferObj->Name) {
735 ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
736 unpack->BufferObj);
737 }
738 }
739 else {
740 /* software fallback */
741 _swrast_DrawPixels(ctx, x, y, width, height,
742 format, type, unpack, pixels);
743 }
744 }
745
746
747
748 /**
749 * Implement glCopyPixels for the front color buffer (or back buffer Pixmap)
750 * for the color buffer. Don't support zooming, pixel transfer, etc.
751 * We do support copying from one window to another, ala glXMakeCurrentRead.
752 */
753 static void
754 xmesa_CopyPixels( GLcontext *ctx,
755 GLint srcx, GLint srcy, GLsizei width, GLsizei height,
756 GLint destx, GLint desty, GLenum type )
757 {
758 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
759 const SWcontext *swrast = SWRAST_CONTEXT( ctx );
760 XMesaDisplay *dpy = xmesa->xm_visual->display;
761 const XMesaGC gc = ((XMesaBuffer) ctx->DrawBuffer)->gc;
762 struct xmesa_renderbuffer *srcXrb = (struct xmesa_renderbuffer *)
763 ctx->ReadBuffer->_ColorReadBuffer;
764 struct xmesa_renderbuffer *dstXrb = (struct xmesa_renderbuffer *)
765 ctx->DrawBuffer->_ColorDrawBuffers[0][0];
766
767 ASSERT(dpy);
768 ASSERT(gc);
769
770 if (swrast->NewState)
771 _swrast_validate_derived( ctx );
772
773 if (ctx->Color.DrawBuffer[0] == GL_FRONT &&
774 ctx->Pixel.ReadBuffer == GL_FRONT &&
775 srcXrb->pixmap &&
776 dstXrb->pixmap &&
777 type == GL_COLOR &&
778 (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
779 ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
780 ctx->Pixel.ZoomX == 1.0 && /* no zooming */
781 ctx->Pixel.ZoomY == 1.0) {
782 /* Note: we don't do any special clipping work here. We could,
783 * but X will do it for us.
784 */
785 srcy = YFLIP(srcXrb, srcy) - height + 1;
786 desty = YFLIP(dstXrb, desty) - height + 1;
787 XCopyArea(dpy, srcXrb->pixmap, dstXrb->pixmap, gc,
788 srcx, srcy, width, height, destx, desty);
789 }
790 else {
791 _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type );
792 }
793 }
794 #endif /* XFree86Server */
795
796
797
798 /*
799 * Every driver should implement a GetString function in order to
800 * return a meaningful GL_RENDERER string.
801 */
802 static const GLubyte *
803 get_string( GLcontext *ctx, GLenum name )
804 {
805 (void) ctx;
806 switch (name) {
807 case GL_RENDERER:
808 #ifdef XFree86Server
809 return (const GLubyte *) "Mesa GLX Indirect";
810 #else
811 return (const GLubyte *) "Mesa X11";
812 #endif
813 case GL_VENDOR:
814 #ifdef XFree86Server
815 return (const GLubyte *) "Mesa project: www.mesa3d.org";
816 #else
817 return NULL;
818 #endif
819 default:
820 return NULL;
821 }
822 }
823
824
825 /*
826 * We implement the glEnable function only because we care about
827 * dither enable/disable.
828 */
829 static void
830 enable( GLcontext *ctx, GLenum pname, GLboolean state )
831 {
832 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
833
834 switch (pname) {
835 case GL_DITHER:
836 if (state)
837 xmesa->pixelformat = xmesa->xm_visual->dithered_pf;
838 else
839 xmesa->pixelformat = xmesa->xm_visual->undithered_pf;
840 break;
841 default:
842 ; /* silence compiler warning */
843 }
844 }
845
846
847 static void
848 clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] )
849 {
850 int i;
851 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
852
853 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
854 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
855 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
856 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
857
858 if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
859 /* black is black */
860 MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
861 sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
862 }
863 else {
864 /* build clear pattern */
865 for (i=0; i<16; i++) {
866 xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
867 DITHER_HPCR(i, 0,
868 xmesa->clearcolor[0],
869 xmesa->clearcolor[1],
870 xmesa->clearcolor[2]);
871 xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
872 DITHER_HPCR(i, 1,
873 xmesa->clearcolor[0],
874 xmesa->clearcolor[1],
875 xmesa->clearcolor[2]);
876 }
877 }
878 }
879
880
881 static void
882 clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
883 {
884 int i;
885 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
886
887 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
888 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
889 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
890 CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
891
892 if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
893 /* black is black */
894 for (i=0; i<16; i++) {
895 XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
896 XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
897 }
898 }
899 else {
900 for (i=0; i<16; i++) {
901 XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
902 DITHER_HPCR(i, 0,
903 xmesa->clearcolor[0],
904 xmesa->clearcolor[1],
905 xmesa->clearcolor[2]));
906 XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
907 DITHER_HPCR(i, 1,
908 xmesa->clearcolor[0],
909 xmesa->clearcolor[1],
910 xmesa->clearcolor[2]));
911 }
912 }
913 /* change tile pixmap content */
914 XMesaPutImage(xmesa->display,
915 (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
916 XMESA_BUFFER(ctx->DrawBuffer)->cleargc,
917 xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
918 }
919
920
921 /**
922 * Called when the driver should update its state, based on the new_state
923 * flags.
924 */
925 void
926 xmesa_update_state( GLcontext *ctx, GLbitfield new_state )
927 {
928 const XMesaContext xmesa = XMESA_CONTEXT(ctx);
929
930 /* Propagate statechange information to swrast and swrast_setup
931 * modules. The X11 driver has no internal GL-dependent state.
932 */
933 _swrast_InvalidateState( ctx, new_state );
934 _ac_InvalidateState( ctx, new_state );
935 _tnl_InvalidateState( ctx, new_state );
936 _swsetup_InvalidateState( ctx, new_state );
937
938 if (ctx->DrawBuffer->Name != 0)
939 return;
940
941 /*
942 * GL_DITHER, GL_READ/DRAW_BUFFER, buffer binding state, etc. effect
943 * renderbuffer span/clear funcs.
944 */
945 if (new_state & (_NEW_COLOR | _NEW_PIXEL | _NEW_BUFFERS)) {
946 XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
947 struct xmesa_renderbuffer *front_xrb, *back_xrb;
948
949 front_xrb = xmbuf->frontxrb;
950 if (front_xrb) {
951 xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
952 xmesa->xm_visual->BitsPerPixel);
953 front_xrb->clearFunc = clear_pixmap;
954 }
955
956 back_xrb = xmbuf->backxrb;
957 if (back_xrb) {
958 xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
959 xmesa->xm_visual->BitsPerPixel);
960 if (xmbuf->backxrb->pixmap) {
961 back_xrb->clearFunc = clear_pixmap;
962 }
963 else {
964 switch (xmesa->xm_visual->BitsPerPixel) {
965 case 8:
966 if (xmesa->xm_visual->hpcr_clear_flag) {
967 back_xrb->clearFunc = clear_HPCR_ximage;
968 }
969 else {
970 back_xrb->clearFunc = clear_8bit_ximage;
971 }
972 break;
973 case 16:
974 back_xrb->clearFunc = clear_16bit_ximage;
975 break;
976 case 24:
977 back_xrb->clearFunc = clear_24bit_ximage;
978 break;
979 case 32:
980 back_xrb->clearFunc = clear_32bit_ximage;
981 break;
982 default:
983 back_xrb->clearFunc = clear_nbit_ximage;
984 break;
985 }
986 }
987 }
988 }
989
990 if (xmesa->xm_visual->hpcr_clear_flag) {
991 /* this depends on whether we're drawing to the front or back buffer */
992 /* XXX FIX THIS! */
993 #if 0
994 if (pixmap) {
995 ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
996 }
997 else {
998 ctx->Driver.ClearColor = clear_color_HPCR_ximage;
999 }
1000 #else
1001 (void) clear_color_HPCR_pixmap;
1002 (void) clear_color_HPCR_ximage;
1003 #endif
1004 }
1005 }
1006
1007
1008
1009 /**
1010 * Called via ctx->Driver.TestProxyTeximage(). Normally, we'd just use
1011 * the _mesa_test_proxy_teximage() fallback function, but we're going to
1012 * special-case the 3D texture case to allow textures up to 512x512x32
1013 * texels.
1014 */
1015 static GLboolean
1016 test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
1017 GLint internalFormat, GLenum format, GLenum type,
1018 GLint width, GLint height, GLint depth, GLint border)
1019 {
1020 if (target == GL_PROXY_TEXTURE_3D) {
1021 /* special case for 3D textures */
1022 if (width * height * depth > 512 * 512 * 64 ||
1023 width < 2 * border ||
1024 (!ctx->Extensions.ARB_texture_non_power_of_two &&
1025 _mesa_bitcount(width - 2 * border) != 1) ||
1026 height < 2 * border ||
1027 (!ctx->Extensions.ARB_texture_non_power_of_two &&
1028 _mesa_bitcount(height - 2 * border) != 1) ||
1029 depth < 2 * border ||
1030 (!ctx->Extensions.ARB_texture_non_power_of_two &&
1031 _mesa_bitcount(depth - 2 * border) != 1)) {
1032 /* Bad size, or too many texels */
1033 return GL_FALSE;
1034 }
1035 return GL_TRUE;
1036 }
1037 else {
1038 /* use the fallback routine for 1D, 2D, cube and rect targets */
1039 return _mesa_test_proxy_teximage(ctx, target, level, internalFormat,
1040 format, type, width, height, depth,
1041 border);
1042 }
1043 }
1044
1045
1046 /**
1047 * In SW, we don't really compress GL_COMPRESSED_RGB[A] textures!
1048 */
1049 static const struct gl_texture_format *
1050 choose_tex_format( GLcontext *ctx, GLint internalFormat,
1051 GLenum format, GLenum type )
1052 {
1053 switch (internalFormat) {
1054 case GL_COMPRESSED_RGB_ARB:
1055 return &_mesa_texformat_rgb;
1056 case GL_COMPRESSED_RGBA_ARB:
1057 return &_mesa_texformat_rgba;
1058 default:
1059 return _mesa_choose_tex_format(ctx, internalFormat, format, type);
1060 }
1061 }
1062
1063
1064 /**
1065 * Called by glViewport.
1066 * This is a good time for us to poll the current X window size and adjust
1067 * our renderbuffers to match the current window size.
1068 * Remember, we have no opportunity to respond to conventional
1069 * X Resize/StructureNotify events since the X driver has no event loop.
1070 * Thus, we poll.
1071 * Note that this trick isn't fool-proof. If the application never calls
1072 * glViewport, our notion of the current window size may be incorrect.
1073 * That problem led to the GLX_MESA_resize_buffers extension.
1074 */
1075 static void
1076 xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
1077 {
1078 XMesaContext xmctx = XMESA_CONTEXT(ctx);
1079 XMesaBuffer xmdrawbuf = XMESA_BUFFER(ctx->WinSysDrawBuffer);
1080 XMesaBuffer xmreadbuf = XMESA_BUFFER(ctx->WinSysReadBuffer);
1081 xmesa_check_and_update_buffer_size(xmctx, xmdrawbuf);
1082 xmesa_check_and_update_buffer_size(xmctx, xmreadbuf);
1083 (void) x;
1084 (void) y;
1085 (void) w;
1086 (void) h;
1087 }
1088
1089
1090 #if ENABLE_EXT_timer_query
1091
1092 /*
1093 * The GL_EXT_timer_query extension is not enabled for the XServer
1094 * indirect renderer. Not sure about how/if wrapping of gettimeofday()
1095 * is done, etc.
1096 */
1097
1098 struct xmesa_query_object
1099 {
1100 struct gl_query_object Base;
1101 struct timeval StartTime;
1102 };
1103
1104
1105 static struct gl_query_object *
1106 xmesa_new_query_object(GLcontext *ctx, GLuint id)
1107 {
1108 struct xmesa_query_object *q = CALLOC_STRUCT(xmesa_query_object);
1109 if (q) {
1110 q->Base.Id = id;
1111 q->Base.Ready = GL_TRUE;
1112 }
1113 return &q->Base;
1114 }
1115
1116
1117 static void
1118 xmesa_begin_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
1119 {
1120 if (target == GL_TIME_ELAPSED_EXT) {
1121 struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
1122 (void) gettimeofday(&xq->StartTime, NULL);
1123 }
1124 }
1125
1126
1127 /**
1128 * Return the difference between the two given times in microseconds.
1129 */
1130 #ifdef __VMS
1131 #define suseconds_t unsigned int
1132 #endif
1133 static GLuint64EXT
1134 time_diff(const struct timeval *t0, const struct timeval *t1)
1135 {
1136 GLuint64EXT seconds0 = t0->tv_sec & 0xff; /* 0 .. 255 seconds */
1137 GLuint64EXT seconds1 = t1->tv_sec & 0xff; /* 0 .. 255 seconds */
1138 GLuint64EXT nanosec0 = (seconds0 * 1000000 + t0->tv_usec) * 1000;
1139 GLuint64EXT nanosec1 = (seconds1 * 1000000 + t1->tv_usec) * 1000;
1140 return nanosec1 - nanosec0;
1141 }
1142
1143
1144 static void
1145 xmesa_end_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
1146 {
1147 if (target == GL_TIME_ELAPSED_EXT) {
1148 struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
1149 struct timeval endTime;
1150 (void) gettimeofday(&endTime, NULL);
1151 /* result is in nanoseconds! */
1152 q->Result = time_diff(&xq->StartTime, &endTime);
1153 }
1154 q->Ready = GL_TRUE;
1155 }
1156
1157 #endif /* ENABLE_timer_query */
1158
1159
1160 /**
1161 * Initialize the device driver function table with the functions
1162 * we implement in this driver.
1163 */
1164 void
1165 xmesa_init_driver_functions( XMesaVisual xmvisual,
1166 struct dd_function_table *driver )
1167 {
1168 driver->GetString = get_string;
1169 driver->UpdateState = xmesa_update_state;
1170 driver->GetBufferSize = NULL; /* OBSOLETE */
1171 driver->Flush = finish_or_flush;
1172 driver->Finish = finish_or_flush;
1173 driver->ClearIndex = clear_index;
1174 driver->ClearColor = clear_color;
1175 driver->IndexMask = index_mask;
1176 driver->ColorMask = color_mask;
1177 driver->Enable = enable;
1178 driver->Clear = clear_buffers;
1179 driver->Viewport = xmesa_viewport;
1180 #ifndef XFree86Server
1181 driver->CopyPixels = xmesa_CopyPixels;
1182 if (xmvisual->undithered_pf == PF_8R8G8B &&
1183 xmvisual->dithered_pf == PF_8R8G8B) {
1184 driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
1185 }
1186 else if (xmvisual->undithered_pf == PF_5R6G5B) {
1187 driver->DrawPixels = xmesa_DrawPixels_5R6G5B;
1188 }
1189 #endif
1190 driver->TestProxyTexImage = test_proxy_teximage;
1191 #if ENABLE_EXT_texure_compression_s3tc
1192 driver->ChooseTextureFormat = choose_tex_format;
1193 #else
1194 (void) choose_tex_format;
1195 #endif
1196
1197 #if ENABLE_EXT_timer_query
1198 driver->NewQueryObject = xmesa_new_query_object;
1199 driver->BeginQuery = xmesa_begin_query;
1200 driver->EndQuery = xmesa_end_query;
1201 #endif
1202 }
1203
1204
1205 #define XMESA_NEW_POINT (_NEW_POINT | \
1206 _NEW_RENDERMODE | \
1207 _SWRAST_NEW_RASTERMASK)
1208
1209 #define XMESA_NEW_LINE (_NEW_LINE | \
1210 _NEW_TEXTURE | \
1211 _NEW_LIGHT | \
1212 _NEW_DEPTH | \
1213 _NEW_RENDERMODE | \
1214 _SWRAST_NEW_RASTERMASK)
1215
1216 #define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \
1217 _NEW_TEXTURE | \
1218 _NEW_LIGHT | \
1219 _NEW_DEPTH | \
1220 _NEW_RENDERMODE | \
1221 _SWRAST_NEW_RASTERMASK)
1222
1223
1224 /**
1225 * Extend the software rasterizer with our line/point/triangle
1226 * functions.
1227 * Called during context creation only.
1228 */
1229 void xmesa_register_swrast_functions( GLcontext *ctx )
1230 {
1231 SWcontext *swrast = SWRAST_CONTEXT( ctx );
1232
1233 swrast->choose_point = xmesa_choose_point;
1234 swrast->choose_line = xmesa_choose_line;
1235 swrast->choose_triangle = xmesa_choose_triangle;
1236
1237 /* XXX these lines have no net effect. Remove??? */
1238 swrast->InvalidatePointMask |= XMESA_NEW_POINT;
1239 swrast->InvalidateLineMask |= XMESA_NEW_LINE;
1240 swrast->InvalidateTriangleMask |= XMESA_NEW_TRIANGLE;
1241 }