Klaus's latest patches and some clean-up

This commit is contained in:
Brian Paul
2002-01-21 18:12:34 +00:00
parent 674012f083
commit 2ef866d1fc
12 changed files with 385 additions and 174 deletions

View File

@@ -1,10 +1,10 @@
/* $Id: s_alpha.c,v 1.4 2001/03/12 00:48:41 gareth Exp $ */ /* $Id: s_alpha.c,v 1.5 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -34,7 +34,84 @@
#include "s_alpha.h" #include "s_alpha.h"
/*
* Apply the alpha test to a span of pixels.
* In: rgba - array of pixels
* In/Out: span -
* Return: 0 = all pixels in the span failed the alpha test.
* 1 = one or more pixels passed the alpha test.
*/
GLint
_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
CONST GLchan rgba[][4])
{
GLuint i;
const GLchan ref = ctx->Color.AlphaRef;
GLubyte *mask = span->mask;
ASSERT (span->filledMask == GL_TRUE);
ASSERT (span->filledAlpha == GL_TRUE);
SW_SPAN_SET_FLAG(span->testedAlpha);
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) {
case GL_LESS:
for (i=span->start; i<span->end; i++) {
mask[i] &= (rgba[i][ACOMP] < ref);
}
break;
case GL_LEQUAL:
for (i=span->start; i<span->end; i++)
mask[i] &= (rgba[i][ACOMP] <= ref);
break;
case GL_GEQUAL:
for (i=span->start; i<span->end; i++) {
mask[i] &= (rgba[i][ACOMP] >= ref);
}
break;
case GL_GREATER:
for (i=span->start; i<span->end; i++) {
mask[i] &= (rgba[i][ACOMP] > ref);
}
break;
case GL_NOTEQUAL:
for (i=span->start; i<span->end; i++) {
mask[i] &= (rgba[i][ACOMP] != ref);
}
break;
case GL_EQUAL:
for (i=span->start; i<span->end; i++) {
mask[i] &= (rgba[i][ACOMP] == ref);
}
break;
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;
}
while ((span->start <= span->end) &&
(mask[span->start] == 0))
span->start ++;
while ((span->end >= span->start) &&
(mask[span->end] == 0))
span->end --;
span->writeAll = GL_FALSE;
if (span->start >= span->end)
return 0;
else
return 1;
}
/* /*
@@ -46,11 +123,11 @@
* 1 = one or more pixels passed the alpha test. * 1 = one or more pixels passed the alpha test.
*/ */
GLint GLint
_mesa_alpha_test( const GLcontext *ctx, _old_alpha_test( const GLcontext *ctx,
GLuint n, CONST GLchan rgba[][4], GLubyte mask[] ) GLuint n, CONST GLchan rgba[][4], GLubyte mask[] )
{ {
GLuint i; GLuint i;
GLchan ref = ctx->Color.AlphaRef; const GLchan ref = ctx->Color.AlphaRef;
/* switch cases ordered from most frequent to less frequent */ /* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) { switch (ctx->Color.AlphaFunc) {

View File

@@ -1,4 +1,4 @@
/* $Id: s_alpha.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */ /* $Id: s_alpha.h,v 1.4 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -34,9 +34,14 @@
extern GLint extern GLint
_mesa_alpha_test( const GLcontext *ctx, GLuint n, _old_alpha_test( const GLcontext *ctx, GLuint n,
CONST GLchan rgba[][4], GLubyte mask[] ); CONST GLchan rgba[][4], GLubyte mask[] );
extern GLint
_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
CONST GLchan rgba[][4]);
#endif #endif

View File

@@ -1,10 +1,10 @@
/* $Id: s_depth.c,v 1.10 2001/12/17 04:54:35 brianp Exp $ */ /* $Id: s_depth.c,v 1.11 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -587,7 +587,7 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
ASSERT(swrast->Driver.WriteDepthSpan); ASSERT(swrast->Driver.WriteDepthSpan);
(*swrast->Driver.WriteDepthSpan)(ctx, span->end, span->x, span->y, zbuffer, span->mask); (*swrast->Driver.WriteDepthSpan)(ctx, span->end, span->x, span->y, zbuffer, span->mask);
if (passed < span->end) if (passed < span->end)
span->write_all = GL_FALSE; span->writeAll = GL_FALSE;
return passed; return passed;
} }
else { else {
@@ -602,7 +602,7 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
passed = depth_test_span32(ctx, span->end, span->x, span->y, zptr, span->depth, span->mask); passed = depth_test_span32(ctx, span->end, span->x, span->y, zptr, span->depth, span->mask);
} }
if (passed < span->end) if (passed < span->end)
span->write_all = GL_FALSE; span->writeAll = GL_FALSE;
return passed; return passed;
} }
} }

View File

@@ -1,4 +1,4 @@
/* $Id: s_fog.c,v 1.16 2001/12/18 04:06:46 brianp Exp $ */ /* $Id: s_fog.c,v 1.17 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -38,7 +38,7 @@
/* /**
* Used to convert current raster distance to a fog factor in [0,1]. * Used to convert current raster distance to a fog factor in [0,1].
*/ */
GLfloat GLfloat
@@ -70,7 +70,7 @@ _mesa_z_to_fogfactor(GLcontext *ctx, GLfloat z)
/* /**
* Apply fog to a span of RGBA pixels. * Apply fog to a span of RGBA pixels.
* Input: ctx - * Input: ctx -
* span - where span->fog and span->fogStep have to be set. * span - where span->fog and span->fogStep have to be set.
@@ -102,7 +102,40 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
} }
} }
/*
/**
* Apply fog given in an array to RGBA pixels.
* Input: ctx -
* span -
* fog - array of fog factors in [0,1]
* red, green, blue, alpha - pixel colors
* Output: red, green, blue, alpha - fogged pixel colors
*/
void
_mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLchan rgba[][4] )
{
GLuint i;
GLchan rFog, gFog, bFog;
ASSERT(fog != NULL);
ASSERT(ctx->Fog.Enabled);
ASSERT(span->filledColor == GL_TRUE);
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 = span->start; i < span->end; 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);
}
}
/**
* Apply fog to an array of RGBA pixels. * Apply fog to an array of RGBA pixels.
* Input: n - number of pixels * Input: n - number of pixels
* fog - array of fog factors in [0,1] * fog - array of fog factors in [0,1]
@@ -132,7 +165,7 @@ _old_fog_rgba_pixels( const GLcontext *ctx,
} }
/* /**
* Apply fog to a span of color index pixels. * Apply fog to a span of color index pixels.
* Input: ctx - * Input: ctx -
* span - where span->fog and span->fogStep have to be set. * span - where span->fog and span->fogStep have to be set.
@@ -158,7 +191,33 @@ _mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
} }
} }
/*
/**
* Apply fog given in an array to a span of color index pixels.
* Input: ctx -
* span -
* fog - array of fog factors in [0,1]
* index - pixel color indexes
* Output: index - fogged pixel color indexes
*/
void
_mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLuint index[] )
{
GLuint idx = (GLuint) ctx->Fog.Index;
GLuint i;
ASSERT(fog != NULL);
ASSERT(ctx->Fog.Enabled);
ASSERT(span->filledColor == GL_TRUE);
for (i = span->start; i < span->end; i++) {
const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * idx);
}
}
/**
* Apply fog to an array of color index pixels. * Apply fog to an array of color index pixels.
* Input: n - number of pixels * Input: n - number of pixels
* fog - array of fog factors in [0,1] * fog - array of fog factors in [0,1]
@@ -180,7 +239,7 @@ _old_fog_ci_pixels( const GLcontext *ctx,
/* /**
* Calculate fog factors (in [0,1]) from window z values * Calculate fog factors (in [0,1]) from window z values
* Input: n - number of pixels * Input: n - number of pixels
* z - array of integer depth values * z - array of integer depth values
@@ -321,7 +380,7 @@ compute_fog_factors_from_z( const GLcontext *ctx,
} }
/* /**
* Apply fog to a span of RGBA pixels. * Apply fog to a span of RGBA pixels.
* Input: ctx - * Input: ctx -
* span - where span->depth has to be filled. * span - where span->depth has to be filled.
@@ -341,10 +400,11 @@ _mesa_depth_fog_rgba_pixels(const GLcontext *ctx, struct sw_span *span,
ASSERT(span->filledColor == GL_TRUE); ASSERT(span->filledColor == GL_TRUE);
compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact ); compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
_old_fog_rgba_pixels( ctx, span->end, fogFact, rgba ); _mesa_fog_rgba_pixels_with_array( ctx, span, fogFact, rgba );
} }
/*
/**
* Apply fog to an array of RGBA pixels. * Apply fog to an array of RGBA pixels.
* Input: n - number of pixels * Input: n - number of pixels
* z - array of integer depth values * z - array of integer depth values
@@ -362,7 +422,7 @@ _old_depth_fog_rgba_pixels( const GLcontext *ctx,
} }
/* /**
* Apply fog to a span of color index pixels. * Apply fog to a span of color index pixels.
* Input: ctx - * Input: ctx -
* span - where span->depth has to be filled. * span - where span->depth has to be filled.
@@ -382,11 +442,11 @@ _mesa_depth_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
ASSERT(span->filledColor == GL_TRUE); ASSERT(span->filledColor == GL_TRUE);
compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact ); compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
_old_fog_ci_pixels( ctx, span->end, fogFact, index ); _mesa_fog_ci_pixels_with_array( ctx, span, fogFact, index );
} }
/* /**
* Apply fog to an array of color index pixels. * Apply fog to an array of color index pixels.
* Input: n - number of pixels * Input: n - number of pixels
* z - array of integer depth values * z - array of integer depth values

View File

@@ -1,4 +1,4 @@
/* $Id: s_fog.h,v 1.6 2001/12/17 04:54:35 brianp Exp $ */ /* $Id: s_fog.h,v 1.7 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -44,11 +44,18 @@ _old_fog_rgba_pixels( const GLcontext *ctx,
extern void extern void
_mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span, _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
GLchan rgba[][4]); GLchan rgba[][4]);
extern void
_mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLchan rgba[][4] );
extern void extern void
_mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span, _mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
GLuint indx[]); GLuint indx[]);
extern void 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, _old_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfloat fog[], GLuint n, const GLfloat fog[],
GLuint indx[] ); GLuint indx[] );

View File

@@ -1,4 +1,4 @@
/* $Id: s_span.c,v 1.22 2002/01/16 16:00:03 brianp Exp $ */ /* $Id: s_span.c,v 1.23 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -105,7 +105,7 @@ stipple_polygon_span( GLcontext *ctx, struct sw_span *span)
m = highbit; m = highbit;
} }
} }
span->write_all = GL_FALSE; span->writeAll = GL_FALSE;
} }
@@ -179,7 +179,7 @@ clip_span( GLcontext *ctx, struct sw_span *span)
} }
else { else {
/* partially off left side */ /* partially off left side */
span->write_all = GL_FALSE; span->writeAll = GL_FALSE;
BZERO(span->mask, -x * sizeof(GLubyte)); BZERO(span->mask, -x * sizeof(GLubyte));
return GL_TRUE; return GL_TRUE;
} }
@@ -488,7 +488,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
/* Do the alpha test */ /* Do the alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) { if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
return; return;
} }
write_all = GL_FALSE; write_all = GL_FALSE;
@@ -575,7 +575,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
*/ */
void void
_mesa_write_index_span( GLcontext *ctx, struct sw_span *span, _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive ) const GLfloat fog[MAX_WIDTH], GLenum primitive)
{ {
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT; const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT;
GLuint indexBackup[MAX_WIDTH]; GLuint indexBackup[MAX_WIDTH];
@@ -659,8 +659,9 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
} }
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */ if (fog != NULL && !swrast->_PreferPixelFog)
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog) _mesa_fog_ci_pixels_with_array( ctx, span, fog, index);
else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, span, index); _mesa_fog_ci_pixels( ctx, span, index);
else else
_mesa_depth_fog_ci_pixels( ctx, span, index); _mesa_depth_fog_ci_pixels( ctx, span, index);
@@ -791,7 +792,6 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
} }
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog) if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, span, indexes ); _mesa_fog_ci_pixels( ctx, span, indexes );
else else
@@ -853,7 +853,7 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
*/ */
void void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span, _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive ) const GLfloat fog[MAX_WIDTH], GLenum primitive)
{ {
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT |
LOGIC_OP_BIT | TEXTURE_BIT; LOGIC_OP_BIT | TEXTURE_BIT;
@@ -898,10 +898,9 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Do the alpha test */ /* Do the alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) { if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba) == 0) {
return; return;
} }
span->write_all = GL_FALSE;
} }
/* I have to think where to put this!! */ /* I have to think where to put this!! */
@@ -943,8 +942,9 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */ /* Per-pixel fog */
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */ if (fog != NULL && !swrast->_PreferPixelFog)
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog) _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba ); _mesa_fog_rgba_pixels( ctx, span, rgba );
else else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba ); _mesa_depth_fog_rgba_pixels( ctx, span, rgba );
@@ -986,12 +986,12 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* write pixels */ /* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, (const GLchan (*)[4]) rgba,
span->write_all ? ((const GLubyte *) NULL) : span->mask ); span->writeAll ? ((const GLubyte *) NULL) : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, (const GLchan (*)[4]) rgba,
span->write_all ? ((const GLubyte *) NULL) : span->mask ); span->writeAll ? ((const GLubyte *) NULL) : span->mask );
} }
} }
} }
@@ -1036,13 +1036,13 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* Do the alpha test */ /* Do the alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
SW_SPAN_SET_FLAG(span->filledAlpha);
for (i = 0; i < span->end; i++) { for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = color[ACOMP]; rgba[i][ACOMP] = color[ACOMP];
} }
if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4])rgba, span->mask ) == 0) { if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4])rgba) == 0) {
return; return;
} }
span->write_all = GL_FALSE;
} }
/* I have to think where to put this!! */ /* I have to think where to put this!! */
@@ -1103,8 +1103,7 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */ /* Per-pixel fog */
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */ if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba ); _mesa_fog_rgba_pixels( ctx, span, rgba );
else else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba ); _mesa_depth_fog_rgba_pixels( ctx, span, rgba );
@@ -1144,11 +1143,11 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* write pixels */ /* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, (const GLchan (*)[4]) rgba,
span->write_all ? ((const GLubyte *) NULL) : span->mask ); span->writeAll ? ((const GLubyte *) NULL) : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, (const GLchan (*)[4]) rgba,
span->write_all ? ((const GLubyte *) NULL) : span->mask ); span->writeAll ? ((const GLubyte *) NULL) : span->mask );
} }
} }
} }
@@ -1170,8 +1169,9 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
else { else {
(*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y, color, span->mask ); (*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y, color, span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_mono_alpha_span( ctx, span->end, span->x, span->y, (GLchan) color[ACOMP], _mesa_write_mono_alpha_span( ctx, span->end, span->x, span->y,
span->write_all ? ((const GLubyte *) NULL) : span->mask ); (GLchan) color[ACOMP],
span->writeAll ? ((const GLubyte *) NULL) : span->mask );
} }
} }
} }
@@ -1219,7 +1219,7 @@ add_colors(CONST struct sw_span *span, GLchan rgba[][4])
*/ */
void void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span, _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLenum primitive ) const GLfloat fog[MAX_WIDTH], GLenum primitive )
{ {
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask); const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
GLchan rgbaBackup[MAX_WIDTH][4]; GLchan rgbaBackup[MAX_WIDTH][4];
@@ -1265,10 +1265,9 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
_swrast_texture_fragments( ctx, 0, span, rgba ); _swrast_texture_fragments( ctx, 0, span, rgba );
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) { if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba ) == 0) {
return; return;
} }
span->write_all = GL_FALSE;
} }
if (ctx->Stencil.Enabled) { if (ctx->Stencil.Enabled) {
@@ -1301,9 +1300,10 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */ /* Per-pixel fog */
if (ctx->Fog.Enabled) { if (ctx->Fog.Enabled) {
/* Is this the right 'if' ?? */ if (fog != NULL && !swrast->_PreferPixelFog)
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog) _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
_old_fog_rgba_pixels( ctx, span->end, fog, rgba ); else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba );
else else
_mesa_depth_fog_rgba_pixels(ctx, span, rgba); _mesa_depth_fog_rgba_pixels(ctx, span, rgba);
} }
@@ -1337,14 +1337,15 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba ); _mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
} }
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba, (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4]) rgba,
span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4]) rgba,
span->writeAll ? NULL : span->mask );
} }
} }
} }
@@ -1391,10 +1392,9 @@ masked_texture_span( GLcontext *ctx, struct sw_span *span)
/* Texture with alpha test */ /* Texture with alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) { if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba ) == 0) {
return; return;
} }
span->write_all = GL_FALSE;
/* Depth test usually in 'rasterize_span' but if alpha test /* Depth test usually in 'rasterize_span' but if alpha test
needed, we have to wait for that test before depth test can needed, we have to wait for that test before depth test can
@@ -1459,11 +1459,13 @@ masked_texture_span( GLcontext *ctx, struct sw_span *span)
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba ); _mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
} }
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba, (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4]) rgba,
span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4]) rgba,
span->writeAll ? NULL : span->mask );
} }
} }
} }
@@ -1500,10 +1502,10 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
/* Texture with alpha test */ /* Texture with alpha test */
if (ctx->Color.AlphaEnabled) { if (ctx->Color.AlphaEnabled) {
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4])rgba, span->mask ) == 0) { if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4])rgba ) == 0) {
return; return;
} }
span->write_all = GL_FALSE;
/* Depth test usually in 'rasterize_span' but if alpha test /* Depth test usually in 'rasterize_span' but if alpha test
needed, we have to wait for that test before depth test can needed, we have to wait for that test before depth test can
be done. */ be done. */
@@ -1550,7 +1552,8 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
#endif #endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) { if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask ); multi_write_rgba_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba, span->mask );
} }
else { else {
/* normal: write to exactly one buffer */ /* normal: write to exactly one buffer */
@@ -1570,11 +1573,13 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba ); _mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
} }
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba, (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4])rgba,
span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) { if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba, _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
span->write_all ? NULL : span->mask ); (const GLchan (*)[4])rgba,
span->writeAll ? NULL : span->mask );
} }
} }
} }
@@ -1655,8 +1660,8 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
} }
if (span->activeMask & SPAN_RGBA) { if (span->activeMask & SPAN_RGBA) {
ASSERT(span->filledColor == GL_FALSE);
SW_SPAN_SET_FLAG(span->filledColor); SW_SPAN_SET_FLAG(span->filledColor);
SW_SPAN_SET_FLAG(span->filledAlpha);
if (span->activeMask & SPAN_FLAT) { if (span->activeMask & SPAN_FLAT) {
GLuint i; GLuint i;
GLchan color[4]; GLchan color[4];
@@ -1696,7 +1701,7 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
} }
if (span->activeMask & SPAN_SPEC) { if (span->activeMask & SPAN_SPEC) {
SW_SPAN_SET_FLAG(span->filledSpecular); SW_SPAN_SET_FLAG(span->filledSpecular);
if (span->activeMask & SPAN_FLAT) { if (span->activeMask & SPAN_FLAT) {
const GLchan r = FixedToChan(span->specRed); const GLchan r = FixedToChan(span->specRed);
const GLchan g = FixedToChan(span->specGreen); const GLchan g = FixedToChan(span->specGreen);
@@ -1993,7 +1998,7 @@ _old_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
(CONST GLchan (*)[4]) rgba, rgba ); (CONST GLchan (*)[4]) rgba, rgba );
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) { if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
return; return;
} }
write_all = GL_FALSE; write_all = GL_FALSE;
@@ -2149,7 +2154,7 @@ _old_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
(CONST GLchan (*)[4]) rgbaIn, rgba ); (CONST GLchan (*)[4]) rgbaIn, rgba );
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) { if (_old_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) {
return; return;
} }
write_all = GL_FALSE; write_all = GL_FALSE;

