Moved the software rasterizer to a new directory.

This commit is contained in:
Keith Whitwell 2000-10-31 18:09:44 +00:00
parent e3a051e053
commit 724abeb058
32 changed files with 244 additions and 7710 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile.X11,v 1.26 2000/10/31 12:40:57 keithw Exp $
# $Id: Makefile.X11,v 1.27 2000/10/31 18:09:44 keithw Exp $
# Mesa 3-D graphics library
# Version: 3.5
@ -20,10 +20,8 @@ LIBDIR = ../lib
CORE_SOURCES = \
aatriangle.c \
accum.c \
alpha.c \
alphabuf.c \
attrib.c \
bbox.c \
bitmap.c \
@ -52,6 +50,7 @@ CORE_SOURCES = \
glapinoop.c \
glthread.c \
hash.c \
highpc.c \
hint.c \
image.c \
imaging.c \
@ -59,23 +58,21 @@ CORE_SOURCES = \
light.c \
lines.c \
logic.c \
lowpc.c \
masking.c \
matrix.c \
mem.c \
mmath.c \
pb.c \
pipeline.c \
pixel.c \
pixeltex.c \
points.c \
polygon.c \
quads.c \
rastpos.c \
readpix.c \
rect.c \
scissor.c \
shade.c \
span.c \
stages.c \
state.c \
stencil.c \
@ -85,7 +82,6 @@ CORE_SOURCES = \
texture.c \
texutil.c \
translate.c \
triangle.c \
varray.c \
vb.c \
vbcull.c \
@ -97,11 +93,39 @@ CORE_SOURCES = \
vertices.c \
winpos.c \
xform.c \
zoom.c \
X86/x86.c \
X86/common_x86.c \
X86/3dnow.c \
X86/katmai.c
X86/katmai.c \
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_alphabuf.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_fog.c \
swrast/s_imaging.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_pb.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_quads.c \
swrast/s_readpix.c \
swrast/s_scissor.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texture.c \
swrast/s_triangle.c \
swrast/s_zoom.c
DRIVER_SOURCES = \
X/glxapi.c \

View file

@ -57,7 +57,7 @@
#include "fxdrv.h"
#include "enums.h"
#include "extensions.h"
#include "pb.h"
#include "swrast/swrast.h"
/* These lookup table are used to extract RGB values in [0,255] from
* 16-bit pixel values.
@ -1061,7 +1061,7 @@ static void fxDDUpdateDDPointers(GLcontext *ctx)
static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
{
if (ctx->Polygon.CullFlag) {
if (ctx->PB->primitive != GL_POLYGON) { /* Lines or Points */
if (ctx->ReducedPrimitive != GL_POLYGON) { /* Lines or Points */
FX_grCullMode(GR_CULL_DISABLE);
FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE;
}

View file

