diff options
Diffstat (limited to 'src/mesa/swrast')
30 files changed, 134 insertions, 1361 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index 9bfa8f2e619..6ba4604e690 100644 --- a/src/mesa/swrast/s_aaline.c +++ b/src/mesa/swrast/s_aaline.c @@ -59,10 +59,8 @@ struct LineInfo /* DO_Z */ GLfloat zPlane[4]; - /* DO_RGBA */ + /* DO_RGBA - always enabled */ GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; - /* DO_INDEX */ - GLfloat iPlane[4]; /* DO_ATTRIBS */ GLfloat wPlane[4]; GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; @@ -325,20 +323,6 @@ compute_coveragef(const struct LineInfo *info, } -/** - * Compute coverage value for color index mode. - * XXX this may not be quite correct. - * \return coverage in [0,15]. - */ -static GLfloat -compute_coveragei(const struct LineInfo *info, - GLint winx, GLint winy) -{ - return compute_coveragef(info, winx, winy) * 15.0F; -} - - - typedef void (*plot_func)(GLcontext *ctx, struct LineInfo *line, int ix, int iy); @@ -475,22 +459,13 @@ segment(GLcontext *ctx, } -#define NAME(x) aa_ci_##x -#define DO_Z -#define DO_ATTRIBS /* for fog */ -#define DO_INDEX -#include "s_aalinetemp.h" - - #define NAME(x) aa_rgba_##x #define DO_Z -#define DO_RGBA #include "s_aalinetemp.h" #define NAME(x) aa_general_rgba_##x #define DO_Z -#define DO_RGBA #define DO_ATTRIBS #include "s_aalinetemp.h" @@ -503,22 +478,15 @@ _swrast_choose_aa_line_function(GLcontext *ctx) ASSERT(ctx->Line.SmoothFlag); - if (ctx->Visual.rgbMode) { - /* RGBA */ - if (ctx->Texture._EnabledCoordUnits != 0 - || ctx->FragmentProgram._Current - || (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - || ctx->Fog.ColorSumEnabled - || swrast->_FogEnabled) { - swrast->Line = aa_general_rgba_line; - } - else { - swrast->Line = aa_rgba_line; - } + if (ctx->Texture._EnabledCoordUnits != 0 + || ctx->FragmentProgram._Current + || (ctx->Light.Enabled && + ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + || ctx->Fog.ColorSumEnabled + || swrast->_FogEnabled) { + swrast->Line = aa_general_rgba_line; } else { - /* Color Index */ - swrast->Line = aa_ci_line; + swrast->Line = aa_rgba_line; } } diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 42ffe9f20c1..c28d47a671d 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -39,11 +39,7 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) const SWcontext *swrast = SWRAST_CONTEXT(ctx); const GLfloat fx = (GLfloat) ix; const GLfloat fy = (GLfloat) iy; -#ifdef DO_INDEX - const GLfloat coverage = compute_coveragei(line, ix, iy); -#else const GLfloat coverage = compute_coveragef(line, ix, iy); -#endif const GLuint i = line->span.end; (void) swrast; @@ -63,15 +59,10 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) #ifdef DO_Z line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane); #endif -#ifdef DO_RGBA line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); -#endif -#ifdef DO_INDEX - line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane); -#endif #if defined(DO_ATTRIBS) ATTRIB_LOOP_BEGIN GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; @@ -101,11 +92,7 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) #endif if (line->span.end == MAX_WIDTH) { -#if defined(DO_RGBA) _swrast_write_rgba_span(ctx, &(line->span)); -#else - _swrast_write_index_span(ctx, &(line->span)); -#endif line->span.end = 0; /* reset counter */ } } @@ -150,7 +137,6 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) compute_plane(line.x0, line.y0, line.x1, line.y1, v0->attrib[FRAG_ATTRIB_WPOS][2], v1->attrib[FRAG_ATTRIB_WPOS][2], line.zPlane); #endif -#ifdef DO_RGBA line.span.arrayMask |= SPAN_RGBA; if (ctx->Light.ShadeModel == GL_SMOOTH) { compute_plane(line.x0, line.y0, line.x1, line.y1, @@ -168,18 +154,6 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) constant_plane(v1->color[BCOMP], line.bPlane); constant_plane(v1->color[ACOMP], line.aPlane); } -#endif -#ifdef DO_INDEX - line.span.arrayMask |= SPAN_INDEX; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->attrib[FRAG_ATTRIB_CI][0], - v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane); - } - else { - constant_plane(v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane); - } -#endif #if defined(DO_ATTRIBS) { const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; @@ -257,18 +231,12 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) segment(ctx, &line, NAME(plot), 0.0, 1.0); } -#if defined(DO_RGBA) _swrast_write_rgba_span(ctx, &(line.span)); -#else - _swrast_write_index_span(ctx, &(line.span)); -#endif } #undef DO_Z -#undef DO_RGBA -#undef DO_INDEX #undef DO_ATTRIBS #undef NAME diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 078f16aea09..fe3338ecef8 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -357,20 +357,6 @@ rgba_aa_tri(GLcontext *ctx, const SWvertex *v2) { #define DO_Z -#define DO_RGBA -#include "s_aatritemp.h" -} - - -static void -index_aa_tri(GLcontext *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ -#define DO_Z -#define DO_ATTRIBS -#define DO_INDEX #include "s_aatritemp.h" } @@ -382,7 +368,6 @@ general_aa_tri(GLcontext *ctx, const SWvertex *v2) { #define DO_Z -#define DO_RGBA #define DO_ATTRIBS #include "s_aatritemp.h" } @@ -406,11 +391,8 @@ _swrast_set_aa_triangle_function(GLcontext *ctx) || NEED_SECONDARY_COLOR(ctx)) { SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri; } - else if (ctx->Visual.rgbMode) { - SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; - } else { - SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri; + SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; } ASSERT(SWRAST_CONTEXT(ctx)->Triangle); diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 76d4005b8ca..5c1c6d9044b 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -33,8 +33,6 @@ * The following macros may be defined to indicate what auxillary information * must be copmuted across the triangle: * DO_Z - if defined, compute Z values - * DO_RGBA - if defined, compute RGBA values - * DO_INDEX - if defined, compute color index values * DO_ATTRIBS - if defined, compute texcoords, varying, etc. */ @@ -55,12 +53,7 @@ #ifdef DO_Z GLfloat zPlane[4]; #endif -#ifdef DO_RGBA GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; -#endif -#ifdef DO_INDEX - GLfloat iPlane[4]; -#endif #if defined(DO_ATTRIBS) GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; GLfloat wPlane[4]; /* win[3] */ @@ -126,7 +119,6 @@ compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); span.arrayMask |= SPAN_Z; #endif -#ifdef DO_RGBA if (ctx->Light.ShadeModel == GL_SMOOTH) { compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane); compute_plane(p0, p1, p2, v0->color[GCOMP], v1->color[GCOMP], v2->color[GCOMP], gPlane); @@ -140,17 +132,6 @@ constant_plane(v2->color[ACOMP], aPlane); } span.arrayMask |= SPAN_RGBA; -#endif -#ifdef DO_INDEX - if (ctx->Light.ShadeModel == GL_SMOOTH) { - compute_plane(p0, p1, p2, (GLfloat) v0->attrib[FRAG_ATTRIB_CI][0], - v1->attrib[FRAG_ATTRIB_CI][0], v2->attrib[FRAG_ATTRIB_CI][0], iPlane); - } - else { - constant_plane(v2->attrib[FRAG_ATTRIB_CI][0], iPlane); - } - span.arrayMask |= SPAN_INDEX; -#endif #if defined(DO_ATTRIBS) { const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; @@ -234,23 +215,14 @@ /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; -#ifdef DO_INDEX - array->coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy); -#else array->coverage[count] = coverage; -#endif #ifdef DO_Z array->z[count] = (GLuint) solve_plane(cx, cy, zPlane); #endif -#ifdef DO_RGBA array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); array->rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane); array->rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane); -#endif -#ifdef DO_INDEX - array->index[count] = (GLint) solve_plane(cx, cy, iPlane); -#endif ix++; count++; coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); @@ -262,11 +234,7 @@ span.x = startX; span.y = iy; span.end = (GLuint) ix - (GLuint) startX; -#if defined(DO_RGBA) _swrast_write_rgba_span(ctx, &span); -#else - _swrast_write_index_span(ctx, &span); -#endif } } else { @@ -304,23 +272,14 @@ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; ASSERT(ix >= 0); -#ifdef DO_INDEX - array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy); -#else array->coverage[ix] = coverage; -#endif #ifdef DO_Z array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); #endif -#ifdef DO_RGBA array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); array->rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane); array->rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane); -#endif -#ifdef DO_INDEX - array->index[ix] = (GLint) solve_plane(cx, cy, iPlane); -#endif ix--; count++; coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); @@ -351,12 +310,7 @@ GLint j; for (j = 0; j < (GLint) n; j++) { array->coverage[j] = array->coverage[j + left]; -#ifdef DO_RGBA COPY_CHAN4(array->rgba[j], array->rgba[j + left]); -#endif -#ifdef DO_INDEX - array->index[j] = array->index[j + left]; -#endif #ifdef DO_Z array->z[j] = array->z[j + left]; #endif @@ -366,18 +320,12 @@ span.x = left; span.y = iy; span.end = n; -#if defined(DO_RGBA) _swrast_write_rgba_span(ctx, &span); -#else - _swrast_write_index_span(ctx, &span); -#endif } } } #undef DO_Z -#undef DO_RGBA -#undef DO_INDEX #undef DO_ATTRIBS #undef DO_OCCLUSION_TEST diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 2dd9ca6348b..854e106b7f0 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -130,11 +130,7 @@ _swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint x, y, width, height; - if (ctx->Visual.accumRedBits == 0) { - /* No accumulation buffer! Not an error. */ - return; - } - + /* No accumulation buffer! Not an error. */ if (!rb || !rb->Data) return; diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 59e26e9ea31..da730213aca 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -125,10 +125,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (count + width >= MAX_WIDTH || row + 1 == height) { /* flush the span */ span.end = count; - if (ctx->Visual.rgbMode) - _swrast_write_rgba_span(ctx, &span); - else - _swrast_write_index_span(ctx, &span); + _swrast_write_rgba_span(ctx, &span); span.end = 0; count = 0; } @@ -192,10 +189,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - if (ctx->Visual.rgbMode) - _swrast_write_rgba_span(ctx, &span); - else - _swrast_write_index_span(ctx, &span); + _swrast_write_rgba_span(ctx, &span); /* get ready for next row */ if (mask != 1) @@ -215,10 +209,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - if (ctx->Visual.rgbMode) - _swrast_write_rgba_span(ctx, &span); - else - _swrast_write_index_span(ctx, &span); + _swrast_write_rgba_span(ctx, &span); /* get ready for next row */ if (mask != 128) diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c index 820297f3eee..7b0a63391fa 100644 --- a/src/mesa/swrast/s_clear.c +++ b/src/mesa/swrast/s_clear.c @@ -51,7 +51,6 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb, SWspan span; GLint i; - ASSERT(ctx->Visual.rgbMode); ASSERT(rb->PutRow); /* Initialize color span with clear color */ @@ -105,45 +104,6 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb, /** - * Clear color index buffer with masking. - */ -static void -clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - 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; - SWspan span; - GLint i; - - ASSERT(!ctx->Visual.rgbMode); - ASSERT(rb->PutRow); - ASSERT(rb->DataType == GL_UNSIGNED_INT); - - /* Initialize index span with clear index */ - INIT_SPAN(span, GL_BITMAP); - span.end = width; - span.arrayMask = SPAN_INDEX; - for (i = 0; i < width;i++) { - span.array->index[i] = ctx->Color.ClearIndex; - } - - /* Note that masking will change the color indexes, but only the - * bits for which the write mask is GL_FALSE. The bits - * which are write-enabled won't get modified. - */ - for (i = 0; i < height;i++) { - span.x = x; - span.y = y + i; - _swrast_mask_ci_span(ctx, rb, &span); - /* write masked row */ - rb->PutRow(ctx, rb, width, x, y + i, span.array->index, NULL); - } -} - - -/** * Clear an rgba color buffer without channel masking. */ static void @@ -158,8 +118,6 @@ clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint buf) GLvoid *clearVal; GLint i; - ASSERT(ctx->Visual.rgbMode); - ASSERT(ctx->Color.ColorMask[buf][0] && ctx->Color.ColorMask[buf][1] && ctx->Color.ColorMask[buf][2] && @@ -197,50 +155,6 @@ clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint buf) /** - * Clear color index buffer without masking. - */ -static void -clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - 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; - GLubyte clear8; - GLushort clear16; - GLuint clear32; - GLvoid *clearVal; - GLint i; - - ASSERT(!ctx->Visual.rgbMode); - - ASSERT(rb->PutMonoRow); - - /* setup clear value */ - switch (rb->DataType) { - case GL_UNSIGNED_BYTE: - clear8 = (GLubyte) ctx->Color.ClearIndex; - clearVal = &clear8; - break; - case GL_UNSIGNED_SHORT: - clear16 = (GLushort) ctx->Color.ClearIndex; - clearVal = &clear16; - break; - case GL_UNSIGNED_INT: - clear32 = ctx->Color.ClearIndex; - clearVal = &clear32; - break; - default: - _mesa_problem(ctx, "Bad rb DataType in clear_color_buffer"); - return; - } - - for (i = 0; i < height; i++) - rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL); -} - - -/** * Clear the front/back/left/right/aux color buffers. * This function is usually only called if the device driver can't * clear its own color buffers for some reason (such as with masking). @@ -252,25 +166,14 @@ clear_color_buffers(GLcontext *ctx) for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) { struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf]; - if (ctx->Visual.rgbMode) { - if (ctx->Color.ColorMask[buf][0] == 0 || - ctx->Color.ColorMask[buf][1] == 0 || - ctx->Color.ColorMask[buf][2] == 0 || - ctx->Color.ColorMask[buf][3] == 0) { - clear_rgba_buffer_with_masking(ctx, rb, buf); - } - else { - clear_rgba_buffer(ctx, rb, buf); - } + if (ctx->Color.ColorMask[buf][0] == 0 || + ctx->Color.ColorMask[buf][1] == 0 || + ctx->Color.ColorMask[buf][2] == 0 || + ctx->Color.ColorMask[buf][3] == 0) { + clear_rgba_buffer_with_masking(ctx, rb, buf); } else { - const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1; - if ((ctx->Color.IndexMask & indexMask) != indexMask) { - clear_ci_buffer_with_masking(ctx, rb); - } - else { - clear_ci_buffer(ctx, rb); - } + clear_rgba_buffer(ctx, rb, buf); } } } diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 0d4680db9f7..751966348b1 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -63,24 +63,17 @@ _swrast_update_rasterflags( GLcontext *ctx ) if (swrast->_FogEnabled) rasterMask |= FOG_BIT; if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT; if (ctx->Stencil._Enabled) rasterMask |= STENCIL_BIT; - if (ctx->Visual.rgbMode) { - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - if (!ctx->Color.ColorMask[i][0] || - !ctx->Color.ColorMask[i][1] || - !ctx->Color.ColorMask[i][2] || - !ctx->Color.ColorMask[i][3]) { - rasterMask |= MASKING_BIT; - break; - } + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!ctx->Color.ColorMask[i][0] || + !ctx->Color.ColorMask[i][1] || + !ctx->Color.ColorMask[i][2] || + !ctx->Color.ColorMask[i][3]) { + rasterMask |= MASKING_BIT; + break; } - if (ctx->Color._LogicOpEnabled) rasterMask |= LOGIC_OP_BIT; - if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT; - } - else { - if (ctx->Color.IndexMask != 0xffffffff) rasterMask |= MASKING_BIT; - if (ctx->Color.IndexLogicOpEnabled) rasterMask |= LOGIC_OP_BIT; } - + if (ctx->Color._LogicOpEnabled) rasterMask |= LOGIC_OP_BIT; + if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT; if ( ctx->Viewport.X < 0 || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width || ctx->Viewport.Y < 0 @@ -100,19 +93,14 @@ _swrast_update_rasterflags( GLcontext *ctx ) /* more than one color buffer designated for writing (or zero buffers) */ rasterMask |= MULTI_DRAW_BIT; } - else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) { - rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */ - } - if (ctx->Visual.rgbMode) { - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - if (ctx->Color.ColorMask[i][0] + - ctx->Color.ColorMask[i][1] + - ctx->Color.ColorMask[i][2] + - ctx->Color.ColorMask[i][3] == 0) { - rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ - break; - } + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (ctx->Color.ColorMask[i][0] + + ctx->Color.ColorMask[i][1] + + ctx->Color.ColorMask[i][2] + + ctx->Color.ColorMask[i][3] == 0) { + rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ + break; } } @@ -892,12 +880,7 @@ _swrast_flush( GLcontext *ctx ) SWcontext *swrast = SWRAST_CONTEXT(ctx); /* flush any pending fragments from rendering points */ if (swrast->PointSpan.end > 0) { - if (ctx->Visual.rgbMode) { - _swrast_write_rgba_span(ctx, &(swrast->PointSpan)); - } - else { - _swrast_write_index_span(ctx, &(swrast->PointSpan)); - } + _swrast_write_rgba_span(ctx, &(swrast->PointSpan)); swrast->PointSpan.end = 0; } } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 3f37c027e4a..f4f0c8a330e 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -307,100 +307,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } -static void -copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, - GLint destx, GLint desty ) -{ - GLuint *tmpImage,*p; - GLint sy, dy, stepy; - GLint j; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - GLint overlapping; - SWspan span; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_INDEX; - - if (ctx->DrawBuffer == ctx->ReadBuffer) { - overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, - ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - } - else { - overlapping = GL_FALSE; - } - - /* Determine if copy should be bottom-to-top or top-to-bottom */ - if (!overlapping && srcy < desty) { - /* top-down max-to-min */ - sy = srcy + height - 1; - dy = desty + height - 1; - stepy = -1; - } - else { - /* bottom-up min-to-max */ - sy = srcy; - dy = desty; - stepy = 1; - } - - if (overlapping) { - GLint ssy = sy; - tmpImage = (GLuint *) malloc(width * height * sizeof(GLuint)); - if (!tmpImage) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); - return; - } - /* read the image */ - p = tmpImage; - for (j = 0; j < height; j++, ssy += stepy) { - _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, ssy, p ); - p += width; - } - p = tmpImage; - } - else { - tmpImage = NULL; /* silence compiler warning */ - p = NULL; - } - - for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - /* Get color indexes */ - if (overlapping) { - memcpy(span.array->index, p, width * sizeof(GLuint)); - p += width; - } - else { - _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, sy, span.array->index ); - } - - if (ctx->_ImageTransferState) - _mesa_apply_ci_transfer_ops(ctx, ctx->_ImageTransferState, - width, span.array->index); - - /* write color indexes */ - span.x = destx; - span.y = dy; - span.end = width; - if (zoom) - _swrast_write_zoomed_index_span(ctx, destx, desty, &span); - else - _swrast_write_index_span(ctx, &span); - } - - if (overlapping) - free(tmpImage); -} - - /** * Convert floating point Z values to integer Z values with pixel transfer's * Z scale and bias. @@ -522,18 +428,10 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, span.x = destx; span.y = dy; span.end = width; - if (fb->Visual.rgbMode) { - if (zoom) - _swrast_write_zoomed_depth_span(ctx, destx, desty, &span); - else - _swrast_write_rgba_span(ctx, &span); - } - else { - if (zoom) - _swrast_write_zoomed_depth_span(ctx, destx, desty, &span); - else - _swrast_write_index_span(ctx, &span); - } + if (zoom) + _swrast_write_zoomed_depth_span(ctx, destx, desty, &span); + else + _swrast_write_rgba_span(ctx, &span); } if (overlapping) @@ -909,12 +807,7 @@ _swrast_CopyPixels( GLcontext *ctx, if (!fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, type)) { switch (type) { case GL_COLOR: - if (ctx->Visual.rgbMode) { - copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } - else { - copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } + copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); break; case GL_DEPTH: copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty ); diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 3e36cf9a7e5..ed637cac124 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -526,7 +526,7 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ) /* Convert floating point values in [0,1] to device Z coordinates in * [0, DepthMax]. - * ex: If the the Z buffer has 24 bits, DepthMax = 0xffffff. + * ex: If the Z buffer has 24 bits, DepthMax = 0xffffff. * * XXX this all falls apart if we have 31 or more bits of Z because * the triangle rasterization code produces unsigned Z values. Negative diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 7571d5b8c0d..3cec3a7a2ba 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -267,7 +267,7 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, if (format == GL_COLOR_INDEX && type == GL_UNSIGNED_BYTE) { const GLubyte *src = (const GLubyte *) pixels + unpack.SkipRows * unpack.RowLength + unpack.SkipPixels; - if (ctx->Visual.rgbMode && rbType == GL_UNSIGNED_BYTE) { + if (rbType == GL_UNSIGNED_BYTE) { /* convert ubyte/CI data to ubyte/RGBA */ if (simpleZoom) { GLint row; @@ -299,22 +299,6 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, } return GL_TRUE; } - else if (!ctx->Visual.rgbMode && rbType == GL_UNSIGNED_INT) { - /* write CI data to CI frame buffer */ - GLint row; - if (simpleZoom) { - for (row = 0; row < drawHeight; row++) { - GLuint index32[MAX_WIDTH]; - GLint col; - for (col = 0; col < drawWidth; col++) - index32[col] = src[col]; - rb->PutRow(ctx, rb, drawWidth, destX, destY, index32, NULL); - src += unpack.RowLength; - destY += yStep; - } - return GL_TRUE; - } - } } /* can't handle this pixel format and/or data type */ @@ -324,57 +308,6 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, /* - * Draw color index image. - */ -static void -draw_index_pixels( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) -{ - const GLint imgX = x, imgY = y; - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - GLint row, skipPixels; - SWspan span; - - INIT_SPAN(span, GL_BITMAP); - span.arrayMask = SPAN_INDEX; - _swrast_span_default_attribs(ctx, &span); - - /* - * General solution - */ - skipPixels = 0; - while (skipPixels < width) { - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); - ASSERT(spanWidth <= MAX_WIDTH); - for (row = 0; row < height; row++) { - const GLvoid *source = _mesa_image_address2d(unpack, pixels, - width, height, - GL_COLOR_INDEX, type, - row, skipPixels); - _mesa_unpack_index_span(ctx, spanWidth, GL_UNSIGNED_INT, - span.array->index, type, source, unpack, - ctx->_ImageTransferState); - - /* These may get changed during writing/clipping */ - span.x = x + skipPixels; - span.y = y + row; - span.end = spanWidth; - - if (zoom) - _swrast_write_zoomed_index_span(ctx, imgX, imgY, &span); - else - _swrast_write_index_span(ctx, &span); - } - skipPixels += spanWidth; - } -} - - - -/* * Draw stencil image. */ static void @@ -441,7 +374,6 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, && ctx->DrawBuffer->Visual.depthBits == 16 && !scaleOrBias && !zoom - && ctx->Visual.rgbMode && width <= MAX_WIDTH && !unpack->SwapBytes) { /* Special case: directly write 16-bit depth values */ @@ -462,7 +394,6 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, else if (type == GL_UNSIGNED_INT && !scaleOrBias && !zoom - && ctx->Visual.rgbMode && width <= MAX_WIDTH && !unpack->SwapBytes) { /* Special case: shift 32-bit values down to Visual.depthBits */ @@ -515,11 +446,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, if (zoom) { _swrast_write_zoomed_depth_span(ctx, x, y, &span); } - else if (ctx->Visual.rgbMode) { - _swrast_write_rgba_span(ctx, &span); - } else { - _swrast_write_index_span(ctx, &span); + _swrast_write_rgba_span(ctx, &span); } } skipPixels += spanWidth; @@ -867,11 +795,6 @@ _swrast_DrawPixels( GLcontext *ctx, draw_depth_pixels( ctx, x, y, width, height, type, unpack, pixels ); break; case GL_COLOR_INDEX: - if (ctx->Visual.rgbMode) - draw_rgba_pixels(ctx, x,y, width, height, format, type, unpack, pixels); - else - draw_index_pixels(ctx, x, y, width, height, type, unpack, pixels); - break; case GL_RED: case GL_GREEN: case GL_BLUE: diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c index 2e6066983d5..373b1416e28 100644 --- a/src/mesa/swrast/s_feedback.c +++ b/src/mesa/swrast/s_feedback.c @@ -46,7 +46,7 @@ feedback_vertex(GLcontext * ctx, const SWvertex * v, const SWvertex * pv) win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF; win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3]; - _mesa_feedback_vertex(ctx, win, color, v->attrib[FRAG_ATTRIB_CI][0], vtc); + _mesa_feedback_vertex(ctx, win, color, vtc); } diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index 0472bbf553c..3fc84392133 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -122,38 +122,6 @@ else { \ } \ } -/* As above, but CI mode (XXX try to merge someday) */ -#define FOG_LOOP_CI(FOG_FUNC) \ -if (span->arrayAttribs & FRAG_BIT_FOGC) { \ - GLuint i; \ - for (i = 0; i < span->end; i++) { \ - const GLfloat fogCoord = span->array->attribs[FRAG_ATTRIB_FOGC][i][0]; \ - const GLfloat c = FABSF(fogCoord); \ - GLfloat f; \ - FOG_FUNC(f, c); \ - f = CLAMP(f, 0.0F, 1.0F); \ - index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); \ - } \ -} \ -else { \ - const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \ - GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \ - const GLfloat wStep = span->attrStepX[FRAG_ATTRIB_WPOS][3]; \ - GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; \ - GLuint i; \ - for (i = 0; i < span->end; i++) { \ - const GLfloat c = FABSF(fogCoord) / w; \ - GLfloat f; \ - FOG_FUNC(f, c); \ - f = CLAMP(f, 0.0F, 1.0F); \ - index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); \ - fogCoord += fogStep; \ - w += wStep; \ - } \ -} - - - /** * Apply fog to a span of RGBA pixels. * The fog value are either in the span->array->fog array or interpolated from @@ -275,56 +243,3 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span ) } } } - - -/** - * As above, but color index mode. - */ -void -_swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) -{ - const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); - const GLuint fogIndex = (GLuint) ctx->Fog.Index; - GLuint *index = span->array->index; - - ASSERT(swrast->_FogEnabled); - ASSERT(span->arrayMask & SPAN_INDEX); - - /* we need to compute fog blend factors */ - if (swrast->_PreferPixelFog) { - /* The span's fog values are fog coordinates, now compute blend factors - * and blend the fragment colors with the fog color. - */ - switch (ctx->Fog.Mode) { - case GL_LINEAR: - { - const GLfloat fogEnd = ctx->Fog.End; - const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End) - ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start); - FOG_LOOP_CI(LINEAR_FOG); - } - break; - case GL_EXP: - { - const GLfloat density = -ctx->Fog.Density; - FOG_LOOP_CI(EXP_FOG); - } - break; - case GL_EXP2: - { - const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; - FOG_LOOP_CI(EXP2_FOG); - } - break; - default: - _mesa_problem(ctx, "Bad fog mode in _swrast_fog_ci_span"); - return; - } - } - else { - /* The span's fog start/step/array values are blend factors in [0,1]. - * They were previously computed per-vertex. - */ - FOG_LOOP_CI(BLEND_FOG); - } -} diff --git a/src/mesa/swrast/s_fog.h b/src/mesa/swrast/s_fog.h index 50760d88af7..06107de3f9d 100644 --- a/src/mesa/swrast/s_fog.h +++ b/src/mesa/swrast/s_fog.h @@ -37,8 +37,4 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z); extern void _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span ); -extern void -_swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ); - - #endif diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index cff36042cbb..7db5af4ae1c 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -87,10 +87,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) for (i = 0; i < span->end; i++) y[i]++; } - if (ctx->Visual.rgbMode) - _swrast_write_rgba_span(ctx, span); - else - _swrast_write_index_span(ctx, span); + _swrast_write_rgba_span(ctx, span); } } else { @@ -106,10 +103,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) for (i = 0; i < span->end; i++) x[i]++; } - if (ctx->Visual.rgbMode) - _swrast_write_rgba_span(ctx, span); - else - _swrast_write_index_span(ctx, span); + _swrast_write_rgba_span(ctx, span); } } } @@ -120,12 +114,6 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) /***** Rasterization *****/ /**********************************************************************/ -/* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/ -#define NAME simple_no_z_ci_line -#define INTERP_INDEX -#define RENDER_SPAN(span) _swrast_write_index_span(ctx, &span) -#include "s_linetemp.h" - /* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/ #define NAME simple_no_z_rgba_line #define INTERP_RGBA @@ -133,25 +121,6 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) #include "s_linetemp.h" -/* Z, fog, wide, stipple color index line */ -#define NAME ci_line -#define INTERP_INDEX -#define INTERP_Z -#define INTERP_ATTRIBS /* for fog */ -#define RENDER_SPAN(span) \ - if (ctx->Line.StippleFlag) { \ - span.arrayMask |= SPAN_MASK; \ - compute_stipple_mask(ctx, span.end, span.array->mask); \ - } \ - if (ctx->Line.Width > 1.0) { \ - draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ - } \ - else { \ - _swrast_write_index_span(ctx, &span); \ - } -#include "s_linetemp.h" - - /* Z, fog, wide, stipple RGBA line */ #define NAME rgba_line #define INTERP_RGBA @@ -256,7 +225,6 @@ void _swrast_choose_line( GLcontext *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLboolean rgbmode = ctx->Visual.rgbMode; GLboolean specular = (ctx->Fog.ColorSumEnabled || (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); @@ -277,23 +245,17 @@ _swrast_choose_line( GLcontext *ctx ) || ctx->Line.Width != 1.0 || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ - if (rgbmode) #if CHAN_BITS == 32 - USE(general_line); + USE(general_line); #else - USE(rgba_line); + USE(rgba_line); #endif - else - USE(ci_line); } else { ASSERT(!ctx->Depth.Test); ASSERT(ctx->Line.Width == 1.0); /* simple lines */ - if (rgbmode) - USE(simple_no_z_rgba_line); - else - USE(simple_no_z_ci_line); + USE(simple_no_z_rgba_line); } } else if (ctx->RenderMode == GL_FEEDBACK) { diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 1abf8d6c7f3..033431df232 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -31,8 +31,6 @@ * The following macros may be defined to indicate what auxillary information * must be interplated along the line: * INTERP_Z - if defined, interpolate Z values - * INTERP_RGBA - if defined, interpolate RGBA values - * INTERP_INDEX - if defined, interpolate color index values * INTERP_ATTRIBS - if defined, interpolate attribs (texcoords, varying, etc) * * When one can directly address pixels in the color buffer the following @@ -86,7 +84,6 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) DEPTH_TYPE *zPtr; #elif defined(INTERP_Z) const GLint depthBits = ctx->DrawBuffer->Visual.depthBits; -/*ctx->Visual.depthBits;*/ #endif #ifdef PIXEL_ADDRESS PIXEL_TYPE *pixelPtr; @@ -223,7 +220,6 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) /* * Span setup: compute start and step values for all interpolated values. */ -#ifdef INTERP_RGBA interpFlags |= SPAN_RGBA; if (ctx->Light.ShadeModel == GL_SMOOTH) { span.red = ChanToFixed(vert0->color[0]); @@ -245,19 +241,6 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) span.blueStep = 0; span.alphaStep = 0; } -#endif -#ifdef INTERP_INDEX - interpFlags |= SPAN_INDEX; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - span.index = FloatToFixed(vert0->attrib[FRAG_ATTRIB_CI][0]); - span.indexStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_CI][0] - - vert0->attrib[FRAG_ATTRIB_CI][0]) / numPixels; - } - else { - span.index = FloatToFixed(vert1->attrib[FRAG_ATTRIB_CI][0]); - span.indexStep = 0; - } -#endif #if defined(INTERP_Z) || defined(DEPTH_TYPE) interpFlags |= SPAN_Z; { @@ -407,9 +390,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) #undef NAME #undef INTERP_Z -#undef INTERP_RGBA #undef INTERP_ATTRIBS -#undef INTERP_INDEX #undef PIXEL_ADDRESS #undef PIXEL_TYPE #undef DEPTH_TYPE diff --git a/src/mesa/swrast/s_logic.c b/src/mesa/swrast/s_logic.c index f0274b4c0b1..c36a16e665c 100644 --- a/src/mesa/swrast/s_logic.c +++ b/src/mesa/swrast/s_logic.c @@ -182,33 +182,6 @@ logicop_uint4(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[], -/* - * Apply the current logic operator to a span of CI pixels. This is only - * used if the device driver can't do logic ops. - */ -void -_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span) -{ - GLuint dest[MAX_WIDTH]; - GLuint *index = span->array->index; - - ASSERT(span->end < MAX_WIDTH); - ASSERT(rb->DataType == GL_UNSIGNED_INT); - - /* Read dest values from frame buffer */ - if (span->arrayMask & SPAN_XY) { - _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y, - dest, sizeof(GLuint)); - } - else { - rb->GetRow(ctx, rb, span->end, span->x, span->y, dest); - } - - logicop_uint1(ctx, span->end, index, dest, span->array->mask); -} - - /** * Apply the current logic operator to a span of RGBA pixels. * We can handle horizontal runs of pixels (spans) or arrays of x/y diff --git a/src/mesa/swrast/s_logic.h b/src/mesa/swrast/s_logic.h index ba20cd7b325..e8cfae33f23 100644 --- a/src/mesa/swrast/s_logic.h +++ b/src/mesa/swrast/s_logic.h @@ -29,12 +29,6 @@ #include "swrast.h" - -extern void -_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span); - - extern void _swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, SWspan *span); diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c index 69c2feb6da8..e38d90f199e 100644 --- a/src/mesa/swrast/s_masking.c +++ b/src/mesa/swrast/s_masking.c @@ -101,34 +101,3 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, } } } - - -/** - * Apply the index mask to a span of color index values. - */ -void -_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span) -{ - const GLuint srcMask = ctx->Color.IndexMask; - const GLuint dstMask = ~srcMask; - GLuint *index = span->array->index; - GLuint dest[MAX_WIDTH]; - GLuint i; - - ASSERT(span->arrayMask & SPAN_INDEX); - ASSERT(span->end <= MAX_WIDTH); - ASSERT(rb->DataType == GL_UNSIGNED_INT); - - if (span->arrayMask & SPAN_XY) { - _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y, - dest, sizeof(GLuint)); - } - else { - _swrast_read_index_span(ctx, rb, span->end, span->x, span->y, dest); - } - - for (i = 0; i < span->end; i++) { - index[i] = (index[i] & srcMask) | (dest[i] & dstMask); - } -} diff --git a/src/mesa/swrast/s_masking.h b/src/mesa/swrast/s_masking.h index fed47f8cfbe..3ba4f8356cb 100644 --- a/src/mesa/swrast/s_masking.h +++ b/src/mesa/swrast/s_masking.h @@ -34,9 +34,4 @@ extern void _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, SWspan *span, GLuint buf); - -extern void -_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span); - #endif diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index a9a704a16ee..1663ece8294 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -244,7 +244,6 @@ static void smooth_point(GLcontext *ctx, const SWvertex *vert) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLboolean ciMode = !ctx->Visual.rgbMode; SWspan span; GLfloat size, alphaAtten; @@ -335,10 +334,6 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) if (dist2 >= rmin2) { /* compute partial coverage */ coverage = 1.0F - (dist2 - rmin2) * cscale; - if (ciMode) { - /* coverage in [0,15] */ - coverage *= 15.0; - } } else { /* full coverage */ @@ -369,7 +364,6 @@ static void large_point(GLcontext *ctx, const SWvertex *vert) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLboolean ciMode = !ctx->Visual.rgbMode; SWspan span; GLfloat size; @@ -389,22 +383,15 @@ large_point(GLcontext *ctx, const SWvertex *vert) span.arrayMask = SPAN_XY; span.facing = swrast->PointLineFacing; - if (ciMode) { - span.interpMask = SPAN_Z | SPAN_INDEX; - span.index = FloatToFixed(vert->attrib[FRAG_ATTRIB_CI][0]); - span.indexStep = 0; - } - else { - span.interpMask = SPAN_Z | SPAN_RGBA; - span.red = ChanToFixed(vert->color[0]); - span.green = ChanToFixed(vert->color[1]); - span.blue = ChanToFixed(vert->color[2]); - span.alpha = ChanToFixed(vert->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - } + span.interpMask = SPAN_Z | SPAN_RGBA; + span.red = ChanToFixed(vert->color[0]); + span.green = ChanToFixed(vert->color[1]); + span.blue = ChanToFixed(vert->color[2]); + span.alpha = ChanToFixed(vert->color[3]); + span.redStep = 0; + span.greenStep = 0; + span.blueStep = 0; + span.alphaStep = 0; /* need these for fragment programs */ span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; @@ -466,7 +453,6 @@ static void pixel_point(GLcontext *ctx, const SWvertex *vert) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLboolean ciMode = !ctx->Visual.rgbMode; /* * Note that unlike the other functions, we put single-pixel points * into a special span array in order to render as many points as @@ -480,10 +466,7 @@ pixel_point(GLcontext *ctx, const SWvertex *vert) /* Span init */ span->interpMask = 0; span->arrayMask = SPAN_XY | SPAN_Z; - if (ciMode) - span->arrayMask |= SPAN_INDEX; - else - span->arrayMask |= SPAN_RGBA; + span->arrayMask |= SPAN_RGBA; /*span->arrayMask |= SPAN_LAMBDA;*/ span->arrayAttribs = swrast->_ActiveAttribMask; /* we'll produce these vals */ @@ -497,10 +480,7 @@ pixel_point(GLcontext *ctx, const SWvertex *vert) (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT)) || span->facing != swrast->PointLineFacing) { if (span->end > 0) { - if (ciMode) - _swrast_write_index_span(ctx, span); - else - _swrast_write_rgba_span(ctx, span); + _swrast_write_rgba_span(ctx, span); span->end = 0; } } @@ -510,15 +490,11 @@ pixel_point(GLcontext *ctx, const SWvertex *vert) span->facing = swrast->PointLineFacing; /* fragment attributes */ - if (ciMode) { - span->array->index[count] = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0]; - } - else { - span->array->rgba[count][RCOMP] = vert->color[0]; - span->array->rgba[count][GCOMP] = vert->color[1]; - span->array->rgba[count][BCOMP] = vert->color[2]; - span->array->rgba[count][ACOMP] = vert->color[3]; - } + span->array->rgba[count][RCOMP] = vert->color[0]; + span->array->rgba[count][GCOMP] = vert->color[1]; + span->array->rgba[count][BCOMP] = vert->color[2]; + span->array->rgba[count][ACOMP] = vert->color[3]; + ATTRIB_LOOP_BEGIN COPY_4V(span->array->attribs[attr][count], vert->attrib[attr]); ATTRIB_LOOP_END diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 41911337b84..368311e14dd 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -41,42 +41,6 @@ #include "s_stencil.h" -/* - * Read a block of color index pixels. - */ -static void -read_index_pixels( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - GLint i; - - if (!rb) - return; - - /* width should never be > MAX_WIDTH since we did clipping earlier */ - ASSERT(width <= MAX_WIDTH); - - /* process image row by row */ - for (i = 0; i < height; i++) { - GLuint index[MAX_WIDTH]; - GLvoid *dest; - ASSERT(rb->DataType == GL_UNSIGNED_INT); - rb->GetRow(ctx, rb, width, x, y + i, index); - - dest = _mesa_image_address2d(packing, pixels, width, height, - GL_COLOR_INDEX, type, i, 0); - - _mesa_pack_index_span(ctx, width, type, dest, index, - &ctx->Pack, ctx->_ImageTransferState); - } -} - - - /** * Read pixels for format=GL_DEPTH_COMPONENT. */ @@ -289,21 +253,21 @@ fast_read_rgba_pixels( GLcontext *ctx, /** * When we're using a low-precision color buffer (like 16-bit 5/6/5) * we have to adjust our color values a bit to pass conformance. - * The problem is when a 5 or 6-bit color value is convert to an 8-bit + * The problem is when a 5 or 6-bit color value is converted to an 8-bit * value and then a floating point value, the floating point values don't * increment uniformly as the 5 or 6-bit value is incremented. * * This function adjusts floating point values to compensate. */ static void -adjust_colors(GLcontext *ctx, GLuint n, GLfloat rgba[][4]) +adjust_colors(const struct gl_framebuffer *fb, GLuint n, GLfloat rgba[][4]) { - const GLuint rShift = 8 - ctx->Visual.redBits; - const GLuint gShift = 8 - ctx->Visual.greenBits; - const GLuint bShift = 8 - ctx->Visual.blueBits; - const GLfloat rScale = 1.0F / (GLfloat) ((1 << ctx->Visual.redBits ) - 1); - const GLfloat gScale = 1.0F / (GLfloat) ((1 << ctx->Visual.greenBits) - 1); - const GLfloat bScale = 1.0F / (GLfloat) ((1 << ctx->Visual.blueBits ) - 1); + const GLuint rShift = 8 - fb->Visual.redBits; + const GLuint gShift = 8 - fb->Visual.greenBits; + const GLuint bShift = 8 - fb->Visual.blueBits; + const GLfloat rScale = 1.0F / (GLfloat) ((1 << fb->Visual.redBits ) - 1); + const GLfloat gScale = 1.0F / (GLfloat) ((1 << fb->Visual.greenBits) - 1); + const GLfloat bScale = 1.0F / (GLfloat) ((1 << fb->Visual.blueBits ) - 1); GLuint i; for (i = 0; i < n; i++) { GLint r, g, b; @@ -373,18 +337,7 @@ read_rgba_pixels( GLcontext *ctx, /* read full RGBA, FLOAT image */ dest = tmpImage; for (row = 0; row < height; row++, y++) { - if (fb->Visual.rgbMode) { - _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest); - } - else { - GLuint index[MAX_WIDTH]; - ASSERT(rb->DataType == GL_UNSIGNED_INT); - rb->GetRow(ctx, rb, width, x, y, index); - _mesa_apply_ci_transfer_ops(ctx, - transferOps & IMAGE_SHIFT_OFFSET_BIT, - width, index); - _mesa_map_ci_to_rgba(ctx, width, index, (GLfloat (*)[4]) dest); - } + _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest); _mesa_apply_rgba_transfer_ops(ctx, transferOps & IMAGE_PRE_CONVOLUTION_BITS, width, (GLfloat (*)[4]) dest); @@ -431,25 +384,13 @@ read_rgba_pixels( GLcontext *ctx, for (row = 0; row < height; row++, y++) { /* Get float rgba pixels */ - if (fb->Visual.rgbMode) { - _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba); - } - else { - /* read CI and convert to RGBA */ - GLuint index[MAX_WIDTH]; - ASSERT(rb->DataType == GL_UNSIGNED_INT); - rb->GetRow(ctx, rb, width, x, y, index); - _mesa_apply_ci_transfer_ops(ctx, - transferOps & IMAGE_SHIFT_OFFSET_BIT, - width, index); - _mesa_map_ci_to_rgba(ctx, width, index, rgba); - } + _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba); /* apply fudge factor for shallow color buffers */ if (fb->Visual.redBits < 8 || fb->Visual.greenBits < 8 || fb->Visual.blueBits < 8) { - adjust_colors(ctx, width, rgba); + adjust_colors(fb, width, rgba); } /* pack the row of RGBA pixels into user's buffer */ @@ -592,10 +533,6 @@ _swrast_ReadPixels( GLcontext *ctx, return; switch (format) { - case GL_COLOR_INDEX: - read_index_pixels(ctx, x, y, width, height, type, pixels, - &clippedPacking); - break; case GL_STENCIL_INDEX: read_stencil_pixels(ctx, x, y, width, height, type, pixels, &clippedPacking); diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index dada3643606..687c8eb0bf8 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -60,6 +60,7 @@ void _swrast_span_default_attribs(GLcontext *ctx, SWspan *span) { + GLchan r, g, b, a; /* Z*/ { const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; @@ -80,41 +81,33 @@ _swrast_span_default_attribs(GLcontext *ctx, SWspan *span) span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0; /* primary color, or color index */ - if (ctx->Visual.rgbMode) { - GLchan r, g, b, a; - UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]); - UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]); - UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]); - UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]); + UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]); + UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]); + UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]); + UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]); #if CHAN_TYPE == GL_FLOAT - span->red = r; - span->green = g; - span->blue = b; - span->alpha = a; + span->red = r; + span->green = g; + span->blue = b; + span->alpha = a; #else - span->red = IntToFixed(r); - span->green = IntToFixed(g); - span->blue = IntToFixed(b); - span->alpha = IntToFixed(a); + span->red = IntToFixed(r); + span->green = IntToFixed(g); + span->blue = IntToFixed(b); + span->alpha = IntToFixed(a); #endif - span->redStep = 0; - span->greenStep = 0; - span->blueStep = 0; - span->alphaStep = 0; - span->interpMask |= SPAN_RGBA; - - COPY_4V(span->attrStart[FRAG_ATTRIB_COL0], ctx->Current.RasterColor); - ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(span->attrStepY[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0); - } - else { - span->index = FloatToFixed(ctx->Current.RasterIndex); - span->indexStep = 0; - span->interpMask |= SPAN_INDEX; - } + span->redStep = 0; + span->greenStep = 0; + span->blueStep = 0; + span->alphaStep = 0; + span->interpMask |= SPAN_RGBA; + + COPY_4V(span->attrStart[FRAG_ATTRIB_COL0], ctx->Current.RasterColor); + ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0); + ASSIGN_4V(span->attrStepY[FRAG_ATTRIB_COL0], 0.0, 0.0, 0.0, 0.0); /* Secondary color */ - if (ctx->Visual.rgbMode && (ctx->Light.Enabled || ctx->Fog.ColorSumEnabled)) + if (ctx->Light.Enabled || ctx->Fog.ColorSumEnabled) { COPY_4V(span->attrStart[FRAG_ATTRIB_COL1], ctx->Current.RasterSecondaryColor); ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL1], 0.0, 0.0, 0.0, 0.0); @@ -374,38 +367,6 @@ interpolate_float_colors(SWspan *span) -/* Fill in the span.color.index array from the interpolation values */ -static INLINE void -interpolate_indexes(GLcontext *ctx, SWspan *span) -{ - GLfixed index = span->index; - const GLint indexStep = span->indexStep; - const GLuint n = span->end; - GLuint *indexes = span->array->index; - GLuint i; - (void) ctx; - - ASSERT(!(span->arrayMask & SPAN_INDEX)); - - if ((span->interpMask & SPAN_FLAT) || (indexStep == 0)) { - /* constant color */ - index = FixedToInt(index); - for (i = 0; i < n; i++) { - indexes[i] = index; - } - } - else { - /* interpolate */ - for (i = 0; i < n; i++) { - indexes[i] = FixedToInt(index); - index += indexStep; - } - } - span->arrayMask |= SPAN_INDEX; - span->interpMask &= ~SPAN_INDEX; -} - - /** * Fill in the span.zArray array from the span->z, zStep values. */ @@ -842,249 +803,6 @@ clip_span( GLcontext *ctx, SWspan *span ) /** - * Apply all the per-fragment opertions to a span of color index fragments - * and write them to the enabled color drawbuffers. - * The 'span' parameter can be considered to be const. Note that - * span->interpMask and span->arrayMask may be changed but will be restored - * to their original values before returning. - */ -void -_swrast_write_index_span( GLcontext *ctx, SWspan *span) -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLbitfield origInterpMask = span->interpMask; - const GLbitfield origArrayMask = span->arrayMask; - struct gl_framebuffer *fb = ctx->DrawBuffer; - - ASSERT(span->end <= MAX_WIDTH); - ASSERT(span->primitive == GL_POINT || span->primitive == GL_LINE || - span->primitive == GL_POLYGON || span->primitive == GL_BITMAP); - ASSERT((span->interpMask | span->arrayMask) & SPAN_INDEX); - /* - ASSERT((span->interpMask & span->arrayMask) == 0); - */ - - if (span->arrayMask & SPAN_MASK) { - /* mask was initialized by caller, probably glBitmap */ - span->writeAll = GL_FALSE; - } - else { - memset(span->array->mask, 1, span->end); - span->writeAll = GL_TRUE; - } - - /* Clipping */ - if ((swrast->_RasterMask & CLIP_BIT) || (span->primitive != GL_POLYGON)) { - if (!clip_span(ctx, span)) { - return; - } - } - - if (!(span->arrayMask & SPAN_MASK)) { - /* post-clip sanity check */ - assert(span->x >= 0); - assert(span->y >= 0); - } - - /* Depth bounds test */ - if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { - if (!_swrast_depth_bounds_test(ctx, span)) { - return; - } - } - -#ifdef DEBUG - /* Make sure all fragments are within window bounds */ - if (span->arrayMask & SPAN_XY) { - GLuint i; - for (i = 0; i < span->end; i++) { - if (span->array->mask[i]) { - assert(span->array->x[i] >= fb->_Xmin); - assert(span->array->x[i] < fb->_Xmax); - assert(span->array->y[i] >= fb->_Ymin); - assert(span->array->y[i] < fb->_Ymax); - } - } - } -#endif - - /* Polygon Stippling */ - if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) { - stipple_polygon_span(ctx, span); - } - - /* Stencil and Z testing */ - if (ctx->Stencil._Enabled || ctx->Depth.Test) { - if (!(span->arrayMask & SPAN_Z)) - _swrast_span_interpolate_z(ctx, span); - - if (ctx->Transform.DepthClamp) - _swrast_depth_clamp_span(ctx, span); - - if (ctx->Stencil._Enabled) { - if (!_swrast_stencil_and_ztest_span(ctx, span)) { - span->arrayMask = origArrayMask; - return; - } - } - else { - ASSERT(ctx->Depth.Test); - if (!_swrast_depth_test_span(ctx, span)) { - span->interpMask = origInterpMask; - span->arrayMask = origArrayMask; - return; - } - } - } - - if (ctx->Query.CurrentOcclusionObject) { - /* update count of 'passed' fragments */ - struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; - GLuint i; - for (i = 0; i < span->end; i++) - q->Result += span->array->mask[i]; - } - - /* we have to wait until after occlusion to do this test */ - if (ctx->Color.IndexMask == 0) { - /* write no pixels */ - span->arrayMask = origArrayMask; - return; - } - - /* Interpolate the color indexes if needed */ - if (swrast->_FogEnabled || - ctx->Color.IndexLogicOpEnabled || - ctx->Color.IndexMask != 0xffffffff || - (span->arrayMask & SPAN_COVERAGE)) { - if (!(span->arrayMask & SPAN_INDEX) /*span->interpMask & SPAN_INDEX*/) { - interpolate_indexes(ctx, span); - } - } - - /* Fog */ - if (swrast->_FogEnabled) { - _swrast_fog_ci_span(ctx, span); - } - - /* Antialias coverage application */ - if (span->arrayMask & SPAN_COVERAGE) { - const GLfloat *coverage = span->array->coverage; - GLuint *index = span->array->index; - GLuint i; - for (i = 0; i < span->end; i++) { - ASSERT(coverage[i] < 16); - index[i] = (index[i] & ~0xf) | ((GLuint) coverage[i]); - } - } - - /* - * Write to renderbuffers - */ - { - const GLuint numBuffers = fb->_NumColorDrawBuffers; - GLuint buf; - - for (buf = 0; buf < numBuffers; buf++) { - struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buf]; - GLuint indexSave[MAX_WIDTH]; - - ASSERT(rb->_BaseFormat == GL_COLOR_INDEX); - - if (numBuffers > 1) { - /* save indexes for second, third renderbuffer writes */ - memcpy(indexSave, span->array->index, - span->end * sizeof(indexSave[0])); - } - - if (ctx->Color.IndexLogicOpEnabled) { - _swrast_logicop_ci_span(ctx, rb, span); - } - - if (ctx->Color.IndexMask != 0xffffffff) { - _swrast_mask_ci_span(ctx, rb, span); - } - - if (!(span->arrayMask & SPAN_INDEX) && span->indexStep == 0) { - /* all fragments have same color index */ - GLubyte index8; - GLushort index16; - GLuint index32; - void *value; - - if (rb->DataType == GL_UNSIGNED_BYTE) { - index8 = FixedToInt(span->index); - value = &index8; - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - index16 = FixedToInt(span->index); - value = &index16; - } - else { - ASSERT(rb->DataType == GL_UNSIGNED_INT); - index32 = FixedToInt(span->index); - value = &index32; - } - - if (span->arrayMask & SPAN_XY) { - rb->PutMonoValues(ctx, rb, span->end, span->array->x, - span->array->y, value, span->array->mask); - } - else { - rb->PutMonoRow(ctx, rb, span->end, span->x, span->y, - value, span->array->mask); - } - } - else { - /* each fragment is a different color */ - GLubyte index8[MAX_WIDTH]; - GLushort index16[MAX_WIDTH]; - void *values; - - if (rb->DataType == GL_UNSIGNED_BYTE) { - GLuint k; - for (k = 0; k < span->end; k++) { - index8[k] = (GLubyte) span->array->index[k]; - } - values = index8; - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLuint k; - for (k = 0; k < span->end; k++) { - index16[k] = (GLushort) span->array->index[k]; - } - values = index16; - } - else { - ASSERT(rb->DataType == GL_UNSIGNED_INT); - values = span->array->index; - } - - if (span->arrayMask & SPAN_XY) { - rb->PutValues(ctx, rb, span->end, - span->array->x, span->array->y, - values, span->array->mask); - } - else { - rb->PutRow(ctx, rb, span->end, span->x, span->y, - values, span->array->mask); - } - } - - if (buf + 1 < numBuffers) { - /* restore original span values */ - memcpy(span->array->index, indexSave, - span->end * sizeof(indexSave[0])); - } - } /* for buf */ - } - - span->interpMask = origInterpMask; - span->arrayMask = origArrayMask; -} - - -/** * Add specular colors to primary colors. * Only called during fixed-function operation. * Result is float color array (FRAG_ATTRIB_COL0). @@ -1630,74 +1348,6 @@ _swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb, /** - * Read CI pixels from a renderbuffer. Clipping will be done to prevent - * reading ouside the buffer's boundaries. - */ -void -_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLuint index[] ) -{ - const GLint bufWidth = (GLint) rb->Width; - const GLint bufHeight = (GLint) rb->Height; - - if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) { - /* completely above, below, or right */ - memset(index, 0, n * sizeof(GLuint)); - } - else { - GLint skip, length; - if (x < 0) { - /* left edge clipping */ - skip = -x; - length = (GLint) n - skip; - if (length < 0) { - /* completely left of window */ - return; - } - if (length > bufWidth) { - length = bufWidth; - } - } - else if ((GLint) (x + n) > bufWidth) { - /* right edge clipping */ - skip = 0; - length = bufWidth - x; - if (length < 0) { - /* completely to right of window */ - return; - } - } - else { - /* no clipping */ - skip = 0; - length = (GLint) n; - } - - ASSERT(rb->GetRow); - ASSERT(rb->_BaseFormat == GL_COLOR_INDEX); - - if (rb->DataType == GL_UNSIGNED_BYTE) { - GLubyte index8[MAX_WIDTH]; - GLint i; - rb->GetRow(ctx, rb, length, x + skip, y, index8); - for (i = 0; i < length; i++) - index[skip + i] = index8[i]; - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLushort index16[MAX_WIDTH]; - GLint i; - rb->GetRow(ctx, rb, length, x + skip, y, index16); - for (i = 0; i < length; i++) - index[skip + i] = index16[i]; - } - else if (rb->DataType == GL_UNSIGNED_INT) { - rb->GetRow(ctx, rb, length, x + skip, y, index + skip); - } - } -} - - -/** * Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid * reading values outside the buffer bounds. * We can use this for reading any format/type of renderbuffer. diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index 0eabae20e03..aaf1fec2a8b 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -41,13 +41,12 @@ */ /*@{*/ #define SPAN_RGBA 0x01 /**< interpMask and arrayMask */ -#define SPAN_INDEX 0x02 /**< interpMask and arrayMask */ -#define SPAN_Z 0x04 /**< interpMask and arrayMask */ -#define SPAN_FLAT 0x08 /**< interpMask: flat shading? */ -#define SPAN_XY 0x10 /**< array.x[], y[] valid? */ -#define SPAN_MASK 0x20 /**< was array.mask[] filled in by caller? */ -#define SPAN_LAMBDA 0x40 /**< array.lambda[] valid? */ -#define SPAN_COVERAGE 0x80 /**< array.coverage[] valid? */ +#define SPAN_Z 0x02 /**< interpMask and arrayMask */ +#define SPAN_FLAT 0x04 /**< interpMask: flat shading? */ +#define SPAN_XY 0x08 /**< array.x[], y[] valid? */ +#define SPAN_MASK 0x10 /**< was array.mask[] filled in by caller? */ +#define SPAN_LAMBDA 0x20 /**< array.lambda[] valid? */ +#define SPAN_COVERAGE 0x40 /**< array.coverage[] valid? */ /*@}*/ @@ -187,9 +186,6 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, GLfloat s, GLfloat t, GLfloat q, GLfloat invQ); -extern void -_swrast_write_index_span( GLcontext *ctx, SWspan *span); - extern void _swrast_write_rgba_span( GLcontext *ctx, SWspan *span); @@ -200,10 +196,6 @@ _swrast_read_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLenum type, GLvoid *rgba); extern void -_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLuint indx[] ); - -extern void _swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], void *values, GLuint valueSize); diff --git a/src/mesa/swrast/s_spantemp.h b/src/mesa/swrast/s_spantemp.h index bab2ca7378f..2948a90f6bb 100644 --- a/src/mesa/swrast/s_spantemp.h +++ b/src/mesa/swrast/s_spantemp.h @@ -31,7 +31,6 @@ * Define the following macros before including this file: * NAME(BASE) to generate the function name (i.e. add prefix or suffix) * RB_TYPE the renderbuffer DataType - * CI_MODE if set, color index mode, else RGBA * SPAN_VARS to declare any local variables * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel @@ -46,9 +45,7 @@ #include "main/macros.h" -#ifdef CI_MODE -#define RB_COMPONENTS 1 -#elif !defined(RB_COMPONENTS) +#if !defined(RB_COMPONENTS) #define RB_COMPONENTS 4 #endif @@ -60,11 +57,7 @@ NAME(get_row)( GLcontext *ctx, struct gl_renderbuffer *rb, #ifdef SPAN_VARS SPAN_VARS #endif -#ifdef CI_MODE - RB_TYPE *dest = (RB_TYPE *) values; -#else RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; -#endif GLuint i; INIT_PIXEL_PTR(pixel, x, y); for (i = 0; i < count; i++) { @@ -82,11 +75,7 @@ NAME(get_values)( GLcontext *ctx, struct gl_renderbuffer *rb, #ifdef SPAN_VARS SPAN_VARS #endif -#ifdef CI_MODE - RB_TYPE *dest = (RB_TYPE *) values; -#else RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values; -#endif GLuint i; for (i = 0; i < count; i++) { INIT_PIXEL_PTR(pixel, x[i], y[i]); @@ -125,7 +114,6 @@ NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb, } -#if !defined(CI_MODE) static void NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, @@ -149,7 +137,6 @@ NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb, } (void) rb; } -#endif static void @@ -226,7 +213,6 @@ NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb, #undef NAME #undef RB_TYPE #undef RB_COMPONENTS -#undef CI_MODE #undef SPAN_VARS #undef INIT_PIXEL_PTR #undef INC_PIXEL_PTR diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index ff7deecc392..997c2f4bb79 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -475,6 +475,18 @@ clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max, /** + * Compute slice/image to use for 1D or 2D array texture. + */ +static INLINE GLint +tex_array_slice(GLfloat coord, GLsizei size) +{ + GLint slice = IFLOOR(coord + 0.5f); + slice = CLAMP(slice, 0, size - 1); + return slice; +} + + +/** * Compute nearest integer texcoords for given texobj and coordinate. */ static INLINE void @@ -506,13 +518,13 @@ nearest_texcoord(const struct gl_texture_object *texObj, break; case GL_TEXTURE_1D_ARRAY_EXT: *i = nearest_texel_location(texObj->WrapS, img, width, texcoord[0]); - *j = clamp_rect_coord_nearest(texObj->WrapT, texcoord[1], height); + *j = tex_array_slice(texcoord[1], height); *k = 0; break; case GL_TEXTURE_2D_ARRAY_EXT: *i = nearest_texel_location(texObj->WrapS, img, width, texcoord[0]); *j = nearest_texel_location(texObj->WrapT, img, height, texcoord[1]); - *k = clamp_rect_coord_nearest(texObj->WrapR, texcoord[2], depth); + *k = tex_array_slice(texcoord[2], depth); break; default: *i = *j = *k = 0; @@ -556,7 +568,7 @@ linear_texcoord(const struct gl_texture_object *texObj, case GL_TEXTURE_1D_ARRAY_EXT: linear_texel_locations(texObj->WrapS, img, width, texcoord[0], i0, i1, wi); - *j0 = clamp_rect_coord_nearest(texObj->WrapT, texcoord[1], height); + *j0 = tex_array_slice(texcoord[1], height); *j1 = *j0; *slice = 0; break; @@ -566,7 +578,7 @@ linear_texcoord(const struct gl_texture_object *texObj, texcoord[0], i0, i1, wi); linear_texel_locations(texObj->WrapT, img, height, texcoord[1], j0, j1, wj); - *slice = clamp_rect_coord_nearest(texObj->WrapR, texcoord[2], depth); + *slice = tex_array_slice(texcoord[2], depth); break; default: @@ -2269,7 +2281,6 @@ sample_lambda_rect(GLcontext *ctx, } - /**********************************************************************/ /* 2D Texture Array Sampling Functions */ /**********************************************************************/ @@ -2293,7 +2304,7 @@ sample_2d_array_nearest(GLcontext *ctx, i = nearest_texel_location(tObj->WrapS, img, width, texcoord[0]); j = nearest_texel_location(tObj->WrapT, img, height, texcoord[1]); - array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth); + array = tex_array_slice(texcoord[2], depth); if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height || @@ -2328,7 +2339,7 @@ sample_2d_array_linear(GLcontext *ctx, linear_texel_locations(tObj->WrapS, img, width, texcoord[0], &i0, &i1, &a); linear_texel_locations(tObj->WrapT, img, height, texcoord[1], &j0, &j1, &b); - array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth); + array = tex_array_slice(texcoord[2], depth); if (array < 0 || array >= depth) { COPY_4V(rgba, tObj->BorderColor.f); @@ -2601,7 +2612,7 @@ sample_1d_array_nearest(GLcontext *ctx, (void) ctx; i = nearest_texel_location(tObj->WrapS, img, width, texcoord[0]); - array = clamp_rect_coord_nearest(tObj->WrapT, texcoord[1], height); + array = tex_array_slice(texcoord[1], height); if (i < 0 || i >= (GLint) img->Width || array < 0 || array >= (GLint) img->Height) { @@ -2633,7 +2644,7 @@ sample_1d_array_linear(GLcontext *ctx, GLfloat t0[4], t1[4]; linear_texel_locations(tObj->WrapS, img, width, texcoord[0], &i0, &i1, &a); - array = clamp_rect_coord_nearest(tObj->WrapT, texcoord[1], height); + array = tex_array_slice(texcoord[1], height); if (img->Border) { i0 += img->Border; diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 11184b72ce3..812dddf15c6 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -70,18 +70,6 @@ _swrast_culltriangle( GLcontext *ctx, /* - * Render a smooth or flat-shaded color index triangle. - */ -#define NAME ci_triangle -#define INTERP_Z 1 -#define INTERP_ATTRIBS 1 /* just for fog */ -#define INTERP_INDEX 1 -#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span); -#include "s_tritemp.h" - - - -/* * Render a flat-shaded RGBA triangle. */ #define NAME flat_rgba_triangle @@ -1007,7 +995,6 @@ void _swrast_choose_triangle( GLcontext *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLboolean rgbmode = ctx->Visual.rgbMode; if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { @@ -1029,23 +1016,15 @@ _swrast_choose_triangle( GLcontext *ctx ) ctx->Depth.Mask == GL_FALSE && ctx->Depth.Func == GL_LESS && !ctx->Stencil._Enabled) { - if ((rgbmode && - ctx->Color.ColorMask[0][0] == 0 && - ctx->Color.ColorMask[0][1] == 0 && - ctx->Color.ColorMask[0][2] == 0 && - ctx->Color.ColorMask[0][3] == 0) - || - (!rgbmode && ctx->Color.IndexMask == 0)) { + if (ctx->Color.ColorMask[0][0] == 0 && + ctx->Color.ColorMask[0][1] == 0 && + ctx->Color.ColorMask[0][2] == 0 && + ctx->Color.ColorMask[0][3] == 0) { USE(occlusion_zless_triangle); return; } } - if (!rgbmode) { - USE(ci_triangle); - return; - } - /* * XXX should examine swrast->_ActiveAttribMask to determine what * needs to be interpolated. diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 8e3c5b5eebb..0aa8739f4f2 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -32,7 +32,6 @@ * INTERP_Z - if defined, interpolate integer Z values * INTERP_RGB - if defined, interpolate integer RGB values * INTERP_ALPHA - if defined, interpolate integer Alpha values - * INTERP_INDEX - if defined, interpolate color index values * INTERP_INT_TEX - if defined, interpolate integer ST texcoords * (fast, simple 2-D texture mapping, without * perspective correction) @@ -319,9 +318,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, { GLint scan_from_left_to_right; /* true if scanning left-to-right */ -#ifdef INTERP_INDEX - GLfloat didx, didy; -#endif /* * Execute user-supplied setup code @@ -398,21 +394,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, # endif } #endif /* INTERP_RGB */ -#ifdef INTERP_INDEX - span.interpMask |= SPAN_INDEX; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - GLfloat eMaj_di = vMax->attrib[FRAG_ATTRIB_CI][0] - vMin->attrib[FRAG_ATTRIB_CI][0]; - GLfloat eBot_di = vMid->attrib[FRAG_ATTRIB_CI][0] - vMin->attrib[FRAG_ATTRIB_CI][0]; - didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di); - didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx); - span.indexStep = SignedFloatToFixed(didx); - } - else { - span.interpMask |= SPAN_FLAT; - didx = didy = 0.0F; - span.indexStep = 0; - } -#endif #ifdef INTERP_INT_TEX { GLfloat eMaj_ds = (vMax->attrib[FRAG_ATTRIB_TEX0][0] - vMin->attrib[FRAG_ATTRIB_TEX0][0]) * S_SCALE; @@ -531,9 +512,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA GLint aLeft = 0, fdaOuter = 0, fdaInner; #endif -#ifdef INTERP_INDEX - GLfixed iLeft=0, diOuter=0, diInner; -#endif #ifdef INTERP_INT_TEX GLfixed sLeft=0, dsOuter=0, dsInner; GLfixed tLeft=0, dtOuter=0, dtInner; @@ -697,18 +675,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #endif /* INTERP_RGB */ -#ifdef INTERP_INDEX - if (ctx->Light.ShadeModel == GL_SMOOTH) { - iLeft = (GLfixed)(vLower->attrib[FRAG_ATTRIB_CI][0] * FIXED_SCALE - + didx * adjx + didy * adjy) + FIXED_HALF; - diOuter = SignedFloatToFixed(didy + dxOuter * didx); - } - else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - iLeft = FloatToFixed(v2->attrib[FRAG_ATTRIB_CI][0]); - diOuter = 0; - } -#endif #ifdef INTERP_INT_TEX { GLfloat s0, t0; @@ -784,9 +750,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA fdaInner = fdaOuter + span.alphaStep; #endif -#ifdef INTERP_INDEX - diInner = diOuter + span.indexStep; -#endif #ifdef INTERP_INT_TEX dsInner = dsOuter + span.intTexStep[0]; dtInner = dtOuter + span.intTexStep[1]; @@ -822,9 +785,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA span.alpha = aLeft; #endif -#ifdef INTERP_INDEX - span.index = iLeft; -#endif #ifdef INTERP_INT_TEX span.intTex[0] = sLeft; span.intTex[1] = tLeft; @@ -855,9 +815,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA CLAMP_INTERPOLANT(alpha, alphaStep, len); #endif -#ifdef INTERP_INDEX - CLAMP_INTERPOLANT(index, indexStep, len); -#endif { RENDER_SPAN( span ); } @@ -896,9 +853,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA aLeft += fdaOuter; #endif -#ifdef INTERP_INDEX - iLeft += diOuter; -#endif #ifdef INTERP_INT_TEX sLeft += dsOuter; tLeft += dtOuter; @@ -931,9 +885,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #ifdef INTERP_ALPHA aLeft += fdaInner; #endif -#ifdef INTERP_INDEX - iLeft += diInner; -#endif #ifdef INTERP_INT_TEX sLeft += dsInner; tLeft += dtInner; @@ -967,7 +918,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, #undef INTERP_Z #undef INTERP_RGB #undef INTERP_ALPHA -#undef INTERP_INDEX #undef INTERP_INT_TEX #undef INTERP_ATTRIBS diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index bec16208e3d..f224627d50e 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -185,15 +185,6 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, zoomed.arrayAttribs |= FRAG_BIT_COL0; /* we'll produce these values */ ASSERT(span->arrayMask & SPAN_RGBA); } - else if (format == GL_COLOR_INDEX) { - /* copy Z info */ - zoomed.z = span->z; - zoomed.zStep = span->zStep; - /* we'll generate an array of color indexes */ - zoomed.interpMask = span->interpMask & ~SPAN_INDEX; - zoomed.arrayMask |= SPAN_INDEX; - ASSERT(span->arrayMask & SPAN_INDEX); - } else if (format == GL_DEPTH_COMPONENT) { /* Copy color info */ zoomed.red = span->red; @@ -288,16 +279,6 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, } } } - else if (format == GL_COLOR_INDEX) { - const GLuint *indexes = (const GLuint *) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - zoomed.array->index[i] = indexes[j]; - } - } else if (format == GL_DEPTH_COMPONENT) { const GLuint *zValues = (const GLuint *) src; GLint i; @@ -307,8 +288,8 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, ASSERT(j < (GLint) span->end); zoomed.array->z[i] = zValues[j]; } - /* Now, fall into either the RGB or COLOR_INDEX path below */ - format = ctx->Visual.rgbMode ? GL_RGBA : GL_COLOR_INDEX; + /* Now, fall into the RGB path below */ + format = GL_RGBA; } /* write the span in rows [r0, r1) */ @@ -335,22 +316,6 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, } } } - else if (format == GL_COLOR_INDEX) { - /* use specular color array for temp storage */ - GLuint *indexSave = (GLuint *) zoomed.array->attribs[FRAG_ATTRIB_FOGC]; - const GLint end = zoomed.end; /* save */ - if (y1 - y0 > 1) { - memcpy(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint)); - } - for (zoomed.y = y0; zoomed.y < y1; zoomed.y++) { - _swrast_write_index_span(ctx, &zoomed); - zoomed.end = end; /* restore */ - if (y1 - y0 > 1) { - /* restore the colors */ - memcpy(zoomed.array->index, indexSave, zoomed.end * sizeof(GLuint)); - } - } - } } @@ -371,15 +336,6 @@ _swrast_write_zoomed_rgb_span(GLcontext *ctx, GLint imgX, GLint imgY, void -_swrast_write_zoomed_index_span(GLcontext *ctx, GLint imgX, GLint imgY, - const SWspan *span) -{ - zoom_span(ctx, imgX, imgY, span, - (const GLvoid *) span->array->index, GL_COLOR_INDEX); -} - - -void _swrast_write_zoomed_depth_span(GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span) { diff --git a/src/mesa/swrast/s_zoom.h b/src/mesa/swrast/s_zoom.h index d2815b41a0e..43917be65fc 100644 --- a/src/mesa/swrast/s_zoom.h +++ b/src/mesa/swrast/s_zoom.h @@ -37,10 +37,6 @@ _swrast_write_zoomed_rgb_span(GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, const GLvoid *rgb); extern void -_swrast_write_zoomed_index_span(GLcontext *ctx, GLint imgX, GLint imgY, - const SWspan *span); - -extern void _swrast_write_zoomed_depth_span(GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span); |