Converted line drawing over to new span code, pb no longer used.

Big clean-up of line drawing code.
Removed many obsolete span processing functions.
This commit is contained in:
Brian Paul
2002-02-02 21:40:33 +00:00
parent 733a4b602b
commit b37a084357
21 changed files with 630 additions and 1286 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: s_aalinetemp.h,v 1.16 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_aalinetemp.h,v 1.17 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -100,7 +100,7 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy)
#endif
if (line->span.end == MAX_WIDTH) {
#ifdef DO_TEX
#if defined(DO_TEX) || defined(DO_MULTITEX)
_mesa_write_texture_span(ctx, &line->span, GL_LINE);
#elif defined(DO_RGBA)
_mesa_write_rgba_span(ctx, &line->span, GL_LINE);
@@ -293,7 +293,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
segment(ctx, &line, NAME(plot), 0.0, 1.0);
}
#ifdef DO_TEX
#if defined(DO_TEX) || defined(DO_MULTITEX)
_mesa_write_texture_span(ctx, &line.span, GL_LINE);
#elif defined(DO_RGBA)
_mesa_write_rgba_span(ctx, &line.span, GL_LINE);

View File

@@ -1,4 +1,4 @@
/* $Id: s_alpha.c,v 1.8 2002/01/31 00:27:43 brianp Exp $ */
/* $Id: s_alpha.c,v 1.9 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -218,64 +218,3 @@ _mesa_alpha_test( const GLcontext *ctx, struct sw_span *span )
else
return 1;
}
/*
* Apply the alpha test to a span of pixels.
* In: rgba - array of pixels
* In/Out: mask - current pixel mask. Pixels which fail the alpha test
* will set the corresponding mask flag to 0.
* Return: 0 = all pixels in the span failed the alpha test.
* 1 = one or more pixels passed the alpha test.
*/
GLint
_old_alpha_test( const GLcontext *ctx,
GLuint n, CONST GLchan rgba[][4], GLubyte mask[] )
{
GLuint i;
const GLchan ref = ctx->Color.AlphaRef;
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) {
case GL_LESS:
for (i=0;i<n;i++) {
mask[i] &= (rgba[i][ACOMP] < ref);
}
return 1;
case GL_LEQUAL:
for (i=0;i<n;i++)
mask[i] &= (rgba[i][ACOMP] <= ref);
return 1;
case GL_GEQUAL:
for (i=0;i<n;i++) {
mask[i] &= (rgba[i][ACOMP] >= ref);
}
return 1;
case GL_GREATER:
for (i=0;i<n;i++) {
mask[i] &= (rgba[i][ACOMP] > ref);
}
return 1;
case GL_NOTEQUAL:
for (i=0;i<n;i++) {
mask[i] &= (rgba[i][ACOMP] != ref);
}
return 1;
case GL_EQUAL:
for (i=0;i<n;i++) {
mask[i] &= (rgba[i][ACOMP] == ref);
}
return 1;
case GL_ALWAYS:
/* do nothing */
return 1;
case GL_NEVER:
/* caller should check for zero! */
return 0;
default:
_mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
return 0;
}
/* Never get here */
/*return 1;*/
}

View File