@ -1,4 +1,4 @@
/* $Id: osmesa.c,v 1.24 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: osmesa.c,v 1.25 2000/10/31 18:09:46 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -48,9 +48,12 @@
#include "types.h"
#include "vb.h"
#include "extensions.h"
#include "swrast/s_depth.h"
#endif
/*
* This is the OS/Mesa context struct.
* Notice how it includes a GLcontext. By doing this we're mimicking
@ -1236,9 +1239,9 @@ static void flat_rgba_line( GLcontext *ctx,
#define PLOT(X,Y) { GLuint *ptr4 = PIXELADDR4(X,Y); *ptr4 = pixel; }
#ifdef WIN32
#include "..\linetemp.h"
#include "..\swrast\s_linetemp.h"
#else
#include "linetemp.h"
#include "swrast/s_linetemp.h"
#endif
}
@ -1265,9 +1268,9 @@ static void flat_rgba_z_line( GLcontext *ctx,
}
#ifdef WIN32
#include "..\linetemp.h"
#include "..\swrast\s_linetemp.h"
#else
#include "linetemp.h"
#include "swrast/s_linetemp.h"
#endif
}
@ -1301,9 +1304,9 @@ static void flat_blend_rgba_line( GLcontext *ctx,
}
#ifdef WIN32
#include "..\linetemp.h"
#include "..\swrast\s_linetemp.h"
#else
#include "linetemp.h"
#include "swrast/s_linetemp.h"
#endif
}
@ -1340,9 +1343,9 @@ static void flat_blend_rgba_z_line( GLcontext *ctx,
}
#ifdef WIN32
#include "..\linetemp.h"
#include "..\swrast\s_linetemp.h"
#else
#include "linetemp.h"
#include "swrast/s_linetemp.h"
#endif
}
@ -1380,9 +1383,9 @@ static void flat_blend_rgba_z_line_write( GLcontext *ctx,
}
#ifdef WIN32
#include "..\linetemp.h"
#include "..\swrast\s_linetemp.h"
#else
#include "linetemp.h"
#include "swrast/s_linetemp.h"
#endif
}
@ -1512,6 +1515,7 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{ \
GLint i, len = RIGHT-LEFT; \
GLuint *img = PIXELADDR4(LEFT,Y); \
(void) fffog; \
for (i=0;i<len;i++,img++) { \
GLdepth z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
@ -1524,9 +1528,9 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
} \
}
#ifdef WIN32
#include "..\tritemp.h"
#include "..\swrast\s_tritemp.h"
#else
#include "tritemp.h"
#include "swrast/s_tritemp.h"
#endif
}
@ -1553,6 +1557,7 @@ static void flat_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{ \
GLint i, len = RIGHT-LEFT; \
GLuint *img = PIXELADDR4(LEFT,Y); \
(void) fffog; \
for (i=0;i<len;i++,img++) { \
GLdepth z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
@ -1563,9 +1568,9 @@ static void flat_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
} \
}
#ifdef WIN32
#include "..\tritemp.h"
#include "..\swrast\s_tritemp.h"
#else
#include "tritemp.h"
#include "swrast/s_tritemp.h"
#endif
}

View file

@ -1,4 +1,4 @@
/* $Id: xm_api.c,v 1.4 2000/10/30 13:32:03 keithw Exp $ */
/* $Id: xm_api.c,v 1.5 2000/10/31 18:09:46 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -76,6 +76,7 @@
#include "conf.h"
#endif
#include "macros.h"
#include "swrast/swrast.h"
#ifndef GLX_NONE_EXT
#define GLX_NONE_EXT 0x8000

View file

@ -1,4 +1,4 @@
/* $Id: xm_line.c,v 1.4 2000/09/28 22:44:32 brianp Exp $ */
/* $Id: xm_line.c,v 1.5 2000/10/31 18:09:46 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -39,6 +39,9 @@
#include "types.h"
#include "xmesaP.h"
/* Internal swrast includes:
*/
#include "swrast/s_depth.h"
/**********************************************************************/
@ -167,7 +170,7 @@ static void flat_TRUECOLOR_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -188,7 +191,7 @@ static void flat_8A8B8G8R_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -208,7 +211,7 @@ static void flat_8R8G8B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -231,7 +234,7 @@ static void flat_8R8G8B24_line( GLcontext *ctx,
pixelPtr->b = color[BCOMP]; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -251,7 +254,7 @@ static void flat_5R6G5B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -270,7 +273,7 @@ static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -293,7 +296,7 @@ static void flat_DITHER8_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -315,7 +318,7 @@ static void flat_LOOKUP8_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -336,7 +339,7 @@ static void flat_HPCR_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -363,7 +366,7 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx,
XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -389,7 +392,7 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -415,7 +418,7 @@ static void flat_8R8G8B_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -442,7 +445,7 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx,
pixelPtr->b = color[BCOMP]; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -467,7 +470,7 @@ static void flat_5R6G5B_z_line( GLcontext *ctx,
*zPtr = Z; \
*pixelPtr = pixel; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -491,7 +494,7 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
*zPtr = Z; \
PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -518,7 +521,7 @@ static void flat_DITHER8_z_line( GLcontext *ctx,
*zPtr = Z; \
*pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -546,7 +549,7 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}
@ -573,7 +576,7 @@ static void flat_HPCR_z_line( GLcontext *ctx,
*pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
}
#include "linetemp.h"
#include "swrast/s_linetemp.h"
}

View file

@ -1,4 +1,4 @@
/* $Id: xm_tri.c,v 1.5 2000/10/30 13:32:03 keithw Exp $ */
/* $Id: xm_tri.c,v 1.6 2000/10/31 18:09:47 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -39,6 +39,10 @@
#include "types.h"
#include "xmesaP.h"
/* Internal swrast includes:
*/
#include "swrast/s_depth.h"
@ -119,7 +123,7 @@ static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -154,7 +158,7 @@ static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -188,7 +192,7 @@ static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -224,7 +228,7 @@ static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -258,7 +262,7 @@ static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -292,7 +296,7 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -326,7 +330,7 @@ static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -361,7 +365,7 @@ static void smooth_DITHER8_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -398,7 +402,7 @@ static void smooth_DITHER_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -432,7 +436,7 @@ static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -466,7 +470,7 @@ static void smooth_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -498,7 +502,7 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -530,7 +534,7 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, GLuint v0,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -562,7 +566,7 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -595,7 +599,7 @@ static void flat_8R8G8B24_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -625,7 +629,7 @@ static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -657,7 +661,7 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -688,7 +692,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -721,7 +725,7 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -753,7 +757,7 @@ static void flat_DITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -786,7 +790,7 @@ static void flat_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -821,7 +825,7 @@ static void flat_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffz += fdzdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -846,7 +850,7 @@ static void smooth_TRUECOLOR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -872,7 +876,7 @@ static void smooth_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -898,7 +902,7 @@ static void smooth_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -926,7 +930,7 @@ static void smooth_8R8G8B24_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
pixel++; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -951,7 +955,7 @@ static void smooth_TRUEDITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -977,7 +981,7 @@ static void smooth_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1003,7 +1007,7 @@ static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx, GLuint v0,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1030,7 +1034,7 @@ static void smooth_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1055,7 +1059,7 @@ static void smooth_DITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1082,7 +1086,7 @@ static void smooth_LOOKUP8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1109,7 +1113,7 @@ static void smooth_HPCR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1132,7 +1136,7 @@ static void flat_TRUECOLOR_triangle( GLcontext *ctx, GLuint v0,
XMesaPutPixel( img, xx, yy, pixel ); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1157,7 +1161,7 @@ static void flat_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0,
*pixel = (PIXEL_TYPE) p; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1182,7 +1186,7 @@ static void flat_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*pixel = (PIXEL_TYPE) p; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1208,7 +1212,7 @@ static void flat_8R8G8B24_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
pixel++; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
/*
@ -1229,7 +1233,7 @@ static void flat_TRUEDITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaPutPixel( img, xx, yy, p ); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1255,7 +1259,7 @@ static void flat_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*pixel = (PIXEL_TYPE) p; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1279,7 +1283,7 @@ static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
color[GCOMP], color[BCOMP]); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1305,7 +1309,7 @@ static void flat_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*pixel = (PIXEL_TYPE) FLAT_DITHER(xx); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1329,7 +1333,7 @@ static void flat_DITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaPutPixel( img, xx, yy, p ); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1355,7 +1359,7 @@ static void flat_HPCR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*pixel = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}
@ -1383,7 +1387,7 @@ static void flat_LOOKUP8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*pixel = p; \
} \
}
#include "tritemp.h"
#include "swrast/s_tritemp.h"
}

View file

@ -1,4 +1,4 @@
# $Id: Makefile.X11,v 1.26 2000/10/31 12:40:57 keithw Exp $
# $Id: Makefile.X11,v 1.27 2000/10/31 18:09:44 keithw Exp $
# Mesa 3-D graphics library
# Version: 3.5
@ -20,10 +20,8 @@ LIBDIR = ../lib
CORE_SOURCES = \
aatriangle.c \
accum.c \
alpha.c \
alphabuf.c \
attrib.c \
bbox.c \
bitmap.c \
@ -52,6 +50,7 @@ CORE_SOURCES = \
glapinoop.c \
glthread.c \
hash.c \
highpc.c \
hint.c \
image.c \
imaging.c \
@ -59,23 +58,21 @@ CORE_SOURCES = \
light.c \
lines.c \
logic.c \
lowpc.c \
masking.c \
matrix.c \
mem.c \
mmath.c \
pb.c \
pipeline.c \
pixel.c \
pixeltex.c \
points.c \
polygon.c \
quads.c \
rastpos.c \
readpix.c \
rect.c \
scissor.c \
shade.c \
span.c \
stages.c \
state.c \
stencil.c \
@ -85,7 +82,6 @@ CORE_SOURCES = \
texture.c \
texutil.c \
translate.c \
triangle.c \
varray.c \
vb.c \
vbcull.c \
@ -97,11 +93,39 @@ CORE_SOURCES = \
vertices.c \
winpos.c \
xform.c \
zoom.c \
X86/x86.c \
X86/common_x86.c \
X86/3dnow.c \
X86/katmai.c
X86/katmai.c \
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_alphabuf.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_fog.c \
swrast/s_imaging.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_pb.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_quads.c \
swrast/s_readpix.c \
swrast/s_scissor.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texture.c \
swrast/s_triangle.c \
swrast/s_zoom.c
DRIVER_SOURCES = \
X/glxapi.c \

View file

@ -1,4 +1,4 @@
/* $Id: accum.c,v 1.30 2000/10/30 13:31:59 keithw Exp $ */
/* $Id: accum.c,v 1.31 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -33,68 +33,12 @@
#include "context.h"
#include "macros.h"
#include "mem.h"
#include "masking.h"
#include "span.h"
#include "state.h"
#include "types.h"
#include "swrast/swrast.h"
#endif
/*
* Accumulation buffer notes
*
* Normally, accumulation buffer values are GLshorts with values in
* [-32767, 32767] which represent floating point colors in [-1, 1],
* as suggested by the OpenGL specification.
*
* We optimize for the common case used for full-scene antialiasing:
* // start with accum buffer cleared to zero
* glAccum(GL_LOAD, w); // or GL_ACCUM the first image
* glAccum(GL_ACCUM, w);
* ...
* glAccum(GL_ACCUM, w);
* glAccum(GL_RETURN, 1.0);
* That is, we start with an empty accumulation buffer and accumulate
* n images, each with weight w = 1/n.
* In this scenario, we can simply store unscaled integer values in
* the accum buffer instead of scaled integers. We'll also keep track
* of the w value so when we do GL_RETURN we simply divide the accumulated
* values by n (=1/w).
* This lets us avoid _many_ int->float->int conversions.
*/
#if CHAN_BITS == 8
#define USE_OPTIMIZED_ACCUM /* enable the optimization */
#endif
void
_mesa_alloc_accum_buffer( GLcontext *ctx )
{
GLint n;
if (ctx->DrawBuffer->Accum) {
FREE( ctx->DrawBuffer->Accum );
ctx->DrawBuffer->Accum = NULL;
}
/* allocate accumulation buffer if not already present */
n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4 * sizeof(GLaccum);
ctx->DrawBuffer->Accum = (GLaccum *) MALLOC( n );
if (!ctx->DrawBuffer->Accum) {
/* unable to setup accumulation buffer */
gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
}
#ifdef USE_OPTIMIZED_ACCUM
ctx->IntegerAccumMode = GL_TRUE;
#else
ctx->IntegerAccumMode = GL_FALSE;
#endif
ctx->IntegerAccumScaler = 0.0;
}
void
@ -111,42 +55,11 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
}
/*
* This is called when we fall out of optimized/unscaled accum buffer mode.
* That is, we convert each unscaled accum buffer value into a scaled value
* representing the range[-1, 1].
*/
static void rescale_accum( GLcontext *ctx )
{
const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4;
const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
const GLfloat s = ctx->IntegerAccumScaler * (32767.0 / fChanMax);
GLaccum *accum = ctx->DrawBuffer->Accum;
GLuint i;
assert(ctx->IntegerAccumMode);
assert(accum);
for (i = 0; i < n; i++) {
accum[i] = (GLaccum) (accum[i] * s);
}
ctx->IntegerAccumMode = GL_FALSE;
}
void
_mesa_Accum( GLenum op, GLfloat value )
{
GET_CURRENT_CONTEXT(ctx);
GLuint xpos, ypos, width, height, width4;
GLfloat acc_scale;
GLchan rgba[MAX_WIDTH][4];
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
const GLint iChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
GLuint xpos, ypos, width, height;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glAccum");
@ -155,22 +68,6 @@ _mesa_Accum( GLenum op, GLfloat value )
return;
}
if (!ctx->DrawBuffer->Accum) {
_mesa_warning(ctx, "Calling glAccum() without an accumulation buffer (low memory?)");
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
if (ctx->NewState)
gl_update_state( ctx );
@ -189,351 +86,7 @@ _mesa_Accum( GLenum op, GLfloat value )
height = ctx->DrawBuffer->Height;
}
width4 = 4 * width;
switch (op) {
case GL_ADD:
if (value != 0.0F) {
const GLaccum intVal = (GLaccum) (value * acc_scale);
GLuint j;
/* Leave optimized accum buffer mode */
if (ctx->IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
GLaccum * acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
GLuint i;
for (i = 0; i < width4; i++) {
acc[i] += intVal;
}
ypos++;
}
}
break;
case GL_MULT:
if (value != 1.0F) {
GLuint j;
/* Leave optimized accum buffer mode */
if (ctx->IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
GLuint i;
for (i = 0; i < width4; i++) {
acc[i] = (GLaccum) ( (GLfloat) acc[i] * value );
}
ypos++;
}
}
break;
case GL_ACCUM:
if (value == 0.0F)
return;
(*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
/* May have to leave optimized accum buffer mode */
if (ctx->IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
ctx->IntegerAccumScaler = value;
if (ctx->IntegerAccumMode && value != ctx->IntegerAccumScaler)
rescale_accum(ctx);
RENDER_START(ctx);
if (ctx->IntegerAccumMode) {
/* simply add integer color values into accum buffer */
GLuint j;
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i = i4 = 0; i < width; i++, i4+=4) {
acc[i4+0] += rgba[i][RCOMP];
acc[i4+1] += rgba[i][GCOMP];
acc[i4+2] += rgba[i][BCOMP];
acc[i4+3] += rgba[i][ACOMP];
}
acc += width4;
ypos++;
}
}
else {
/* scaled integer accum buffer */
const GLfloat rscale = value * acc_scale / fChanMax;
const GLfloat gscale = value * acc_scale / fChanMax;
const GLfloat bscale = value * acc_scale / fChanMax;
const GLfloat ascale = value * acc_scale / fChanMax;
GLuint j;
for (j=0;j<height;j++) {
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
GLuint i;
gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i=0;i<width;i++) {
*acc += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale ); acc++;
*acc += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale ); acc++;
*acc += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale ); acc++;
*acc += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale ); acc++;
}
ypos++;
}
}
/* restore read buffer = draw buffer (the default) */
(*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
RENDER_FINISH(ctx);
break;
case GL_LOAD:
(*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
/* This is a change to go into optimized accum buffer mode */
if (value > 0.0 && value <= 1.0) {
#ifdef USE_OPTIMIZED_ACCUM
ctx->IntegerAccumMode = GL_TRUE;
#else
ctx->IntegerAccumMode = GL_FALSE;
#endif
ctx->IntegerAccumScaler = value;
}
else {
ctx->IntegerAccumMode = GL_FALSE;
ctx->IntegerAccumScaler = 0.0;
}
RENDER_START(ctx);
if (ctx->IntegerAccumMode) {
/* just copy values into accum buffer */
GLuint j;
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i = i4 = 0; i < width; i++, i4 += 4) {
acc[i4+0] = rgba[i][RCOMP];
acc[i4+1] = rgba[i][GCOMP];
acc[i4+2] = rgba[i][BCOMP];
acc[i4+3] = rgba[i][ACOMP];
}
acc += width4;
ypos++;
}
}
else {
/* scaled integer accum buffer */
const GLfloat rscale = value * acc_scale / fChanMax;
const GLfloat gscale = value * acc_scale / fChanMax;
const GLfloat bscale = value * acc_scale / fChanMax;
const GLfloat ascale = value * acc_scale / fChanMax;
const GLfloat d = 3.0 / acc_scale;
GLuint i, j;
for (j = 0; j < height; j++) {
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i=0;i<width;i++) {
*acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d);
*acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d);
*acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale + d);
*acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale + d);
}
ypos++;
}
}
/* restore read buffer = draw buffer (the default) */
(*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
RENDER_FINISH(ctx);
break;
case GL_RETURN:
/* May have to leave optimized accum buffer mode */
if (ctx->IntegerAccumMode && value != 1.0)
rescale_accum(ctx);
RENDER_START(ctx);
if (ctx->IntegerAccumMode && ctx->IntegerAccumScaler > 0) {
/* build lookup table to avoid many floating point multiplies */
static GLchan multTable[32768];
static GLfloat prevMult = 0.0;
const GLfloat mult = ctx->IntegerAccumScaler;
const GLint max = MIN2((GLint) (256 / mult), 32767);
GLuint j;
if (mult != prevMult) {
for (j = 0; j < max; j++)
multTable[j] = (GLint) ((GLfloat) j * mult + 0.5F);
prevMult = mult;
}
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
GLuint i, i4;
for (i = i4 = 0; i < width; i++, i4 += 4) {
ASSERT(acc[i4+0] < max);
ASSERT(acc[i4+1] < max);
ASSERT(acc[i4+2] < max);
ASSERT(acc[i4+3] < max);
rgba[i][RCOMP] = multTable[acc[i4+0]];
rgba[i][GCOMP] = multTable[acc[i4+1]];
rgba[i][BCOMP] = multTable[acc[i4+2]];
rgba[i][ACOMP] = multTable[acc[i4+3]];
}
if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
(*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
(const GLchan (*)[4])rgba, NULL );
ypos++;
}
}
else {
const GLfloat rscale = value / acc_scale * fChanMax;
const GLfloat gscale = value / acc_scale * fChanMax;
const GLfloat bscale = value / acc_scale * fChanMax;
const GLfloat ascale = value / acc_scale * fChanMax;
GLuint i, j;
for (j=0;j<height;j++) {
const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
for (i=0;i<width;i++) {
GLint r, g, b, a;
r = (GLint) ( (GLfloat) (*acc++) * rscale + 0.5F );
g = (GLint) ( (GLfloat) (*acc++) * gscale + 0.5F );
b = (GLint) ( (GLfloat) (*acc++) * bscale + 0.5F );
a = (GLint) ( (GLfloat) (*acc++) * ascale + 0.5F );
rgba[i][RCOMP] = CLAMP( r, 0, iChanMax );
rgba[i][GCOMP] = CLAMP( g, 0, iChanMax );
rgba[i][BCOMP] = CLAMP( b, 0, iChanMax );
rgba[i][ACOMP] = CLAMP( a, 0, iChanMax );
}
if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
(*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
(const GLchan (*)[4])rgba, NULL );
ypos++;
}
}
RENDER_FINISH(ctx);
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glAccum" );
}
}
/*
* Clear the accumulation Buffer.
*/
void
_mesa_clear_accum_buffer( GLcontext *ctx )
{
GLuint buffersize;
GLfloat acc_scale;
if (ctx->Visual.AccumRedBits==0) {
/* No accumulation buffer! */
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
/* number of pixels */
buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
if (!ctx->DrawBuffer->Accum) {
/* try to alloc accumulation buffer */
ctx->DrawBuffer->Accum = (GLaccum *)
MALLOC( buffersize * 4 * sizeof(GLaccum) );
}
if (ctx->DrawBuffer->Accum) {
if (ctx->Scissor.Enabled) {
/* Limit clear to scissor box */
GLaccum r, g, b, a;
GLint i, j;
GLint width, height;
GLaccum *row;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
width = 4 * (ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin);
height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
/* ptr to first element to clear */
row = ctx->DrawBuffer->Accum
+ 4 * (ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
+ ctx->DrawBuffer->Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
row[i+1] = g;
row[i+2] = b;
row[i+3] = a;
}
row += 4 * ctx->DrawBuffer->Width;
}
}
else {
/* clear whole buffer */
if (ctx->Accum.ClearColor[0]==0.0 &&
ctx->Accum.ClearColor[1]==0.0 &&
ctx->Accum.ClearColor[2]==0.0 &&
ctx->Accum.ClearColor[3]==0.0) {
/* Black */
BZERO( ctx->DrawBuffer->Accum, buffersize * 4 * sizeof(GLaccum) );
}
else {
/* Not black */
GLaccum *acc, r, g, b, a;
GLuint i;
acc = ctx->DrawBuffer->Accum;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
for (i=0;i<buffersize;i++) {
*acc++ = r;
*acc++ = g;
*acc++ = b;
*acc++ = a;
}
}
}
/* update optimized accum state vars */
if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
#ifdef USE_OPTIMIZED_ACCUM
ctx->IntegerAccumMode = GL_TRUE;
#else
ctx->IntegerAccumMode = GL_FALSE;
#endif
ctx->IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
}
else {
ctx->IntegerAccumMode = GL_FALSE;
}
}
if (!ctx->Driver.Accum ||
!ctx->Driver.Accum( ctx, op, value, xpos, ypos, width, height ))
_swrast_Accum( ctx, op, value, xpos, ypos, width, height );
}

