diff options
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 217 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_line.c | 254 | ||||
-rw-r--r-- | src/mesa/swrast/s_lines.c | 752 | ||||
-rw-r--r-- | src/mesa/swrast/s_linetemp.h | 560 |
4 files changed, 412 insertions, 1371 deletions
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 2699890186a..09d52073ed7 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,8 +1,8 @@ -/* $Id: osmesa.c,v 1.97 2002/11/13 16:57:44 brianp Exp $ */ +/* $Id: osmesa.c,v 1.98 2002/11/14 03:48:03 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -393,14 +393,12 @@ do { \ /* * Draw a flat-shaded, RGB line into an osmesa buffer. */ -static void -flat_rgba_line( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) -{ - const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); +#define NAME flat_rgba_line +#define CLIP_HACK 1 +#define SETUP_CODE \ + const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \ const GLchan *color = vert1->color; -#define INTERP_XY 1 -#define CLIP_HACK 1 #define PLOT(X, Y) \ do { \ GLchan *p = PIXELADDR4(X, Y); \ @@ -412,22 +410,20 @@ do { \ #else #include "swrast/s_linetemp.h" #endif -} + /* * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. */ -static void -flat_rgba_z_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1) -{ - const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); - const GLchan *color = vert1->color; - -#define INTERP_XY 1 +#define NAME flat_rgba_z_line +#define CLIP_HACK 1 #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define CLIP_HACK 1 +#define SETUP_CODE \ + const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \ + const GLchan *color = vert1->color; + #define PLOT(X, Y) \ do { \ if (Z < *zPtr) { \ @@ -438,167 +434,13 @@ do { \ } \ } while (0) - #ifdef WIN32 #include "..\swrast\s_linetemp.h" #else #include "swrast/s_linetemp.h" #endif -} -/* - * Draw a flat-shaded, alpha-blended, RGB line into an osmesa buffer. - * XXX update for GLchan - */ -static void -flat_blend_rgba_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); - const GLint rshift = osmesa->rshift; - const GLint gshift = osmesa->gshift; - const GLint bshift = osmesa->bshift; - const GLint avalue = vert0->color[3]; - const GLint msavalue = CHAN_MAX - avalue; - const GLint rvalue = vert1->color[0]*avalue; - const GLint gvalue = vert1->color[1]*avalue; - const GLint bvalue = vert1->color[2]*avalue; - -#define INTERP_XY 1 -#define CLIP_HACK 1 -#define PLOT(X,Y) \ - { GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \ - GLuint pixel = 0; \ - pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift);\ - pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift);\ - pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift);\ - *ptr4 = pixel; \ - } - -#if 0 /* XXX use this in the future */ -#define PLOT(X,Y) \ - { \ - GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \ - pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \ - pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \ - pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \ - pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \ - } -#endif - -#ifdef WIN32 -#include "..\swrast\s_linetemp.h" -#else -#include "swrast/s_linetemp.h" -#endif -} - - -/* - * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. - * But don't write to Z buffer. - * XXX update for GLchan - */ -static void -flat_blend_rgba_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); - const GLint rshift = osmesa->rshift; - const GLint gshift = osmesa->gshift; - const GLint bshift = osmesa->bshift; - const GLint avalue = vert0->color[3]; - const GLint msavalue = 256 - avalue; - const GLint rvalue = vert1->color[0]*avalue; - const GLint gvalue = vert1->color[1]*avalue; - const GLint bvalue = vert1->color[2]*avalue; - -#define INTERP_XY 1 -#define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define CLIP_HACK 1 -#define PLOT(X,Y) \ - if (Z < *zPtr) { \ - GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \ - GLuint pixel = 0; \ - pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \ - pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \ - pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \ - *ptr4 = pixel; \ - } - -#if 0 /* XXX use this in the future */ -#define PLOT(X,Y) \ - if (Z < *zPtr) { \ - GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \ - pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \ - pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \ - pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \ - pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \ - } -#endif - -#ifdef WIN32 -#include "..\swrast\s_linetemp.h" -#else -#include "swrast/s_linetemp.h" -#endif -} - - -/* - * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. - * XXX update for GLchan - */ -static void -flat_blend_rgba_z_line_write( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); - const GLint rshift = osmesa->rshift; - const GLint gshift = osmesa->gshift; - const GLint bshift = osmesa->bshift; - const GLint avalue = vert0->color[3]; - const GLint msavalue = 256 - avalue; - const GLint rvalue = vert1->color[0]*avalue; - const GLint gvalue = vert1->color[1]*avalue; - const GLint bvalue = vert1->color[2]*avalue; - -#define INTERP_XY 1 -#define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define CLIP_HACK 1 -#define PLOT(X,Y) \ - if (Z < *zPtr) { \ - GLuint *ptr4 = (GLuint *) PIXELADDR4(X, Y); \ - GLuint pixel = 0; \ - pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \ - pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \ - pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \ - *ptr4 = pixel; \ - *zPtr = Z; \ - } - -#if 0 /* XXX use this in the future */ -#define PLOT(X,Y) \ - if (Z < *zPtr) { \ - GLchan *pixel = (GLchan *) PIXELADDR4(X, Y); \ - pixel[rInd] = (pixel[rInd] * msavalue + rvalue) >> CHAN_BITS; \ - pixel[gInd] = (pixel[gInd] * msavalue + gvalue) >> CHAN_BITS; \ - pixel[bInd] = (pixel[bInd] * msavalue + bvalue) >> CHAN_BITS; \ - pixel[aInd] = (pixel[aInd] * msavalue + avalue) >> CHAN_BITS; \ - *zPtr = Z; \ - } -#endif - -#ifdef WIN32 -#include "..\swrast\s_linetemp.h" -#else -#include "swrast/s_linetemp.h" -#endif -} - /* * Analyze context state to see if we can provide a fast line drawing @@ -633,39 +475,6 @@ osmesa_choose_line_function( GLcontext *ctx ) return (swrast_line_func) flat_rgba_line; } - if (swrast->_RasterMask==(DEPTH_BIT|BLEND_BIT) - && ctx->Depth.Func==GL_LESS - && ctx->Depth.Mask==GL_TRUE - && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS - && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA - && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendSrcA==GL_SRC_ALPHA - && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { - return (swrast_line_func) flat_blend_rgba_z_line_write; - } - - if (swrast->_RasterMask==(DEPTH_BIT|BLEND_BIT) - && ctx->Depth.Func==GL_LESS - && ctx->Depth.Mask==GL_FALSE - && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS - && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA - && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendSrcA==GL_SRC_ALPHA - && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { - return (swrast_line_func) flat_blend_rgba_z_line; - } - - if (swrast->_RasterMask==BLEND_BIT - && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA - && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendSrcA==GL_SRC_ALPHA - && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA - && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { - return (swrast_line_func) flat_blend_rgba_line; - } - return (swrast_line_func) NULL; } diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c index 989969d024d..55cc5c7790b 100644 --- a/src/mesa/drivers/x11/xm_line.c +++ b/src/mesa/drivers/x11/xm_line.c @@ -1,10 +1,10 @@ -/* $Id: xm_line.c,v 1.20 2002/06/15 03:03:10 brianp Exp $ */ +/* $Id: xm_line.c,v 1.21 2002/11/14 03:48:03 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 5.1 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -123,73 +123,60 @@ void xmesa_choose_point( GLcontext *ctx ) /* * Draw a flat-shaded, PF_TRUECOLOR line into an XImage. */ -static void flat_TRUECOLOR_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - XMesaImage *img = xmesa->xm_buffer->backimage; - unsigned long pixel; +#define NAME flat_TRUECOLOR_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + XMesaImage *img = xmesa->xm_buffer->backimage; \ + unsigned long pixel; \ PACK_TRUECOLOR( pixel, color[0], color[1], color[2] ); - -#define INTERP_XY 1 #define CLIP_HACK 1 #define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); - #include "swrast/s_linetemp.h" -} /* * Draw a flat-shaded, PF_8A8B8G8R line into an XImage. */ -static void flat_8A8B8G8R_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_8A8B8G8R_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] ); - #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = pixel; - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_8R8G8B line into an XImage. */ -static void flat_8R8G8B_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_8R8G8B_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] ); - #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = pixel; - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_8R8G8B24 line into an XImage. */ -static void flat_8R8G8B24_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; +#define NAME flat_8R8G8B24_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ const GLubyte *color = vert1->color; - #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) @@ -199,130 +186,109 @@ static void flat_8R8G8B24_line( GLcontext *ctx, pixelPtr->g = color[GCOMP]; \ pixelPtr->b = color[BCOMP]; \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_5R6G5B line into an XImage. */ -static void flat_5R6G5B_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_5R6G5B_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] ); - #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = pixel; - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage. */ -static void flat_DITHER_5R6G5B_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; +#define NAME flat_DITHER_5R6G5B_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ const GLubyte *color = vert1->color; - #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] ); - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage. */ -static void flat_DITHER8_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - GLint r = color[0], g = color[1], b = color[2]; +#define NAME flat_DITHER8_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + GLint r = color[0], g = color[1], b = color[2]; \ DITHER_SETUP; - -#define INTERP_XY 1 #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b); - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage. */ -static void flat_LOOKUP8_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - GLubyte pixel; - LOOKUP_SETUP; +#define NAME flat_LOOKUP8_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + GLubyte pixel; \ + LOOKUP_SETUP; \ pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] ); - #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = pixel; - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, PF_HPCR line into an XImage. */ -static void flat_HPCR_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_HPCR_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLint r = color[0], g = color[1], b = color[2]; - -#define INTERP_XY 1 #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define CLIP_HACK 1 #define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b); - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage. */ -static void flat_TRUECOLOR_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - XMesaImage *img = xmesa->xm_buffer->backimage; - unsigned long pixel; +#define NAME flat_TRUECOLOR_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + XMesaImage *img = xmesa->xm_buffer->backimage; \ + unsigned long pixel; \ PACK_TRUECOLOR( pixel, color[0], color[1], color[2] ); - -#define INTERP_XY 1 #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define CLIP_HACK 1 @@ -331,21 +297,18 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx, *zPtr = Z; \ XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage. */ -static void flat_8A8B8G8R_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_8A8B8G8R_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] ); - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLuint @@ -357,21 +320,18 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx, *zPtr = Z; \ *pixelPtr = pixel; \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage. */ -static void flat_8R8G8B_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_8R8G8B_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] ); - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLuint @@ -383,20 +343,17 @@ static void flat_8R8G8B_z_line( GLcontext *ctx, *zPtr = Z; \ *pixelPtr = pixel; \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage. */ -static void flat_8R8G8B24_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; +#define NAME flat_8R8G8B24_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ const GLubyte *color = vert1->color; - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE bgr_t @@ -410,21 +367,18 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx, pixelPtr->g = color[GCOMP]; \ pixelPtr->b = color[BCOMP]; \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage. */ -static void flat_5R6G5B_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_5R6G5B_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] ); - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLushort @@ -437,18 +391,16 @@ static void flat_5R6G5B_z_line( GLcontext *ctx, *pixelPtr = pixel; \ } #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage. */ -static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; +#define NAME flat_DITHER_5R6G5B_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ const GLubyte *color = vert1->color; - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLushort @@ -461,21 +413,18 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx, PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \ } #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage. */ -static void flat_DITHER8_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - GLint r = color[0], g = color[1], b = color[2]; +#define NAME flat_DITHER8_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + GLint r = color[0], g = color[1], b = color[2]; \ DITHER_SETUP; - -#define INTERP_XY 1 #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte @@ -488,21 +437,19 @@ static void flat_DITHER8_z_line( GLcontext *ctx, *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \ } #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage. */ -static void flat_LOOKUP8_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; - GLubyte pixel; - LOOKUP_SETUP; +#define NAME flat_LOOKUP8_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ + GLubyte pixel; \ + LOOKUP_SETUP; \ pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] ); - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte @@ -514,22 +461,18 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx, *zPtr = Z; \ *pixelPtr = pixel; \ } - #include "swrast/s_linetemp.h" -} + /* * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage. */ -static void flat_HPCR_z_line( GLcontext *ctx, - const SWvertex *vert0, const SWvertex *vert1 ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = vert1->color; +#define NAME flat_HPCR_z_line +#define SETUP_CODE \ + XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ + const GLubyte *color = vert1->color; \ GLint r = color[0], g = color[1], b = color[2]; - -#define INTERP_XY 1 #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte @@ -541,9 +484,8 @@ static void flat_HPCR_z_line( GLcontext *ctx, *zPtr = Z; \ *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \ } - #include "swrast/s_linetemp.h" -} + static swrast_line_func get_line_func( GLcontext *ctx ) diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 1cb95596836..001b4dc3168 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -1,8 +1,8 @@ -/* $Id: s_lines.c,v 1.32 2002/10/30 19:59:33 brianp Exp $ */ +/* $Id: s_lines.c,v 1.33 2002/11/14 03:48:03 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -127,607 +127,104 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor ) /**********************************************************************/ -/* Flat, color index line */ -static void flat_ci_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLint *x, *y; - struct sw_span span; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - ASSERT(!ctx->Line.StippleFlag); - ASSERT(ctx->Line.Width == 1.0F); - - INIT_SPAN(span, GL_LINE, 0, SPAN_INDEX, SPAN_XY); - span.index = IntToFixed(vert1->index); - span.indexStep = 0; - x = span.array->x; - y = span.array->y; - -#define INTERP_XY 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - span.end++; \ - } - +/* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/ +#define NAME simple_ci_line +#define INTERP_INDEX +#define RENDER_SPAN(span) _mesa_write_index_span(ctx, &span) #include "s_linetemp.h" - _mesa_write_index_span(ctx, &span); -} - - -/* Flat-shaded, RGBA line */ -static void flat_rgba_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - struct sw_span span; - GLint *x, *y; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - ASSERT(!ctx->Line.StippleFlag); - ASSERT(ctx->Line.Width == 1.0F); - - INIT_SPAN(span, GL_LINE, 0, SPAN_RGBA, SPAN_XY); - span.red = ChanToFixed(vert1->color[0]); - span.green = ChanToFixed(vert1->color[1]); - span.blue = ChanToFixed(vert1->color[2]); - span.alpha = ChanToFixed(vert1->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - x = span.array->x; - y = span.array->y; - -#define INTERP_XY 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - span.end++; \ - } +/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/ +#define NAME simple_rgba_line +#define INTERP_RGBA +#define RENDER_SPAN(span) _mesa_write_rgba_span(ctx, &span); #include "s_linetemp.h" - _mesa_write_rgba_span(ctx, &span); -} - -/* Smooth shaded, color index line */ -static void smooth_ci_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - struct sw_span span; - GLint *x, *y; - GLuint *index; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - ASSERT(!ctx->Line.StippleFlag); - ASSERT(ctx->Line.Width == 1.0F); - - INIT_SPAN(span, GL_LINE, 0, 0, SPAN_XY | SPAN_INDEX); - x = span.array->x; - y = span.array->y; - index = span.array->index; - -#define INTERP_XY 1 -#define INTERP_INDEX 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - index[span.end] = I; \ - span.end++; \ +/* Z, fog, wide, stipple color index line */ +#define NAME general_ci_line +#define INTERP_INDEX +#define INTERP_Z +#define INTERP_FOG +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, dx > dy); \ + } \ + else { \ + _mesa_write_index_span(ctx, &span); \ } - #include "s_linetemp.h" - _mesa_write_index_span(ctx, &span); -} - - -/* Smooth-shaded, RGBA line */ -static void smooth_rgba_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - struct sw_span span; - GLint *x, *y; - GLchan (*rgba)[4]; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - ASSERT(!ctx->Line.StippleFlag); - ASSERT(ctx->Line.Width == 1.0F); - - INIT_SPAN(span, GL_LINE, 0, 0, SPAN_XY | SPAN_RGBA); - x = span.array->x; - y = span.array->y; - rgba = span.array->rgba; - -#define INTERP_XY 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - rgba[span.end][RCOMP] = FixedToInt(r0); \ - rgba[span.end][GCOMP] = FixedToInt(g0); \ - rgba[span.end][BCOMP] = FixedToInt(b0); \ - rgba[span.end][ACOMP] = FixedToInt(a0); \ - span.end++; \ - } - -#include "s_linetemp.h" - - _mesa_write_rgba_span(ctx, &span); -} - - -/* Smooth shaded, color index, any width, maybe stippled */ -static void general_smooth_ci_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLint *x, *y; - GLdepth *z; - GLfloat *fog; - GLuint *index; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - - INIT_SPAN(span, GL_LINE, 0, 0, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_INDEX); - x = span.array->x; - y = span.array->y; - z = span.array->z; - fog = span.array->fog; - index = span.array->index; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_INDEX 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - z[span.end] = Z; \ - fog[span.end] = fog0; \ - index[span.end] = I; \ - span.end++; \ - } -#include "s_linetemp.h" - - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_index_span(ctx, &span); - } -} - -/* Flat shaded, color index, any width, maybe stippled */ -static void general_flat_ci_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLint *x, *y; - GLdepth *z; - GLfloat *fog; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - - INIT_SPAN(span, GL_LINE, 0, SPAN_INDEX, - SPAN_XY | SPAN_Z | SPAN_FOG); - span.index = IntToFixed(vert1->index); - span.indexStep = 0; - x = span.array->x; - y = span.array->y; - z = span.array->z; - fog = span.array->fog; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - z[span.end] = Z; \ - fog[span.end] = fog0; \ - span.end++; \ +/* Z, fog, wide, stipple RGBA line */ +#define NAME general_rgba_line +#define INTERP_RGBA +#define INTERP_Z +#define INTERP_FOG +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, dx > dy); \ + } \ + else { \ + _mesa_write_rgba_span(ctx, &span); \ } #include "s_linetemp.h" - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_index_span(ctx, &span); - } -} - - - -static void general_smooth_rgba_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLint *x, *y; - GLdepth *z; - GLchan (*rgba)[4]; - GLfloat *fog; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - - INIT_SPAN(span, GL_LINE, 0, 0, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA); - x = span.array->x; - y = span.array->y; - z = span.array->z; - rgba = span.array->rgba; - fog = span.array->fog; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - z[span.end] = Z; \ - rgba[span.end][RCOMP] = FixedToInt(r0); \ - rgba[span.end][GCOMP] = FixedToInt(g0); \ - rgba[span.end][BCOMP] = FixedToInt(b0); \ - rgba[span.end][ACOMP] = FixedToInt(a0); \ - fog[span.end] = fog0; \ - span.end++; \ +/* Single-texture line, w/ fog, Z, specular, etc. */ +#define NAME textured_line +#define INTERP_RGBA +#define INTERP_Z +#define INTERP_FOG +#define INTERP_TEX +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, dx > dy); \ + } \ + else { \ + _mesa_write_texture_span(ctx, &span); \ } #include "s_linetemp.h" - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_rgba_span(ctx, &span); - } -} - -static void general_flat_rgba_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLint *x, *y; - GLdepth *z; - GLfloat *fog; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - - INIT_SPAN(span, GL_LINE, 0, SPAN_RGBA, - SPAN_XY | SPAN_Z | SPAN_FOG); - span.red = ChanToFixed(vert1->color[0]); - span.green = ChanToFixed(vert1->color[1]); - span.blue = ChanToFixed(vert1->color[2]); - span.alpha = ChanToFixed(vert1->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - x = span.array->x; - y = span.array->y; - z = span.array->z; - fog = span.array->fog; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define PLOT(X,Y) \ - { \ - x[span.end] = X; \ - y[span.end] = Y; \ - z[span.end] = Z; \ - fog[span.end] = fog0; \ - span.end++; \ +/* Multi-texture or separate specular line, w/ fog, Z, specular, etc. */ +#define NAME multitextured_line +#define INTERP_RGBA +#define INTERP_SPEC +#define INTERP_Z +#define INTERP_FOG +#define INTERP_MULTITEX +#define RENDER_SPAN(span) \ + if (ctx->Line.StippleFlag) { \ + span.arrayMask |= SPAN_MASK; \ + compute_stipple_mask(ctx, span.end, span.array->mask); \ + } \ + if (ctx->Line.Width > 1.0) { \ + draw_wide_line(ctx, &span, dx > dy); \ + } \ + else { \ + _mesa_write_texture_span(ctx, &span); \ } #include "s_linetemp.h" - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_rgba_span(ctx, &span); - } -} -/* Flat-shaded, textured, any width, maybe stippled */ -static void flat_textured_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - - INIT_SPAN(span, GL_LINE, 0, SPAN_RGBA | SPAN_SPEC, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_TEXTURE | SPAN_LAMBDA); - span.red = ChanToFixed(vert1->color[0]); - span.green = ChanToFixed(vert1->color[1]); - span.blue = ChanToFixed(vert1->color[2]); - span.alpha = ChanToFixed(vert1->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - span.specRed = ChanToFixed(vert1->specular[0]); - span.specGreen = ChanToFixed(vert1->specular[1]); - span.specBlue = ChanToFixed(vert1->specular[2]); - span.specRedStep = 0; - span.specGreenStep = 0; - span.specBlueStep = 0; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_TEX 1 -#define PLOT(X,Y) \ - { \ - span.array->x[span.end] = X; \ - span.array->y[span.end] = Y; \ - span.array->z[span.end] = Z; \ - span.array->fog[span.end] = fog0; \ - span.array->texcoords[0][span.end][0] = fragTexcoord[0]; \ - span.array->texcoords[0][span.end][1] = fragTexcoord[1]; \ - span.array->texcoords[0][span.end][2] = fragTexcoord[2]; \ - span.array->lambda[0][span.end] = 0.0; \ - span.end++; \ - } -#include "s_linetemp.h" - - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_texture_span(ctx, &span); - } -} - - - -/* Smooth-shaded, textured, any width, maybe stippled */ -static void smooth_textured_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - - INIT_SPAN(span, GL_LINE, 0, 0, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA | SPAN_TEXTURE | SPAN_LAMBDA); - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define INTERP_TEX 1 -#define PLOT(X,Y) \ - { \ - span.array->x[span.end] = X; \ - span.array->y[span.end] = Y; \ - span.array->z[span.end] = Z; \ - span.array->fog[span.end] = fog0; \ - span.array->rgba[span.end][RCOMP] = FixedToInt(r0); \ - span.array->rgba[span.end][GCOMP] = FixedToInt(g0); \ - span.array->rgba[span.end][BCOMP] = FixedToInt(b0); \ - span.array->rgba[span.end][ACOMP] = FixedToInt(a0); \ - span.array->texcoords[0][span.end][0] = fragTexcoord[0]; \ - span.array->texcoords[0][span.end][1] = fragTexcoord[1]; \ - span.array->texcoords[0][span.end][2] = fragTexcoord[2]; \ - span.array->lambda[0][span.end] = 0.0; \ - span.end++; \ - } -#include "s_linetemp.h" - - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_texture_span(ctx, &span); - } -} - - -/* Smooth-shaded, multitextured, any width, maybe stippled, separate specular - * color interpolation. - */ -static void smooth_multitextured_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLuint u; - - ASSERT(ctx->Light.ShadeModel == GL_SMOOTH); - - INIT_SPAN(span, GL_LINE, 0, 0, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA | SPAN_SPEC | SPAN_TEXTURE | SPAN_LAMBDA); - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_RGB 1 -#define INTERP_SPEC 1 -#define INTERP_ALPHA 1 -#define INTERP_MULTITEX 1 -#define PLOT(X,Y) \ - { \ - span.array->x[span.end] = X; \ - span.array->y[span.end] = Y; \ - span.array->z[span.end] = Z; \ - span.array->fog[span.end] = fog0; \ - span.array->rgba[span.end][RCOMP] = FixedToInt(r0); \ - span.array->rgba[span.end][GCOMP] = FixedToInt(g0); \ - span.array->rgba[span.end][BCOMP] = FixedToInt(b0); \ - span.array->rgba[span.end][ACOMP] = FixedToInt(a0); \ - span.array->spec[span.end][RCOMP] = FixedToInt(sr0); \ - span.array->spec[span.end][GCOMP] = FixedToInt(sg0); \ - span.array->spec[span.end][BCOMP] = FixedToInt(sb0); \ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \ - if (ctx->Texture.Unit[u]._ReallyEnabled) { \ - span.array->texcoords[u][span.end][0] = fragTexcoord[u][0]; \ - span.array->texcoords[u][span.end][1] = fragTexcoord[u][1]; \ - span.array->texcoords[u][span.end][2] = fragTexcoord[u][2]; \ - span.array->lambda[u][span.end] = 0.0; \ - } \ - } \ - span.end++; \ - } -#include "s_linetemp.h" - - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_texture_span(ctx, &span); - } -} - - -/* Flat-shaded, multitextured, any width, maybe stippled, separate specular - * color interpolation. - */ -static void flat_multitextured_line( GLcontext *ctx, - const SWvertex *vert0, - const SWvertex *vert1 ) -{ - GLboolean xMajor = GL_FALSE; - struct sw_span span; - GLuint u; - - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - - INIT_SPAN(span, GL_LINE, 0, SPAN_RGBA | SPAN_SPEC, - SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_TEXTURE | SPAN_LAMBDA); - span.red = ChanToFixed(vert1->color[0]); - span.green = ChanToFixed(vert1->color[1]); - span.blue = ChanToFixed(vert1->color[2]); - span.alpha = ChanToFixed(vert1->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - span.specRed = ChanToFixed(vert1->specular[0]); - span.specGreen = ChanToFixed(vert1->specular[1]); - span.specBlue = ChanToFixed(vert1->specular[2]); - span.specRedStep = 0; - span.specGreenStep = 0; - span.specBlueStep = 0; - -#define SET_XMAJOR 1 -#define INTERP_XY 1 -#define INTERP_Z 1 -#define INTERP_FOG 1 -#define INTERP_MULTITEX 1 -#define PLOT(X,Y) \ - { \ - span.array->x[span.end] = X; \ - span.array->y[span.end] = Y; \ - span.array->z[span.end] = Z; \ - span.array->fog[span.end] = fog0; \ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \ - if (ctx->Texture.Unit[u]._ReallyEnabled) { \ - span.array->texcoords[u][span.end][0] = fragTexcoord[u][0]; \ - span.array->texcoords[u][span.end][1] = fragTexcoord[u][1]; \ - span.array->texcoords[u][span.end][2] = fragTexcoord[u][2]; \ - span.array->lambda[u][span.end] = 0.0; \ - } \ - } \ - span.end++; \ - } -#include "s_linetemp.h" - - if (ctx->Line.StippleFlag) { - span.arrayMask |= SPAN_MASK; - compute_stipple_mask(ctx, span.end, span.array->mask); - } - - if (ctx->Line.Width > 1.0) { - draw_wide_line(ctx, &span, xMajor); - } - else { - _mesa_write_texture_span(ctx, &span); - } -} - - -void _swrast_add_spec_terms_line( GLcontext *ctx, - const SWvertex *v0, - const SWvertex *v1 ) +void +_swrast_add_spec_terms_line( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1 ) { SWvertex *ncv0 = (SWvertex *)v0; SWvertex *ncv1 = (SWvertex *)v1; @@ -751,30 +248,18 @@ _mesa_print_line_function(GLcontext *ctx) SWcontext *swrast = SWRAST_CONTEXT(ctx); _mesa_printf("Line Func == "); - if (swrast->Line == flat_ci_line) - _mesa_printf("flat_ci_line\n"); - else if (swrast->Line == flat_rgba_line) - _mesa_printf("flat_rgba_line\n"); - else if (swrast->Line == smooth_ci_line) - _mesa_printf("smooth_ci_line\n"); - else if (swrast->Line == smooth_rgba_line) - _mesa_printf("smooth_rgba_line\n"); - else if (swrast->Line == general_smooth_ci_line) - _mesa_printf("general_smooth_ci_line\n"); - else if (swrast->Line == general_flat_ci_line) - _mesa_printf("general_flat_ci_line\n"); - else if (swrast->Line == general_smooth_rgba_line) - _mesa_printf("general_smooth_rgba_line\n"); - else if (swrast->Line == general_flat_rgba_line) - _mesa_printf("general_flat_rgba_line\n"); - else if (swrast->Line == flat_textured_line) - _mesa_printf("flat_textured_line\n"); - else if (swrast->Line == smooth_textured_line) - _mesa_printf("smooth_textured_line\n"); - else if (swrast->Line == smooth_multitextured_line) - _mesa_printf("smooth_multitextured_line\n"); - else if (swrast->Line == flat_multitextured_line) - _mesa_printf("flat_multitextured_line\n"); + if (swrast->Line == simple_ci_line) + _mesa_printf("simple_ci_line\n"); + else if (swrast->Line == simple_rgba_line) + _mesa_printf("simple_rgba_line\n"); + else if (swrast->Line == general_ci_line) + _mesa_printf("general_ci_line\n"); + else if (swrast->Line == general_rgba_line) + _mesa_printf("general_rgba_line\n"); + else if (swrast->Line == textured_line) + _mesa_printf("textured_line\n"); + else if (swrast->Line == multitextured_line) + _mesa_printf("multitextured_line\n"); else _mesa_printf("Driver func %p\n", (void *) swrast->Line); } @@ -822,54 +307,29 @@ _swrast_choose_line( GLcontext *ctx ) ASSERT(swrast->Triangle); } else if (ctx->Texture._EnabledUnits) { - if (ctx->Texture._EnabledUnits > 1 || - (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) { + /* textured lines */ + if (ctx->Texture._EnabledUnits > 0x1 || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) { /* multi-texture and/or separate specular color */ - if (ctx->Light.ShadeModel == GL_SMOOTH) - USE(smooth_multitextured_line); - else - USE(flat_multitextured_line); + USE(multitextured_line); } else { - if (ctx->Light.ShadeModel == GL_SMOOTH) { - USE(smooth_textured_line); - } - else { - USE(flat_textured_line); - } + USE(textured_line); } } + else if (ctx->Depth.Test || ctx->Fog.Enabled || ctx->Line.Width != 1.0 + || ctx->Line.StippleFlag) { + /* no texture, but Z, fog, width>1, stipple, etc. */ + if (rgbmode) + USE(general_rgba_line); + else + USE(general_ci_line); + } else { - if (ctx->Light.ShadeModel == GL_SMOOTH) { - if (ctx->Depth.Test || ctx->Fog.Enabled || ctx->Line.Width != 1.0 - || ctx->Line.StippleFlag) { - if (rgbmode) - USE(general_smooth_rgba_line); - else - USE(general_smooth_ci_line); - } - else { - if (rgbmode) - USE(smooth_rgba_line); - else - USE(smooth_ci_line); - } - } - else { - if (ctx->Depth.Test || ctx->Fog.Enabled || ctx->Line.Width != 1.0 - || ctx->Line.StippleFlag) { - if (rgbmode) - USE(general_flat_rgba_line); - else - USE(general_flat_ci_line); - } - else { - if (rgbmode) - USE(flat_rgba_line); - else - USE(flat_ci_line); - } - } + /* simplest lines */ + if (rgbmode) + USE(simple_rgba_line); + else + USE(simple_ci_line); } } else if (ctx->RenderMode == GL_FEEDBACK) { diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 1fb14dcd10a..4d21d1c9daf 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -1,8 +1,8 @@ -/* $Id: s_linetemp.h,v 1.14 2002/11/09 21:26:41 brianp Exp $ */ +/* $Id: s_linetemp.h,v 1.15 2002/11/14 03:48:03 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -34,9 +34,8 @@ * must be interplated along the line: * INTERP_Z - if defined, interpolate Z values * INTERP_FOG - if defined, interpolate FOG values - * INTERP_RGB - if defined, interpolate RGB values + * INTERP_RGBA - if defined, interpolate RGBA values * INTERP_SPEC - if defined, interpolate specular RGB values - * INTERP_ALPHA - if defined, interpolate Alpha values * INTERP_INDEX - if defined, interpolate color index values * INTERP_TEX - if defined, interpolate unit 0 texcoords * INTERP_MULTITEX - if defined, interpolate multi-texcoords @@ -70,100 +69,35 @@ */ -/*void line( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )*/ +static void +NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) { + struct sw_span span; + GLuint interpFlags = 0; + GLuint arrayFlags = SPAN_XY; GLint x0 = (GLint) vert0->win[0]; GLint x1 = (GLint) vert1->win[0]; GLint y0 = (GLint) vert0->win[1]; GLint y1 = (GLint) vert1->win[1]; GLint dx, dy; -#ifdef INTERP_XY + GLint numPixels; GLint xstep, ystep; -#endif -#ifdef INTERP_Z - GLint z0, z1, dz; +#if defined(DEPTH_TYPE) const GLint depthBits = ctx->Visual.depthBits; const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; -# define FixedToDepth(F) ((F) >> fixedToDepthShift) -# ifdef DEPTH_TYPE +#define FixedToDepth(F) ((F) >> fixedToDepthShift) GLint zPtrXstep, zPtrYstep; DEPTH_TYPE *zPtr; -# endif -#endif -#ifdef INTERP_FOG - GLfloat fog0 = vert0->fog; - GLfloat dfog = vert1->fog - fog0; -#endif -#ifdef INTERP_RGB - GLfixed r0 = ChanToFixed(vert0->color[0]); - GLfixed dr = ChanToFixed(vert1->color[0]) - r0; - GLfixed g0 = ChanToFixed(vert0->color[1]); - GLfixed dg = ChanToFixed(vert1->color[1]) - g0; - GLfixed b0 = ChanToFixed(vert0->color[2]); - GLfixed db = ChanToFixed(vert1->color[2]) - b0; -#endif -#ifdef INTERP_SPEC - GLfixed sr0 = ChanToFixed(vert0->specular[0]); - GLfixed dsr = ChanToFixed(vert1->specular[0]) - sr0; - GLfixed sg0 = ChanToFixed(vert0->specular[1]); - GLfixed dsg = ChanToFixed(vert1->specular[1]) - sg0; - GLfixed sb0 = ChanToFixed(vert0->specular[2]); - GLfixed dsb = ChanToFixed(vert1->specular[2]) - sb0; -#endif -#ifdef INTERP_ALPHA - GLfixed a0 = ChanToFixed(vert0->color[3]); - GLfixed da = ChanToFixed(vert1->color[3]) - a0; -#endif -#ifdef INTERP_INDEX - GLint i0 = vert0->index << 8; - GLint di = (GLint) (vert1->index << 8) - i0; -#endif -#ifdef INTERP_TEX - const GLfloat invw0 = vert0->win[3]; - const GLfloat invw1 = vert1->win[3]; - GLfloat tex[4]; - GLfloat dtex[4]; - GLfloat fragTexcoord[4]; -#endif -#ifdef INTERP_MULTITEX - const GLfloat invw0 = vert0->win[3]; - const GLfloat invw1 = vert1->win[3]; - GLfloat tex[MAX_TEXTURE_UNITS][4]; - GLfloat dtex[MAX_TEXTURE_UNITS][4]; - GLfloat fragTexcoord[MAX_TEXTURE_UNITS][4]; +#elif defined(INTERP_Z) + const GLint depthBits = ctx->Visual.depthBits; #endif #ifdef PIXEL_ADDRESS PIXEL_TYPE *pixelPtr; GLint pixelXstep, pixelYstep; #endif -#ifdef INTERP_TEX - { - tex[0] = invw0 * vert0->texcoord[0][0]; - dtex[0] = invw1 * vert1->texcoord[0][0] - tex[0]; - tex[1] = invw0 * vert0->texcoord[0][1]; - dtex[1] = invw1 * vert1->texcoord[0][1] - tex[1]; - tex[2] = invw0 * vert0->texcoord[0][2]; - dtex[2] = invw1 * vert1->texcoord[0][2] - tex[2]; - tex[3] = invw0 * vert0->texcoord[0][3]; - dtex[3] = invw1 * vert1->texcoord[0][3] - tex[3]; - } -#endif -#ifdef INTERP_MULTITEX - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - tex[u][0] = invw0 * vert0->texcoord[u][0]; - dtex[u][0] = invw1 * vert1->texcoord[u][0] - tex[u][0]; - tex[u][1] = invw0 * vert0->texcoord[u][1]; - dtex[u][1] = invw1 * vert1->texcoord[u][1] - tex[u][1]; - tex[u][2] = invw0 * vert0->texcoord[u][2]; - dtex[u][2] = invw1 * vert1->texcoord[u][2] - tex[u][2]; - tex[u][3] = invw0 * vert0->texcoord[u][3]; - dtex[u][3] = invw1 * vert1->texcoord[u][3] - tex[u][3]; - } - } - } + +#ifdef SETUP_CODE + SETUP_CODE #endif /* Cull primitives with malformed coordinates. @@ -174,6 +108,27 @@ return; } +#ifdef INTERP_RGBA + interpFlags |= SPAN_RGBA; +#endif +#ifdef INTERP_SPEC + interpFlags |= SPAN_SPEC; +#endif +#ifdef INTERP_INDEX + interpFlags |= SPAN_INDEX; +#endif +#ifdef INTERP_Z + interpFlags |= SPAN_Z; +#endif +#ifdef INTERP_FOG + interpFlags |= SPAN_FOG; +#endif +#if defined(INTERP_TEX) || defined(INTERP_MULTITEX) + interpFlags |= SPAN_TEXTURE; +#endif + + INIT_SPAN(span, GL_LINE, 0, interpFlags, arrayFlags); + /* printf("%s():\n", __FUNCTION__); printf(" (%f, %f, %f) -> (%f, %f, %f)\n", @@ -212,31 +167,14 @@ } } #endif + dx = x1 - x0; dy = y1 - y0; - if (dx==0 && dy==0) { + if (dx == 0 && dy == 0) return; - } - /* - * Setup - */ -#ifdef SETUP_CODE - SETUP_CODE -#endif - -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0); -# endif - if (depthBits <= 16) { - z0 = FloatToFixed(vert0->win[2]) + FIXED_HALF; - z1 = FloatToFixed(vert1->win[2]) + FIXED_HALF; - } - else { - z0 = (int) vert0->win[2]; - z1 = (int) vert1->win[2]; - } +#ifdef DEPTH_TYPE + zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0); #endif #ifdef PIXEL_ADDRESS pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0); @@ -244,10 +182,8 @@ if (dx<0) { dx = -dx; /* make positive */ -#ifdef INTERP_XY xstep = -1; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtrXstep = -((GLint)sizeof(DEPTH_TYPE)); #endif #ifdef PIXEL_ADDRESS @@ -255,10 +191,8 @@ #endif } else { -#ifdef INTERP_XY xstep = 1; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtrXstep = ((GLint)sizeof(DEPTH_TYPE)); #endif #ifdef PIXEL_ADDRESS @@ -268,10 +202,8 @@ if (dy<0) { dy = -dy; /* make positive */ -#ifdef INTERP_XY ystep = -1; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtrYstep = -((GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE))); #endif #ifdef PIXEL_ADDRESS @@ -279,10 +211,8 @@ #endif } else { -#ifdef INTERP_XY ystep = 1; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtrYstep = (GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE)); #endif #ifdef PIXEL_ADDRESS @@ -290,146 +220,157 @@ #endif } - /* - * Draw - */ + ASSERT(dx >= 0); + ASSERT(dy >= 0); - if (dx>dy) { - /*** X-major line ***/ - GLint i; - GLint errorInc = dy+dy; - GLint error = errorInc-dx; - GLint errorDec = error-dx; -#ifdef SET_XMAJOR - xMajor = GL_TRUE; -#endif -#ifdef INTERP_Z - dz = (z1-z0) / dx; -#endif -#ifdef INTERP_FOG - dfog /= dx; -#endif -#ifdef INTERP_RGB - dr /= dx; /* convert from whole line delta to per-pixel delta */ - dg /= dx; - db /= dx; + span.end = numPixels = MAX2(dx, dy); + +#ifdef INTERP_RGBA + if (ctx->Light.ShadeModel == GL_SMOOTH) { + span.red = ChanToFixed(vert0->color[0]); + span.green = ChanToFixed(vert0->color[1]); + span.blue = ChanToFixed(vert0->color[2]); + span.alpha = ChanToFixed(vert0->color[3]); + span.redStep = (ChanToFixed(vert1->color[0]) - span.red ) / numPixels; + span.greenStep = (ChanToFixed(vert1->color[1]) - span.green) / numPixels; + span.blueStep = (ChanToFixed(vert1->color[2]) - span.blue ) / numPixels; + span.alphaStep = (ChanToFixed(vert1->color[3]) - span.alpha) / numPixels; + } + else { + span.red = ChanToFixed(vert1->color[0]); + span.green = ChanToFixed(vert1->color[1]); + span.blue = ChanToFixed(vert1->color[2]); + span.alpha = ChanToFixed(vert1->color[3]); + span.redStep = 0; + span.greenStep = 0; + span.blueStep = 0; + span.alphaStep = 0; + } #endif #ifdef INTERP_SPEC - dsr /= dx; /* convert from whole line delta to per-pixel delta */ - dsg /= dx; - dsb /= dx; -#endif -#ifdef INTERP_ALPHA - da /= dx; + if (ctx->Light.ShadeModel == GL_SMOOTH) { + span.specRed = ChanToFixed(vert0->specular[0]); + span.specGreen = ChanToFixed(vert0->specular[1]); + span.specBlue = ChanToFixed(vert0->specular[2]); + span.specRedStep = (ChanToFixed(vert1->specular[0]) - span.specRed) / numPixels; + span.specGreenStep = (ChanToFixed(vert1->specular[1]) - span.specBlue) / numPixels; + span.specBlueStep = (ChanToFixed(vert1->specular[2]) - span.specGreen) / numPixels; + } + else { + span.specRed = ChanToFixed(vert1->specular[0]); + span.specGreen = ChanToFixed(vert1->specular[1]); + span.specBlue = ChanToFixed(vert1->specular[2]); + span.specRedStep = 0; + span.specGreenStep = 0; + span.specBlueStep = 0; + } #endif #ifdef INTERP_INDEX - di /= dx; + if (ctx->Light.ShadeModel == GL_SMOOTH) { + span.index = IntToFixed(vert0->index); + span.indexStep = IntToFixed(vert1->index - vert0->index) / numPixels; + } + else { + span.index = IntToFixed(vert1->index); + span.indexStep = 0; + } #endif -#ifdef INTERP_TEX - { - const GLfloat invDx = 1.0F / (GLfloat) dx; - dtex[0] *= invDx; - dtex[1] *= invDx; - dtex[2] *= invDx; - dtex[3] *= invDx; +#if defined(INTERP_Z) || defined(DEPTH_TYPE) + { + if (depthBits <= 16) { + span.z = FloatToFixed(vert0->win[2]) + FIXED_HALF; + span.zStep = FloatToFixed(vert1->win[2] - vert0->win[2]) / numPixels; } -#endif -#ifdef INTERP_MULTITEX - { - const GLfloat invDx = 1.0F / (GLfloat) dx; - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - dtex[u][0] *= invDx; - dtex[u][1] *= invDx; - dtex[u][2] *= invDx; - dtex[u][3] *= invDx; - } - } + else { + span.z = vert0->win[2]; + span.zStep = (vert1->win[2] - vert0->win[2]) / numPixels; } + } #endif - - for (i=0;i<dx;i++) { -#ifdef INTERP_Z - GLdepth Z = FixedToDepth(z0); -#endif -#ifdef INTERP_INDEX - GLint I = i0 >> 8; +#ifdef INTERP_FOG + span.fog = vert0->fog; + span.fogStep = (vert1->fog - vert0->fog) / numPixels; #endif #ifdef INTERP_TEX - { - const GLfloat invQ = tex[3] ? (1.0F / tex[3]) : 1.0F; - fragTexcoord[0] = tex[0] * invQ; - fragTexcoord[1] = tex[1] * invQ; - fragTexcoord[2] = tex[2] * invQ; - fragTexcoord[3] = tex[3]; - } + { + const GLfloat invw0 = vert0->win[3]; + const GLfloat invw1 = vert1->win[3]; + const GLfloat invLen = 1.0F / numPixels; + GLfloat ds, dt, dr, dq; + span.tex[0][0] = invw0 * vert0->texcoord[0][0]; + span.tex[0][1] = invw0 * vert0->texcoord[0][1]; + span.tex[0][2] = invw0 * vert0->texcoord[0][2]; + span.tex[0][3] = invw0 * vert0->texcoord[0][3]; + ds = (invw1 * vert1->texcoord[0][0]) - span.tex[0][0]; + dt = (invw1 * vert1->texcoord[0][1]) - span.tex[0][1]; + dr = (invw1 * vert1->texcoord[0][2]) - span.tex[0][2]; + dq = (invw1 * vert1->texcoord[0][3]) - span.tex[0][3]; + span.texStepX[0][0] = ds * invLen; + span.texStepX[0][1] = dt * invLen; + span.texStepX[0][2] = dr * invLen; + span.texStepX[0][3] = dq * invLen; + span.texStepY[0][0] = 0.0F; + span.texStepY[0][1] = 0.0F; + span.texStepY[0][2] = 0.0F; + span.texStepY[0][3] = 0.0F; + } #endif #ifdef INTERP_MULTITEX - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - const GLfloat invQ = 1.0F / tex[u][3]; - fragTexcoord[u][0] = tex[u][0] * invQ; - fragTexcoord[u][1] = tex[u][1] * invQ; - fragTexcoord[u][2] = tex[u][2] * invQ; - fragTexcoord[u][3] = tex[u][3]; - } - } - } + { + const GLfloat invLen = 1.0F / numPixels; + GLuint u; + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + const GLfloat invw0 = vert0->win[3]; + const GLfloat invw1 = vert1->win[3]; + GLfloat ds, dt, dr, dq; + span.tex[u][0] = invw0 * vert0->texcoord[u][0]; + span.tex[u][1] = invw0 * vert0->texcoord[u][1]; + span.tex[u][2] = invw0 * vert0->texcoord[u][2]; + span.tex[u][3] = invw0 * vert0->texcoord[u][3]; + ds = (invw1 * vert1->texcoord[u][0]) - span.tex[u][0]; + dt = (invw1 * vert1->texcoord[u][1]) - span.tex[u][1]; + dr = (invw1 * vert1->texcoord[u][2]) - span.tex[u][2]; + dq = (invw1 * vert1->texcoord[u][3]) - span.tex[u][3]; + span.texStepX[u][0] = ds * invLen; + span.texStepX[u][1] = dt * invLen; + span.texStepX[u][2] = dr * invLen; + span.texStepX[u][3] = dq * invLen; + span.texStepY[u][0] = 0.0F; + span.texStepY[u][1] = 0.0F; + span.texStepY[u][2] = 0.0F; + span.texStepY[u][3] = 0.0F; + } + } + } #endif - PLOT( x0, y0 ); + /* + * Draw + */ -#ifdef INTERP_XY - x0 += xstep; -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); -# endif - z0 += dz; -#endif -#ifdef INTERP_FOG - fog0 += dfog; -#endif -#ifdef INTERP_RGB - r0 += dr; - g0 += dg; - b0 += db; -#endif -#ifdef INTERP_SPEC - sr0 += dsr; - sg0 += dsg; - sb0 += dsb; -#endif -#ifdef INTERP_ALPHA - a0 += da; -#endif -#ifdef INTERP_INDEX - i0 += di; + if (dx > dy) { + /*** X-major line ***/ + GLint i; + GLint errorInc = dy+dy; + GLint error = errorInc-dx; + GLint errorDec = error-dx; + + for (i = 0; i < dx; i++) { +#ifdef DEPTH_TYPE + GLdepth Z = FixedToDepth(span.z); #endif -#ifdef INTERP_TEX - tex[0] += dtex[0]; - tex[1] += dtex[1]; - tex[2] += dtex[2]; - tex[3] += dtex[3]; +#ifdef PLOT + PLOT( x0, y0 ); +#else + span.array->x[i] = x0; + span.array->y[i] = y0; #endif -#ifdef INTERP_MULTITEX - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - tex[u][0] += dtex[u][0]; - tex[u][1] += dtex[u][1]; - tex[u][2] += dtex[u][2]; - tex[u][3] += dtex[u][3]; - } - } - } + x0 += xstep; +#ifdef DEPTH_TYPE + zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); + span.z += span.zStep; #endif - #ifdef PIXEL_ADDRESS pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); #endif @@ -438,10 +379,8 @@ } else { error += errorDec; -#ifdef INTERP_XY y0 += ystep; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); #endif #ifdef PIXEL_ADDRESS @@ -456,131 +395,21 @@ GLint errorInc = dx+dx; GLint error = errorInc-dy; GLint errorDec = error-dy; -#ifdef INTERP_Z - dz = (z1-z0) / dy; -#endif -#ifdef INTERP_FOG - dfog /= dy; -#endif -#ifdef INTERP_RGB - dr /= dy; /* convert from whole line delta to per-pixel delta */ - dg /= dy; - db /= dy; -#endif -#ifdef INTERP_SPEC - dsr /= dy; /* convert from whole line delta to per-pixel delta */ - dsg /= dy; - dsb /= dy; -#endif -#ifdef INTERP_ALPHA - da /= dy; -#endif -#ifdef INTERP_INDEX - di /= dy; -#endif -#ifdef INTERP_TEX - { - const GLfloat invDy = 1.0F / (GLfloat) dy; - dtex[0] *= invDy; - dtex[1] *= invDy; - dtex[2] *= invDy; - dtex[3] *= invDy; - } -#endif -#ifdef INTERP_MULTITEX - { - const GLfloat invDy = 1.0F / (GLfloat) dy; - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - dtex[u][0] *= invDy; - dtex[u][1] *= invDy; - dtex[u][2] *= invDy; - dtex[u][3] *= invDy; - } - } - } -#endif for (i=0;i<dy;i++) { -#ifdef INTERP_Z - GLdepth Z = FixedToDepth(z0); +#ifdef DEPTH_TYPE + GLdepth Z = FixedToDepth(span.z); #endif -#ifdef INTERP_INDEX - GLint I = i0 >> 8; +#ifdef PLOT + PLOT( x0, y0 ); +#else + span.array->x[i] = x0; + span.array->y[i] = y0; #endif -#ifdef INTERP_TEX - { - const GLfloat invQ = tex[3] ? (1.0F / tex[3]) : 1.0F; - fragTexcoord[0] = tex[0] * invQ; - fragTexcoord[1] = tex[1] * invQ; - fragTexcoord[2] = tex[2] * invQ; - fragTexcoord[3] = tex[3]; - } -#endif -#ifdef INTERP_MULTITEX - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - const GLfloat invQ = 1.0F / tex[u][3]; - fragTexcoord[u][0] = tex[u][0] * invQ; - fragTexcoord[u][1] = tex[u][1] * invQ; - fragTexcoord[u][2] = tex[u][2] * invQ; - fragTexcoord[u][3] = tex[u][3]; - } - } - } -#endif - - PLOT( x0, y0 ); - -#ifdef INTERP_XY y0 += ystep; -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE +#ifdef DEPTH_TYPE zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); -# endif - z0 += dz; -#endif -#ifdef INTERP_FOG - fog0 += dfog; -#endif -#ifdef INTERP_RGB - r0 += dr; - g0 += dg; - b0 += db; -#endif -#ifdef INTERP_SPEC - sr0 += dsr; - sg0 += dsg; - sb0 += dsb; -#endif -#ifdef INTERP_ALPHA - a0 += da; -#endif -#ifdef INTERP_INDEX - i0 += di; -#endif -#ifdef INTERP_TEX - tex[0] += dtex[0]; - tex[1] += dtex[1]; - tex[2] += dtex[2]; - tex[3] += dtex[3]; -#endif -#ifdef INTERP_MULTITEX - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u]._ReallyEnabled) { - tex[u][0] += dtex[u][0]; - tex[u][1] += dtex[u][1]; - tex[u][2] += dtex[u][2]; - tex[u][3] += dtex[u][3]; - } - } - } + span.z += span.zStep; #endif #ifdef PIXEL_ADDRESS pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep); @@ -590,10 +419,8 @@ } else { error += errorDec; -#ifdef INTERP_XY x0 += xstep; -#endif -#if defined(INTERP_Z) && defined(DEPTH_TYPE) +#ifdef DEPTH_TYPE zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); #endif #ifdef PIXEL_ADDRESS @@ -603,15 +430,18 @@ } } +#ifdef RENDER_SPAN + RENDER_SPAN( span ); +#endif + } -#undef INTERP_XY +#undef NAME #undef INTERP_Z #undef INTERP_FOG -#undef INTERP_RGB +#undef INTERP_RGBA #undef INTERP_SPEC -#undef INTERP_ALPHA #undef INTERP_TEX #undef INTERP_MULTITEX #undef INTERP_INDEX @@ -623,4 +453,4 @@ #undef PLOT #undef CLIP_HACK #undef FixedToDepth -#undef SET_XMAJOR +#undef RENDER_SPAN |