@@ -1,4 +1,4 @@
/* $Id: s_alpha.h,v 1.5 2002/01/31 00:27:43 brianp Exp $ */
/* $Id: s_alpha.h,v 1.6 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,15 +33,8 @@
#include "swrast.h"
extern GLint
_old_alpha_test( const GLcontext *ctx, GLuint n,
CONST GLchan rgba[][4], GLubyte mask[] );
extern GLint
_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span );
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: s_blend.c,v 1.11 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_blend.c,v 1.12 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_pb.h"
#include "s_span.h"
@@ -702,31 +701,3 @@ _mesa_blend_span( GLcontext *ctx, const struct sw_span *span,
SWRAST_CONTEXT(ctx)->BlendFunc( ctx, span->end, span->mask, rgba,
(const GLchan (*)[4]) framebuffer );
}
/*
* 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[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
ASSERT(!ctx->Color.ColorLogicOpEnabled);
/* Read pixels from current color buffer */
(*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
swrast->BlendFunc( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
}

View File

@@ -1,10 +1,10 @@
/* $Id: s_blend.h,v 1.5 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_blend.h,v 1.6 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.1
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -39,11 +39,6 @@ _mesa_blend_span( GLcontext *ctx, const struct sw_span *span,
GLchan rgba[][4] );
extern void
_mesa_blend_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
extern void
_swrast_choose_blend_func( GLcontext *ctx );

View File

@@ -1,4 +1,4 @@
/* $Id: s_context.c,v 1.28 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_context.c,v 1.29 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,7 +31,7 @@
#include "mtypes.h"
#include "mem.h"
#include "s_pb.h"
#include "swrast.h"
#include "s_points.h"
#include "s_lines.h"
#include "s_triangle.h"
@@ -467,12 +467,6 @@ _swrast_CreateContext( GLcontext *ctx )
if (!swrast)
return GL_FALSE;
swrast->PB = _mesa_alloc_pb();
if (!swrast->PB) {
FREE(swrast);
return GL_FALSE;
}
swrast->NewState = ~0;
swrast->choose_point = _swrast_choose_point;
@@ -513,7 +507,6 @@ _swrast_DestroyContext( GLcontext *ctx )
fprintf(stderr, "_swrast_DestroyContext\n");
}
FREE( swrast->PB );
FREE( swrast );
ctx->swrast_context = 0;
@@ -561,3 +554,10 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
fprintf(stderr, "\n");
}
}
void
_swrast_flush( GLcontext *ctx )
{
/* no-op */
}

View File

@@ -1,4 +1,4 @@
/* $Id: s_context.h,v 1.15 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_context.h,v 1.16 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -123,7 +123,6 @@ typedef struct
/* Working values:
*/
struct pixel_buffer* PB;
GLuint StippleCounter; /* Line stipple counter */
GLuint NewState;
GLuint StateChanges;

View File