View file

@ -1,4 +1,4 @@
/* $Id: accum.h,v 1.3 2000/02/02 21:52:26 brianp Exp $ */
/* $Id: accum.h,v 1.4 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -32,14 +32,6 @@
#include "types.h"
extern void
_mesa_alloc_accum_buffer( GLcontext *ctx );
extern void
_mesa_clear_accum_buffer( GLcontext *ctx );
extern void
_mesa_Accum( GLenum op, GLfloat value );

View file

@ -1,4 +1,4 @@
/* $Id: blend.c,v 1.23 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: blend.c,v 1.24 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,13 +30,10 @@
#include "all.h"
#else
#include "glheader.h"
#include "alphabuf.h"
#include "blend.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
#include "pb.h"
#include "span.h"
#include "types.h"
#endif
@ -322,632 +319,3 @@ _mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
ctx->NewState |= _NEW_COLOR;
}
#ifdef USE_MMX_ASM
#define _BLENDAPI _ASMAPI
#else
#define _BLENDAPI
#endif
/*
* Common transparency blending mode.
*/
static void _BLENDAPI
blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLuint i;
ASSERT(ctx->Color.BlendEquation==GL_FUNC_ADD_EXT);
ASSERT(ctx->Color.BlendSrcRGB==GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA);
(void) ctx;
for (i=0;i<n;i++) {
if (mask[i]) {
const GLint t = rgba[i][ACOMP]; /* t in [0, CHAN_MAX] */
if (t == 0) {
/* 0% alpha */
rgba[i][RCOMP] = dest[i][RCOMP];
rgba[i][GCOMP] = dest[i][GCOMP];
rgba[i][BCOMP] = dest[i][BCOMP];
rgba[i][ACOMP] = dest[i][ACOMP];
}
else if (t == CHAN_MAX) {
/* 100% alpha, no-op */
}
else {
#if 0
/* This is pretty close, but Glean complains */
const GLint s = CHAN_MAX - t;
const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s + 1) >> 8;
const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s + 1) >> 8;
const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s + 1) >> 8;
const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s + 1) >> 8;
#elif 0
/* This is slower but satisfies Glean */
const GLint s = CHAN_MAX - t;
const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) / 255;
const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) / 255;
const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) / 255;
const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) / 255;
#else
#if CHAN_BITS == 8
/* This satisfies Glean and should be reasonably fast */
/* Contributed by Nathan Hand */
#define DIV255(X) (((X) << 8) + (X) + 256) >> 16
const GLint s = CHAN_MAX - t;
const GLint r = DIV255(rgba[i][RCOMP] * t + dest[i][RCOMP] * s);
const GLint g = DIV255(rgba[i][GCOMP] * t + dest[i][GCOMP] * s);
const GLint b = DIV255(rgba[i][BCOMP] * t + dest[i][BCOMP] * s);
const GLint a = DIV255(rgba[i][ACOMP] * t + dest[i][ACOMP] * s);
#undef DIV255
#else
const GLint s = CHAN_MAX - t;
const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) / CHAN_MAX;
const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) / CHAN_MAX;
const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) / CHAN_MAX;
const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) / CHAN_MAX;
#endif
#endif
ASSERT(r <= CHAN_MAX);
ASSERT(g <= CHAN_MAX);
ASSERT(b <= CHAN_MAX);
ASSERT(a <= CHAN_MAX);
rgba[i][RCOMP] = (GLchan) r;
rgba[i][GCOMP] = (GLchan) g;
rgba[i][BCOMP] = (GLchan) b;
rgba[i][ACOMP] = (GLchan) a;
}
}
}
}
/*
* Add src and dest.
*/
static void _BLENDAPI
blend_add( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLuint i;
ASSERT(ctx->Color.BlendEquation==GL_FUNC_ADD_EXT);
ASSERT(ctx->Color.BlendSrcRGB==GL_ONE);
ASSERT(ctx->Color.BlendDstRGB==GL_ONE);
(void) ctx;
for (i=0;i<n;i++) {
if (mask[i]) {
GLint r = rgba[i][RCOMP] + dest[i][RCOMP];
GLint g = rgba[i][GCOMP] + dest[i][GCOMP];
GLint b = rgba[i][BCOMP] + dest[i][BCOMP];
GLint a = rgba[i][ACOMP] + dest[i][ACOMP];
rgba[i][RCOMP] = (GLchan) MIN2( r, CHAN_MAX );
rgba[i][GCOMP] = (GLchan) MIN2( g, CHAN_MAX );
rgba[i][BCOMP] = (GLchan) MIN2( b, CHAN_MAX );
rgba[i][ACOMP] = (GLchan) MIN2( a, CHAN_MAX );
}
}
}
/*
* Blend min function (for GL_EXT_blend_minmax)
*/
static void _BLENDAPI
blend_min( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLuint i;
ASSERT(ctx->Color.BlendEquation==GL_MIN_EXT);
(void) ctx;
for (i=0;i<n;i++) {
if (mask[i]) {
rgba[i][RCOMP] = (GLchan) MIN2( rgba[i][RCOMP], dest[i][RCOMP] );
rgba[i][GCOMP] = (GLchan) MIN2( rgba[i][GCOMP], dest[i][GCOMP] );
rgba[i][BCOMP] = (GLchan) MIN2( rgba[i][BCOMP], dest[i][BCOMP] );
rgba[i][ACOMP] = (GLchan) MIN2( rgba[i][ACOMP], dest[i][ACOMP] );
}
}
}
/*
* Blend max function (for GL_EXT_blend_minmax)
*/
static void _BLENDAPI
blend_max( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLuint i;
ASSERT(ctx->Color.BlendEquation==GL_MAX_EXT);
(void) ctx;
for (i=0;i<n;i++) {
if (mask[i]) {
rgba[i][RCOMP] = (GLchan) MAX2( rgba[i][RCOMP], dest[i][RCOMP] );
rgba[i][GCOMP] = (GLchan) MAX2( rgba[i][GCOMP], dest[i][GCOMP] );
rgba[i][BCOMP] = (GLchan) MAX2( rgba[i][BCOMP], dest[i][BCOMP] );
rgba[i][ACOMP] = (GLchan) MAX2( rgba[i][ACOMP], dest[i][ACOMP] );
}
}
}
/*
* Modulate: result = src * dest
*/
static void _BLENDAPI
blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLuint i;
(void) ctx;
for (i=0;i<n;i++) {
if (mask[i]) {
GLint r = (rgba[i][RCOMP] * dest[i][RCOMP]) >> 8;
GLint g = (rgba[i][GCOMP] * dest[i][GCOMP]) >> 8;
GLint b = (rgba[i][BCOMP] * dest[i][BCOMP]) >> 8;
GLint a = (rgba[i][ACOMP] * dest[i][ACOMP]) >> 8;
rgba[i][RCOMP] = (GLchan) r;
rgba[i][GCOMP] = (GLchan) g;
rgba[i][BCOMP] = (GLchan) b;
rgba[i][ACOMP] = (GLchan) a;
}
}
}
/*
* General case blend pixels.
* Input: n - number of pixels
* mask - the usual write mask
* In/Out: rgba - the incoming and modified pixels
* Input: dest - the pixels from the dest color buffer
*/
static void _BLENDAPI
blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
GLfloat rscale = 1.0F / CHAN_MAXF;
GLfloat gscale = 1.0F / CHAN_MAXF;
GLfloat bscale = 1.0F / CHAN_MAXF;
GLfloat ascale = 1.0F / CHAN_MAXF;
GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
GLint Rs, Gs, Bs, As; /* Source colors */
GLint Rd, Gd, Bd, Ad; /* Dest colors */
GLfloat sR, sG, sB, sA; /* Source scaling */
GLfloat dR, dG, dB, dA; /* Dest scaling */
GLfloat r, g, b, a;
/* Source Color */
Rs = rgba[i][RCOMP];
Gs = rgba[i][GCOMP];
Bs = rgba[i][BCOMP];
As = rgba[i][ACOMP];
/* Frame buffer color */
Rd = dest[i][RCOMP];
Gd = dest[i][GCOMP];
Bd = dest[i][BCOMP];
Ad = dest[i][ACOMP];
/* Source RGB factor */
switch (ctx->Color.BlendSrcRGB) {
case GL_ZERO:
sR = sG = sB = 0.0F;
break;
case GL_ONE:
sR = sG = sB = 1.0F;
break;
case GL_DST_COLOR:
sR = (GLfloat) Rd * rscale;
sG = (GLfloat) Gd * gscale;
sB = (GLfloat) Bd * bscale;
break;
case GL_ONE_MINUS_DST_COLOR:
sR = 1.0F - (GLfloat) Rd * rscale;
sG = 1.0F - (GLfloat) Gd * gscale;
sB = 1.0F - (GLfloat) Bd * bscale;
break;
case GL_SRC_ALPHA:
sR = sG = sB = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
sR = sG = sB = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
sR = sG = sB = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
sR = sG = sB = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_SRC_ALPHA_SATURATE:
if (As < CHAN_MAX - Ad) {
sR = sG = sB = (GLfloat) As * ascale;
}
else {
sR = sG = sB = 1.0F - (GLfloat) Ad * ascale;
}
break;
case GL_CONSTANT_COLOR:
sR = ctx->Color.BlendColor[0];
sG = ctx->Color.BlendColor[1];
sB = ctx->Color.BlendColor[2];
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
sR = 1.0F - ctx->Color.BlendColor[0];
sG = 1.0F - ctx->Color.BlendColor[1];
sB = 1.0F - ctx->Color.BlendColor[2];
break;
case GL_CONSTANT_ALPHA:
sR = sG = sB = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
sR = sG = sB = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_SRC_COLOR: /* GL_NV_blend_square */
sR = (GLfloat) Rs * rscale;
sG = (GLfloat) Gs * gscale;
sB = (GLfloat) Bs * bscale;
break;
case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */
sR = 1.0F - (GLfloat) Rs * rscale;
sG = 1.0F - (GLfloat) Gs * gscale;
sB = 1.0F - (GLfloat) Bs * bscale;
break;
default:
/* this should never happen */
gl_problem(ctx, "Bad blend source RGB factor in do_blend");
return;
}
/* Source Alpha factor */
switch (ctx->Color.BlendSrcA) {
case GL_ZERO:
sA = 0.0F;
break;
case GL_ONE:
sA = 1.0F;
break;
case GL_DST_COLOR:
sA = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_COLOR:
sA = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_SRC_ALPHA:
sA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
sA = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
sA =(GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
sA = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_SRC_ALPHA_SATURATE:
sA = 1.0;
break;
case GL_CONSTANT_COLOR:
sA = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
sA = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_CONSTANT_ALPHA:
sA = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
sA = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_SRC_COLOR: /* GL_NV_blend_square */
sA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */
sA = 1.0F - (GLfloat) As * ascale;
break;
default:
/* this should never happen */
sA = 0.0F;
gl_problem(ctx, "Bad blend source A factor in do_blend");
}
/* Dest RGB factor */
switch (ctx->Color.BlendDstRGB) {
case GL_ZERO:
dR = dG = dB = 0.0F;
break;
case GL_ONE:
dR = dG = dB = 1.0F;
break;
case GL_SRC_COLOR:
dR = (GLfloat) Rs * rscale;
dG = (GLfloat) Gs * gscale;
dB = (GLfloat) Bs * bscale;
break;
case GL_ONE_MINUS_SRC_COLOR:
dR = 1.0F - (GLfloat) Rs * rscale;
dG = 1.0F - (GLfloat) Gs * gscale;
dB = 1.0F - (GLfloat) Bs * bscale;
break;
case GL_SRC_ALPHA:
dR = dG = dB = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
dR = dG = dB = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
dR = dG = dB = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
dR = dG = dB = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_CONSTANT_COLOR:
dR = ctx->Color.BlendColor[0];
dG = ctx->Color.BlendColor[1];
dB = ctx->Color.BlendColor[2];
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
dR = 1.0F - ctx->Color.BlendColor[0];
dG = 1.0F - ctx->Color.BlendColor[1];
dB = 1.0F - ctx->Color.BlendColor[2];
break;
case GL_CONSTANT_ALPHA:
dR = dG = dB = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
dR = dG = dB = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_DST_COLOR: /* GL_NV_blend_square */
dR = (GLfloat) Rd * rscale;
dG = (GLfloat) Gd * gscale;
dB = (GLfloat) Bd * bscale;
break;
case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */
dR = 1.0F - (GLfloat) Rd * rscale;
dG = 1.0F - (GLfloat) Gd * gscale;
dB = 1.0F - (GLfloat) Bd * bscale;
break;
default:
/* this should never happen */
dR = dG = dB = 0.0F;
gl_problem(ctx, "Bad blend dest RGB factor in do_blend");
}
/* Dest Alpha factor */
switch (ctx->Color.BlendDstA) {
case GL_ZERO:
dA = 0.0F;
break;
case GL_ONE:
dA = 1.0F;
break;
case GL_SRC_COLOR:
dA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_COLOR:
dA = 1.0F - (GLfloat) As * ascale;
break;
case GL_SRC_ALPHA:
dA = (GLfloat) As * ascale;
break;
case GL_ONE_MINUS_SRC_ALPHA:
dA = (GLfloat) 1.0F - (GLfloat) As * ascale;
break;
case GL_DST_ALPHA:
dA = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_ALPHA:
dA = 1.0F - (GLfloat) Ad * ascale;
break;
case GL_CONSTANT_COLOR:
dA = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
dA = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_CONSTANT_ALPHA:
dA = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
dA = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_DST_COLOR: /* GL_NV_blend_square */
dA = (GLfloat) Ad * ascale;
break;
case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */
dA = 1.0F - (GLfloat) Ad * ascale;
break;
default:
/* this should never happen */
dA = 0.0F;
gl_problem(ctx, "Bad blend dest A factor in do_blend");
return;
}
/* Due to round-off problems we have to clamp against zero. */
/* Optimization: we don't have to do this for all src & dst factors */
if (dA < 0.0F) dA = 0.0F;
if (dR < 0.0F) dR = 0.0F;
if (dG < 0.0F) dG = 0.0F;
if (dB < 0.0F) dB = 0.0F;
if (sA < 0.0F) sA = 0.0F;
if (sR < 0.0F) sR = 0.0F;
if (sG < 0.0F) sG = 0.0F;
if (sB < 0.0F) sB = 0.0F;
ASSERT( sR <= 1.0 );
ASSERT( sG <= 1.0 );
ASSERT( sB <= 1.0 );
ASSERT( sA <= 1.0 );
ASSERT( dR <= 1.0 );
ASSERT( dG <= 1.0 );
ASSERT( dB <= 1.0 );
ASSERT( dA <= 1.0 );
/* compute blended color */
if (ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) {
r = Rs * sR + Rd * dR + 0.5F;
g = Gs * sG + Gd * dG + 0.5F;
b = Bs * sB + Bd * dB + 0.5F;
a = As * sA + Ad * dA + 0.5F;
}
else if (ctx->Color.BlendEquation==GL_FUNC_SUBTRACT_EXT) {
r = Rs * sR - Rd * dR + 0.5F;
g = Gs * sG - Gd * dG + 0.5F;
b = Bs * sB - Bd * dB + 0.5F;
a = As * sA - Ad * dA + 0.5F;
}
else if (ctx->Color.BlendEquation==GL_FUNC_REVERSE_SUBTRACT_EXT) {
r = Rd * dR - Rs * sR + 0.5F;
g = Gd * dG - Gs * sG + 0.5F;
b = Bd * dB - Bs * sB + 0.5F;
a = Ad * dA - As * sA + 0.5F;
}
else {
/* should never get here */
r = g = b = a = 0.0F; /* silence uninitialized var warning */
gl_problem(ctx, "unexpected BlendEquation in blend_general()");
}
/* final clamping */
rgba[i][RCOMP] = (GLchan) (GLint) CLAMP( r, 0.0F, CHAN_MAXF );
rgba[i][GCOMP] = (GLchan) (GLint) CLAMP( g, 0.0F, CHAN_MAXF );
rgba[i][BCOMP] = (GLchan) (GLint) CLAMP( b, 0.0F, CHAN_MAXF );
rgba[i][ACOMP] = (GLchan) (GLint) CLAMP( a, 0.0F, CHAN_MAXF );
}
}
}
#if defined(USE_MMX_ASM)
#include "X86/mmx.h"
#include "X86/common_x86_asm.h"
#endif
/*
* Analyze current blending parameters to pick fastest blending function.
* Result: the ctx->Color.BlendFunc pointer is updated.
*/
static void set_blend_function( GLcontext *ctx )
{
const GLenum eq = ctx->Color.BlendEquation;
const GLenum srcRGB = ctx->Color.BlendSrcRGB;
const GLenum dstRGB = ctx->Color.BlendDstRGB;
const GLenum srcA = ctx->Color.BlendSrcA;
const GLenum dstA = ctx->Color.BlendDstA;
#if defined(USE_MMX_ASM)
/* Hmm. A table here would have 12^4 == way too many entries.
* Provide a hook for MMX instead.
*/
if ( cpu_has_mmx ) {
gl_mmx_set_blend_function( ctx );
}
else
#endif
if (srcRGB != srcA || dstRGB != dstA) {
ctx->Color.BlendFunc = blend_general;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB==GL_SRC_ALPHA
&& dstRGB==GL_ONE_MINUS_SRC_ALPHA) {
ctx->Color.BlendFunc = blend_transparency;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB==GL_ONE && dstRGB==GL_ONE) {
ctx->Color.BlendFunc = blend_add;
}
else if (((eq==GL_FUNC_ADD_EXT || eq==GL_FUNC_REVERSE_SUBTRACT_EXT)
&& (srcRGB==GL_ZERO && dstRGB==GL_SRC_COLOR))
||
((eq==GL_FUNC_ADD_EXT || eq==GL_FUNC_SUBTRACT_EXT)
&& (srcRGB==GL_DST_COLOR && dstRGB==GL_ZERO))) {
ctx->Color.BlendFunc = blend_modulate;
}
else if (eq==GL_MIN_EXT) {
ctx->Color.BlendFunc = blend_min;
}
else if (eq==GL_MAX_EXT) {
ctx->Color.BlendFunc = blend_max;
}
else {
ctx->Color.BlendFunc = blend_general;
}
}
/*
* Apply the blending operator to a span of pixels.
* Input: n - number of pixels in span
* x, y - location of leftmost pixel in span in window coords.
* mask - boolean mask indicating which pixels to blend.
* In/Out: rgba - pixel values
*/
void
_mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLchan rgba[][4], const GLubyte mask[] )
{
GLchan dest[MAX_WIDTH][4];
/* Check if device driver can do the work */
if (ctx->Color.BlendEquation==GL_LOGIC_OP &&
!ctx->Color.ColorLogicOpEnabled) {
return;
}
/* Read span of current frame buffer pixels */
gl_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
if (!ctx->Color.BlendFunc)
set_blend_function(ctx);
(*ctx->Color.BlendFunc)( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
}
/*
* Apply the blending operator to an array of pixels.
* Input: n - number of pixels in span
* x, y - array of pixel locations
* mask - boolean mask indicating which pixels to blend.
* In/Out: rgba - pixel values
*/
void
_mesa_blend_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
GLchan dest[PB_SIZE][4];
/* Check if device driver can do the work */
if (ctx->Color.BlendEquation==GL_LOGIC_OP &&
!ctx->Color.ColorLogicOpEnabled) {
return;
}
/* Read pixels from current color buffer */
(*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
if (!ctx->Color.BlendFunc)
set_blend_function(ctx);
(*ctx->Color.BlendFunc)( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
}

View file

@ -1,4 +1,4 @@
/* $Id: blend.h,v 1.5 2000/10/28 18:34:48 brianp Exp $ */
/* $Id: blend.h,v 1.6 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,19 +31,6 @@
#include "types.h"
extern void
_mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLchan rgba[][4], const GLubyte mask[] );
extern void
_mesa_blend_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
extern void
_mesa_BlendFunc( GLenum sfactor, GLenum dfactor );

View file

@ -1,4 +1,4 @@
/* $Id: buffers.c,v 1.17 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: buffers.c,v 1.18 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,7 +30,6 @@
#else
#include "glheader.h"
#include "accum.h"
#include "alphabuf.h"
#include "buffers.h"
#include "context.h"
#include "depth.h"
@ -41,6 +40,7 @@
#include "stencil.h"
#include "state.h"
#include "types.h"
#include "swrast/swrast.h"
#endif
@ -86,172 +86,12 @@ _mesa_ClearColor( GLclampf red, GLclampf green,
/*
* Clear the color buffer when glColorMask or glIndexMask is in effect.
*/
static void
clear_color_buffer_with_masking( GLcontext *ctx )
{
const GLint x = ctx->DrawBuffer->Xmin;
const GLint y = ctx->DrawBuffer->Ymin;
const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
if (ctx->Visual.RGBAflag) {
/* RGBA mode */
const GLchan r = (GLint) (ctx->Color.ClearColor[0] * CHAN_MAXF);
const GLchan g = (GLint) (ctx->Color.ClearColor[1] * CHAN_MAXF);
const GLchan b = (GLint) (ctx->Color.ClearColor[2] * CHAN_MAXF);
const GLchan a = (GLint) (ctx->Color.ClearColor[3] * CHAN_MAXF);
GLint i;
for (i = 0; i < height; i++) {
GLchan rgba[MAX_WIDTH][4];
GLint j;
for (j=0; j<width; j++) {
rgba[j][RCOMP] = r;
rgba[j][GCOMP] = g;
rgba[j][BCOMP] = b;
rgba[j][ACOMP] = a;
}
_mesa_mask_rgba_span( ctx, width, x, y + i, rgba );
(*ctx->Driver.WriteRGBASpan)( ctx, width, x, y + i,
(CONST GLchan (*)[4]) rgba, NULL );
}
}
else {
/* Color index mode */
GLuint span[MAX_WIDTH];
GLubyte mask[MAX_WIDTH];
GLint i, j;
MEMSET( mask, 1, width );
for (i=0;i<height;i++) {
for (j=0;j<width;j++) {
span[j] = ctx->Color.ClearIndex;
}
_mesa_mask_index_span( ctx, width, x, y + i, span );
(*ctx->Driver.WriteCI32Span)( ctx, width, x, y + i, span, mask );
}
}
}
/*
* Clear a color buffer without index/channel masking.
*/
static void
clear_color_buffer(GLcontext *ctx)
{
const GLint x = ctx->DrawBuffer->Xmin;
const GLint y = ctx->DrawBuffer->Ymin;
const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
if (ctx->Visual.RGBAflag) {
/* RGBA mode */
const GLchan r = (GLint) (ctx->Color.ClearColor[0] * CHAN_MAXF);
const GLchan g = (GLint) (ctx->Color.ClearColor[1] * CHAN_MAXF);
const GLchan b = (GLint) (ctx->Color.ClearColor[2] * CHAN_MAXF);
const GLchan a = (GLint) (ctx->Color.ClearColor[3] * CHAN_MAXF);
GLchan span[MAX_WIDTH][4];
GLint i;
ASSERT(colorMask == 0xffffffff);
for (i = 0; i < width; i++) {
span[i][RCOMP] = r;
span[i][GCOMP] = g;
span[i][BCOMP] = b;
span[i][ACOMP] = a;
}
for (i = 0; i < height; i++) {
(*ctx->Driver.WriteRGBASpan)( ctx, width, x, y + i,
(CONST GLchan (*)[4]) span, NULL );
}
}
else {
/* Color index mode */
ASSERT(ctx->Color.IndexMask == ~0);
if (ctx->Visual.IndexBits == 8) {
/* 8-bit clear */
GLubyte span[MAX_WIDTH];
GLint i;
MEMSET(span, ctx->Color.ClearIndex, width);
for (i = 0; i < height; i++) {
(*ctx->Driver.WriteCI8Span)( ctx, width, x, y + i, span, NULL );
}
}
else {
/* non 8-bit clear */
GLuint span[MAX_WIDTH];
GLint i;
for (i = 0; i < width; i++) {
span[i] = ctx->Color.ClearIndex;
}
for (i = 0; i < height; i++) {
(*ctx->Driver.WriteCI32Span)( ctx, width, x, y + i, span, NULL );
}
}
}
}
/*
* Clear the front/back/left/right color buffers.
* This function is usually only called if we need to clear the
* buffers with masking.
*/
static void
clear_color_buffers(GLcontext *ctx)
{
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
GLuint bufferBit;
/* loop over four possible dest color buffers */
for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
if (bufferBit & ctx->Color.DrawDestMask) {
if (bufferBit == FRONT_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
(void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
}
else if (bufferBit == FRONT_RIGHT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
(void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
}
else if (bufferBit == BACK_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
(void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT);
}
else {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
(void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
}
if (colorMask != 0xffffffff) {
clear_color_buffer_with_masking(ctx);
}
else {
clear_color_buffer(ctx);
}
}
}
/* restore default read/draw buffers */
(void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
(void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer );
}
void
_mesa_Clear( GLbitfield mask )
{
GET_CURRENT_CONTEXT(ctx);
#ifdef PROFILE
GLdouble t0 = gl_time();
#endif
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClear");
if (MESA_VERBOSE & VERBOSE_API)
@ -298,29 +138,9 @@ _mesa_Clear( GLbitfield mask )
}
#endif
RENDER_START(ctx);
/* do software clearing here */
if (newMask) {
if (newMask & ctx->Color.DrawDestMask) clear_color_buffers(ctx);
if (newMask & GL_DEPTH_BUFFER_BIT) _mesa_clear_depth_buffer(ctx);
if (newMask & GL_ACCUM_BUFFER_BIT) _mesa_clear_accum_buffer(ctx);
if (newMask & GL_STENCIL_BUFFER_BIT) _mesa_clear_stencil_buffer(ctx);
}
/* clear software-based alpha buffer(s) */
if ( (mask & GL_COLOR_BUFFER_BIT)
&& ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]) {
_mesa_clear_alpha_buffers( ctx );
}
RENDER_FINISH(ctx);
#ifdef PROFILE
ctx->ClearTime += gl_time() - t0;
ctx->ClearCount++;
#endif
if (newMask)
_swrast_Clear( ctx, newMask, !ctx->Scissor.Enabled,
x, y, width, height );
}
}
@ -561,17 +381,5 @@ _mesa_ResizeBuffersMESA( void )
ctx->DrawBuffer->Width = buf_width;
ctx->DrawBuffer->Height = buf_height;
/* Reallocate other buffers if needed. */
if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
_mesa_alloc_depth_buffer( ctx );
}
if (ctx->DrawBuffer->UseSoftwareStencilBuffer) {
_mesa_alloc_stencil_buffer( ctx );
}
if (ctx->DrawBuffer->UseSoftwareAccumBuffer) {
_mesa_alloc_accum_buffer( ctx );
}
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
_mesa_alloc_alpha_buffers( ctx );
}
_swrast_alloc_buffers( ctx );
}

