X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fx11%2Fxm_tri.c;h=17bbc27a5c53d09c31713d42774247209b30c9ed;hb=66ab7271016615cf485fb0b71832833d2e0f99a7;hp=a25d58092b8dfb2ed6c957f10018cd36202d327e;hpb=c19d783e0715ac01ad4d3fd0705500d2bf6f7039;p=mesa.git diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index a25d58092b8..17bbc27a5c5 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1,21 +1,21 @@ -/* $Id: xm_tri.c,v 1.9 2000/11/14 17:40:15 brianp Exp $ */ +/* $Id: xm_tri.c,v 1.29 2002/10/30 20:24:47 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. - * + * Version: 4.1 + * + * 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"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -35,8 +35,9 @@ #include "glxheader.h" #include "depth.h" #include "macros.h" -#include "vb.h" -#include "types.h" +#include "imports.h" +#include "mmath.h" +#include "mtypes.h" #include "xmesaP.h" /* Internal swrast includes: @@ -47,7 +48,6 @@ - /**********************************************************************/ /*** Triangle rendering ***/ /**********************************************************************/ @@ -57,32 +57,34 @@ * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle. */ static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \ - GLint len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + GLuint i; \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + unsigned long p; \ + PACK_TRUECOLOR(p, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + XMesaPutPixel(img, x, y, p); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -92,9 +94,9 @@ static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx, * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle. */ static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -103,21 +105,22 @@ static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;iDriverCtx; #define INTERP_Z 1 @@ -137,21 +140,22 @@ static void smooth_8R8G8B_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;iDriverCtx; #define INTERP_Z 1 @@ -171,23 +175,24 @@ static void smooth_8R8G8B24_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ir = FixedToInt(ffr); \ - ptr->g = FixedToInt(ffg); \ - ptr->b = FixedToInt(ffb); \ - zRow[i] = z; \ - } \ - ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \ - ffz += fdzdx; \ - } \ -} + +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + PIXEL_TYPE *ptr = pRow + i; \ + ptr->r = FixedToInt(span.red); \ + ptr->g = FixedToInt(span.green); \ + ptr->b = FixedToInt(span.blue); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -196,32 +201,34 @@ static void smooth_8R8G8B24_z_triangle( GLcontext *ctx, * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle. */ static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + unsigned long p; \ + PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + XMesaPutPixel(img, x, y, p); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -230,9 +237,9 @@ static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx, * XImage, smooth, depth-buffered, PF_5R6G5B triangle. */ static void smooth_5R6G5B_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -241,21 +248,22 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;iDriverCtx; #define INTERP_Z 1 @@ -275,21 +283,23 @@ static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -298,9 +308,9 @@ static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx, * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle. */ static void smooth_DITHER8_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -309,22 +319,24 @@ static void smooth_DITHER8_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - XDITHER_SETUP(yy); \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + XDITHER_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red),\ + FixedToInt(span.green), FixedToInt(span.blue) ); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -333,35 +345,34 @@ static void smooth_DITHER8_z_triangle( GLcontext *ctx, * XImage, smooth, depth-buffered, PF_DITHER triangle. */ static void smooth_DITHER_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 -#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) -#define PIXEL_TYPE GLubyte -#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - XDITHER_SETUP(yy); \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + XDITHER_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + unsigned long p = XDITHER(x, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + XMesaPutPixel(img, x, y, p); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -369,10 +380,10 @@ static void smooth_DITHER_z_triangle( GLcontext *ctx, /* * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle. */ -static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -381,22 +392,23 @@ static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - LOOKUP_SETUP; \ - (void) fffog; \ - for (i=0;iDriverCtx; #define INTERP_Z 1 @@ -417,21 +429,23 @@ static void smooth_HPCR_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue) ); \ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -440,9 +454,9 @@ static void smooth_HPCR_z_triangle( GLcontext *ctx, * XImage, flat, depth-buffered, PF_TRUECOLOR triangle. */ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; @@ -450,21 +464,20 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx, #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ unsigned long pixel; \ - PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]); - -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0], v2->color[1], v2->color[2]); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + XMesaPutPixel(img, x, y, pixel); \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -472,10 +485,10 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_8A8B8G8R triangle. */ -static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -484,21 +497,19 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ - unsigned long p = PACK_8B8G8R( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + pRow[i] = (PIXEL_TYPE) p; \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -506,10 +517,10 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_8R8G8B triangle. */ -static void flat_8R8G8B_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_8R8G8B_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -517,22 +528,20 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - unsigned long p = PACK_8R8G8B( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + pRow[i] = (PIXEL_TYPE) p; \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -540,34 +549,32 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_8R8G8B24 triangle. */ -static void flat_8R8G8B24_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_8R8G8B24_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = v0->color; + const GLubyte *color = v2->color; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ir = color[RCOMP]; \ ptr->g = color[GCOMP]; \ ptr->b = color[BCOMP]; \ zRow[i] = z; \ } \ - ffz += fdzdx; \ - } \ -} + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -575,31 +582,30 @@ static void flat_8R8G8B24_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_TRUEDITHER triangle. */ -static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0], \ - v0->color[1], v0->color[2] ); \ - XMesaPutPixel( img, xx, yy, p ); \ - zRow[i] = z; \ - } \ - ffz += fdzdx; \ - } \ -} +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + unsigned long p; \ + PACK_TRUEDITHER(p, x, y, v2->color[0], \ + v2->color[1], v2->color[2]); \ + XMesaPutPixel(img, x, y, p); \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -607,10 +613,10 @@ static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_5R6G5B triangle. */ -static void flat_5R6G5B_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_5R6G5B_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -618,22 +624,20 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - unsigned long p = PACK_5R6G5B( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ if (z < zRow[i]) { \ pRow[i] = (PIXEL_TYPE) p; \ zRow[i] = z; \ } \ - ffz += fdzdx; \ - } \ -} + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -641,32 +645,31 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle. */ -static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = v0->color; + const GLubyte *color = v2->color; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;ixm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ if (z < zRow[i]) { \ - PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \ + PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \ color[GCOMP], color[BCOMP]); \ zRow[i] = z; \ } \ - ffz += fdzdx; \ - } \ -} + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -674,10 +677,10 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle. */ -static void flat_DITHER8_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_DITHER8_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -686,22 +689,21 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx, #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ - FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] ); - -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, len = RIGHT-LEFT; \ - FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \ - (void) fffog; \ - for (i=0;icolor[0], v2->color[1], v2->color[2] ); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ if (z < zRow[i]) { \ - pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \ + pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \ zRow[i] = z; \ } \ - ffz += fdzdx; \ - } \ -} + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -709,33 +711,32 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, PF_DITHER triangle. */ -static void flat_DITHER_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_DITHER_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ - FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] ); - -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - FLAT_DITHER_ROW_SETUP(yy); \ - (void) fffog; \ - for (i=0;icolor[0], v2->color[1], v2->color[2] ); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + FLAT_DITHER_ROW_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + unsigned long p = FLAT_DITHER(x); \ + XMesaPutPixel(img, x, y, p); \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -743,10 +744,10 @@ static void flat_DITHER_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle. */ -static void flat_HPCR_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_HPCR_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -754,23 +755,22 @@ static void flat_HPCR_z_triangle( GLcontext *ctx, #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - GLubyte r = v0->color[0]; \ - GLubyte g = v0->color[1]; \ - GLubyte b = v0->color[2]; -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;icolor[0]; \ + GLubyte g = v2->color[1]; \ + GLubyte b = v2->color[2]; +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + #include "swrast/s_tritemp.h" } @@ -778,10 +778,10 @@ static void flat_HPCR_z_triangle( GLcontext *ctx, /* * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle. */ -static void flat_LOOKUP8_z_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_LOOKUP8_z_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 @@ -791,23 +791,21 @@ static void flat_LOOKUP8_z_triangle( GLcontext *ctx, #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ LOOKUP_SETUP; \ - GLubyte r = v0->color[0]; \ - GLubyte g = v0->color[1]; \ - GLubyte b = v0->color[2]; \ + GLubyte r = v2->color[0]; \ + GLubyte g = v2->color[1]; \ + GLubyte b = v2->color[2]; \ GLubyte p = LOOKUP(r,g,b); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint i, len = RIGHT-LEFT; \ - (void) fffog; \ - for (i=0;iDriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_RGB 1 -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - for (xx=LEFT;xxxm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + unsigned long p; \ + PACK_TRUECOLOR(p, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + XMesaPutPixel(img, x, y, p); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -841,26 +842,26 @@ static void smooth_TRUECOLOR_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle. */ -static void smooth_8A8B8G8R_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_8A8B8G8R_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxDriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxDriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxr = FixedToInt(ffr); \ - pixel->g = FixedToInt(ffg); \ - pixel->b = FixedToInt(ffb); \ - ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \ - pixel++; \ - } \ -} +#define RENDER_SPAN( span ) \ + GLuint i; \ + PIXEL_TYPE *pixel = pRow; \ + for (i = 0; i < span.end; i++, pixel++) { \ + pixel->r = FixedToInt(span.red); \ + pixel->g = FixedToInt(span.green); \ + pixel->b = FixedToInt(span.blue); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -924,25 +925,27 @@ static void smooth_8R8G8B24_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle. */ -static void smooth_TRUEDITHER_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_TRUEDITHER_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_RGB 1 -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - for (xx=LEFT;xxxm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + unsigned long p; \ + PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + XMesaPutPixel(img, x, y, p ); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -950,26 +953,26 @@ static void smooth_TRUEDITHER_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle. */ -static void smooth_5R6G5B_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_5R6G5B_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxDriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxxm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -1004,27 +1008,28 @@ static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle. */ -static void smooth_DITHER8_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_DITHER8_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - PIXEL_TYPE *pixel = pRow; \ - XDITHER_SETUP(yy); \ - for (xx=LEFT;xxxm_buffer, span.y); \ + XDITHER_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue) ); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -1032,26 +1037,27 @@ static void smooth_DITHER8_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, PF_DITHER triangle. */ -static void smooth_DITHER_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_DITHER_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; - #define INTERP_RGB 1 -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - XDITHER_SETUP(yy); \ - for (xx=LEFT;xxxm_buffer, span.y); \ + XDITHER_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + unsigned long p = XDITHER(x, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue) ); \ + XMesaPutPixel(img, x, y, p); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -1059,28 +1065,27 @@ static void smooth_DITHER_triangle( GLcontext *ctx, /* * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle. */ -static void smooth_LOOKUP8_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void smooth_LOOKUP8_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - LOOKUP_SETUP; \ - for (xx=LEFT;xxDriverCtx; - #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxxm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \ + FixedToInt(span.green), FixedToInt(span.blue)); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + #include "swrast/s_tritemp.h" } @@ -1117,24 +1122,24 @@ static void smooth_HPCR_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle. */ -static void flat_TRUECOLOR_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_TRUECOLOR_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define SETUP_CODE \ unsigned long pixel; \ - PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]); + PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + XMesaPutPixel(img, x, y, pixel); \ + } -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - for (xx=LEFT;xxDriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ - unsigned long p = PACK_8B8G8R( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxcolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + pRow[i] = (PIXEL_TYPE) p; \ + } + #include "swrast/s_tritemp.h" } @@ -1169,26 +1172,24 @@ static void flat_8A8B8G8R_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle. */ -static void flat_8R8G8B_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_8R8G8B_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - unsigned long p = PACK_8R8G8B( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxcolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + pRow[i] = (PIXEL_TYPE) p; \ + } + #include "swrast/s_tritemp.h" } @@ -1196,50 +1197,48 @@ static void flat_8R8G8B_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle. */ -static void flat_8R8G8B24_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_8R8G8B24_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = v0->color; + const GLubyte *color = v2->color; #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ +#define RENDER_SPAN( span ) \ + GLuint i; \ PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxr = color[RCOMP]; \ pixel->g = color[GCOMP]; \ pixel->b = color[BCOMP]; \ - pixel++; \ - } \ -} + } + #include "swrast/s_tritemp.h" } /* * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle. */ -static void flat_TRUEDITHER_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_TRUEDITHER_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - for (xx=LEFT;xxcolor[0], \ - v0->color[1], v0->color[2] ); \ - XMesaPutPixel( img, xx, yy, p ); \ - } \ -} +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + unsigned long p; \ + PACK_TRUEDITHER(p, x, y, v2->color[0], \ + v2->color[1], v2->color[2] ); \ + XMesaPutPixel(img, x, y, p); \ + } + #include "swrast/s_tritemp.h" } @@ -1248,26 +1247,24 @@ static void flat_TRUEDITHER_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle. */ -static void flat_5R6G5B_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_5R6G5B_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - unsigned long p = PACK_5R6G5B( v0->color[0], \ - v0->color[1], v0->color[2] ); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxcolor[0], \ + v2->color[1], v2->color[2] ); +#define RENDER_SPAN( span ) \ + GLuint i; \ + for (i = 0; i < span.end; i++) { \ + pRow[i] = (PIXEL_TYPE) p; \ + } + #include "swrast/s_tritemp.h" } @@ -1275,25 +1272,24 @@ static void flat_5R6G5B_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle. */ -static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - const GLubyte *color = v0->color; + const GLubyte *color = v2->color; #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxxm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \ + color[GCOMP], color[BCOMP]); \ + } + #include "swrast/s_tritemp.h" } @@ -1301,27 +1297,26 @@ static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle. */ -static void flat_DITHER8_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_DITHER8_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ - FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] ); + FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] ); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \ + for (i = 0; i < span.end; i++, x++) { \ + pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \ + } -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \ - for (xx=LEFT;xxDriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define SETUP_CODE \ - FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] ); - -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - FLAT_DITHER_ROW_SETUP(yy); \ - for (xx=LEFT;xxcolor[0], v2->color[1], v2->color[2] ); + +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + FLAT_DITHER_ROW_SETUP(y); \ + for (i = 0; i < span.end; i++, x++) { \ + unsigned long p = FLAT_DITHER(x); \ + XMesaPutPixel(img, x, y, p ); \ + } + #include "swrast/s_tritemp.h" } @@ -1355,27 +1350,26 @@ static void flat_DITHER_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle. */ -static void flat_HPCR_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_HPCR_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) -#define SETUP_CODE \ - GLubyte r = v0->color[0]; \ - GLubyte g = v0->color[1]; \ - GLubyte b = v0->color[2]; -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxcolor[0]; \ + GLubyte g = v2->color[1]; \ + GLubyte b = v2->color[2]; +#define RENDER_SPAN( span ) \ + GLuint i; \ + GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \ + for (i = 0; i < span.end; i++, x++) { \ + pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \ + } + #include "swrast/s_tritemp.h" } @@ -1383,10 +1377,10 @@ static void flat_HPCR_triangle( GLcontext *ctx, /* * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle. */ -static void flat_LOOKUP8_triangle( GLcontext *ctx, - SWvertex *v0, - SWvertex *v1, - SWvertex *v2 ) +static void flat_LOOKUP8_triangle( GLcontext *ctx, + const SWvertex *v0, + const SWvertex *v1, + const SWvertex *v2 ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) @@ -1394,113 +1388,129 @@ static void flat_LOOKUP8_triangle( GLcontext *ctx, #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define SETUP_CODE \ LOOKUP_SETUP; \ - GLubyte r = v0->color[0]; \ - GLubyte g = v0->color[1]; \ - GLubyte b = v0->color[2]; \ + GLubyte r = v2->color[0]; \ + GLubyte g = v2->color[1]; \ + GLubyte b = v2->color[2]; \ GLubyte p = LOOKUP(r,g,b); -#define INNER_LOOP( LEFT, RIGHT, Y ) \ -{ \ - GLint xx; \ - PIXEL_TYPE *pixel = pRow; \ - for (xx=LEFT;xxRenderMode != GL_RENDER) return (swrast_tri_func) NULL; if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL; - if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL; + if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL; + if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_tri_func) NULL; + if (ctx->Polygon.CullFlag && + ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + return (swrast_tri_func) NULL; if (xmesa->xm_buffer->buffer==XIMAGE) { if ( ctx->Light.ShadeModel==GL_SMOOTH && swrast->_RasterMask==DEPTH_BIT && ctx->Depth.Func==GL_LESS && ctx->Depth.Mask==GL_TRUE - && ctx->Visual.DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS + && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: - return smooth_TRUECOLOR_z_triangle; + USE(smooth_TRUECOLOR_z_triangle); case PF_8A8B8G8R: - return smooth_8A8B8G8R_z_triangle; + USE(smooth_8A8B8G8R_z_triangle); case PF_8R8G8B: - return smooth_8R8G8B_z_triangle; + USE(smooth_8R8G8B_z_triangle); case PF_8R8G8B24: - return smooth_8R8G8B24_z_triangle; + USE(smooth_8R8G8B24_z_triangle); case PF_TRUEDITHER: - return smooth_TRUEDITHER_z_triangle; + USE(smooth_TRUEDITHER_z_triangle); case PF_5R6G5B: - return smooth_5R6G5B_z_triangle; + USE(smooth_5R6G5B_z_triangle); case PF_DITHER_5R6G5B: - return smooth_DITHER_5R6G5B_z_triangle; + USE(smooth_DITHER_5R6G5B_z_triangle); case PF_HPCR: - return smooth_HPCR_z_triangle; + USE(smooth_HPCR_z_triangle); case PF_DITHER: - return (depth==8) ? smooth_DITHER8_z_triangle - : smooth_DITHER_z_triangle; + if (depth == 8) + USE(smooth_DITHER8_z_triangle); + else + USE(smooth_DITHER_z_triangle); + break; case PF_LOOKUP: - return (depth==8) ? smooth_LOOKUP8_z_triangle : (swrast_tri_func)NULL; + if (depth == 8) + USE(smooth_LOOKUP8_z_triangle); + else + return (swrast_tri_func) NULL; default: - return (swrast_tri_func)NULL; + return (swrast_tri_func) NULL; } } if ( ctx->Light.ShadeModel==GL_FLAT && swrast->_RasterMask==DEPTH_BIT && ctx->Depth.Func==GL_LESS && ctx->Depth.Mask==GL_TRUE - && ctx->Visual.DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS + && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: - return flat_TRUECOLOR_z_triangle; + USE(flat_TRUECOLOR_z_triangle); case PF_8A8B8G8R: - return flat_8A8B8G8R_z_triangle; + USE(flat_8A8B8G8R_z_triangle); case PF_8R8G8B: - return flat_8R8G8B_z_triangle; + USE(flat_8R8G8B_z_triangle); case PF_8R8G8B24: - return flat_8R8G8B24_z_triangle; + USE(flat_8R8G8B24_z_triangle); case PF_TRUEDITHER: - return flat_TRUEDITHER_z_triangle; + USE(flat_TRUEDITHER_z_triangle); case PF_5R6G5B: - return flat_5R6G5B_z_triangle; + USE(flat_5R6G5B_z_triangle); case PF_DITHER_5R6G5B: - return flat_DITHER_5R6G5B_z_triangle; + USE(flat_DITHER_5R6G5B_z_triangle); case PF_HPCR: - return flat_HPCR_z_triangle; + USE(flat_HPCR_z_triangle); case PF_DITHER: - return (depth==8) ? flat_DITHER8_z_triangle - : flat_DITHER_z_triangle; + if (depth == 8) + USE(flat_DITHER8_z_triangle); + else + USE(flat_DITHER_z_triangle); + break; case PF_LOOKUP: - return (depth==8) ? flat_LOOKUP8_z_triangle : (swrast_tri_func)NULL; + if (depth == 8) + USE(flat_LOOKUP8_z_triangle); + else + return (swrast_tri_func) NULL; default: - return (swrast_tri_func)NULL; + return (swrast_tri_func) NULL; } } if ( swrast->_RasterMask==0 /* no depth test */ @@ -1583,28 +1613,34 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx ) && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: - return smooth_TRUECOLOR_triangle; + USE(smooth_TRUECOLOR_triangle); case PF_8A8B8G8R: - return smooth_8A8B8G8R_triangle; + USE(smooth_8A8B8G8R_triangle); case PF_8R8G8B: - return smooth_8R8G8B_triangle; + USE(smooth_8R8G8B_triangle); case PF_8R8G8B24: - return smooth_8R8G8B24_triangle; + USE(smooth_8R8G8B24_triangle); case PF_TRUEDITHER: - return smooth_TRUEDITHER_triangle; + USE(smooth_TRUEDITHER_triangle); case PF_5R6G5B: - return smooth_5R6G5B_triangle; + USE(smooth_5R6G5B_triangle); case PF_DITHER_5R6G5B: - return smooth_DITHER_5R6G5B_triangle; + USE(smooth_DITHER_5R6G5B_triangle); case PF_HPCR: - return smooth_HPCR_triangle; + USE(smooth_HPCR_triangle); case PF_DITHER: - return (depth==8) ? smooth_DITHER8_triangle - : smooth_DITHER_triangle; + if (depth == 8) + USE(smooth_DITHER8_triangle); + else + USE(smooth_DITHER_triangle); + break; case PF_LOOKUP: - return (depth==8) ? smooth_LOOKUP8_triangle : (swrast_tri_func)NULL; + if (depth == 8) + USE(smooth_LOOKUP8_triangle); + else + return (swrast_tri_func) NULL; default: - return (swrast_tri_func)NULL; + return (swrast_tri_func) NULL; } } @@ -1613,32 +1649,38 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx ) && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: - return flat_TRUECOLOR_triangle; + USE(flat_TRUECOLOR_triangle); case PF_TRUEDITHER: - return flat_TRUEDITHER_triangle; + USE(flat_TRUEDITHER_triangle); case PF_8A8B8G8R: - return flat_8A8B8G8R_triangle; + USE(flat_8A8B8G8R_triangle); case PF_8R8G8B: - return flat_8R8G8B_triangle; + USE(flat_8R8G8B_triangle); case PF_8R8G8B24: - return flat_8R8G8B24_triangle; + USE(flat_8R8G8B24_triangle); case PF_5R6G5B: - return flat_5R6G5B_triangle; + USE(flat_5R6G5B_triangle); case PF_DITHER_5R6G5B: - return flat_DITHER_5R6G5B_triangle; + USE(flat_DITHER_5R6G5B_triangle); case PF_HPCR: - return flat_HPCR_triangle; + USE(flat_HPCR_triangle); case PF_DITHER: - return (depth==8) ? flat_DITHER8_triangle - : flat_DITHER_triangle; + if (depth == 8) + USE(flat_DITHER8_triangle); + else + USE(flat_DITHER_triangle); + break; case PF_LOOKUP: - return (depth==8) ? flat_LOOKUP8_triangle : (swrast_tri_func)NULL; + if (depth == 8) + USE(flat_LOOKUP8_triangle); + else + return (swrast_tri_func) NULL; default: - return (swrast_tri_func)NULL; + return (swrast_tri_func) NULL; } } - return (swrast_tri_func)NULL; + return (swrast_tri_func) NULL; } else { /* draw to pixmap */ @@ -1649,7 +1691,7 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx ) /* Override for the swrast tri-selection function. Try to use one * of our internal tri functions, otherwise fall back to the - * standard swrast functions. + * standard swrast functions. */ void xmesa_choose_triangle( GLcontext *ctx ) {