summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-09-07 15:45:26 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-09-07 15:45:26 +0000
commitc4c639c9a46967678725370cb9824031a068633c (patch)
treef0008c2a00c6f5f65cc4800b87a560a39551b569 /src/mesa/main
parent18f73b622ffa1d1cebea5556b9ebe53a9adc31ac (diff)
Removed ctx->Driver.LogicOp().
ctx->Driver.Index/ColorMask() now return void. Removed SWmasking and SWLogicOpEnabled variables. LogicOps and color/index masking are no longer special-case device driver functions. The Xlib driver was the only driver that used them. Things are more uniform now.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/accum.c11
-rw-r--r--src/mesa/main/blend.c10
-rw-r--r--src/mesa/main/buffers.c6
-rw-r--r--src/mesa/main/context.c4
-rw-r--r--src/mesa/main/dd.h22
-rw-r--r--src/mesa/main/state.c137
6 files changed, 37 insertions, 153 deletions
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 79733d6aca3..7b2f1ca57ee 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -1,4 +1,4 @@
-/* $Id: accum.c,v 1.23 2000/07/15 03:14:25 brianp Exp $ */
+/* $Id: accum.c,v 1.24 2000/09/07 15:45:26 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -140,6 +140,7 @@ _mesa_Accum( GLenum op, GLfloat value )
GLuint xpos, ypos, width, height, width4;
GLfloat acc_scale;
GLubyte 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;
@@ -350,11 +351,11 @@ _mesa_Accum( GLenum op, GLfloat value )
if (ctx->IntegerAccumMode && ctx->IntegerAccumScaler > 0) {
/* build lookup table to avoid many floating point multiplies */
- const GLfloat mult = ctx->IntegerAccumScaler;
static GLchan multTable[32768];
static GLfloat prevMult = 0.0;
- GLuint j;
+ 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);
@@ -376,7 +377,7 @@ _mesa_Accum( GLenum op, GLfloat value )
rgba[i][BCOMP] = multTable[acc[i4+2]];
rgba[i][ACOMP] = multTable[acc[i4+3]];
}
- if (ctx->Color.SWmasking) {
+ if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
(*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
@@ -403,7 +404,7 @@ _mesa_Accum( GLenum op, GLfloat value )
rgba[i][BCOMP] = CLAMP( b, 0, iChanMax );
rgba[i][ACOMP] = CLAMP( a, 0, iChanMax );
}
- if (ctx->Color.SWmasking) {
+ if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
(*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 431fa603d27..b9b2b4788bb 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1,4 +1,4 @@
-/* $Id: blend.c,v 1.17 2000/08/30 18:21:06 brianp Exp $ */
+/* $Id: blend.c,v 1.18 2000/09/07 15:45:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -875,7 +875,8 @@ _mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLubyte dest[MAX_WIDTH][4];
/* Check if device driver can do the work */
- if (ctx->Color.BlendEquation==GL_LOGIC_OP && !ctx->Color.SWLogicOpEnabled) {
+ if (ctx->Color.BlendEquation==GL_LOGIC_OP &&
+ !ctx->Color.ColorLogicOpEnabled) {
return;
}
@@ -890,8 +891,6 @@ _mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
-
-
/*
* Apply the blending operator to an array of pixels.
* Input: n - number of pixels in span
@@ -907,7 +906,8 @@ _mesa_blend_pixels( GLcontext *ctx,
GLubyte dest[PB_SIZE][4];
/* Check if device driver can do the work */
- if (ctx->Color.BlendEquation==GL_LOGIC_OP && !ctx->Color.SWLogicOpEnabled) {
+ if (ctx->Color.BlendEquation==GL_LOGIC_OP &&
+ !ctx->Color.ColorLogicOpEnabled) {
return;
}
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 566afed929a..dd87009031f 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -142,6 +142,7 @@ clear_color_buffer(GLcontext *ctx)
const GLint y = ctx->DrawBuffer->Ymin;
const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1;
const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
if (ctx->Visual->RGBAflag) {
/* RGBA mode */
@@ -152,7 +153,7 @@ clear_color_buffer(GLcontext *ctx)
GLubyte span[MAX_WIDTH][4];
GLint i;
- ASSERT(!ctx->Color.SWmasking);
+ ASSERT(colorMask == 0xffffffff);
for (i = 0; i < width; i++) {
span[i][RCOMP] = r;
@@ -201,6 +202,7 @@ clear_color_buffer(GLcontext *ctx)
static void
clear_color_buffers(GLcontext *ctx)
{
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
GLuint bufferBit;
/* loop over four possible dest color buffers */
@@ -219,7 +221,7 @@ clear_color_buffers(GLcontext *ctx)
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
}
- if (ctx->Color.SWmasking) {
+ if (colorMask != 0xffffffff) {
clear_color_buffer_with_masking(ctx);
}
else {
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 2b29d80f83f..5fbe5d0838a 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.82 2000/09/05 20:28:06 brianp Exp $ */
+/* $Id: context.c,v 1.83 2000/09/07 15:45:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -815,7 +815,6 @@ init_attrib_groups( GLcontext *ctx )
ctx->Color.ColorMask[1] = 0xff;
ctx->Color.ColorMask[2] = 0xff;
ctx->Color.ColorMask[3] = 0xff;
- ctx->Color.SWmasking = GL_FALSE;
ctx->Color.ClearIndex = 0;
ASSIGN_4V( ctx->Color.ClearColor, 0.0, 0.0, 0.0, 0.0 );
ctx->Color.DrawBuffer = GL_FRONT;
@@ -832,7 +831,6 @@ init_attrib_groups( GLcontext *ctx )
ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
ctx->Color.IndexLogicOpEnabled = GL_FALSE;
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
- ctx->Color.SWLogicOpEnabled = GL_FALSE;
ctx->Color.LogicOp = GL_COPY;
ctx->Color.DitherFlag = GL_TRUE;
ctx->Color.MultiDrawBuffer = GL_FALSE;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index d37eac3d1f8..66a740d4ec6 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.29 2000/09/07 15:38:49 brianp Exp $ */
+/* $Id: dd.h,v 1.30 2000/09/07 15:45:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -336,23 +336,6 @@ struct dd_function_table {
* This is called whenever glFlush() is called.
*/
- GLboolean (*IndexMask)( GLcontext *ctx, GLuint mask );
- /*
- * Implements glIndexMask() if possible, else return GL_FALSE.
- */
-
- GLboolean (*ColorMask)( GLcontext *ctx,
- GLboolean rmask, GLboolean gmask,
- GLboolean bmask, GLboolean amask );
- /*
- * Implements glColorMask() if possible, else return GL_FALSE.
- */
-
- GLboolean (*LogicOp)( GLcontext *ctx, GLenum op );
- /*
- * Implements glLogicOp() if possible, else return GL_FALSE.
- */
-
void (*Dither)( GLcontext *ctx, GLboolean enable );
/*
* Enable/disable dithering.
@@ -933,6 +916,8 @@ struct dd_function_table {
GLenum dfactorRGB, GLenum sfactorA,
GLenum dfactorA );
void (*ClearDepth)(GLcontext *ctx, GLclampd d);
+ void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
+ GLboolean bmask, GLboolean amask );
void (*CullFace)(GLcontext *ctx, GLenum mode);
void (*FrontFace)(GLcontext *ctx, GLenum mode);
void (*DepthFunc)(GLcontext *ctx, GLenum func);
@@ -941,6 +926,7 @@ struct dd_function_table {
void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
+ void (*IndexMask)(GLcontext *ctx, GLuint mask);
void (*Lightfv)(GLcontext *ctx, GLenum light,
GLenum pname, const GLfloat *params, GLint nparams );
void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index caca1f87f94..9a40102f5d4 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.23 2000/08/23 14:33:04 brianp Exp $ */
+/* $Id: state.c,v 1.24 2000/09/07 15:45:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -666,114 +666,6 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
/**********************************************************************/
-/*
- * Since the device driver may or may not support pixel logic ops we
- * have to make some extensive tests to determine whether or not
- * software-implemented logic operations have to be used.
- */
-static void update_pixel_logic( GLcontext *ctx )
-{
- if (ctx->Visual->RGBAflag) {
- /* RGBA mode blending w/ Logic Op */
- if (ctx->Color.ColorLogicOpEnabled) {
- if (ctx->Driver.LogicOp
- && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) {
- /* Device driver can do logic, don't have to do it in software */
- ctx->Color.SWLogicOpEnabled = GL_FALSE;
- }
- else {
- /* Device driver can't do logic op so we do it in software */
- ctx->Color.SWLogicOpEnabled = GL_TRUE;
- }
- }
- else {
- /* no logic op */
- if (ctx->Driver.LogicOp) {
- (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY );
- }
- ctx->Color.SWLogicOpEnabled = GL_FALSE;
- }
- }
- else {
- /* CI mode Logic Op */
- if (ctx->Color.IndexLogicOpEnabled) {
- if (ctx->Driver.LogicOp
- && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) {
- /* Device driver can do logic, don't have to do it in software */
- ctx->Color.SWLogicOpEnabled = GL_FALSE;
- }
- else {
- /* Device driver can't do logic op so we do it in software */
- ctx->Color.SWLogicOpEnabled = GL_TRUE;
- }
- }
- else {
- /* no logic op */
- if (ctx->Driver.LogicOp) {
- (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY );
- }
- ctx->Color.SWLogicOpEnabled = GL_FALSE;
- }
- }
-}
-
-
-
-/*
- * Check if software implemented RGBA or Color Index masking is needed.
- */
-static void update_pixel_masking( GLcontext *ctx )
-{
- if (ctx->Visual->RGBAflag) {
- GLuint *colorMask = (GLuint *) ctx->Color.ColorMask;
- if (*colorMask == 0xffffffff) {
- /* disable masking */
- if (ctx->Driver.ColorMask) {
- (void) (*ctx->Driver.ColorMask)( ctx, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
- }
- ctx->Color.SWmasking = GL_FALSE;
- }
- else {
- /* Ask driver to do color masking, if it can't then
- * do it in software
- */
- GLboolean red = ctx->Color.ColorMask[RCOMP] ? GL_TRUE : GL_FALSE;
- GLboolean green = ctx->Color.ColorMask[GCOMP] ? GL_TRUE : GL_FALSE;
- GLboolean blue = ctx->Color.ColorMask[BCOMP] ? GL_TRUE : GL_FALSE;
- GLboolean alpha = ctx->Color.ColorMask[ACOMP] ? GL_TRUE : GL_FALSE;
- if (ctx->Driver.ColorMask
- && (*ctx->Driver.ColorMask)( ctx, red, green, blue, alpha )) {
- ctx->Color.SWmasking = GL_FALSE;
- }
- else {
- ctx->Color.SWmasking = GL_TRUE;
- }
- }
- }
- else {
- if (ctx->Color.IndexMask==0xffffffff) {
- /* disable masking */
- if (ctx->Driver.IndexMask) {
- (void) (*ctx->Driver.IndexMask)( ctx, 0xffffffff );
- }
- ctx->Color.SWmasking = GL_FALSE;
- }
- else {
- /* Ask driver to do index masking, if it can't then
- * do it in software
- */
- if (ctx->Driver.IndexMask
- && (*ctx->Driver.IndexMask)( ctx, ctx->Color.IndexMask )) {
- ctx->Color.SWmasking = GL_FALSE;
- }
- else {
- ctx->Color.SWmasking = GL_TRUE;
- }
- }
- }
-}
-
-
static void update_fog_mode( GLcontext *ctx )
{
int old_mode = ctx->FogMode;
@@ -807,15 +699,22 @@ static void update_rasterflags( GLcontext *ctx )
{
ctx->RasterMask = 0;
- if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT;
- if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT;
- if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT;
- if (ctx->FogMode==FOG_FRAGMENT) ctx->RasterMask |= FOG_BIT;
- if (ctx->Color.SWLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT;
- if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT;
- if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT;
- if (ctx->Color.SWmasking) ctx->RasterMask |= MASKING_BIT;
- if (ctx->Texture.ReallyEnabled) ctx->RasterMask |= TEXTURE_BIT;
+ if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT;
+ if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT;
+ if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT;
+ if (ctx->FogMode == FOG_FRAGMENT) ctx->RasterMask |= FOG_BIT;
+ if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT;
+ if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT;
+ if (ctx->Visual->RGBAflag) {
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ if (colorMask != 0xffffffff) ctx->RasterMask |= MASKING_BIT;
+ if (ctx->Color.ColorLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT;
+ if (ctx->Texture.ReallyEnabled) ctx->RasterMask |= TEXTURE_BIT;
+ }
+ else {
+ if (ctx->Color.IndexMask != 0xffffffff) ctx->RasterMask |= MASKING_BIT;
+ if (ctx->Color.IndexLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT;
+ }
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]
@@ -984,8 +883,6 @@ void gl_update_state( GLcontext *ctx )
if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING | NEW_FOG | NEW_TEXTURE_ENABLE)) {
if (ctx->NewState & (NEW_RASTER_OPS | NEW_TEXTURE_ENABLE)) {
- update_pixel_logic(ctx);
- update_pixel_masking(ctx);
update_fog_mode(ctx);
update_rasterflags(ctx);
if (ctx->Driver.Dither) {