View file

@ -1,4 +1,4 @@
/* $Id: colortab.c,v 1.24 2000/10/30 13:32:00 keithw Exp $ */
/* $Id: colortab.c,v 1.25 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -35,7 +35,6 @@
#include "macros.h"
#include "mem.h"
#include "mmath.h"
#include "span.h"
#endif

View file

@ -1,4 +1,4 @@
/* $Id: context.c,v 1.101 2000/10/30 18:50:42 keithw Exp $ */
/* $Id: context.c,v 1.102 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -49,7 +49,6 @@
#include "matrix.h"
#include "mem.h"
#include "mmath.h"
#include "pb.h"
#include "pipeline.h"
#include "shade.h"
#include "simple_list.h"
@ -66,6 +65,7 @@
#include "vbxform.h"
#include "vertices.h"
#include "xform.h"
#include "swrast/swrast.h"
#endif
#if defined(MESA_TRACE)
@ -445,7 +445,6 @@ one_time_init( void )
gl_init_clip();
gl_init_eval();
_mesa_init_fog();
_mesa_init_math();
gl_init_lists();
gl_init_shade();
@ -1470,9 +1469,8 @@ _mesa_initialize_context( GLcontext *ctx,
return GL_FALSE;
}
ctx->input = ctx->VB->IM;
ctx->PB = gl_alloc_pb();
if (!ctx->PB) {
if (!_swrast_create_context( ctx )) {
ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
@ -1486,7 +1484,7 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Shared = alloc_shared_state();
if (!ctx->Shared) {
ALIGN_FREE( ctx->VB );
FREE( ctx->PB );
_swrast_destroy_context( ctx );
return GL_FALSE;
}
}
@ -1517,7 +1515,7 @@ _mesa_initialize_context( GLcontext *ctx,
if (!alloc_proxy_textures(ctx)) {
free_shared_state(ctx, ctx->Shared);
ALIGN_FREE( ctx->VB );
FREE( ctx->PB );
_swrast_destroy_context( ctx );
return GL_FALSE;
}
@ -1545,7 +1543,7 @@ _mesa_initialize_context( GLcontext *ctx,
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
ALIGN_FREE( ctx->VB );
FREE( ctx->PB );
_swrast_destroy_context( ctx );
if (ctx->Exec)
FREE( ctx->Exec );
}
@ -1561,7 +1559,7 @@ _mesa_initialize_context( GLcontext *ctx,
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
ALIGN_FREE( ctx->VB );
FREE( ctx->PB );
_swrast_destroy_context( ctx );
FREE( ctx->Exec );
FREE( ctx->Save );
return GL_FALSE;
@ -1575,7 +1573,7 @@ _mesa_initialize_context( GLcontext *ctx,
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
ALIGN_FREE( ctx->VB );
FREE( ctx->PB );
_swrast_destroy_context( ctx );
FREE( ctx->Exec );
FREE( ctx->Save );
FREE( ctx->TraceCtx );
@ -1649,7 +1647,7 @@ _mesa_free_context_data( GLcontext *ctx )
}
}
FREE( ctx->PB );
_swrast_destroy_context( ctx );
if (ctx->input != ctx->VB->IM)
gl_immediate_free( ctx->input );

View file

@ -1,4 +1,4 @@
/* $Id: convolve.c,v 1.8 2000/10/30 13:32:00 keithw Exp $ */
/* $Id: convolve.c,v 1.9 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -41,7 +41,6 @@
#include "convolve.h"
#include "context.h"
#include "image.h"
#include "span.h"
#include "types.h"
#endif

View file

@ -1,4 +1,4 @@
/* $Id: dd.h,v 1.36 2000/10/30 13:32:00 keithw Exp $ */
/* $Id: dd.h,v 1.37 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -474,6 +474,11 @@ struct dd_function_table {
/* This is called by glBitmap. Works the same as DrawPixels, above.
*/
GLboolean (*Accum)( GLcontext *ctx, GLenum op,
GLfloat value, GLint xpos, GLint ypos,
GLint width, GLint height );
/* Hardware accum buffer.
*/
/***
*** Texture mapping functions:

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: depth.h,v 1.8 2000/04/11 20:42:22 brianp Exp $ */
/* $Id: depth.h,v 1.9 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -49,41 +49,5 @@ _mesa_DepthMask( GLboolean flag );
/*
* Internal functions
*/
extern GLvoid *
_mesa_zbuffer_address(GLcontext *ctx, GLint x, GLint y);
extern GLuint
_mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] );
extern void
_mesa_depth_test_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
extern void
_mesa_read_depth_span( GLcontext *ctx,
GLint n, GLint x, GLint y, GLdepth depth[] );
extern void
_mesa_read_depth_span_float( GLcontext *ctx, GLint n, GLint x, GLint y,
GLfloat depth[] );
extern void
_mesa_alloc_depth_buffer( GLcontext* ctx );
extern void
_mesa_clear_depth_buffer( GLcontext* ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: drawpix.c,v 1.43 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: drawpix.c,v 1.44 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,819 +31,17 @@
#include "glheader.h"
#include "colormac.h"
#include "context.h"
#include "convolve.h"
#include "drawpix.h"
#include "feedback.h"
#include "image.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
#include "pixel.h"
#include "pixeltex.h"
#include "span.h"
#include "state.h"
#include "stencil.h"
#include "texture.h"
#include "types.h"
#include "zoom.h"
#include "swrast/swrast.h"
#endif
/*
* Given the dest position, size and skipPixels and skipRows values
* for a glDrawPixels command, perform clipping of the image bounds
* so the result lies withing the context's buffer bounds.
* Return: GL_TRUE if image is ready for drawing
* GL_FALSE if image was completely clipped away (draw nothing)
*/
GLboolean
_mesa_clip_pixelrect(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
GLint *skipPixels, GLint *skipRows)
{
const GLframebuffer *buffer = ctx->DrawBuffer;
/* left clipping */
if (*destX < buffer->Xmin) {
*skipPixels += (buffer->Xmin - *destX);
*width -= (buffer->Xmin - *destX);
*destX = buffer->Xmin;
}
/* right clipping */
if (*destX + *width > buffer->Xmax)
*width -= (*destX + *width - buffer->Xmax);
if (*width <= 0)
return GL_FALSE;
/* bottom clipping */
if (*destY < buffer->Ymin) {
*skipRows += (buffer->Ymin - *destY);
*height -= (buffer->Ymin - *destY);
*destY = buffer->Ymin;
}
/* top clipping */
if (*destY + *height > buffer->Ymax)
*height -= (*destY + *height - buffer->Ymax);
if (*height <= 0)
return GL_TRUE;
return GL_TRUE;
}
/*
* Try to do a fast and simple RGB(a) glDrawPixels.
* Return: GL_TRUE if success, GL_FALSE if slow path must be used instead
*/
static GLboolean
fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels)
{
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
GLchan rgb[MAX_WIDTH][3];
GLchan rgba[MAX_WIDTH][4];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glDrawPixels",
GL_FALSE);
if (!ctx->Current.RasterPosValid) {
return GL_TRUE; /* no-op */
}
if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0
&& ctx->Texture.ReallyEnabled == 0
&& unpack->Alignment == 1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
GLint destX = x;
GLint destY = y;
GLint drawWidth = width; /* actual width drawn */
GLint drawHeight = height; /* actual height drawn */
GLint skipPixels = unpack->SkipPixels;
GLint skipRows = unpack->SkipRows;
GLint rowLength;
GLdepth zSpan[MAX_WIDTH]; /* only used when zooming */
GLint zoomY0 = 0;
if (unpack->RowLength > 0)
rowLength = unpack->RowLength;
else
rowLength = width;
/* If we're not using pixel zoom then do all clipping calculations
* now. Otherwise, we'll let the gl_write_zoomed_*_span() functions
* handle the clipping.
*/
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* horizontal clipping */
if (destX < ctx->DrawBuffer->Xmin) {
skipPixels += (ctx->DrawBuffer->Xmin - destX);
drawWidth -= (ctx->DrawBuffer->Xmin - destX);
destX = ctx->DrawBuffer->Xmin;
}
if (destX + drawWidth > ctx->DrawBuffer->Xmax)
drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax);
if (drawWidth <= 0)
return GL_TRUE;
/* vertical clipping */
if (destY < ctx->DrawBuffer->Ymin) {
skipRows += (ctx->DrawBuffer->Ymin - destY);
drawHeight -= (ctx->DrawBuffer->Ymin - destY);
destY = ctx->DrawBuffer->Ymin;
}
if (destY + drawHeight > ctx->DrawBuffer->Ymax)
drawHeight -= (destY + drawHeight - ctx->DrawBuffer->Ymax);
if (drawHeight <= 0)
return GL_TRUE;
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down image */
/* horizontal clipping */
if (destX < ctx->DrawBuffer->Xmin) {
skipPixels += (ctx->DrawBuffer->Xmin - destX);
drawWidth -= (ctx->DrawBuffer->Xmin - destX);
destX = ctx->DrawBuffer->Xmin;
}
if (destX + drawWidth > ctx->DrawBuffer->Xmax)
drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax);
if (drawWidth <= 0)
return GL_TRUE;
/* vertical clipping */
if (destY > ctx->DrawBuffer->Ymax) {
skipRows += (destY - ctx->DrawBuffer->Ymax);
drawHeight -= (destY - ctx->DrawBuffer->Ymax);
destY = ctx->DrawBuffer->Ymax;
}
if (destY - drawHeight < ctx->DrawBuffer->Ymin)
drawHeight -= (ctx->DrawBuffer->Ymin - (destY - drawHeight));
if (drawHeight <= 0)
return GL_TRUE;
}
else {
/* setup array of fragment Z value to pass to zoom function */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual.DepthMaxF);
GLint i;
ASSERT(drawWidth < MAX_WIDTH);
for (i=0; i<drawWidth; i++)
zSpan[i] = z;
/* save Y value of first row */
zoomY0 = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
}
/*
* Ready to draw!
* The window region at (destX, destY) of size (drawWidth, drawHeight)
* will be written to.
* We'll take pixel data from buffer pointed to by "pixels" but we'll
* skip "skipRows" rows and skip "skipPixels" pixels/row.
*/
if (format == GL_RGBA && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 4;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(void *) src, NULL);
src += rowLength * 4;
destY++;
}
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down */
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(void *) src, NULL);
src += rowLength * 4;
}
}
else {
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
zSpan, 0, (void *) src, zoomY0);
src += rowLength * 4;
destY++;
}
}
}
return GL_TRUE;
}
else if (format == GL_RGB && type == CHAN_TYPE
&& ctx->ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 3;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
GLint row;
for (row=0; row<drawHeight; row++) {
(*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(void *) src, NULL);
src += rowLength * 3;
destY++;
}
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down */
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
(*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(void *) src, NULL);
src += rowLength * 3;
}
}
else {
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
gl_write_zoomed_rgb_span(ctx, drawWidth, destX, destY,
zSpan, 0, (void *) src, zoomY0);
src += rowLength * 3;
destY++;
}
}
}
return GL_TRUE;
}
else if (format == GL_LUMINANCE && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels);
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
rgb[i][0] = src[i];
rgb[i][1] = src[i];
rgb[i][2] = src[i];
}
(*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(void *) rgb, NULL);
src += rowLength;
destY++;
}
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
rgb[i][0] = src[i];
rgb[i][1] = src[i];
rgb[i][2] = src[i];
}
destY--;
(*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(void *) rgb, NULL);
src += rowLength;
}
}
else {
/* with zooming */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
rgb[i][0] = src[i];
rgb[i][1] = src[i];
rgb[i][2] = src[i];
}
gl_write_zoomed_rgb_span(ctx, drawWidth, destX, destY,
zSpan, 0, (void *) rgb, zoomY0);
src += rowLength;
destY++;
}
}
}
return GL_TRUE;
}
else if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE
&& ctx->ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels)*2;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
rgba[i][1] = *ptr;
rgba[i][2] = *ptr++;
rgba[i][3] = *ptr++;
}
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(void *) rgba, NULL);
src += rowLength*2;
destY++;
}
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
rgba[i][1] = *ptr;
rgba[i][2] = *ptr++;
rgba[i][3] = *ptr++;
}
destY--;
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(void *) rgba, NULL);
src += rowLength*2;
}
}
else {
/* with zooming */
GLint row;
ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLchan *ptr = src;
GLint i;
for (i=0;i<drawWidth;i++) {
rgba[i][0] = *ptr;
rgba[i][1] = *ptr;
rgba[i][2] = *ptr++;
rgba[i][3] = *ptr++;
}
gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
zSpan, 0, (void *) rgba, zoomY0);
src += rowLength*2;
destY++;
}
}
}
return GL_TRUE;
}
else if (format==GL_COLOR_INDEX && type==GL_UNSIGNED_BYTE) {
GLubyte *src = (GLubyte *) pixels + skipRows * rowLength + skipPixels;
if (ctx->Visual.RGBAflag) {
/* convert CI data to RGBA */
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(const GLchan (*)[4]) rgba,
NULL);
src += rowLength;
destY++;
}
return GL_TRUE;
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down */
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
destY--;
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(const GLchan (*)[4]) rgba,
NULL);
src += rowLength;
}
return GL_TRUE;
}
else {
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
zSpan, 0, (void *) rgba, zoomY0);
src += rowLength;
destY++;
}
return GL_TRUE;
}
}
else if (ctx->ImageTransferState==0) {
/* write CI data to CI frame buffer */
GLint row;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
for (row=0; row<drawHeight; row++) {
(*ctx->Driver.WriteCI8Span)(ctx, drawWidth, destX, destY,
src, NULL);
src += rowLength;
destY++;
}
return GL_TRUE;
}
else {
/* with zooming */
return GL_FALSE;
}
}
}
else {
/* can't handle this pixel format and/or data type here */
return GL_FALSE;
}
}
/* can't do a simple draw, have to use slow path */
return GL_FALSE;
}
/*
* Do glDrawPixels of index pixels.
*/
static void
draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum type, const GLvoid *pixels )
{
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLint row, drawWidth;
GLdepth zspan[MAX_WIDTH];
drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual.DepthMaxF);
GLint i;
for (i = 0; i < drawWidth; i++) {
zspan[i] = zval;
}
}
/*
* General solution
*/
for (row = 0; row < height; row++, y++) {
GLuint indexes[MAX_WIDTH];
const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
type, source, &ctx->Unpack,
ctx->ImageTransferState);
if (zoom) {
gl_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, desty);
}
else {
gl_write_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, GL_BITMAP);
}
}
}
/*
* Do glDrawPixels of stencil image. The image datatype may either
* be GLubyte or GLbitmap.
*/
static void
draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum type, const GLvoid *pixels )
{
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLint row, drawWidth;
if (type != GL_BYTE &&
type != GL_UNSIGNED_BYTE &&
type != GL_SHORT &&
type != GL_UNSIGNED_SHORT &&
type != GL_INT &&
type != GL_UNSIGNED_INT &&
type != GL_FLOAT &&
type != GL_BITMAP) {
gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels(stencil type)");
return;
}
drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
for (row = 0; row < height; row++, y++) {
GLstencil values[MAX_WIDTH];
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, destType, values,
type, source, &ctx->Unpack,
ctx->ImageTransferState);
if (ctx->ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
_mesa_shift_and_offset_stencil( ctx, drawWidth, values );
}
if (ctx->Pixel.MapStencilFlag) {
_mesa_map_stencil( ctx, drawWidth, values );
}
if (zoom) {
gl_write_zoomed_stencil_span( ctx, (GLuint) drawWidth, x, y,
values, desty );
}
else {
_mesa_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values );
}
}
}
/*
* Do a glDrawPixels of depth values.
*/
static void
draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum type, const GLvoid *pixels )
{
const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLchan rgba[MAX_WIDTH][4];
GLuint ispan[MAX_WIDTH];
GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
if (type != GL_BYTE
&& type != GL_UNSIGNED_BYTE
&& type != GL_SHORT
&& type != GL_UNSIGNED_SHORT
&& type != GL_INT
&& type != GL_UNSIGNED_INT
&& type != GL_FLOAT) {
gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels(type)");
return;
}
/* Colors or indexes */
if (ctx->Visual.RGBAflag) {
GLint r = FLOAT_TO_CHAN(ctx->Current.RasterColor[0]);
GLint g = FLOAT_TO_CHAN(ctx->Current.RasterColor[1]);
GLint b = FLOAT_TO_CHAN(ctx->Current.RasterColor[2]);
GLint a = FLOAT_TO_CHAN(ctx->Current.RasterColor[3]);
GLint i;
for (i = 0; i < drawWidth; i++) {
rgba[i][RCOMP] = r;
rgba[i][GCOMP] = g;
rgba[i][BCOMP] = b;
rgba[i][ACOMP] = a;
}
}
else {
GLint i;
for (i = 0; i < drawWidth; i++) {
ispan[i] = ctx->Current.RasterIndex;
}
}
if (type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort)
&& !bias_or_scale && !zoom && ctx->Visual.RGBAflag) {
/* Special case: directly write 16-bit depth values */
GLint row;
for (row = 0; row < height; row++, y++) {
GLdepth zspan[MAX_WIDTH];
const GLushort *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
GLint i;
for (i = 0; i < width; i++)
zspan[i] = zptr[i];
gl_write_rgba_span( ctx, width, x, y, zspan, 0, rgba, GL_BITMAP );
}
}
else if (type==GL_UNSIGNED_INT && ctx->Visual.DepthBits == 32
&& !bias_or_scale && !zoom && ctx->Visual.RGBAflag) {
/* Special case: directly write 32-bit depth values */
GLint row;
for (row = 0; row < height; row++, y++) {
const GLuint *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
gl_write_rgba_span( ctx, width, x, y, zptr, 0, rgba, GL_BITMAP );
}
}
else {
/* General case */
GLint row;
for (row = 0; row < height; row++, y++) {
GLdepth zspan[MAX_WIDTH];
const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
_mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src,
&ctx->Unpack, ctx->ImageTransferState );
if (ctx->Visual.RGBAflag) {
if (zoom) {
gl_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0,
(const GLchan (*)[4]) rgba, desty);
}
else {
gl_write_rgba_span(ctx, width, x, y, zspan, 0, rgba, GL_BITMAP);
}
}
else {
if (zoom) {
gl_write_zoomed_index_span(ctx, width, x, y, zspan, 0,
ispan, GL_BITMAP);
}
else {
gl_write_index_span(ctx, width, x, y, zspan, 0,
ispan, GL_BITMAP);
}
}
}
}
}
/*
* Do glDrawPixels of RGBA pixels.
*/
static void
draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels )
{
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLdepth zspan[MAX_WIDTH];
GLboolean quickDraw;
GLfloat *convImage = NULL;
GLuint transferOps = ctx->ImageTransferState;
if (!_mesa_is_legal_format_and_type(format, type)) {
gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
return;
}
/* Try an optimized glDrawPixels first */
if (fast_draw_pixels(ctx, x, y, width, height, format, type, pixels))
return;
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual.DepthMaxF);
GLint i;
for (i=0;i<width;i++) {
zspan[i] = z;
}
}
if (ctx->RasterMask == 0 && !zoom && x >= 0 && y >= 0
&& x + width <= ctx->DrawBuffer->Width
&& y + height <= ctx->DrawBuffer->Height) {
quickDraw = GL_TRUE;
}
else {
quickDraw = GL_FALSE;
}
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
/* Convolution has to be handled specially. We'll create an
* intermediate image, applying all pixel transfer operations
* up to convolution. Then we'll convolve the image. Then
* we'll proceed with the rest of the transfer operations and
* rasterize the image.
*/
GLint row;
GLfloat *dest, *tmpImage;
tmpImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat));
if (!tmpImage) {
gl_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
return;
}
convImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat));
if (!convImage) {
FREE(tmpImage);
gl_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
return;
}
/* Unpack the image and apply transfer ops up to convolution */
dest = tmpImage;
for (row = 0; row < height; row++) {
const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
_mesa_unpack_float_color_span(ctx, width, GL_RGBA, (void *) dest,
format, type, source, unpack,
transferOps & IMAGE_PRE_CONVOLUTION_BITS,
GL_FALSE);
dest += width * 4;
}
/* do convolution */
if (ctx->Pixel.Convolution2DEnabled) {
_mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
}
else {
ASSERT(ctx->Pixel.Separable2DEnabled);
_mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
}
FREE(tmpImage);
/* continue transfer ops and draw the convolved image */
unpack = &_mesa_native_packing;
pixels = convImage;
format = GL_RGBA;
type = GL_FLOAT;
transferOps &= IMAGE_POST_CONVOLUTION_BITS;
}
/*
* General solution
*/
{
GLchan rgba[MAX_WIDTH][4];
GLint row;
if (width > MAX_WIDTH)
width = MAX_WIDTH;
for (row = 0; row < height; row++, y++) {
const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
_mesa_unpack_chan_color_span(ctx, width, GL_RGBA, (void*) rgba,
format, type, source, unpack,
transferOps);
if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) ||
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
/* XXX not sure how multitexture is supposed to work here */
MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
_mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q);
gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
primary_rgba, rgba);
}
}
}
if (quickDraw) {
(*ctx->Driver.WriteRGBASpan)( ctx, width, x, y,
(CONST GLchan (*)[]) rgba, NULL);
}
else if (zoom) {
gl_write_zoomed_rgba_span( ctx, width, x, y, zspan, 0,
(CONST GLchan (*)[]) rgba, desty );
}
else {
gl_write_rgba_span( ctx, (GLuint) width, x, y, zspan, 0,
rgba, GL_BITMAP);
}
}
}
if (convImage) {
FREE(convImage);
}
}
/*
@ -872,42 +70,16 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
ctx->OcclusionResult = GL_TRUE;
/* see if device driver can do the drawpix */
RENDER_START(ctx);
if (ctx->Driver.DrawPixels
&& (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,
&ctx->Unpack, pixels)) {
return;
}
/* finished */
} else
_swrast_DrawPixels( ctx, x, y, width, height, format, type,
&ctx->Unpack, pixels );
RENDER_START(ctx);
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );
break;
case GL_DEPTH_COMPONENT:
draw_depth_pixels( ctx, x, y, width, height, type, pixels );
break;
case GL_COLOR_INDEX:
if (ctx->Visual.RGBAflag)
draw_rgba_pixels(ctx, x,y, width, height, format, type, pixels);
else
draw_index_pixels(ctx, x, y, width, height, type, pixels);
break;
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_RGB:
case GL_BGR:
case GL_RGBA:
case GL_BGRA:
case GL_ABGR_EXT:
draw_rgba_pixels(ctx, x, y, width, height, format, type, pixels);
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" );
}
RENDER_FINISH(ctx);
}
else if (ctx->RenderMode==GL_FEEDBACK) {

View file

@ -1,4 +1,4 @@
/* $Id: drawpix.h,v 1.3 1999/11/22 22:21:38 brianp Exp $ */
/* $Id: drawpix.h,v 1.4 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,14 +31,6 @@
#include "types.h"
extern GLboolean
_mesa_clip_pixelrect(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
GLint *skipPixels, GLint *skipRows);
extern void
_mesa_DrawPixels( GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels );

View file

@ -1,4 +1,4 @@
/* $Id: feedback.c,v 1.14 2000/10/30 13:32:00 keithw Exp $ */
/* $Id: feedback.c,v 1.15 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -36,7 +36,6 @@
#include "macros.h"
#include "mmath.h"
#include "types.h"
#include "triangle.h"
#endif
@ -205,6 +204,24 @@ static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv )
}
static GLboolean cull_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
{
struct vertex_buffer *VB = ctx->VB;
GLfloat (*win)[4] = VB->Win.data;
GLfloat ex = win[v1][0] - win[v0][0];
GLfloat ey = win[v1][1] - win[v0][1];
GLfloat fx = win[v2][0] - win[v0][0];
GLfloat fy = win[v2][1] - win[v0][1];
GLfloat c = ex*fy-ey*fx;
if (c * ctx->backface_sign > 0)
return 0;
return 1;
}
/*
* Put triangle in feedback buffer.
@ -212,7 +229,7 @@ static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv )
void gl_feedback_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
{
if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) {
if (cull_triangle( ctx, v0, v1, v2, 0 )) {
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN );
FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */
@ -308,7 +325,7 @@ void gl_select_triangle( GLcontext *ctx,
{
const struct vertex_buffer *VB = ctx->VB;
if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) {
if (cull_triangle( ctx, v0, v1, v2, 0 )) {
const GLfloat zs = 1.0F / ctx->Visual.DepthMaxF;
gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs );
gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs );

View file

@ -1,4 +1,4 @@
/* $Id: fog.c,v 1.26 2000/10/30 13:32:00 keithw Exp $ */
/* $Id: fog.c,v 1.27 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -148,10 +148,6 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
void
_mesa_init_fog( void )
{
}
static GLvector1f *get_fogcoord_ptr( GLcontext *ctx, GLvector1f *tmp )
{
@ -249,157 +245,3 @@ _mesa_make_win_fog_coords( struct vertex_buffer *VB )
make_win_fog_coords( VB, get_fogcoord_ptr( VB->ctx, &tmp ) );
}
/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* fog - array of interpolated screen-space fog coordinates in [0..1]
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
void
_mesa_fog_rgba_pixels( const GLcontext *ctx,
GLuint n,
const GLfixed fog[],
GLchan rgba[][4] )
{
GLfixed rFog = ctx->Fog.Color[0] * CHAN_MAXF;
GLfixed gFog = ctx->Fog.Color[1] * CHAN_MAXF;
GLfixed bFog = ctx->Fog.Color[2] * CHAN_MAXF;
GLuint i;
for (i=0;i<n;i++) {
GLfixed f = CLAMP(fog[i], 0, FIXED_ONE);
GLfixed g = FIXED_ONE - f;
rgba[i][0] = (f*rgba[i][0] + g*rFog) >> FIXED_SHIFT;
rgba[i][1] = (f*rgba[i][1] + g*gFog) >> FIXED_SHIFT;
rgba[i][2] = (f*rgba[i][2] + g*bFog) >> FIXED_SHIFT;
}
}
/*
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* z - array of integer depth values
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
void
_mesa_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfixed fog[], GLuint index[] )
{
GLuint idx = ctx->Fog.Index;
GLuint i;
for (i=0;i<n;i++) {
GLfixed f = FixedToFloat(CLAMP(fog[i], 0, FIXED_ONE));
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F-f) * idx);
}
}
/*
* Calculate fog coords from window z values
* Input: n - number of pixels
* z - array of integer depth values
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*
* Use lookup table & interpolation?
*/
void
_mesa_win_fog_coords_from_z( const GLcontext *ctx,
GLuint n,
const GLdepth z[],
GLfixed fogcoord[] )
{
GLfloat c = ctx->ProjectionMatrix.m[10];
GLfloat d = ctx->ProjectionMatrix.m[14];
GLuint i;
GLfloat tz = ctx->Viewport.WindowMap.m[MAT_TZ];
GLfloat szInv = 1.0F / ctx->Viewport.WindowMap.m[MAT_SZ];
switch (ctx->Fog.Mode) {
case GL_LINEAR:
{
GLfloat fogEnd = ctx->Fog.End;
GLfloat fogScale = (GLfloat) FIXED_ONE / (ctx->Fog.End -
ctx->Fog.Start);
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = -d / (c+ndcz);
if (eyez < 0.0) eyez = -eyez;
fogcoord[i] = (GLint)(fogEnd - eyez) * fogScale;
}
}
break;
case GL_EXP:
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = d / (c+ndcz);
if (eyez < 0.0) eyez = -eyez;
fogcoord[i] = FloatToFixed(exp( -ctx->Fog.Density * eyez ));
}
break;
case GL_EXP2:
{
GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;
GLfloat eyez = d / (c+ndcz);
GLfloat tmp = negDensitySquared * eyez * eyez;
#if defined(__alpha__) || defined(__alpha)
/* XXX this underflow check may be needed for other systems */
if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP;
#endif
fogcoord[i] = FloatToFixed(exp( tmp ));
}
}
break;
default:
gl_problem(ctx, "Bad fog mode in _mesa_win_fog_coords_from_z");
return;
}
}
/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* z - array of integer depth values
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
void
_mesa_depth_fog_rgba_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLchan rgba[][4] )
{
GLfixed fog[MAX_WIDTH];
_mesa_win_fog_coords_from_z( ctx, n, z, fog );
_mesa_fog_rgba_pixels( ctx, n, fog, rgba );
}
/*
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* z - array of integer depth values
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
void
_mesa_depth_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint index[] )
{
GLfixed fog[MAX_WIDTH];
_mesa_win_fog_coords_from_z( ctx, n, z, fog );
_mesa_fog_ci_pixels( ctx, n, fog, index );
}

View file

@ -1,4 +1,4 @@
/* $Id: fog.h,v 1.8 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: fog.h,v 1.9 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -49,39 +49,8 @@ extern void
_mesa_Fogiv(GLenum pname, const GLint *params );
extern void
_mesa_fog_rgba_pixels( const GLcontext *ctx,
GLuint n, const GLfixed fog[],
GLchan rgba[][4] );
extern void
_mesa_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfixed fog[], GLuint indx[] );
extern void
_mesa_make_win_fog_coords( struct vertex_buffer *VB );
extern void
_mesa_win_fog_coords_from_z( const GLcontext *ctx,
GLuint n,
const GLdepth z[],
GLfixed fogcoord[] );
extern void
_mesa_depth_fog_rgba_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLchan rgba[][4] );
extern void
_mesa_depth_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint index[] );
extern void
_mesa_init_fog( void );
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: lines.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */
/* $Id: lines.h,v 1.3 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -38,8 +38,5 @@ _mesa_LineWidth( GLfloat width );
extern void
_mesa_LineStipple( GLint factor, GLushort pattern );
extern void
gl_set_line_function( GLcontext *ctx );
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: points.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */
/* $Id: points.h,v 1.3 2000/10/31 18:09:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -47,7 +47,5 @@ extern void
_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params );
extern void gl_set_point_function( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: state.c,v 1.38 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: state.c,v 1.39 2000/10/31 18:09:45 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -68,7 +68,6 @@
#include "pixeltex.h"
#include "points.h"
#include "polygon.h"
#include "quads.h"
#include "rastpos.h"
#include "readpix.h"
#include "rect.h"
@ -80,12 +79,12 @@
#include "texobj.h"
#include "texstate.h"
#include "texture.h"
#include "triangle.h"
#include "types.h"
#include "varray.h"
#include "vbfill.h"
#include "vbrender.h"
#include "winpos.h"
#include "swrast/swrast.h"
#endif
@ -1002,10 +1001,10 @@ void gl_update_state( GLcontext *ctx )
* and triangle functions.
*/
if (ctx->IndirectTriangles & DD_SW_RASTERIZE) {
gl_set_point_function(ctx);
gl_set_line_function(ctx);
gl_set_triangle_function(ctx);
gl_set_quad_function(ctx);
_swrast_set_point_function(ctx);
_swrast_set_line_function(ctx);
_swrast_set_triangle_function(ctx);
_swrast_set_quad_function(ctx);
if ((ctx->IndirectTriangles &
(DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL)) ==

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: stencil.h,v 1.6 2000/04/11 21:26:57 brianp Exp $ */
/* $Id: stencil.h,v 1.7 2000/10/31 18:09:45 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -49,32 +49,4 @@ _mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass );
extern GLboolean
_mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] );
extern GLboolean
_mesa_stencil_and_ztest_pixels( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] );
extern void
_mesa_read_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
GLstencil stencil[] );
extern void
_mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
const GLstencil stencil[] );
extern void
_mesa_alloc_stencil_buffer( GLcontext *ctx );
extern void
_mesa_clear_stencil_buffer( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: teximage.c,v 1.57 2000/10/30 16:32:43 brianp Exp $ */
/* $Id: teximage.c,v 1.58 2000/10/31 18:09:45 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -35,7 +35,6 @@
#include "macros.h"
#include "mem.h"
#include "mmath.h"
#include "span.h"
#include "state.h"
#include "teximage.h"
#include "texstate.h"

View file

@ -1,4 +1,4 @@
/* $Id: texstate.c,v 1.19 2000/10/30 13:32:01 keithw Exp $ */
/* $Id: texstate.c,v 1.20 2000/10/31 18:09:45 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -41,6 +41,7 @@
#include "texture.h"
#include "types.h"
#include "xform.h"
#include "swrast/swrast.h"
#endif
@ -1683,7 +1684,7 @@ void gl_update_dirty_texobjs( GLcontext *ctx )
for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
next = t->NextDirty;
_mesa_test_texobj_completeness(ctx, t);
_mesa_set_texture_sampler(t);
_swrast_set_texture_sampler(t); /* swrast should do this internally */
t->NextDirty = NULL;
t->Dirty = GL_FALSE;
}