View File

@@ -1,4 +1,4 @@
/* $Id: s_span.h,v 1.10 2002/01/16 16:00:04 brianp Exp $ */ /* $Id: s_span.h,v 1.11 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -47,7 +47,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
void void
_mesa_write_index_span( GLcontext *ctx, struct sw_span *span, _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive); const GLfloat fog[MAX_WIDTH], GLenum primitive);
extern void extern void
_mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span, _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
@@ -55,7 +55,7 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
extern void extern void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span, _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
GLenum primitive ); const GLfloat fog[MAX_WIDTH], GLenum primitive);
extern void extern void
_mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span, _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
@@ -63,7 +63,7 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
extern void extern void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span, _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
const GLfloat fog[], GLenum primitive ); const GLfloat fog[MAX_WIDTH], GLenum primitive );
extern void extern void

View File

@@ -1,4 +1,4 @@
/* $Id: s_stencil.c,v 1.14 2002/01/08 14:56:51 brianp Exp $ */ /* $Id: s_stencil.c,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -586,7 +586,7 @@ _mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
span->y, stencil, span->mask ); span->y, stencil, span->mask );
} }
span->write_all = GL_FALSE; span->writeAll = GL_FALSE;
return result; return result;
} }

View File

@@ -1,4 +1,4 @@
/* $Id: s_triangle.c,v 1.47 2002/01/16 16:00:04 brianp Exp $ */ /* $Id: s_triangle.c,v 1.48 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -107,7 +107,7 @@ static void smooth_ci_triangle( GLcontext *ctx,
span.color.index[i] = FixedToInt(span.index); \ span.color.index[i] = FixedToInt(span.index); \
span.index += span.indexStep; \ span.index += span.indexStep; \
} \ } \
_mesa_write_index_span(ctx, &span, GL_POLYGON); _mesa_write_index_span(ctx, &span, NULL, GL_POLYGON);
#include "s_tritemp.h" #include "s_tritemp.h"
} }
@@ -155,6 +155,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLuint i; \ GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \ SW_SPAN_SET_FLAG(span.filledColor); \
SW_SPAN_SET_FLAG(span.filledAlpha); \
for (i = 0; i < span.end; i++) { \ for (i = 0; i < span.end; i++) { \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \ span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \ span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
@@ -165,7 +166,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
span.blue += span.blueStep; \ span.blue += span.blueStep; \
span.alpha += span.alphaStep; \ span.alpha += span.alphaStep; \
} \ } \
_mesa_write_rgba_span(ctx, &span, GL_POLYGON); _mesa_write_rgba_span(ctx, &span, NULL, GL_POLYGON);
#include "s_tritemp.h" #include "s_tritemp.h"
@@ -192,7 +193,7 @@ static void simple_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \ #define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \ SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \ const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \ const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
const GLfloat theight = (GLfloat) obj->Image[b]->Height; \ const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
const GLint twidth_log2 = obj->Image[b]->WidthLog2; \ const GLint twidth_log2 = obj->Image[b]->WidthLog2; \
@@ -221,7 +222,8 @@ static void simple_textured_triangle( GLcontext *ctx,
span.intTex[1] += span.intTexStep[1]; \ span.intTex[1] += span.intTexStep[1]; \
} \ } \
(*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \ (*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
(CONST GLchan (*)[3]) span.color.rgb, NULL ); (CONST GLchan (*)[3]) span.color.rgb, \
NULL );
#include "s_tritemp.h" #include "s_tritemp.h"
} }
@@ -248,13 +250,13 @@ static void simple_z_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \ #define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \ SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \ const GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \ const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
GLfloat theight = (GLfloat) obj->Image[b]->Height; \ const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
GLint twidth_log2 = obj->Image[b]->WidthLog2; \ const GLint twidth_log2 = obj->Image[b]->WidthLog2; \
const GLchan *texture = (const GLchan *) obj->Image[b]->Data; \ const GLchan *texture = (const GLchan *) obj->Image[b]->Data; \
GLint smask = obj->Image[b]->Width - 1; \ const GLint smask = obj->Image[b]->Width - 1; \
GLint tmask = obj->Image[b]->Height - 1; \ const GLint tmask = obj->Image[b]->Height - 1; \
if (!texture) { \ if (!texture) { \
/* this shouldn't happen */ \ /* this shouldn't happen */ \
return; \ return; \
@@ -286,7 +288,8 @@ static void simple_z_textured_triangle( GLcontext *ctx,
span.z += span.zStep; \ span.z += span.zStep; \
} \ } \
(*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \ (*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
(CONST GLchan (*)[3]) span.color.rgb, span.mask ); (CONST GLchan (*)[3]) span.color.rgb, \
span.mask );
#include "s_tritemp.h" #include "s_tritemp.h"
} }
@@ -552,7 +555,7 @@ affine_span(GLcontext *ctx, struct sw_span *span,
} }
break; break;
} }
_mesa_write_rgba_span(ctx, span, GL_POLYGON); _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
#undef SPAN_NEAREST #undef SPAN_NEAREST
#undef SPAN_LINEAR #undef SPAN_LINEAR
@@ -581,9 +584,9 @@ static void affine_textured_triangle( GLcontext *ctx,
struct affine_info info; \ struct affine_info info; \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
struct gl_texture_object *obj = unit->Current2D; \ struct gl_texture_object *obj = unit->Current2D; \
GLint b = obj->BaseLevel; \ const GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \ const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
GLfloat theight = (GLfloat) obj->Image[b]->Height; \ const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
info.texture = (const GLchan *) obj->Image[b]->Data; \ info.texture = (const GLchan *) obj->Image[b]->Data; \
info.twidth_log2 = obj->Image[b]->WidthLog2; \ info.twidth_log2 = obj->Image[b]->WidthLog2; \
info.smask = obj->Image[b]->Width - 1; \ info.smask = obj->Image[b]->Width - 1; \
@@ -824,7 +827,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
break; break;
} }
_mesa_write_rgba_span(ctx, span, GL_POLYGON); _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
#undef SPAN_NEAREST #undef SPAN_NEAREST
@@ -852,9 +855,9 @@ static void persp_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \ #define SETUP_CODE \
struct persp_info info; \ struct persp_info info; \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
struct gl_texture_object *obj = unit->Current2D; \ const struct gl_texture_object *obj = unit->Current2D; \
GLint b = obj->BaseLevel; \ const GLint b = obj->BaseLevel; \
info.texture = (const GLchan *) obj->Image[b]->Data; \ info.texture = (const GLchan *) obj->Image[b]->Data; \
info.twidth_log2 = obj->Image[b]->WidthLog2; \ info.twidth_log2 = obj->Image[b]->WidthLog2; \
info.smask = obj->Image[b]->Width - 1; \ info.smask = obj->Image[b]->Width - 1; \
@@ -932,22 +935,20 @@ static void general_textured_triangle( GLcontext *ctx,
(void) fixedToDepthShift; (void) fixedToDepthShift;
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLfloat fogSpan[MAX_WIDTH]; \
GLuint i; \ GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \ SW_SPAN_SET_FLAG(span.filledColor); \
SW_SPAN_SET_FLAG(span.filledAlpha); \
SW_SPAN_SET_FLAG(span.filledTex[0]); \ SW_SPAN_SET_FLAG(span.filledTex[0]); \
/* NOTE: we could just call rasterize_span() here instead */ \ /* NOTE: we could just call rasterize_span() here instead */ \
for (i = 0; i < span.end; i++) { \ for (i = 0; i < span.end; i++) { \
GLdouble invQ = span.tex[0][3] ? (1.0 / span.tex[0][3]) : 1.0; \ GLdouble invQ = span.tex[0][3] ? (1.0 / span.tex[0][3]) : 1.0; \
span.depth[i] = FixedToDepth(span.z); \ span.depth[i] = FixedToDepth(span.z); \
span.z += span.zStep; \ span.z += span.zStep; \
fogSpan[i] = span.fog; \
span.fog += span.fogStep; \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \ span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \ span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
span.color.rgba[i][BCOMP] = FixedToChan(span.blue); \ span.color.rgba[i][BCOMP] = FixedToChan(span.blue); \
span.color.rgba[i][ACOMP] = FixedToChan(span.alpha); \ span.color.rgba[i][ACOMP] = FixedToChan(span.alpha); \
span.red += span.redStep; \ span.red += span.redStep; \
span.green += span.greenStep; \ span.green += span.greenStep; \
span.blue += span.blueStep; \ span.blue += span.blueStep; \
span.alpha += span.alphaStep; \ span.alpha += span.alphaStep; \
@@ -959,8 +960,7 @@ static void general_textured_triangle( GLcontext *ctx,
span.tex[0][2] += span.texStep[0][2]; \ span.tex[0][2] += span.texStep[0][2]; \
span.tex[0][3] += span.texStep[0][3]; \ span.tex[0][3] += span.texStep[0][3]; \
} \ } \
_mesa_write_texture_span( ctx, &span, fogSpan, \ _mesa_write_texture_span( ctx, &span, NULL, GL_POLYGON );
GL_POLYGON );
#include "s_tritemp.h" #include "s_tritemp.h"
} }
@@ -1124,7 +1124,7 @@ static void occlusion_zless_triangle( GLcontext *ctx,
#define RENDER_SPAN( span ) \ #define RENDER_SPAN( span ) \
GLuint i; \ GLuint i; \
for (i = 0; i < span.end; i++) { \ for (i = 0; i < span.end; i++) { \
GLdepth z = FixedToDepth(span.z); \ GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \ if (z < zRow[i]) { \
ctx->OcclusionResult = GL_TRUE; \ ctx->OcclusionResult = GL_TRUE; \
return; \ return; \

View File

@@ -1,10 +1,10 @@
/* $Id: s_zoom.c,v 1.7 2001/12/17 04:54:35 brianp Exp $ */ /* $Id: s_zoom.c,v 1.8 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,8 @@
#include "glheader.h" #include "glheader.h"
#include "macros.h" #include "macros.h"
#include "mem.h"
#include "colormac.h"
#include "s_context.h" #include "s_context.h"
#include "s_span.h" #include "s_span.h"
@@ -33,6 +35,36 @@
#include "s_zoom.h" #include "s_zoom.h"
#ifdef DEBUG
#define SAVE_SPAN(span) struct sw_span tmp_span = (span);
#define RESTORE_SPAN(span) \
{ \
GLint i; \
for (i=tmp_span.start; i<tmp_span.end; i++) { \
if (tmp_span.color.rgba[i][RCOMP] != \
(span).color.rgba[i][RCOMP] || \
tmp_span.color.rgba[i][GCOMP] != \
(span).color.rgba[i][GCOMP] || \
tmp_span.color.rgba[i][BCOMP] != \
(span).color.rgba[i][BCOMP]) { \
fprintf(stderr, "glZoom: Color-span changed in subfunction."); \
} \
if (tmp_span.depth[i] != (span).depth[i]) { \
fprintf(stderr, "glZoom: Depth-span changed in subfunction."); \
} \
} \
(span) = tmp_span; \
}
#else /* DEBUG not defined */
#define SAVE_SPAN(span) GLint start = (span).start, end = (span).end;
#define RESTORE_SPAN(span) (span).start = start, (span).end = end; \
(span).writeAll = GL_TRUE;
#endif /* DEBUG */
/* /*
* Write a span of pixels to the frame buffer while applying a pixel zoom. * Write a span of pixels to the frame buffer while applying a pixel zoom.
@@ -49,25 +81,31 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
const GLfloat *fog, const GLfloat *fog,
CONST GLchan rgba[][4], GLint y0 ) CONST GLchan rgba[][4], GLint y0 )
{ {
GLint m; GLint r0, r1, row;
GLint r0, r1, row, r; GLint i, j;
GLint i, j, skipcol; struct sw_span dstspan;
GLchan zrgba[MAX_WIDTH][4]; /* zoomed pixel colors */
GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */
GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */ GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH ); const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
const GLuint *srcRGBA32 = (const GLuint *) rgba;
GLuint *dstRGBA32 = (GLuint *) zrgba; SW_SPAN_RESET (dstspan);
/* compute width of output row */ /* compute width of output row */
m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); dstspan.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
if (m==0) { if (dstspan.end == 0) {
return; return;
} }
/*here ok or better latter? like it was before */
else if (dstspan.end > maxwidth) {
dstspan.end = maxwidth;
}
if (ctx->Pixel.ZoomX<0.0) { if (ctx->Pixel.ZoomX<0.0) {
/* adjust x coordinate for left/right mirroring */ /* adjust x coordinate for left/right mirroring */
x = x - m; dstspan.x = x - dstspan.end;
} }
else
dstspan.x = x;
/* compute which rows to draw */ /* compute which rows to draw */
row = y-y0; row = y-y0;
@@ -93,47 +131,53 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
} }
/* check if left edge is outside window */ /* check if left edge is outside window */
skipcol = 0; if (dstspan.x < 0) {
if (x<0) { dstspan.start = -x;
skipcol = -x;
m += x;
} }
/* make sure span isn't too long or short */ /* make sure span isn't too long or short */
if (m>maxwidth) { /* if (m>maxwidth) {
m = maxwidth; m = maxwidth;
} }*/
else if (m<=0) {
if (dstspan.end <= dstspan.start) {
return; return;
} }
ASSERT( m <= MAX_WIDTH ); ASSERT( dstspan.end <= MAX_WIDTH );
/* zoom the span horizontally */ /* zoom the span horizontally */
if (ctx->Pixel.ZoomX==-1.0F) { if (ctx->Pixel.ZoomX==-1.0F) {
SW_SPAN_SET_FLAG(dstspan.filledColor);
SW_SPAN_SET_FLAG(dstspan.filledAlpha);
SW_SPAN_SET_FLAG(dstspan.filledDepth);
/* n==m */ /* n==m */
for (j=0;j<m;j++) { for (j=dstspan.start; j<dstspan.end; j++) {
i = n - (j+skipcol) - 1; i = n - j - 1;
dstRGBA32[j] = srcRGBA32[i]; COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
zdepth[j] = z[i]; dstspan.depth[j] = z[i];
} }
if (fog && ctx->Fog.Enabled) { if (fog && ctx->Fog.Enabled) {
for (j=0;j<m;j++) { for (j=dstspan.start; j<dstspan.end; j++) {
i = n - (j+skipcol) - 1; i = n - j - 1;
zfog[j] = fog[i]; zfog[j] = fog[i];
} }
} }
} }
else { else {
GLfloat xscale = 1.0F / ctx->Pixel.ZoomX; const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
for (j=0;j<m;j++) { SW_SPAN_SET_FLAG(dstspan.filledColor);
i = (GLint) ((j+skipcol) * xscale); SW_SPAN_SET_FLAG(dstspan.filledAlpha);
SW_SPAN_SET_FLAG(dstspan.filledDepth);
for (j=dstspan.start; j<dstspan.end; j++) {
i = (GLint) (j * xscale);
if (i<0) i = n + i - 1; if (i<0) i = n + i - 1;
dstRGBA32[j] = srcRGBA32[i]; COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
zdepth[j] = z[i]; dstspan.depth[j] = z[i];
} }
if (fog && ctx->Fog.Enabled) { if (fog && ctx->Fog.Enabled) {
for (j=0;j<m;j++) { for (j=dstspan.start; j<dstspan.end; j++) {
i = (GLint) ((j+skipcol) * xscale); i = (GLint) (j * xscale);
if (i<0) i = n + i - 1; if (i<0) i = n + i - 1;
zfog[j] = fog[i]; zfog[j] = fog[i];
} }
@@ -141,9 +185,13 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
} }
/* write the span */ /* write the span */
for (r=r0; r<r1; r++) { for (dstspan.y = r0; dstspan.y < r1; dstspan.y++) {
_old_write_rgba_span( ctx, m, x+skipcol, r, zdepth, SAVE_SPAN(dstspan);
(fog ? zfog : 0), zrgba, NULL, GL_BITMAP ); _mesa_write_rgba_span(ctx, &dstspan, (fog ? zfog : NULL), GL_BITMAP);
RESTORE_SPAN(dstspan);
/* problem here: "dstspan" can change inside
"_mesa_write_rgba_span". Best solution: make copy "tmpspan"
and give to function, but too slow */
} }
} }

View File

@@ -1,10 +1,10 @@
/* $Id: s_zoom.h,v 1.5 2001/05/03 22:13:32 brianp Exp $ */ /* $Id: s_zoom.h,v 1.6 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -30,7 +30,7 @@
#include "mtypes.h" #include "mtypes.h"
#include "swrast.h"
extern void extern void
_mesa_write_zoomed_rgba_span( GLcontext *ctx, _mesa_write_zoomed_rgba_span( GLcontext *ctx,

View File

@@ -1,4 +1,4 @@
/* $Id: swrast.h,v 1.14 2002/01/10 16:54:29 brianp Exp $ */ /* $Id: swrast.h,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "mtypes.h" #include "mtypes.h"
/* The software rasterizer now uses this format for vertices. Thus a /* The software rasterizer now uses this format for vertices. Thus a
* 'RasterSetup' stage or other translation is required between the * 'RasterSetup' stage or other translation is required between the
* tnl module and the swrast rasterization functions. This serves to * tnl module and the swrast rasterization functions. This serves to
@@ -98,9 +97,15 @@ typedef struct {
struct sw_span { struct sw_span {
GLint x, y; GLint x, y;
GLuint start, end; /* start=first pixel in span, end=last pixel in span*/
/* only end is used until now.(end was before called count) */ /* only need to process pixels between start <= i < end */
GLuint start, end;
/* This flag indicates that only a part of the span is visible */
GLboolean writeAll;
GLuint activeMask; /* OR of the SPAN_* flags */ GLuint activeMask; /* OR of the SPAN_* flags */
#if CHAN_TYPE == GL_FLOAT #if CHAN_TYPE == GL_FLOAT
GLfloat red, redStep; GLfloat red, redStep;
GLfloat green, greenStep; GLfloat green, greenStep;
@@ -127,29 +132,33 @@ struct sw_span {
GLfloat rho[MAX_TEXTURE_UNITS]; GLfloat rho[MAX_TEXTURE_UNITS];
GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS]; GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS];
GLboolean write_all; /* This flag indicates that only a part of */ /**
/*the span is visible. */ * Arrays of fragment values. These will either be computed from the
#ifdef DEBUG * x/xStep values above or loadd from glDrawPixels, etc.
GLboolean filledDepth, filledMask, filledAlpha; */
GLboolean filledColor, filledSpecular;
GLboolean filledLambda[MAX_TEXTURE_UNITS], filledTex[MAX_TEXTURE_UNITS];
GLboolean testedDepth, testedAlpha;
#endif
/* The interpolated fragment values */
GLdepth depth[MAX_WIDTH]; GLdepth depth[MAX_WIDTH];
union { union {
GLchan rgb[MAX_WIDTH][3]; GLchan rgb[MAX_WIDTH][3];
GLchan rgba[MAX_WIDTH][4]; GLchan rgba[MAX_WIDTH][4];
GLuint index[MAX_WIDTH]; GLuint index[MAX_WIDTH];
} color; } color;
GLchan specular[MAX_WIDTH][4]; GLchan specular[MAX_WIDTH][4];
GLint itexcoords[MAX_WIDTH][2]; /* s, t */ GLint itexcoords[MAX_WIDTH][2]; /* Integer texture (s, t) */
GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4]; /* s, t, r */ /* Texture (s,t,r). 4th component only used for pixel texture */
GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4];
GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH]; GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
GLfloat coverage[MAX_WIDTH]; GLfloat coverage[MAX_WIDTH];
GLubyte mask[MAX_WIDTH]; GLubyte mask[MAX_WIDTH];
#ifdef DEBUG
GLboolean filledDepth, filledMask, filledAlpha;
GLboolean filledColor, filledSpecular;
GLboolean filledLambda[MAX_TEXTURE_UNITS], filledTex[MAX_TEXTURE_UNITS];
GLboolean testedDepth, testedAlpha;
#endif
}; };
#ifdef DEBUG #ifdef DEBUG
#define SW_SPAN_SET_FLAG(flag) {ASSERT((flag) == GL_FALSE);(flag) = GL_TRUE;} #define SW_SPAN_SET_FLAG(flag) {ASSERT((flag) == GL_FALSE);(flag) = GL_TRUE;}
#define SW_SPAN_RESET(span) { \ #define SW_SPAN_RESET(span) { \
@@ -160,10 +169,10 @@ struct sw_span {
MAX_TEXTURE_UNITS*sizeof(GLboolean)); \ MAX_TEXTURE_UNITS*sizeof(GLboolean)); \
MEMSET((span).filledLambda, GL_FALSE, \ MEMSET((span).filledLambda, GL_FALSE, \
MAX_TEXTURE_UNITS*sizeof(GLboolean)); \ MAX_TEXTURE_UNITS*sizeof(GLboolean)); \
(span).start = 0; (span).write_all = GL_TRUE;} (span).start = 0; (span).writeAll = GL_TRUE;}
#else #else
#define SW_SPAN_SET_FLAG(flag) ; #define SW_SPAN_SET_FLAG(flag) ;
#define SW_SPAN_RESET(span) {(span).start = 0;(span).write_all = GL_TRUE;} #define SW_SPAN_RESET(span) {(span).start = 0;(span).writeAll = GL_TRUE;}
#endif #endif
struct swrast_device_driver; struct swrast_device_driver;