1 /* $Id: osmesa.c,v 1.80 2002/06/13 04:28:30 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Off-Screen Mesa rendering / Rendering into client memory space
31 * Note on thread safety: this driver is thread safe. All
32 * functions are reentrant. The notion of current context is
33 * managed by the core _mesa_make_current() and _mesa_get_current_context()
34 * functions. Those functions are thread-safe.
39 #include "GL/osmesa.h"
44 #include "extensions.h"
51 #include "texformat.h"
53 #include "array_cache/acache.h"
54 #include "swrast/swrast.h"
55 #include "swrast_setup/swrast_setup.h"
56 #include "swrast/s_context.h"
57 #include "swrast/s_depth.h"
58 #include "swrast/s_lines.h"
59 #include "swrast/s_triangle.h"
61 #include "tnl/t_context.h"
62 #include "tnl/t_pipeline.h"
67 * This is the OS/Mesa context struct.
68 * Notice how it includes a GLcontext. By doing this we're mimicking
69 * C++ inheritance/derivation.
70 * Later, we can cast a GLcontext pointer into an OSMesaContext pointer
73 struct osmesa_context
{
74 GLcontext gl_ctx
; /* The core GL/Mesa context */
75 GLvisual
*gl_visual
; /* Describes the buffers */
76 GLframebuffer
*gl_buffer
; /* Depth, stencil, accum, etc buffers */
77 GLenum format
; /* either GL_RGBA or GL_COLOR_INDEX */
78 void *buffer
; /* the image buffer */
79 GLint width
, height
; /* size of image buffer */
80 GLint rowlength
; /* number of pixels per row */
81 GLint userRowLength
; /* user-specified number of pixels per row */
82 GLint rshift
, gshift
; /* bit shifts for RGBA formats */
84 GLint rInd
, gInd
, bInd
, aInd
;/* index offsets for RGBA formats */
85 GLchan
*rowaddr
[MAX_HEIGHT
]; /* address of first pixel in each image row */
86 GLboolean yup
; /* TRUE -> Y increases upward */
87 /* FALSE -> Y increases downward */
92 /* A forward declaration: */
93 static void osmesa_update_state( GLcontext
*ctx
, GLuint newstate
);
94 static void osmesa_register_swrast_functions( GLcontext
*ctx
);
98 #define OSMESA_CONTEXT(ctx) ((OSMesaContext) (ctx->DriverCtx))
102 /**********************************************************************/
103 /***** Public Functions *****/
104 /**********************************************************************/
108 * Create an Off-Screen Mesa rendering context. The only attribute needed is
109 * an RGBA vs Color-Index mode flag.
111 * Input: format - either GL_RGBA or GL_COLOR_INDEX
112 * sharelist - specifies another OSMesaContext with which to share
113 * display lists. NULL indicates no sharing.
114 * Return: an OSMesaContext or 0 if error
116 GLAPI OSMesaContext GLAPIENTRY
117 OSMesaCreateContext( GLenum format
, OSMesaContext sharelist
)
119 return OSMesaCreateContextExt(format
, DEFAULT_SOFTWARE_DEPTH_BITS
,
128 * Create context and specify size of ancillary buffers.
130 GLAPI OSMesaContext GLAPIENTRY
131 OSMesaCreateContextExt( GLenum format
, GLint depthBits
, GLint stencilBits
,
132 GLint accumBits
, OSMesaContext sharelist
)
134 OSMesaContext osmesa
;
135 GLint rshift
, gshift
, bshift
, ashift
;
136 GLint rind
, gind
, bind
, aind
;
137 GLint indexBits
= 0, redBits
= 0, greenBits
= 0, blueBits
= 0, alphaBits
=0;
140 const GLubyte
*i1
= (GLubyte
*) &i4
;
141 const GLint little_endian
= *i1
;
144 rind
= gind
= bind
= aind
= 0;
145 if (format
==OSMESA_COLOR_INDEX
) {
147 rshift
= gshift
= bshift
= ashift
= 0;
150 else if (format
==OSMESA_RGBA
) {
153 greenBits
= CHAN_BITS
;
154 blueBits
= CHAN_BITS
;
155 alphaBits
= CHAN_BITS
;
174 else if (format
==OSMESA_BGRA
) {
177 greenBits
= CHAN_BITS
;
178 blueBits
= CHAN_BITS
;
179 alphaBits
= CHAN_BITS
;
198 else if (format
==OSMESA_ARGB
) {
201 greenBits
= CHAN_BITS
;
202 blueBits
= CHAN_BITS
;
203 alphaBits
= CHAN_BITS
;
222 else if (format
==OSMESA_RGB
) {
225 greenBits
= CHAN_BITS
;
226 blueBits
= CHAN_BITS
;
237 else if (format
==OSMESA_BGR
) {
240 greenBits
= CHAN_BITS
;
241 blueBits
= CHAN_BITS
;
252 else if (format
==OSMESA_RGB_565
) {
262 rind
= 0; /* not used */
272 osmesa
= (OSMesaContext
) CALLOC_STRUCT(osmesa_context
);
274 osmesa
->gl_visual
= _mesa_create_visual( rgbmode
,
275 GL_FALSE
, /* double buffer */
276 GL_FALSE
, /* stereo */
287 alphaBits
? accumBits
: 0,
290 if (!osmesa
->gl_visual
) {
295 _mesa_init_default_imports( &imports
, (void *) osmesa
);
296 if (!_mesa_initialize_context(&osmesa
->gl_ctx
,
298 sharelist
? &sharelist
->gl_ctx
299 : (GLcontext
*) NULL
,
301 _mesa_destroy_visual( osmesa
->gl_visual
);
306 _mesa_enable_sw_extensions(&(osmesa
->gl_ctx
));
307 _mesa_enable_1_3_extensions(&(osmesa
->gl_ctx
));
309 osmesa
->gl_buffer
= _mesa_create_framebuffer( osmesa
->gl_visual
,
310 (GLboolean
) ( osmesa
->gl_visual
->depthBits
> 0 ),
311 (GLboolean
) ( osmesa
->gl_visual
->stencilBits
> 0 ),
312 (GLboolean
) ( osmesa
->gl_visual
->accumRedBits
> 0 ),
313 GL_FALSE
/* s/w alpha */ );
315 if (!osmesa
->gl_buffer
) {
316 _mesa_destroy_visual( osmesa
->gl_visual
);
317 _mesa_free_context_data( &osmesa
->gl_ctx
);
321 osmesa
->format
= format
;
322 osmesa
->buffer
= NULL
;
325 osmesa
->userRowLength
= 0;
326 osmesa
->rowlength
= 0;
327 osmesa
->yup
= GL_TRUE
;
328 osmesa
->rshift
= rshift
;
329 osmesa
->gshift
= gshift
;
330 osmesa
->bshift
= bshift
;
331 osmesa
->ashift
= ashift
;
338 /* Initialize the software rasterizer and helper modules.
341 GLcontext
*ctx
= &osmesa
->gl_ctx
;
343 _swrast_CreateContext( ctx
);
344 _ac_CreateContext( ctx
);
345 _tnl_CreateContext( ctx
);
346 _swsetup_CreateContext( ctx
);
348 _swsetup_Wakeup( ctx
);
349 osmesa_register_swrast_functions( ctx
);
359 * Destroy an Off-Screen Mesa rendering context.
361 * Input: ctx - the context to destroy
363 GLAPI
void GLAPIENTRY
OSMesaDestroyContext( OSMesaContext ctx
)
366 _swsetup_DestroyContext( &ctx
->gl_ctx
);
367 _tnl_DestroyContext( &ctx
->gl_ctx
);
368 _ac_DestroyContext( &ctx
->gl_ctx
);
369 _swrast_DestroyContext( &ctx
->gl_ctx
);
371 _mesa_destroy_visual( ctx
->gl_visual
);
372 _mesa_destroy_framebuffer( ctx
->gl_buffer
);
373 _mesa_free_context_data( &ctx
->gl_ctx
);
381 * Recompute the values of the context's rowaddr array.
383 static void compute_row_addresses( OSMesaContext ctx
)
385 GLint bytesPerPixel
, bytesPerRow
, i
;
386 GLubyte
*origin
= (GLubyte
*) ctx
->buffer
;
388 if (ctx
->format
== OSMESA_COLOR_INDEX
) {
390 bytesPerPixel
= 1 * sizeof(GLchan
);
392 else if ((ctx
->format
== OSMESA_RGB
) || (ctx
->format
== OSMESA_BGR
)) {
394 bytesPerPixel
= 3 * sizeof(GLchan
);
396 else if (ctx
->format
== OSMESA_RGB_565
) {
397 /* 5/6/5 RGB pixel in 16 bits */
402 bytesPerPixel
= 4 * sizeof(GLchan
);
405 bytesPerRow
= ctx
->rowlength
* bytesPerPixel
;
408 /* Y=0 is bottom line of window */
409 for (i
= 0; i
< MAX_HEIGHT
; i
++) {
410 ctx
->rowaddr
[i
] = (GLchan
*) ((GLubyte
*) origin
+ i
* bytesPerRow
);
414 /* Y=0 is top line of window */
415 for (i
= 0; i
< MAX_HEIGHT
; i
++) {
416 GLint j
= ctx
->height
- i
- 1;
417 ctx
->rowaddr
[i
] = (GLchan
*) ((GLubyte
*) origin
+ j
* bytesPerRow
);
424 * Bind an OSMesaContext to an image buffer. The image buffer is just a
425 * block of memory which the client provides. Its size must be at least
426 * as large as width*height*sizeof(type). Its address should be a multiple
427 * of 4 if using RGBA mode.
429 * Image data is stored in the order of glDrawPixels: row-major order
430 * with the lower-left image pixel stored in the first array position
431 * (ie. bottom-to-top).
433 * If the context's viewport hasn't been initialized yet, it will now be
434 * initialized to (0,0,width,height).
436 * Input: ctx - the rendering context
437 * buffer - the image buffer memory
438 * type - data type for pixel components
439 * Normally, only GL_UNSIGNED_BYTE and GL_UNSIGNED_SHORT_5_6_5
440 * are supported. But if Mesa's been compiled with CHAN_BITS==16
441 * then type must be GL_UNSIGNED_SHORT. And if Mesa's been build
442 * with CHAN_BITS==32 then type must be GL_FLOAT.
443 * width, height - size of image buffer in pixels, at least 1
444 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
445 * invalid buffer address, invalid type, width<1, height<1,
446 * width>internal limit or height>internal limit.
448 GLAPI GLboolean GLAPIENTRY
449 OSMesaMakeCurrent( OSMesaContext ctx
, void *buffer
, GLenum type
,
450 GLsizei width
, GLsizei height
)
452 if (!ctx
|| !buffer
||
453 width
< 1 || height
< 1 ||
454 width
> MAX_WIDTH
|| height
> MAX_HEIGHT
) {
458 if (ctx
->format
== OSMESA_RGB_565
) {
459 if (type
!= GL_UNSIGNED_SHORT_5_6_5
)
462 else if (type
!= CHAN_TYPE
) {
466 osmesa_update_state( &ctx
->gl_ctx
, 0 );
467 _mesa_make_current( &ctx
->gl_ctx
, ctx
->gl_buffer
);
469 ctx
->buffer
= buffer
;
471 ctx
->height
= height
;
472 if (ctx
->userRowLength
)
473 ctx
->rowlength
= ctx
->userRowLength
;
475 ctx
->rowlength
= width
;
477 compute_row_addresses( ctx
);
480 if (ctx
->gl_ctx
.Viewport
.Width
== 0) {
481 /* initialize viewport and scissor box to buffer size */
482 _mesa_Viewport( 0, 0, width
, height
);
483 ctx
->gl_ctx
.Scissor
.Width
= width
;
484 ctx
->gl_ctx
.Scissor
.Height
= height
;
487 /* this will make ensure we recognize the new buffer size */
488 _mesa_ResizeBuffersMESA();
496 GLAPI OSMesaContext GLAPIENTRY
OSMesaGetCurrentContext( void )
498 GLcontext
*ctx
= _mesa_get_current_context();
500 return (OSMesaContext
) ctx
;
507 GLAPI
void GLAPIENTRY
OSMesaPixelStore( GLint pname
, GLint value
)
509 OSMesaContext ctx
= OSMesaGetCurrentContext();
512 case OSMESA_ROW_LENGTH
:
514 _mesa_error( &ctx
->gl_ctx
, GL_INVALID_VALUE
,
515 "OSMesaPixelStore(value)" );
518 ctx
->userRowLength
= value
;
519 ctx
->rowlength
= value
;
522 ctx
->yup
= value
? GL_TRUE
: GL_FALSE
;
525 _mesa_error( &ctx
->gl_ctx
, GL_INVALID_ENUM
, "OSMesaPixelStore(pname)" );
529 compute_row_addresses( ctx
);
533 GLAPI
void GLAPIENTRY
OSMesaGetIntegerv( GLint pname
, GLint
*value
)
535 OSMesaContext ctx
= OSMesaGetCurrentContext();
542 *value
= ctx
->height
;
545 *value
= ctx
->format
;
550 case OSMESA_ROW_LENGTH
:
551 *value
= ctx
->rowlength
;
556 case OSMESA_MAX_WIDTH
:
559 case OSMESA_MAX_HEIGHT
:
563 _mesa_error(&ctx
->gl_ctx
, GL_INVALID_ENUM
, "OSMesaGetIntergerv(pname)");
569 * Return the depth buffer associated with an OSMesa context.
570 * Input: c - the OSMesa context
571 * Output: width, height - size of buffer in pixels
572 * bytesPerValue - bytes per depth value (2 or 4)
573 * buffer - pointer to depth buffer values
574 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
576 GLAPI GLboolean GLAPIENTRY
577 OSMesaGetDepthBuffer( OSMesaContext c
, GLint
*width
, GLint
*height
,
578 GLint
*bytesPerValue
, void **buffer
)
580 if ((!c
->gl_buffer
) || (!c
->gl_buffer
->DepthBuffer
)) {
588 *width
= c
->gl_buffer
->Width
;
589 *height
= c
->gl_buffer
->Height
;
590 if (c
->gl_visual
->depthBits
<= 16)
591 *bytesPerValue
= sizeof(GLushort
);
593 *bytesPerValue
= sizeof(GLuint
);
594 *buffer
= c
->gl_buffer
->DepthBuffer
;
600 * Return the color buffer associated with an OSMesa context.
601 * Input: c - the OSMesa context
602 * Output: width, height - size of buffer in pixels
603 * format - the pixel format (OSMESA_FORMAT)
604 * buffer - pointer to color buffer values
605 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
607 GLAPI GLboolean GLAPIENTRY
608 OSMesaGetColorBuffer( OSMesaContext c
, GLint
*width
,
609 GLint
*height
, GLint
*format
, void **buffer
)
629 struct name_address
{
634 static struct name_address functions
[] = {
635 { "OSMesaCreateContext", (void *) OSMesaCreateContext
},
636 { "OSMesaCreateContextExt", (void *) OSMesaCreateContextExt
},
637 { "OSMesaDestroyContext", (void *) OSMesaDestroyContext
},
638 { "OSMesaMakeCurrent", (void *) OSMesaMakeCurrent
},
639 { "OSMesaGetCurrentContext", (void *) OSMesaGetCurrentContext
},
640 { "OSMesaPixelsStore", (void *) OSMesaPixelStore
},
641 { "OSMesaGetIntegerv", (void *) OSMesaGetIntegerv
},
642 { "OSMesaGetDepthBuffer", (void *) OSMesaGetDepthBuffer
},
643 { "OSMesaGetColorBuffer", (void *) OSMesaGetColorBuffer
},
644 { "OSMesaGetProcAddress", (void *) OSMesaGetProcAddress
},
648 GLAPI
void * GLAPIENTRY
649 OSMesaGetProcAddress( const char *funcName
)
652 for (i
= 0; functions
[i
].Name
; i
++) {
653 if (strcmp(functions
[i
].Name
, funcName
) == 0)
654 return (void *) functions
[i
].Address
;
656 return (void *) _glapi_get_proc_address(funcName
);
660 /**********************************************************************/
661 /*** Device Driver Functions ***/
662 /**********************************************************************/
669 #define PACK_RGBA(DST, R, G, B, A) \
671 (DST)[osmesa->rInd] = R; \
672 (DST)[osmesa->gInd] = G; \
673 (DST)[osmesa->bInd] = B; \
674 (DST)[osmesa->aInd] = A; \
677 #define PACK_RGB(DST, R, G, B) \
684 #define PACK_BGR(DST, R, G, B) \
691 #define PACK_RGB_565(DST, R, G, B) \
693 (DST) = (((int) (R) << 8) & 0xf800) | (((int) (G) << 3) & 0x7e0) | ((int) (B) >> 3);\
697 #define UNPACK_RED(P) ( (P)[osmesa->rInd] )
698 #define UNPACK_GREEN(P) ( (P)[osmesa->gInd] )
699 #define UNPACK_BLUE(P) ( (P)[osmesa->bInd] )
700 #define UNPACK_ALPHA(P) ( (P)[osmesa->aInd] )
703 #define PIXELADDR1(X,Y) (osmesa->rowaddr[Y] + (X))
704 #define PIXELADDR2(X,Y) (osmesa->rowaddr[Y] + 2 * (X))
705 #define PIXELADDR3(X,Y) (osmesa->rowaddr[Y] + 3 * (X))
706 #define PIXELADDR4(X,Y) (osmesa->rowaddr[Y] + 4 * (X))
710 static GLboolean
set_draw_buffer( GLcontext
*ctx
, GLenum mode
)
713 if (mode
==GL_FRONT_LEFT
) {
722 static void set_read_buffer( GLcontext
*ctx
, GLframebuffer
*buffer
, GLenum mode
)
724 /* separate read buffer not supported */
725 ASSERT(buffer
== ctx
->DrawBuffer
);
726 ASSERT(mode
== GL_FRONT_LEFT
);
730 static void clear( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
731 GLint x
, GLint y
, GLint width
, GLint height
)
733 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
734 const GLuint
*colorMask
= (GLuint
*) &ctx
->Color
.ColorMask
;
736 /* sanity check - we only have a front-left buffer */
737 ASSERT((mask
& (DD_FRONT_RIGHT_BIT
| DD_BACK_LEFT_BIT
| DD_BACK_RIGHT_BIT
)) == 0);
738 if (*colorMask
== 0xffffffff && ctx
->Color
.IndexMask
== 0xffffffff) {
739 if (mask
& DD_FRONT_LEFT_BIT
) {
740 if (osmesa
->format
== OSMESA_COLOR_INDEX
) {
742 /* Clear whole CI buffer */
743 #if CHAN_TYPE == GL_UNSIGNED_BYTE
744 MEMSET(osmesa
->buffer
, ctx
->Color
.ClearIndex
,
745 osmesa
->rowlength
* osmesa
->height
);
747 const GLint n
= osmesa
->rowlength
* osmesa
->height
;
748 GLchan
*buffer
= (GLchan
*) osmesa
->buffer
;
750 for (i
= 0; i
< n
; i
++) {
751 buffer
[i
] = ctx
->Color
.ClearIndex
;
756 /* Clear part of CI buffer */
757 const GLchan clearIndex
= (GLchan
) ctx
->Color
.ClearIndex
;
759 for (i
= 0; i
< height
; i
++) {
760 GLchan
*ptr1
= PIXELADDR1(x
, (y
+ i
));
761 for (j
= 0; j
< width
; j
++) {
762 *ptr1
++ = clearIndex
;
767 else if (osmesa
->format
== OSMESA_RGB
) {
768 const GLchan r
= ctx
->Color
.ClearColor
[0];
769 const GLchan g
= ctx
->Color
.ClearColor
[1];
770 const GLchan b
= ctx
->Color
.ClearColor
[2];
772 /* Clear whole RGB buffer */
773 GLuint n
= osmesa
->rowlength
* osmesa
->height
;
774 GLchan
*ptr3
= (GLchan
*) osmesa
->buffer
;
776 for (i
= 0; i
< n
; i
++) {
777 PACK_RGB(ptr3
, r
, g
, b
);
782 /* Clear part of RGB buffer */
784 for (i
= 0; i
< height
; i
++) {
785 GLchan
*ptr3
= PIXELADDR3(x
, (y
+ i
));
786 for (j
= 0; j
< width
; j
++) {
787 PACK_RGB(ptr3
, r
, g
, b
);
793 else if (osmesa
->format
== OSMESA_BGR
) {
794 const GLchan r
= ctx
->Color
.ClearColor
[0];
795 const GLchan g
= ctx
->Color
.ClearColor
[1];
796 const GLchan b
= ctx
->Color
.ClearColor
[2];
798 /* Clear whole RGB buffer */
799 const GLint n
= osmesa
->rowlength
* osmesa
->height
;
800 GLchan
*ptr3
= (GLchan
*) osmesa
->buffer
;
802 for (i
= 0; i
< n
; i
++) {
803 PACK_BGR(ptr3
, r
, g
, b
);
808 /* Clear part of RGB buffer */
810 for (i
= 0; i
< height
; i
++) {
811 GLchan
*ptr3
= PIXELADDR3(x
, (y
+ i
));
812 for (j
= 0; j
< width
; j
++) {
813 PACK_BGR(ptr3
, r
, g
, b
);
819 else if (osmesa
->format
== OSMESA_RGB_565
) {
820 const GLchan r
= ctx
->Color
.ClearColor
[0];
821 const GLchan g
= ctx
->Color
.ClearColor
[1];
822 const GLchan b
= ctx
->Color
.ClearColor
[2];
824 PACK_RGB_565(clearPixel
, r
, g
, b
);
826 /* Clear whole RGB buffer */
827 const GLuint n
= osmesa
->rowlength
* osmesa
->height
;
828 GLushort
*ptr2
= (GLushort
*) osmesa
->buffer
;
830 for (i
= 0; i
< n
; i
++) {
836 /* clear scissored region */
838 for (i
= 0; i
< height
; i
++) {
839 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
, (y
+ i
));
840 for (j
= 0; j
< width
; j
++) {
848 #if CHAN_TYPE == GL_UNSIGNED_BYTE
849 /* 4-byte pixel value */
851 GLchan
*clr
= (GLchan
*) &clearPixel
;
852 clr
[osmesa
->rInd
] = ctx
->Color
.ClearColor
[0];
853 clr
[osmesa
->gInd
] = ctx
->Color
.ClearColor
[1];
854 clr
[osmesa
->bInd
] = ctx
->Color
.ClearColor
[2];
855 clr
[osmesa
->aInd
] = ctx
->Color
.ClearColor
[3];
857 /* Clear whole RGBA buffer */
858 const GLuint n
= osmesa
->rowlength
* osmesa
->height
;
859 GLuint
*ptr4
= (GLuint
*) osmesa
->buffer
;
862 for (i
= 0; i
< n
; i
++) {
863 *ptr4
++ = clearPixel
;
867 BZERO(ptr4
, n
* sizeof(GLuint
));
871 /* Clear part of RGBA buffer */
873 for (i
= 0; i
< height
; i
++) {
874 GLuint
*ptr4
= (GLuint
*) PIXELADDR4(x
, (y
+ i
));
875 for (j
= 0; j
< width
; j
++) {
876 *ptr4
++ = clearPixel
;
881 const GLchan r
= ctx
->Color
.ClearColor
[0];
882 const GLchan g
= ctx
->Color
.ClearColor
[1];
883 const GLchan b
= ctx
->Color
.ClearColor
[2];
884 const GLchan a
= ctx
->Color
.ClearColor
[3];
886 /* Clear whole RGBA buffer */
887 const GLuint n
= osmesa
->rowlength
* osmesa
->height
;
888 GLchan
*p
= (GLchan
*) osmesa
->buffer
;
890 for (i
= 0; i
< n
; i
++) {
891 PACK_RGBA(p
, r
, g
, b
, a
);
896 /* Clear part of RGBA buffer */
898 for (i
= 0; i
< height
; i
++) {
899 GLchan
*p
= PIXELADDR4(x
, (y
+ i
));
900 for (j
= 0; j
< width
; j
++) {
901 PACK_RGBA(p
, r
, g
, b
, a
);
909 mask
&= ~DD_FRONT_LEFT_BIT
;
914 _swrast_Clear( ctx
, mask
, all
, x
, y
, width
, height
);
919 static void buffer_size( GLframebuffer
*buffer
, GLuint
*width
, GLuint
*height
)
921 /* don't use GET_CURRENT_CONTEXT(ctx) here - it's a problem on Windows */
922 GLcontext
*ctx
= (GLcontext
*) _glapi_get_context();
925 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
926 *width
= osmesa
->width
;
927 *height
= osmesa
->height
;
932 /**********************************************************************/
933 /***** Read/write spans/arrays of RGBA pixels *****/
934 /**********************************************************************/
936 /* Write RGBA pixels to an RGBA (or permuted) buffer. */
938 write_rgba_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
939 CONST GLchan rgba
[][4], const GLubyte mask
[] )
941 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
942 GLchan
*p
= PIXELADDR4(x
, y
);
945 for (i
= 0; i
< n
; i
++, p
+= 4) {
947 PACK_RGBA(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
],
948 rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]);
953 for (i
= 0; i
< n
; i
++, p
+= 4) {
954 PACK_RGBA(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
],
955 rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]);
961 /* Write RGBA pixels to an RGBA buffer. This is the fastest span-writer. */
963 write_rgba_span_rgba( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
964 CONST GLchan rgba
[][4], const GLubyte mask
[] )
966 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
967 GLuint
*ptr4
= (GLuint
*) PIXELADDR4(x
, y
);
968 const GLuint
*rgba4
= (const GLuint
*) rgba
;
970 ASSERT(CHAN_TYPE
== GL_UNSIGNED_BYTE
);
972 for (i
= 0; i
< n
; i
++) {
979 MEMCPY( ptr4
, rgba4
, n
* 4 );
984 /* Write RGB pixels to an RGBA (or permuted) buffer. */
986 write_rgb_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
987 CONST GLchan rgb
[][3], const GLubyte mask
[] )
989 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
990 GLchan
*p
= PIXELADDR4(x
, y
);
993 for (i
= 0; i
< n
; i
++, p
+=4) {
995 PACK_RGBA(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], CHAN_MAX
);
1000 for (i
= 0; i
< n
; i
++, p
+=4) {
1001 PACK_RGBA(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
], CHAN_MAX
);
1009 write_monocolor_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1010 const GLchan color
[4], const GLubyte mask
[] )
1012 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1013 GLchan
*p
= PIXELADDR4(x
, y
);
1015 for (i
= 0; i
< n
; i
++, p
+= 4) {
1017 PACK_RGBA(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
], color
[ACOMP
]);
1025 write_rgba_pixels( const GLcontext
*ctx
, GLuint n
,
1026 const GLint x
[], const GLint y
[],
1027 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1029 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1031 for (i
= 0; i
< n
; i
++) {
1033 GLchan
*p
= PIXELADDR4(x
[i
], y
[i
]);
1034 PACK_RGBA(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
],
1035 rgba
[i
][BCOMP
], rgba
[i
][ACOMP
]);
1043 write_monocolor_pixels( const GLcontext
*ctx
, GLuint n
,
1044 const GLint x
[], const GLint y
[],
1045 const GLchan color
[4], const GLubyte mask
[] )
1047 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1049 for (i
= 0; i
< n
; i
++) {
1051 GLchan
*p
= PIXELADDR4(x
[i
], y
[i
]);
1052 PACK_RGBA(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
], color
[ACOMP
]);
1059 read_rgba_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1062 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1064 GLchan
*p
= PIXELADDR4(x
, y
);
1065 for (i
= 0; i
< n
; i
++, p
+= 4) {
1066 rgba
[i
][RCOMP
] = UNPACK_RED(p
);
1067 rgba
[i
][GCOMP
] = UNPACK_GREEN(p
);
1068 rgba
[i
][BCOMP
] = UNPACK_BLUE(p
);
1069 rgba
[i
][ACOMP
] = UNPACK_ALPHA(p
);
1074 /* Read RGBA pixels from an RGBA buffer */
1076 read_rgba_span_rgba( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1079 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1080 GLuint
*ptr4
= (GLuint
*) PIXELADDR4(x
, y
);
1081 MEMCPY( rgba
, ptr4
, n
* 4 * sizeof(GLchan
) );
1086 read_rgba_pixels( const GLcontext
*ctx
,
1087 GLuint n
, const GLint x
[], const GLint y
[],
1088 GLchan rgba
[][4], const GLubyte mask
[] )
1090 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1092 for (i
= 0; i
< n
; i
++) {
1094 const GLchan
*p
= PIXELADDR4(x
[i
], y
[i
]);
1095 rgba
[i
][RCOMP
] = UNPACK_RED(p
);
1096 rgba
[i
][GCOMP
] = UNPACK_GREEN(p
);
1097 rgba
[i
][BCOMP
] = UNPACK_BLUE(p
);
1098 rgba
[i
][ACOMP
] = UNPACK_ALPHA(p
);
1103 /**********************************************************************/
1104 /***** 3 byte RGB pixel support funcs *****/
1105 /**********************************************************************/
1107 /* Write RGBA pixels to an RGB buffer. */
1109 write_rgba_span_RGB( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1110 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1112 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1113 GLchan
*p
= PIXELADDR3(x
, y
);
1116 for (i
= 0; i
< n
; i
++, p
+= 3) {
1118 PACK_RGB(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1123 for (i
= 0; i
< n
; i
++, p
+= 3) {
1124 PACK_RGB(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1129 /* Write RGBA pixels to an BGR buffer. */
1131 write_rgba_span_BGR( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1132 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1134 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1135 GLchan
*p
= PIXELADDR3(x
, y
);
1138 for (i
= 0; i
< n
; i
++, p
+= 3) {
1140 PACK_BGR(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1145 for (i
= 0; i
< n
; i
++, p
+= 3) {
1146 PACK_BGR(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1151 /* Write RGB pixels to an RGB buffer. */
1153 write_rgb_span_RGB( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1154 CONST GLchan rgb
[][3], const GLubyte mask
[] )
1156 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1157 GLchan
*p
= PIXELADDR3(x
, y
);
1160 for (i
= 0; i
< n
; i
++, p
+= 3) {
1162 PACK_RGB(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1167 for (i
= 0; i
< n
; i
++, p
+= 3) {
1168 PACK_RGB(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1173 /* Write RGB pixels to an BGR buffer. */
1175 write_rgb_span_BGR( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1176 CONST GLchan rgb
[][3], const GLubyte mask
[] )
1178 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1179 GLchan
*p
= PIXELADDR3(x
, y
);
1182 for (i
= 0; i
< n
; i
++, p
+= 3) {
1184 PACK_BGR(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1189 for (i
= 0; i
< n
; i
++, p
+= 3) {
1190 PACK_BGR(p
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1197 write_monocolor_span_RGB( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1198 const GLchan color
[4], const GLubyte mask
[] )
1200 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1201 GLchan
*p
= PIXELADDR3(x
, y
);
1203 for (i
= 0; i
< n
; i
++, p
+= 3) {
1205 PACK_RGB(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1211 write_monocolor_span_BGR( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1212 const GLchan color
[4], const GLubyte mask
[] )
1214 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1215 GLchan
*p
= PIXELADDR3(x
, y
);
1217 for (i
= 0; i
< n
; i
++, p
+= 3) {
1219 PACK_BGR(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1225 write_rgba_pixels_RGB( const GLcontext
*ctx
, GLuint n
,
1226 const GLint x
[], const GLint y
[],
1227 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1229 const OSMesaContext osmesa
= (const OSMesaContext
) ctx
;
1231 for (i
= 0; i
< n
; i
++) {
1233 GLchan
*p
= PIXELADDR3(x
[i
], y
[i
]);
1234 PACK_RGB(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1240 write_rgba_pixels_BGR( const GLcontext
*ctx
, GLuint n
,
1241 const GLint x
[], const GLint y
[],
1242 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1244 const OSMesaContext osmesa
= (const OSMesaContext
) ctx
;
1246 for (i
= 0; i
< n
; i
++) {
1248 GLchan
*p
= PIXELADDR3(x
[i
], y
[i
]);
1249 PACK_BGR(p
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1255 write_monocolor_pixels_RGB( const GLcontext
*ctx
,
1256 GLuint n
, const GLint x
[], const GLint y
[],
1257 const GLchan color
[4], const GLubyte mask
[] )
1259 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1261 for (i
= 0; i
< n
; i
++) {
1263 GLchan
*p
= PIXELADDR3(x
[i
], y
[i
]);
1264 PACK_RGB(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1270 write_monocolor_pixels_BGR( const GLcontext
*ctx
,
1271 GLuint n
, const GLint x
[], const GLint y
[],
1272 const GLchan color
[4], const GLubyte mask
[] )
1274 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1276 for (i
= 0; i
< n
; i
++) {
1278 GLchan
*p
= PIXELADDR3(x
[i
], y
[i
]);
1279 PACK_BGR(p
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1285 read_rgba_span3( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1288 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1290 const GLchan
*p
= PIXELADDR3(x
, y
);
1291 for (i
= 0; i
< n
; i
++, p
+= 3) {
1292 rgba
[i
][RCOMP
] = UNPACK_RED(p
);
1293 rgba
[i
][GCOMP
] = UNPACK_GREEN(p
);
1294 rgba
[i
][BCOMP
] = UNPACK_BLUE(p
);
1295 rgba
[i
][ACOMP
] = CHAN_MAX
;
1300 read_rgba_pixels3( const GLcontext
*ctx
,
1301 GLuint n
, const GLint x
[], const GLint y
[],
1302 GLchan rgba
[][4], const GLubyte mask
[] )
1304 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1306 for (i
= 0; i
< n
; i
++) {
1308 const GLchan
*p
= PIXELADDR3(x
[i
], y
[i
]);
1309 rgba
[i
][RCOMP
] = UNPACK_RED(p
);
1310 rgba
[i
][GCOMP
] = UNPACK_GREEN(p
);
1311 rgba
[i
][BCOMP
] = UNPACK_BLUE(p
);
1312 rgba
[i
][ACOMP
] = CHAN_MAX
;
1318 /**********************************************************************/
1319 /***** 2 byte RGB pixel support funcs *****/
1320 /**********************************************************************/
1322 /* Write RGBA pixels to an RGB_565 buffer. */
1324 write_rgba_span2( const GLcontext
*ctx
,
1325 GLuint n
, GLint x
, GLint y
,
1326 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1328 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1329 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
, y
);
1332 for (i
= 0; i
< n
; i
++, ptr2
++) {
1334 PACK_RGB_565(*ptr2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1339 for (i
= 0; i
< n
; i
++, ptr2
++) {
1340 PACK_RGB_565(*ptr2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1346 /* Write RGB pixels to an RGB_565 buffer. */
1348 write_rgb_span2( const GLcontext
*ctx
,
1349 GLuint n
, GLint x
, GLint y
,
1350 CONST GLchan rgb
[][3], const GLubyte mask
[] )
1352 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1353 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
, y
);
1356 for (i
= 0; i
< n
; i
++, ptr2
++) {
1358 PACK_RGB_565(*ptr2
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1363 for (i
= 0; i
< n
; i
++, ptr2
++) {
1364 PACK_RGB_565(*ptr2
, rgb
[i
][RCOMP
], rgb
[i
][GCOMP
], rgb
[i
][BCOMP
]);
1371 write_monocolor_span2( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1372 const GLchan color
[4], const GLubyte mask
[] )
1374 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1376 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
, y
);
1378 PACK_RGB_565(pixel
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1379 for (i
= 0; i
< n
; i
++, ptr2
++) {
1388 write_rgba_pixels2( const GLcontext
*ctx
,
1389 GLuint n
, const GLint x
[], const GLint y
[],
1390 CONST GLchan rgba
[][4], const GLubyte mask
[] )
1392 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1394 for (i
= 0; i
< n
; i
++) {
1396 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
[i
],y
[i
]);
1397 PACK_RGB_565(*ptr2
, rgba
[i
][RCOMP
], rgba
[i
][GCOMP
], rgba
[i
][BCOMP
]);
1403 write_monocolor_pixels2( const GLcontext
*ctx
,
1404 GLuint n
, const GLint x
[], const GLint y
[],
1405 const GLchan color
[4], const GLubyte mask
[] )
1407 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1410 PACK_RGB_565(pixel
, color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1411 for (i
= 0; i
< n
; i
++) {
1413 GLushort
*ptr2
= (GLushort
*) PIXELADDR2(x
[i
],y
[i
]);
1420 read_rgba_span2( const GLcontext
*ctx
,
1421 GLuint n
, GLint x
, GLint y
,
1424 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1426 const GLushort
*ptr2
= (const GLushort
*) PIXELADDR2(x
, y
);
1427 for (i
= 0; i
< n
; i
++, ptr2
++) {
1428 /* This should be fixed to get the low bits right */
1429 rgba
[i
][RCOMP
] = (*ptr2
>> 8) & 0xFe;
1430 rgba
[i
][GCOMP
] = (*ptr2
>> 3) & 0xFc;
1431 rgba
[i
][BCOMP
] = (*ptr2
<< 3) & 0xFe;
1437 read_rgba_pixels2( const GLcontext
*ctx
,
1438 GLuint n
, const GLint x
[], const GLint y
[],
1439 GLchan rgba
[][4], const GLubyte mask
[] )
1441 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1443 for (i
= 0; i
< n
; i
++) {
1445 /* This should be fixed to get the low bits right */
1446 const GLushort
*ptr2
= (const GLushort
*) PIXELADDR2(x
[i
],y
[i
]);
1447 rgba
[i
][RCOMP
] = (*ptr2
>> 8) & 0xFE;
1448 rgba
[i
][GCOMP
] = (*ptr2
>> 3) & 0xFC;
1449 rgba
[i
][BCOMP
] = (*ptr2
<< 3) & 0xFE;
1457 /**********************************************************************/
1458 /***** Read/write spans/arrays of CI pixels *****/
1459 /**********************************************************************/
1461 /* Write 32-bit color index to buffer */
1463 write_index32_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1464 const GLuint index
[], const GLubyte mask
[] )
1466 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1467 GLchan
*ptr1
= PIXELADDR1(x
, y
);
1470 for (i
=0;i
<n
;i
++,ptr1
++) {
1472 *ptr1
= (GLchan
) index
[i
];
1477 for (i
=0;i
<n
;i
++,ptr1
++) {
1478 *ptr1
= (GLchan
) index
[i
];
1484 /* Write 8-bit color index to buffer */
1486 write_index8_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1487 const GLubyte index
[], const GLubyte mask
[] )
1489 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1490 GLchan
*ptr1
= PIXELADDR1(x
, y
);
1493 for (i
=0;i
<n
;i
++,ptr1
++) {
1495 *ptr1
= (GLchan
) index
[i
];
1500 MEMCPY(ptr1
, index
, n
* sizeof(GLchan
));
1506 write_monoindex_span( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1507 GLuint colorIndex
, const GLubyte mask
[] )
1509 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1510 GLchan
*ptr1
= PIXELADDR1(x
, y
);
1512 for (i
=0;i
<n
;i
++,ptr1
++) {
1514 *ptr1
= (GLchan
) colorIndex
;
1521 write_index_pixels( const GLcontext
*ctx
,
1522 GLuint n
, const GLint x
[], const GLint y
[],
1523 const GLuint index
[], const GLubyte mask
[] )
1525 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1529 GLchan
*ptr1
= PIXELADDR1(x
[i
], y
[i
]);
1530 *ptr1
= (GLchan
) index
[i
];
1537 write_monoindex_pixels( const GLcontext
*ctx
,
1538 GLuint n
, const GLint x
[], const GLint y
[],
1539 GLuint colorIndex
, const GLubyte mask
[] )
1541 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1545 GLchan
*ptr1
= PIXELADDR1(x
[i
], y
[i
]);
1546 *ptr1
= (GLchan
) colorIndex
;
1553 read_index_span( const GLcontext
*ctx
,
1554 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
1556 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1558 const GLchan
*ptr1
= (const GLchan
*) PIXELADDR1(x
, y
);
1559 for (i
=0;i
<n
;i
++,ptr1
++) {
1560 index
[i
] = (GLuint
) *ptr1
;
1566 read_index_pixels( const GLcontext
*ctx
,
1567 GLuint n
, const GLint x
[], const GLint y
[],
1568 GLuint index
[], const GLubyte mask
[] )
1570 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1574 const GLchan
*ptr1
= PIXELADDR1(x
[i
], y
[i
]);
1575 index
[i
] = (GLuint
) *ptr1
;
1582 /**********************************************************************/
1583 /***** Optimized line rendering *****/
1584 /**********************************************************************/
1588 * Draw a flat-shaded, RGB line into an osmesa buffer.
1591 flat_rgba_line( GLcontext
*ctx
, const SWvertex
*vert0
, const SWvertex
*vert1
)
1593 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1594 const GLchan
*color
= vert1
->color
;
1598 #define PLOT(X, Y) \
1600 GLchan *p = PIXELADDR4(X, Y); \
1601 PACK_RGBA(p, color[0], color[1], color[2], color[3]); \
1605 #include "..\swrast\s_linetemp.h"
1607 #include "swrast/s_linetemp.h"
1613 * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer.
1616 flat_rgba_z_line(GLcontext
*ctx
, const SWvertex
*vert0
, const SWvertex
*vert1
)
1618 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1619 const GLchan
*color
= vert1
->color
;
1623 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
1625 #define PLOT(X, Y) \
1628 GLchan *p = PIXELADDR4(X, Y); \
1629 PACK_RGBA(p, color[RCOMP], color[GCOMP], \
1630 color[BCOMP], color[ACOMP]); \
1637 #include "..\swrast\s_linetemp.h"
1639 #include "swrast/s_linetemp.h"
1645 * Draw a flat-shaded, alpha-blended, RGB line into an osmesa buffer.
1646 * XXX update for GLchan
1649 flat_blend_rgba_line( GLcontext
*ctx
,
1650 const SWvertex
*vert0
, const SWvertex
*vert1
)
1652 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1653 const GLint rshift
= osmesa
->rshift
;
1654 const GLint gshift
= osmesa
->gshift
;
1655 const GLint bshift
= osmesa
->bshift
;
1656 const GLint avalue
= vert0
->color
[3];
1657 const GLint msavalue
= CHAN_MAX
- avalue
;
1658 const GLint rvalue
= vert1
->color
[0]*avalue
;
1659 const GLint gvalue
= vert1
->color
[1]*avalue
;
1660 const GLint bvalue
= vert1
->color
[2]*avalue
;
1665 { GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \
1667 pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift);\
1668 pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift);\
1669 pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift);\
1673 #if 0 /* XXX use this in the future */
1676 GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \
1677 pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \
1678 pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \
1679 pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \
1680 pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \
1685 #include "..\swrast\s_linetemp.h"
1687 #include "swrast/s_linetemp.h"
1693 * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer.
1694 * But don't write to Z buffer.
1695 * XXX update for GLchan
1698 flat_blend_rgba_z_line( GLcontext
*ctx
,
1699 const SWvertex
*vert0
, const SWvertex
*vert1
)
1701 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1702 const GLint rshift
= osmesa
->rshift
;
1703 const GLint gshift
= osmesa
->gshift
;
1704 const GLint bshift
= osmesa
->bshift
;
1705 const GLint avalue
= vert0
->color
[3];
1706 const GLint msavalue
= 256 - avalue
;
1707 const GLint rvalue
= vert1
->color
[0]*avalue
;
1708 const GLint gvalue
= vert1
->color
[1]*avalue
;
1709 const GLint bvalue
= vert1
->color
[2]*avalue
;
1713 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
1717 GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \
1719 pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \
1720 pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \
1721 pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \
1725 #if 0 /* XXX use this in the future */
1728 GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \
1729 pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \
1730 pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \
1731 pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \
1732 pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \
1737 #include "..\swrast\s_linetemp.h"
1739 #include "swrast/s_linetemp.h"
1745 * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer.
1746 * XXX update for GLchan
1749 flat_blend_rgba_z_line_write( GLcontext
*ctx
,
1750 const SWvertex
*vert0
, const SWvertex
*vert1
)
1752 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1753 const GLint rshift
= osmesa
->rshift
;
1754 const GLint gshift
= osmesa
->gshift
;
1755 const GLint bshift
= osmesa
->bshift
;
1756 const GLint avalue
= vert0
->color
[3];
1757 const GLint msavalue
= 256 - avalue
;
1758 const GLint rvalue
= vert1
->color
[0]*avalue
;
1759 const GLint gvalue
= vert1
->color
[1]*avalue
;
1760 const GLint bvalue
= vert1
->color
[2]*avalue
;
1764 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
1768 GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \
1770 pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \
1771 pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \
1772 pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \
1777 #if 0 /* XXX use this in the future */
1780 GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \
1781 pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \
1782 pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \
1783 pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \
1784 pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \
1790 #include "..\swrast\s_linetemp.h"
1792 #include "swrast/s_linetemp.h"
1798 * Analyze context state to see if we can provide a fast line drawing
1799 * function, like those in lines.c. Otherwise, return NULL.
1801 static swrast_line_func
1802 osmesa_choose_line_function( GLcontext
*ctx
)
1804 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1805 const SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1807 if (CHAN_BITS
!= 8) return NULL
;
1808 if (ctx
->RenderMode
!= GL_RENDER
) return NULL
;
1809 if (ctx
->Line
.SmoothFlag
) return NULL
;
1810 if (ctx
->Texture
._ReallyEnabled
) return NULL
;
1811 if (ctx
->Light
.ShadeModel
!= GL_FLAT
) return NULL
;
1812 if (ctx
->Line
.Width
!= 1.0F
) return NULL
;
1813 if (ctx
->Line
.StippleFlag
) return NULL
;
1814 if (ctx
->Line
.SmoothFlag
) return NULL
;
1815 if (osmesa
->format
!= OSMESA_RGBA
&&
1816 osmesa
->format
!= OSMESA_BGRA
&&
1817 osmesa
->format
!= OSMESA_ARGB
) return NULL
;
1819 if (swrast
->_RasterMask
==DEPTH_BIT
1820 && ctx
->Depth
.Func
==GL_LESS
1821 && ctx
->Depth
.Mask
==GL_TRUE
1822 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
) {
1823 return (swrast_line_func
) flat_rgba_z_line
;
1826 if (swrast
->_RasterMask
== 0) {
1827 return (swrast_line_func
) flat_rgba_line
;
1830 if (swrast
->_RasterMask
==(DEPTH_BIT
|BLEND_BIT
)
1831 && ctx
->Depth
.Func
==GL_LESS
1832 && ctx
->Depth
.Mask
==GL_TRUE
1833 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1834 && ctx
->Color
.BlendSrcRGB
==GL_SRC_ALPHA
1835 && ctx
->Color
.BlendDstRGB
==GL_ONE_MINUS_SRC_ALPHA
1836 && ctx
->Color
.BlendSrcA
==GL_SRC_ALPHA
1837 && ctx
->Color
.BlendDstA
==GL_ONE_MINUS_SRC_ALPHA
1838 && ctx
->Color
.BlendEquation
==GL_FUNC_ADD_EXT
) {
1839 return (swrast_line_func
) flat_blend_rgba_z_line_write
;
1842 if (swrast
->_RasterMask
==(DEPTH_BIT
|BLEND_BIT
)
1843 && ctx
->Depth
.Func
==GL_LESS
1844 && ctx
->Depth
.Mask
==GL_FALSE
1845 && ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
1846 && ctx
->Color
.BlendSrcRGB
==GL_SRC_ALPHA
1847 && ctx
->Color
.BlendDstRGB
==GL_ONE_MINUS_SRC_ALPHA
1848 && ctx
->Color
.BlendSrcA
==GL_SRC_ALPHA
1849 && ctx
->Color
.BlendDstA
==GL_ONE_MINUS_SRC_ALPHA
1850 && ctx
->Color
.BlendEquation
==GL_FUNC_ADD_EXT
) {
1851 return (swrast_line_func
) flat_blend_rgba_z_line
;
1854 if (swrast
->_RasterMask
==BLEND_BIT
1855 && ctx
->Color
.BlendSrcRGB
==GL_SRC_ALPHA
1856 && ctx
->Color
.BlendDstRGB
==GL_ONE_MINUS_SRC_ALPHA
1857 && ctx
->Color
.BlendSrcA
==GL_SRC_ALPHA
1858 && ctx
->Color
.BlendDstA
==GL_ONE_MINUS_SRC_ALPHA
1859 && ctx
->Color
.BlendEquation
==GL_FUNC_ADD_EXT
) {
1860 return (swrast_line_func
) flat_blend_rgba_line
;
1863 return (swrast_line_func
) NULL
;
1867 /**********************************************************************/
1868 /***** Optimized triangle rendering *****/
1869 /**********************************************************************/
1873 * Smooth-shaded, z-less triangle, RGBA color.
1875 static void smooth_rgba_z_triangle( GLcontext
*ctx
,
1878 const SWvertex
*v2
)
1880 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1883 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
1884 #define INTERP_RGB 1
1885 #define INTERP_ALPHA 1
1886 #define RENDER_SPAN( span ) \
1888 GLchan *img = PIXELADDR4(span->x, span->y); \
1889 for (i = 0; i < span->end; i++, img += 4) { \
1890 const GLdepth z = FixedToDepth(span->z); \
1891 if (z < zRow[i]) { \
1892 PACK_RGBA(img, FixedToChan(span->red), \
1893 FixedToChan(span->green), FixedToChan(span->blue), \
1894 FixedToChan(span->alpha)); \
1897 span->red += span->redStep; \
1898 span->green += span->greenStep; \
1899 span->blue += span->blueStep; \
1900 span->alpha += span->alphaStep; \
1901 span->z += span->zStep; \
1905 #include "..\swrast\s_tritemp.h"
1907 #include "swrast/s_tritemp.h"
1915 * Flat-shaded, z-less triangle, RGBA color.
1917 static void flat_rgba_z_triangle( GLcontext
*ctx
,
1920 const SWvertex
*v2
)
1922 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1924 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
1925 #define SETUP_CODE \
1927 PACK_RGBA((GLchan *) &pixel, v2->color[0], v2->color[1], \
1928 v2->color[2], v2->color[3]);
1930 #define RENDER_SPAN( span ) \
1932 GLuint *img = (GLuint *) PIXELADDR4(span->x, span->y); \
1933 for (i = 0; i < span->end; i++) { \
1934 const GLdepth z = FixedToDepth(span->z); \
1935 if (z < zRow[i]) { \
1939 span->z += span->zStep; \
1943 #include "..\swrast\s_tritemp.h"
1945 #include "swrast/s_tritemp.h"
1952 * Return pointer to an accelerated triangle function if possible.
1954 static swrast_tri_func
1955 osmesa_choose_triangle_function( GLcontext
*ctx
)
1957 const OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
1958 const SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1960 if (CHAN_BITS
!= 8) return (swrast_tri_func
) NULL
;
1961 if (ctx
->RenderMode
!= GL_RENDER
) return (swrast_tri_func
) NULL
;
1962 if (ctx
->Polygon
.SmoothFlag
) return (swrast_tri_func
) NULL
;
1963 if (ctx
->Polygon
.StippleFlag
) return (swrast_tri_func
) NULL
;
1964 if (ctx
->Texture
._ReallyEnabled
) return (swrast_tri_func
) NULL
;
1965 if (osmesa
->format
!= OSMESA_RGBA
&&
1966 osmesa
->format
!= OSMESA_BGRA
&&
1967 osmesa
->format
!= OSMESA_ARGB
) return (swrast_tri_func
) NULL
;
1969 if (swrast
->_RasterMask
== DEPTH_BIT
&&
1970 ctx
->Depth
.Func
== GL_LESS
&&
1971 ctx
->Depth
.Mask
== GL_TRUE
&&
1972 ctx
->Visual
.depthBits
== DEFAULT_SOFTWARE_DEPTH_BITS
) {
1973 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
1974 return (swrast_tri_func
) smooth_rgba_z_triangle
;
1977 return (swrast_tri_func
) flat_rgba_z_triangle
;
1980 return (swrast_tri_func
) NULL
;
1985 /* Override for the swrast triangle-selection function. Try to use one
1986 * of our internal triangle functions, otherwise fall back to the
1987 * standard swrast functions.
1989 static void osmesa_choose_triangle( GLcontext
*ctx
)
1991 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1993 swrast
->Triangle
= osmesa_choose_triangle_function( ctx
);
1994 if (!swrast
->Triangle
)
1995 _swrast_choose_triangle( ctx
);
1998 static void osmesa_choose_line( GLcontext
*ctx
)
2000 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
2002 swrast
->Line
= osmesa_choose_line_function( ctx
);
2004 _swrast_choose_line( ctx
);
2008 #define OSMESA_NEW_LINE (_NEW_LINE | \
2013 _SWRAST_NEW_RASTERMASK)
2015 #define OSMESA_NEW_TRIANGLE (_NEW_POLYGON | \
2020 _SWRAST_NEW_RASTERMASK)
2023 /* Extend the software rasterizer with our line and triangle
2026 static void osmesa_register_swrast_functions( GLcontext
*ctx
)
2028 SWcontext
*swrast
= SWRAST_CONTEXT( ctx
);
2030 swrast
->choose_line
= osmesa_choose_line
;
2031 swrast
->choose_triangle
= osmesa_choose_triangle
;
2033 swrast
->invalidate_line
|= OSMESA_NEW_LINE
;
2034 swrast
->invalidate_triangle
|= OSMESA_NEW_TRIANGLE
;
2038 static const GLubyte
*get_string( GLcontext
*ctx
, GLenum name
)
2044 return (const GLubyte
*) "Mesa OffScreen32";
2045 #elif CHAN_BITS == 16
2046 return (const GLubyte
*) "Mesa OffScreen16";
2048 return (const GLubyte
*) "Mesa OffScreen";
2056 static void osmesa_update_state( GLcontext
*ctx
, GLuint new_state
)
2058 OSMesaContext osmesa
= OSMESA_CONTEXT(ctx
);
2059 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference( ctx
);
2060 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
2062 ASSERT((void *) osmesa
== (void *) ctx
->DriverCtx
);
2065 * XXX these function pointers could be initialized just once during
2066 * context creation since they don't depend on any state changes.
2069 ctx
->Driver
.GetString
= get_string
;
2070 ctx
->Driver
.UpdateState
= osmesa_update_state
;
2071 ctx
->Driver
.SetDrawBuffer
= set_draw_buffer
;
2072 ctx
->Driver
.ResizeBuffers
= _swrast_alloc_buffers
;
2073 ctx
->Driver
.GetBufferSize
= buffer_size
;
2075 ctx
->Driver
.Accum
= _swrast_Accum
;
2076 ctx
->Driver
.Bitmap
= _swrast_Bitmap
;
2077 ctx
->Driver
.Clear
= clear
;
2078 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
2079 ctx
->Driver
.DrawPixels
= _swrast_DrawPixels
;
2080 ctx
->Driver
.ReadPixels
= _swrast_ReadPixels
;
2082 ctx
->Driver
.ChooseTextureFormat
= _mesa_choose_tex_format
;
2083 ctx
->Driver
.TexImage1D
= _mesa_store_teximage1d
;
2084 ctx
->Driver
.TexImage2D
= _mesa_store_teximage2d
;
2085 ctx
->Driver
.TexImage3D
= _mesa_store_teximage3d
;
2086 ctx
->Driver
.TexSubImage1D
= _mesa_store_texsubimage1d
;
2087 ctx
->Driver
.TexSubImage2D
= _mesa_store_texsubimage2d
;
2088 ctx
->Driver
.TexSubImage3D
= _mesa_store_texsubimage3d
;
2089 ctx
->Driver
.TestProxyTexImage
= _mesa_test_proxy_teximage
;
2091 ctx
->Driver
.CopyTexImage1D
= _swrast_copy_teximage1d
;
2092 ctx
->Driver
.CopyTexImage2D
= _swrast_copy_teximage2d
;
2093 ctx
->Driver
.CopyTexSubImage1D
= _swrast_copy_texsubimage1d
;
2094 ctx
->Driver
.CopyTexSubImage2D
= _swrast_copy_texsubimage2d
;
2095 ctx
->Driver
.CopyTexSubImage3D
= _swrast_copy_texsubimage3d
;
2096 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
2097 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
2098 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
2099 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;
2101 ctx
->Driver
.BaseCompressedTexFormat
= _mesa_base_compressed_texformat
;
2102 ctx
->Driver
.CompressedTextureSize
= _mesa_compressed_texture_size
;
2103 ctx
->Driver
.GetCompressedTexImage
= _mesa_get_compressed_teximage
;
2105 /* RGB(A) span/pixel functions */
2106 if (osmesa
->format
== OSMESA_RGB
) {
2107 swdd
->WriteRGBASpan
= write_rgba_span_RGB
;
2108 swdd
->WriteRGBSpan
= write_rgb_span_RGB
;
2109 swdd
->WriteMonoRGBASpan
= write_monocolor_span_RGB
;
2110 swdd
->WriteRGBAPixels
= write_rgba_pixels_RGB
;
2111 swdd
->WriteMonoRGBAPixels
= write_monocolor_pixels_RGB
;
2112 swdd
->ReadRGBASpan
= read_rgba_span3
;
2113 swdd
->ReadRGBAPixels
= read_rgba_pixels3
;
2115 else if (osmesa
->format
== OSMESA_BGR
) {
2116 swdd
->WriteRGBASpan
= write_rgba_span_BGR
;
2117 swdd
->WriteRGBSpan
= write_rgb_span_BGR
;
2118 swdd
->WriteMonoRGBASpan
= write_monocolor_span_BGR
;
2119 swdd
->WriteRGBAPixels
= write_rgba_pixels_BGR
;
2120 swdd
->WriteMonoRGBAPixels
= write_monocolor_pixels_BGR
;
2121 swdd
->ReadRGBASpan
= read_rgba_span3
;
2122 swdd
->ReadRGBAPixels
= read_rgba_pixels3
;
2124 else if (osmesa
->format
== OSMESA_RGB_565
) {
2125 swdd
->WriteRGBASpan
= write_rgba_span2
;
2126 swdd
->WriteRGBSpan
= write_rgb_span2
;
2127 swdd
->WriteMonoRGBASpan
= write_monocolor_span2
;
2128 swdd
->WriteRGBAPixels
= write_rgba_pixels2
;
2129 swdd
->WriteMonoRGBAPixels
= write_monocolor_pixels2
;
2130 swdd
->ReadRGBASpan
= read_rgba_span2
;
2131 swdd
->ReadRGBAPixels
= read_rgba_pixels2
;
2134 /* 4 GLchan / pixel in frame buffer */
2135 swdd
->WriteRGBSpan
= write_rgb_span
;
2136 swdd
->WriteRGBAPixels
= write_rgba_pixels
;
2137 swdd
->WriteMonoRGBASpan
= write_monocolor_span
;
2138 swdd
->WriteMonoRGBAPixels
= write_monocolor_pixels
;
2139 if (osmesa
->format
== OSMESA_RGBA
&&
2140 CHAN_TYPE
== GL_UNSIGNED_BYTE
&&
2141 RCOMP
==0 && GCOMP
==1 && BCOMP
==2 && ACOMP
==3) {
2142 /* special, fast case */
2143 swdd
->WriteRGBASpan
= write_rgba_span_rgba
;
2144 swdd
->ReadRGBASpan
= read_rgba_span_rgba
;
2147 swdd
->WriteRGBASpan
= write_rgba_span
;
2148 swdd
->ReadRGBASpan
= read_rgba_span
;
2150 swdd
->ReadRGBAPixels
= read_rgba_pixels
;
2153 /* CI span/pixel functions */
2154 swdd
->WriteCI32Span
= write_index32_span
;
2155 swdd
->WriteCI8Span
= write_index8_span
;
2156 swdd
->WriteMonoCISpan
= write_monoindex_span
;
2157 swdd
->WriteCI32Pixels
= write_index_pixels
;
2158 swdd
->WriteMonoCIPixels
= write_monoindex_pixels
;
2159 swdd
->ReadCI32Span
= read_index_span
;
2160 swdd
->ReadCI32Pixels
= read_index_pixels
;
2162 swdd
->SetReadBuffer
= set_read_buffer
;
2164 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
2166 _swrast_InvalidateState( ctx
, new_state
);
2167 _swsetup_InvalidateState( ctx
, new_state
);
2168 _ac_InvalidateState( ctx
, new_state
);
2169 _tnl_InvalidateState( ctx
, new_state
);