@@ -1,4 +1,4 @@
/* $Id: s_depth.c,v 1.14 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_depth.c,v 1.15 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,7 +32,6 @@
#include "s_depth.h"
#include "s_context.h"
#include "s_pb.h"
@@ -533,9 +532,7 @@ depth_test_span32( GLcontext *ctx, GLuint n,
/*
* Apply depth test to span of fragments. Hardware or software z buffer.
*/
GLuint
_old_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] )
@@ -1334,8 +1331,6 @@ hardware_depth_test_pixels( GLcontext *ctx, GLuint n, GLdepth zbuffer[],
}
}
void
_mesa_depth_test_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
@@ -1344,7 +1339,7 @@ _mesa_depth_test_pixels( GLcontext *ctx,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (swrast->Driver.ReadDepthPixels) {
/* read depth values from hardware Z buffer */
GLdepth zbuffer[PB_SIZE];
GLdepth zbuffer[MAX_WIDTH];
(*swrast->Driver.ReadDepthPixels)(ctx, n, x, y, zbuffer);
hardware_depth_test_pixels( ctx, n, zbuffer, z, mask );

View File

@@ -1,10 +1,10 @@
/* $Id: s_fog.c,v 1.20 2002/01/28 03:42:28 brianp Exp $ */
/* $Id: s_fog.c,v 1.21 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.1
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -33,7 +33,6 @@
#include "s_context.h"
#include "s_fog.h"
#include "s_pb.h"
@@ -135,34 +134,6 @@ _mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
}
}
/**
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* fog - array of fog factors in [0,1]
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
void
_old_fog_rgba_pixels( const GLcontext *ctx,
GLuint n,
const GLfloat fog[],
GLchan rgba[][4] )
{
GLuint i;
GLchan rFog, gFog, bFog;
UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]);
for (i = 0; i < n; i++) {
const GLfloat f = fog[i];
const GLfloat g = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + g * rFog);
rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + g * gFog);
rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + g * bFog);
}
}
/**
@@ -217,26 +188,6 @@ _mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
}
}
/**
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* fog - array of fog factors in [0,1]
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
void
_old_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfloat fog[], GLuint index[] )
{
GLuint idx = (GLuint) ctx->Fog.Index;
GLuint i;
for (i = 0; i < n; i++) {
const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * idx);
}
}
/**
@@ -391,35 +342,17 @@ void
_mesa_depth_fog_rgba_pixels(const GLcontext *ctx, struct sw_span *span,
GLchan rgba[][4])
{
GLfloat fogFact[PB_SIZE];
GLfloat fogFact[MAX_WIDTH];
ASSERT(ctx->Fog.Enabled);
ASSERT(span->arrayMask & SPAN_Z);
ASSERT(span->end <= PB_SIZE);
ASSERT(span->end <= MAX_WIDTH);
compute_fog_factors_from_z(ctx, span->end, span->zArray, fogFact );
_mesa_fog_rgba_pixels_with_array( ctx, span, fogFact, rgba );
}
/**
* 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
_old_depth_fog_rgba_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLchan rgba[][4] )
{
GLfloat fogFact[PB_SIZE];
ASSERT(n <= PB_SIZE);
compute_fog_factors_from_z( ctx, n, z, fogFact );
_old_fog_rgba_pixels( ctx, n, fogFact, rgba );
}
/**
* Apply fog to a span of color index pixels.
* Input: ctx -
@@ -431,30 +364,12 @@ void
_mesa_depth_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
GLuint index[] )
{
GLfloat fogFact[PB_SIZE];
GLfloat fogFact[MAX_WIDTH];
ASSERT(ctx->Fog.Enabled);
ASSERT(span->arrayMask & SPAN_Z);
ASSERT(span->end <= PB_SIZE);
ASSERT(span->end <= MAX_WIDTH);
compute_fog_factors_from_z(ctx, span->end, span->zArray, fogFact );
_mesa_fog_ci_pixels_with_array( ctx, span, fogFact, index );
}
/**
* 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
_old_depth_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint index[] )
{
GLfloat fogFact[PB_SIZE];
ASSERT(n <= PB_SIZE);
compute_fog_factors_from_z( ctx, n, z, fogFact );
_old_fog_ci_pixels( ctx, n, fogFact, index );
}

View File

@@ -1,4 +1,4 @@
/* $Id: s_fog.h,v 1.7 2002/01/21 18:12:34 brianp Exp $ */
/* $Id: s_fog.h,v 1.8 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,10 +37,6 @@ extern GLfloat
_mesa_z_to_fogfactor(GLcontext *ctx, GLfloat z);
extern void
_old_fog_rgba_pixels( const GLcontext *ctx,
GLuint n, const GLfloat fog[],
GLchan rgba[][4] );
extern void
_mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
GLchan rgba[][4]);
@@ -55,10 +51,6 @@ _mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
extern void
_mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLuint index[] );
extern void
_old_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfloat fog[],
GLuint indx[] );
extern void
_mesa_win_fog_coords_from_z( const GLcontext *ctx,
@@ -69,15 +61,9 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx,
extern void
_mesa_depth_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
GLchan rgba[][4] );
extern void
_old_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, struct sw_span *span,
GLuint index[] );
extern void
_old_depth_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLdepth z[], GLuint index[] );
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
/* $Id: s_linetemp.h,v 1.11 2002/01/16 20:15:01 brianp Exp $ */
/* $Id: s_linetemp.h,v 1.12 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.1
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -56,11 +56,7 @@
* Optionally, one may provide one-time setup code
* SETUP_CODE - code which is to be executed once per line
*
* To enable line stippling define STIPPLE = 1
* To enable wide lines define WIDE = 1
*
* To actually "plot" each pixel either the PLOT macro or
* (XMAJOR_PLOT and YMAJOR_PLOT macros) must be defined...
* To actually "plot" each pixel the PLOT macro must be defined...
* PLOT(X,Y) - code to plot a pixel. Example:
* if (Z < *zPtr) {
* *zPtr = Z;
@@ -140,16 +136,6 @@
PIXEL_TYPE *pixelPtr;
GLint pixelXstep, pixelYstep;
#endif
#ifdef STIPPLE
SWcontext *swrast = SWRAST_CONTEXT(ctx);
#endif
#ifdef WIDE
/* for wide lines, draw all X in [x+min, x+max] or Y in [y+min, y+max] */
GLint width, min, max;
width = (GLint) CLAMP( ctx->Line.Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
min = (width-1) / -2;
max = min + width - 1;
#endif
#ifdef INTERP_TEX
{
tex[0] = invw0 * vert0->texcoord[0][0];
@@ -313,6 +299,9 @@
GLint errorInc = dy+dy;
GLint error = errorInc-dx;
GLint errorDec = error-dx;
#ifdef SET_XMAJOR
xMajor = GL_TRUE;
#endif
#ifdef INTERP_Z
dz = (z1-z0) / dx;
#endif
@@ -360,11 +349,6 @@
#endif
for (i=0;i<dx;i++) {
#ifdef STIPPLE
GLushort m;
m = 1 << ((swrast->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
GLdepth Z = FixedToDepth(z0);
#endif
@@ -394,26 +378,9 @@
}
}
#endif
#ifdef WIDE
{
GLint yy;
GLint ymin = y0 + min;
GLint ymax = y0 + max;
for (yy=ymin;yy<=ymax;yy++) {
PLOT( x0, yy );
}
}
#else
# ifdef XMAJOR_PLOT
XMAJOR_PLOT( x0, y0 );
# else
PLOT( x0, y0 );
# endif
#endif /*WIDE*/
#ifdef STIPPLE
}
swrast->StippleCounter++;
#endif
#ifdef INTERP_XY
x0 += xstep;
#endif
@@ -535,11 +502,6 @@
#endif
for (i=0;i<dy;i++) {
#ifdef STIPPLE
GLushort m;
m = 1 << ((swrast->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
GLdepth Z = FixedToDepth(z0);
#endif
@@ -569,26 +531,9 @@
}
}
#endif
#ifdef WIDE
{
GLint xx;
GLint xmin = x0 + min;
GLint xmax = x0 + max;
for (xx=xmin;xx<=xmax;xx++) {
PLOT( xx, y0 );
}
}
#else
# ifdef YMAJOR_PLOT
YMAJOR_PLOT( x0, y0 );
# else
PLOT( x0, y0 );
# endif
#endif /*WIDE*/
#ifdef STIPPLE
}
swrast->StippleCounter++;
#endif
#ifdef INTERP_XY
y0 += ystep;
#endif
@@ -675,9 +620,6 @@
#undef BYTES_PER_ROW
#undef SETUP_CODE
#undef PLOT
#undef XMAJOR_PLOT
#undef YMAJOR_PLOT
#undef CLIP_HACK
#undef STIPPLE
#undef WIDE
#undef FixedToDepth
#undef SET_XMAJOR

View File

@@ -1,4 +1,4 @@
/* $Id: s_logic.c,v 1.9 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_logic.c,v 1.10 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,7 +32,6 @@
#include "s_alphabuf.h"
#include "s_context.h"
#include "s_logic.h"
#include "s_pb.h"
#include "s_span.h"
@@ -188,24 +187,6 @@ _mesa_logicop_ci_span( GLcontext *ctx, const struct sw_span *span,
/*
* Apply the current logic operator to an array of CI pixels. This is only
* used if the device driver can't do logic ops.
*/
void
_mesa_logicop_ci_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint dest[PB_SIZE];
/* Read dest values from frame buffer */
(*swrast->Driver.ReadCI32Pixels)( ctx, n, x, y, dest, mask );
index_logicop( ctx, n, index, dest, mask );
}
/*
* Apply logic operator to rgba pixels.
* Input: ctx - the context
@@ -512,29 +493,3 @@ _mesa_logicop_rgba_span( GLcontext *ctx, const struct sw_span *span,
(GLchan *) rgba, (const GLchan *) dest);
}
}
/*
* Apply the current logic operator to an array of RGBA pixels.
* This is only used if the device driver can't do logic ops.
*/
void
_mesa_logicop_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
(*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
if (sizeof(GLchan) * 4 == sizeof(GLuint)) {
rgba_logicop_ui(ctx, n, mask, (GLuint *) rgba, (const GLuint *) dest);
}
else {
rgba_logicop_chan(ctx, 4 * n, mask,
(GLchan *) rgba, (const GLchan *) dest);
}
}

View File

@@ -1,4 +1,4 @@
/* $Id: s_logic.h,v 1.4 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_logic.h,v 1.5 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,21 +38,9 @@ _mesa_logicop_ci_span( GLcontext *ctx, const struct sw_span *span,
GLuint index[] );
extern void
_mesa_logicop_ci_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] );
extern void
_mesa_logicop_rgba_span( GLcontext *ctx, const struct sw_span *span,
GLchan rgba[][4] );
extern void
_mesa_logicop_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: s_masking.c,v 1.6 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_masking.c,v 1.7 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,7 +37,6 @@
#include "s_alphabuf.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_pb.h"
#include "s_span.h"
@@ -136,58 +135,6 @@ _mesa_mask_rgba_array( GLcontext *ctx,
/*
* Apply glColorMask to an array of RGBA pixels.
*/
void
_mesa_mask_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
GLuint i;
#if CHAN_BITS == 8
GLuint srcMask = *((GLuint*)ctx->Color.ColorMask);
GLuint dstMask = ~srcMask;
GLuint *rgba32 = (GLuint *) rgba;
GLuint *dest32 = (GLuint *) dest;
(*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
for (i=0; i<n; i++) {
rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
}
#else
const GLint rMask = ctx->Color.ColorMask[RCOMP];
const GLint gMask = ctx->Color.ColorMask[GCOMP];
const GLint bMask = ctx->Color.ColorMask[BCOMP];
const GLint aMask = ctx->Color.ColorMask[ACOMP];
(*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
for (i = 0; i < n; i++) {
if (!rMask) rgba[i][RCOMP] = dest[i][RCOMP];
if (!gMask) rgba[i][GCOMP] = dest[i][GCOMP];
if (!bMask) rgba[i][BCOMP] = dest[i][BCOMP];
if (!aMask) rgba[i][ACOMP] = dest[i][ACOMP];
}
#endif
}
void
_mesa_mask_index_span( GLcontext *ctx, const struct sw_span *span,
GLuint index[] )
@@ -242,29 +189,3 @@ _mesa_mask_index_array( GLcontext *ctx,
index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
}
}
/*
* Apply glIndexMask to an array of CI pixels.
*/
void
_mesa_mask_index_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint i;
GLuint fbindexes[PB_SIZE];
GLuint msrc, mdest;
(*swrast->Driver.ReadCI32Pixels)( ctx, n, x, y, fbindexes, mask );
msrc = ctx->Color.IndexMask;
mdest = ~msrc;
for (i=0;i<n;i++) {
index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
}
}

View File

@@ -1,4 +1,4 @@
/* $Id: s_masking.h,v 1.4 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_masking.h,v 1.5 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,16 +46,6 @@ _mesa_mask_rgba_array( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLchan rgba[][4] );
/*
* Implement glColorMask for an array of RGBA pixels.
*/
extern void
_mesa_mask_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
/*
* Implement glIndexMask for a span of CI pixels.
*/
@@ -64,24 +54,9 @@ _mesa_mask_index_span( GLcontext *ctx, const struct sw_span *span,
GLuint index[] );
/*
* Implement glIndexMask for a span of CI pixels.
*/
extern void
_mesa_mask_index_array( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[] );
/*
* Implement glIndexMask for an array of CI pixels.
*/
extern void
_mesa_mask_index_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] );
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: s_points.h,v 1.5 2001/03/12 00:48:42 gareth Exp $ */
/* $Id: s_points.h,v 1.6 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,10 +30,10 @@
#include "mtypes.h"
void
extern void
_swrast_choose_point( GLcontext *ctx );
void
extern void
_swrast_add_spec_terms_point( GLcontext *ctx,
const SWvertex *v0 );

View File

@@ -1,4 +1,4 @@
/* $Id: s_span.c,v 1.29 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_span.c,v 1.30 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,7 +45,6 @@
#include "s_fog.h"
#include "s_logic.h"
#include "s_masking.h"
#include "s_scissor.h"
#include "s_span.h"
#include "s_stencil.h"
#include "s_texture.h"
@@ -433,10 +432,19 @@ clip_span( GLcontext *ctx, struct sw_span *span )
const GLint n = span->end;
GLubyte *mask = span->mask;
GLint i;
/* note: using & intead of && to reduce branches */
for (i = 0; i < n; i++) {
mask[i] = (x[i] >= xmin) & (x[i] < xmax)
& (y[i] >= ymin) & (y[i] < ymax);
if (span->arrayMask & SPAN_MASK) {
/* note: using & intead of && to reduce branches */
for (i = 0; i < n; i++) {
mask[i] &= (x[i] >= xmin) & (x[i] < xmax)
& (y[i] >= ymin) & (y[i] < ymax);
}
}
else {
/* note: using & intead of && to reduce branches */
for (i = 0; i < n; i++) {
mask[i] = (x[i] >= xmin) & (x[i] < xmax)
& (y[i] >= ymin) & (y[i] < ymax);
}
}
return GL_TRUE; /* some pixels visible */
}
@@ -640,12 +648,26 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
/* Clipping */
if ((swrast->_RasterMask & CLIP_BIT) || (primitive == GL_BITMAP)
|| (primitive == GL_POINT)) {
|| (primitive == GL_POINT) || (primitive == GL_LINE)) {
if (!clip_span(ctx, span)) {
return;
}
}
#ifdef DEBUG
if (span->arrayMask & SPAN_XY) {
int i;
for (i = 0; i < span->end; i++) {
if (span->mask[i]) {
assert(span->xArray[i] >= ctx->DrawBuffer->_Xmin);
assert(span->xArray[i] < ctx->DrawBuffer->_Xmax);
assert(span->yArray[i] >= ctx->DrawBuffer->_Ymin);
assert(span->yArray[i] < ctx->DrawBuffer->_Ymax);
}
}
}
#endif
/* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive == GL_POLYGON) {
stipple_polygon_span(ctx, span);
@@ -801,12 +823,26 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Clipping */
if ((swrast->_RasterMask & CLIP_BIT) || (primitive == GL_BITMAP)
|| (primitive == GL_POINT)) {
|| (primitive == GL_POINT) || (primitive == GL_LINE)) {
if (!clip_span(ctx, span)) {
return;
}
}
#ifdef DEBUG
if (span->arrayMask & SPAN_XY) {
int i;
for (i = 0; i < span->end; i++) {
if (span->mask[i]) {
assert(span->xArray[i] >= ctx->DrawBuffer->_Xmin);
assert(span->xArray[i] < ctx->DrawBuffer->_Xmax);
assert(span->yArray[i] >= ctx->DrawBuffer->_Ymin);
assert(span->yArray[i] < ctx->DrawBuffer->_Ymax);
}
}
}
#endif
/* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive == GL_POLYGON) {
stipple_polygon_span(ctx, span);
@@ -1014,12 +1050,26 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
/* Clipping */
if ((swrast->_RasterMask & CLIP_BIT) || (primitive == GL_BITMAP)
|| (primitive == GL_POINT)) {
|| (primitive == GL_POINT) || (primitive == GL_LINE)) {
if (!clip_span(ctx, span)) {
return;
}
}
#ifdef DEBUG
if (span->arrayMask & SPAN_XY) {
int i;
for (i = 0; i < span->end; i++) {
if (span->mask[i]) {
assert(span->xArray[i] >= ctx->DrawBuffer->_Xmin);
assert(span->xArray[i] < ctx->DrawBuffer->_Xmax);
assert(span->yArray[i] >= ctx->DrawBuffer->_Ymin);
assert(span->yArray[i] < ctx->DrawBuffer->_Ymax);
}
}
}
#endif
/* Polygon Stippling */
if (ctx->Polygon.StippleFlag && primitive == GL_POLYGON) {
stipple_polygon_span(ctx, span);

View File

@@ -1,4 +1,4 @@
/* $Id: s_stencil.c,v 1.18 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_stencil.c,v 1.19 2002/02/02 21:40:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,7 +32,6 @@
#include "s_context.h"
#include "s_depth.h"
#include "s_pb.h"
#include "s_stencil.h"
@@ -236,12 +235,12 @@ static GLboolean
do_stencil_test( GLcontext *ctx, GLuint n, GLstencil stencil[],
GLubyte mask[] )
{
GLubyte fail[PB_SIZE];
GLubyte fail[MAX_WIDTH];
GLboolean allfail = GL_FALSE;
GLuint i;
GLstencil r, s;
ASSERT(n <= PB_SIZE);
ASSERT(n <= MAX_WIDTH);
/*
* Perform stencil test. The results of this operation are stored
@@ -420,7 +419,7 @@ stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLubyte mask[] )
{
ASSERT(ctx->Stencil.Enabled);
ASSERT(n <= PB_SIZE);
ASSERT(n <= MAX_WIDTH);
/*
* Apply the stencil test to the fragments.
@@ -722,7 +721,7 @@ static GLboolean
stencil_test_pixels( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[], GLubyte mask[] )
{
GLubyte fail[PB_SIZE];
GLubyte fail[MAX_WIDTH];
GLstencil r, s;
GLuint i;
GLboolean allfail = GL_FALSE;
@@ -910,19 +909,19 @@ stencil_test_pixels( GLcontext *ctx, GLuint n,
* Return: GL_TRUE - all fragments failed the testing
* GL_FALSE - one or more fragments passed the testing
*/
GLboolean
_mesa_stencil_and_ztest_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
static GLboolean
stencil_and_ztest_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
ASSERT(ctx->Stencil.Enabled);
ASSERT(n <= PB_SIZE);
ASSERT(n <= MAX_WIDTH);
if (swrast->Driver.WriteStencilPixels) {
/*** Hardware stencil buffer ***/
GLstencil stencil[PB_SIZE];
GLubyte origMask[PB_SIZE];
GLstencil stencil[MAX_WIDTH];
GLubyte origMask[MAX_WIDTH];
ASSERT(swrast->Driver.ReadStencilPixels);
(*swrast->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
@@ -938,7 +937,7 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
_mesa_depth_test_pixels(ctx, n, x, y, z, mask);
if (ctx->Stencil.ZFailFunc != GL_KEEP) {
GLubyte failmask[PB_SIZE];
GLubyte failmask[MAX_WIDTH];
GLuint i;
for (i = 0; i < n; i++) {
ASSERT(mask[i] == 0 || mask[i] == 1);
@@ -948,7 +947,7 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
n, stencil, failmask);
}
if (ctx->Stencil.ZPassFunc != GL_KEEP) {
GLubyte passmask[PB_SIZE];
GLubyte passmask[MAX_WIDTH];
GLuint i;
for (i = 0; i < n; i++) {
ASSERT(mask[i] == 0 || mask[i] == 1);
@@ -977,7 +976,7 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
ctx->Stencil.ZPassFunc, mask);
}
else {
GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
GLuint i;
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
@@ -1010,9 +1009,9 @@ GLboolean
_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
{
if (span->arrayMask & SPAN_XY) {
return _mesa_stencil_and_ztest_pixels(ctx, span->end,
span->xArray, span->yArray,
span->zArray, span->mask);
return stencil_and_ztest_pixels(ctx, span->end,
span->xArray, span->yArray,
span->zArray, span->mask);
}
else {
return stencil_and_ztest_span2(ctx, span);

View File

@@ -1,4 +1,4 @@
/* $Id: s_stencil.h,v 1.5 2002/02/02 17:24:11 brianp Exp $ */
/* $Id: s_stencil.h,v 1.6 2002/02/02 21:40:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,11 +38,6 @@ extern GLboolean
_mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span);
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,

View File

@@ -1,4 +1,4 @@
/* $Id: s_texture.c,v 1.48 2002/01/28 04:25:56 brianp Exp $ */
/* $Id: s_texture.c,v 1.49 2002/02/02 21:40:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,6 @@
#include "teximage.h"
#include "s_context.h"
#include "s_pb.h"
#include "s_texture.h"
@@ -3043,7 +3042,7 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n,
if (textureUnit->_Current) { /* XXX need this? */
const struct gl_texture_object *curObj = textureUnit->_Current;
GLchan texel[PB_SIZE][4];
GLchan texel[MAX_WIDTH][4];
if (textureUnit->LodBias != 0.0F) {
/* apply LOD bias, but don't clamp yet */
@@ -3096,10 +3095,10 @@ _swrast_multitexture_fragments( GLcontext *ctx, struct sw_span *span )
{
if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
/* multitexture */
GLchan primary_rgba[PB_SIZE][4];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
ASSERT(span->end < PB_SIZE);
ASSERT(span->end < MAX_WIDTH);
/* save copy of the span colors (the GL_PRIMARY_COLOR) */
MEMCPY(primary_rgba, span->color.rgba, 4 * span->end * sizeof(GLchan));