diff options
author | Jouk <joukj@tarantella.(none)> | 2007-07-25 10:16:11 +0200 |
---|---|---|
committer | Jouk <joukj@tarantella.(none)> | 2007-07-25 10:16:11 +0200 |
commit | eb9a5b6d5127858b01ec12672c999e7d25cd7aed (patch) | |
tree | 91c0302c4d007ddcd0c42fbb8d8de71bf23d3914 /src/mesa/swrast | |
parent | 55f8b7053065ce88296608071feed6f9540f6c0d (diff) | |
parent | 03ec41ddc51e539c989a546f33d22daa2af69095 (diff) |
Merge branch 'master' of git+ssh://[email protected]/git/mesa/mesa
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_aalinetemp.h | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatritemp.h | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_accum.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_atifragshader.c | 7 | ||||
-rw-r--r-- | src/mesa/swrast/s_bitmap.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_buffers.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 9 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.h | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 34 | ||||
-rw-r--r-- | src/mesa/swrast/s_feedback.c | 7 | ||||
-rw-r--r-- | src/mesa/swrast/s_fragprog.c | 26 | ||||
-rw-r--r-- | src/mesa/swrast/s_lines.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_linetemp.h | 5 | ||||
-rw-r--r-- | src/mesa/swrast/s_points.c | 653 | ||||
-rw-r--r-- | src/mesa/swrast/s_pointtemp.h | 406 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 25 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.h | 18 | ||||
-rw-r--r-- | src/mesa/swrast/s_stencil.c | 85 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfilter.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_tritemp.h | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_zoom.c | 22 | ||||
-rw-r--r-- | src/mesa/swrast/swrast.h | 2 |
23 files changed, 627 insertions, 745 deletions
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 3d3511823d7..e7911fec3b5 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -132,13 +132,15 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) line.dx = line.x1 - line.x0; line.dy = line.y1 - line.y0; line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); - line.halfWidth = 0.5F * ctx->Line._Width; + line.halfWidth = 0.5F * CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidthAA, + ctx->Const.MaxLineWidthAA); if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; - INIT_SPAN(line.span, GL_LINE, 0, 0, SPAN_XY | SPAN_COVERAGE); - + INIT_SPAN(line.span, GL_LINE); + line.span.arrayMask = SPAN_XY | SPAN_COVERAGE; line.xAdj = line.dx / line.len * line.halfWidth; line.yAdj = line.dy / line.len * line.halfWidth; diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 34a2305b393..42d74a16328 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -69,7 +69,8 @@ (void) swrast; - INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE); + INIT_SPAN(span, GL_POLYGON); + span.arrayMask = SPAN_COVERAGE; /* determine bottom to top order of vertices */ { diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index f53e7f52c5e..3c45dee3998 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -474,7 +474,9 @@ accum_return(GLcontext *ctx, GLfloat value, SWspan span; /* init color span */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_RGBA; span.x = xpos; span.y = ypos + i; diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c index 947054faa30..55ec757ee06 100644 --- a/src/mesa/swrast/s_atifragshader.c +++ b/src/mesa/swrast/s_atifragshader.c @@ -23,11 +23,10 @@ #include "glheader.h" #include "colormac.h" #include "context.h" -#include "atifragshader.h" #include "macros.h" -#include "program.h" - -#include "s_atifragshader.h" +#include "shader/program.h" +#include "shader/atifragshader.h" +#include "swrast/s_atifragshader.h" /** diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 563b5fe602c..1e7f6c18e6a 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -82,7 +82,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_XY); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_XY; _swrast_span_default_attribs(ctx, &span); for (row = 0; row < height; row++) { @@ -180,7 +182,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_MASK); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_MASK; _swrast_span_default_attribs(ctx, &span); /*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */ diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 35f2dd64909..90a56284c51 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -55,7 +55,9 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) /* Initialize color span with clear color */ /* XXX optimize for clearcolor == black/zero (bzero) */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_RGBA; span.array->ChanType = rb->DataType; if (span.array->ChanType == GL_UNSIGNED_BYTE) { GLubyte clearColor[4]; @@ -119,7 +121,9 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) ASSERT(rb->DataType == GL_UNSIGNED_INT); /* Initialize index span with clear index */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + 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; } diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index cb3bc756a44..39569256514 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -31,9 +31,9 @@ #include "context.h" #include "colormac.h" #include "mtypes.h" -#include "prog_statevars.h" #include "teximage.h" #include "swrast.h" +#include "shader/prog_statevars.h" #include "s_blend.h" #include "s_context.h" #include "s_lines.h" @@ -535,10 +535,11 @@ _swrast_update_texture_samplers(GLcontext *ctx) /** - * Update swrast->_ActiveAttribs, swrast->_NumActiveAttribs, swrast->_ActiveAtttribMask. + * Update swrast->_ActiveAttribs, swrast->_NumActiveAttribs, + * swrast->_ActiveAtttribMask. */ static void -_swrast_update_fragment_attribs(GLcontext *ctx) +_swrast_update_active_attribs(GLcontext *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint attribsMask; @@ -679,7 +680,7 @@ _swrast_validate_derived( GLcontext *ctx ) _NEW_LIGHT | _NEW_PROGRAM | _NEW_TEXTURE)) - _swrast_update_fragment_attribs(ctx); + _swrast_update_active_attribs(ctx); if (swrast->NewState & (_NEW_PROGRAM | _NEW_BUFFERS)) _swrast_update_color_outputs(ctx); diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index f118eb92ca4..daa07e15783 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -43,10 +43,10 @@ #ifndef S_CONTEXT_H #define S_CONTEXT_H -#include "mtypes.h" +#include "main/mtypes.h" +#include "shader/prog_execute.h" #include "swrast.h" #include "s_span.h" -#include "prog_execute.h" typedef void (*texture_sample_func)(GLcontext *ctx, diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 53e584b3b6b..bbe1081860d 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -102,8 +102,10 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLfloat *dest, *tmpImage, *convImage; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; /* allocate space for GLfloat image */ tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); @@ -156,7 +158,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, /* write the new image */ for (row = 0; row < height; row++) { const GLfloat *src = convImage + row * width * 4; - GLvoid *rgba = (GLvoid *) span.array->attribs[FRAG_ATTRIB_COL0]; + GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0]; /* copy convolved colors into span array */ _mesa_memcpy(rgba, src, width * 4 * sizeof(GLfloat)); @@ -232,8 +234,10 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, stepy = 1; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */ if (overlapping) { tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4); @@ -314,8 +318,9 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy, return; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); + 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, @@ -448,8 +453,9 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, return; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_Z; if (ctx->DrawBuffer == ctx->ReadBuffer) { overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index d971d90fb9a..0cf425e1c62 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -70,7 +70,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, return GL_FALSE; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; _swrast_span_default_attribs(ctx, &span); /* copy input params since clipping may change them */ @@ -332,7 +334,8 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, GLint row, skipPixels; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_INDEX; _swrast_span_default_attribs(ctx, &span); /* @@ -395,10 +398,9 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, width, height, GL_COLOR_INDEX, type, row, skipPixels); - _mesa_unpack_index_span(ctx, spanWidth, destType, values, - type, source, unpack, - ctx->_ImageTransferState); - _mesa_apply_stencil_transfer_ops(ctx, spanWidth, values); + _mesa_unpack_stencil_span(ctx, spanWidth, destType, values, + type, source, unpack, + ctx->_ImageTransferState); if (zoom) { _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth, spanX, spanY, values); @@ -427,7 +429,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_Z; _swrast_span_default_attribs(ctx, &span); if (type == GL_UNSIGNED_SHORT @@ -481,7 +484,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, } else { /* General case */ - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + const GLuint depthMax = ctx->DrawBuffer->_DepthMax; GLint skipPixels = 0; /* in case width > MAX_WIDTH do the copy in chunks */ @@ -540,11 +543,14 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, /* Try an optimized glDrawPixels first */ if (fast_draw_rgba_pixels(ctx, x, y, width, height, format, type, - unpack, pixels)) + unpack, pixels)) { return; + } - INIT_SPAN(span, GL_BITMAP, 0, 0x0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { /* Convolution has to be handled specially. We'll create an @@ -689,7 +695,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, const GLint imgX = x, imgY = y; const GLboolean scaleOrBias = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; - const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF; + const GLuint depthMax = ctx->DrawBuffer->_DepthMax; const GLuint stencilMask = ctx->Stencil.WriteMask[0]; const GLuint stencilType = (STENCIL_BITS == 8) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; @@ -777,7 +783,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* general case */ GLuint zValues[MAX_WIDTH]; /* 16 or 32-bit Z value storage */ _mesa_unpack_depth_span(ctx, width, - depthRb->DataType, zValues, depthScale, + depthRb->DataType, zValues, depthMax, type, depthStencilSrc, &clippedUnpack); if (zoom) { _swrast_write_zoomed_z_span(ctx, imgX, imgY, width, x, diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c index 606afc63ba9..07b7409ab57 100644 --- a/src/mesa/swrast/s_feedback.c +++ b/src/mesa/swrast/s_feedback.c @@ -39,19 +39,14 @@ static void feedback_vertex(GLcontext * ctx, const SWvertex * v, const SWvertex * pv) { GLfloat win[4]; - GLfloat color[4]; const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0]; + const GLfloat *color = v->attrib[FRAG_ATTRIB_COL0]; win[0] = v->attrib[FRAG_ATTRIB_WPOS][0]; win[1] = v->attrib[FRAG_ATTRIB_WPOS][1]; win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF; win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3]; - color[0] = CHAN_TO_FLOAT(pv->color[0]); - color[1] = CHAN_TO_FLOAT(pv->color[1]); - color[2] = CHAN_TO_FLOAT(pv->color[2]); - color[3] = CHAN_TO_FLOAT(pv->color[3]); - _mesa_feedback_vertex(ctx, win, color, v->attrib[FRAG_ATTRIB_CI][0], vtc); } diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index a36c1ba4919..14c9868c180 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -22,11 +22,11 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "prog_instruction.h" -#include "texstate.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/texstate.h" +#include "shader/prog_instruction.h" #include "s_fragprog.h" #include "s_span.h" @@ -200,7 +200,6 @@ void _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) { const struct gl_fragment_program *program = ctx->FragmentProgram._Current; - GLuint i; /* incoming colors should be floats */ if (program->Base.InputsRead & FRAG_BIT_COL0) { @@ -209,23 +208,8 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */ - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._Current != NULL) { - const GLboolean enable_shadow = ((1 << i) & program->Base.ShadowSamplers); - _mesa_update_texture_compare_function(ctx->Texture.Unit[i]._Current, - !enable_shadow); - } - } - run_program(ctx, span, 0, span->end); - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._Current != NULL) { - _mesa_update_texture_compare_function(ctx->Texture.Unit[i]._Current, - GL_FALSE); - } - } - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR)) { span->interpMask &= ~SPAN_RGBA; span->arrayMask |= SPAN_RGBA; diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 781146e67f9..15ef6233eda 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -63,12 +63,13 @@ compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] ) static void draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) { - GLint width, start; + const GLint width = (GLint) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + GLint start; ASSERT(span->end < MAX_WIDTH); - width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH ); - if (width & 1) start = width / 2; else @@ -143,7 +144,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -161,7 +162,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -180,7 +181,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -274,7 +275,7 @@ _swrast_choose_line( GLcontext *ctx ) USE(general_line); } else if (ctx->Depth.Test - || ctx->Line._Width != 1.0 + || ctx->Line.Width != 1.0 || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ if (rgbmode) @@ -284,6 +285,7 @@ _swrast_choose_line( GLcontext *ctx ) } else { ASSERT(!ctx->Depth.Test); + ASSERT(ctx->Line.Width == 1.0); /* simple lines */ if (rgbmode) USE(simple_no_z_rgba_line); diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 55548f27b08..1accfc67e2c 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -303,7 +303,10 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) } #endif - INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY); + INIT_SPAN(span, GL_LINE); + span.end = numPixels; + span.interpMask = interpFlags; + span.arrayMask = SPAN_XY; /* * Draw diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 02c9d9b4251..4768fbea972 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -34,134 +34,493 @@ #include "s_span.h" -#define RGBA 0x1 -#define INDEX 0x2 -#define SMOOTH 0x4 -#define ATTRIBS 0x8 -#define SPECULAR 0x10 -#define LARGE 0x20 -#define ATTENUATE 0x40 -#define SPRITE 0x80 - - -/* - * CI points with size == 1.0 - */ -#define FLAGS (INDEX) -#define NAME size1_ci_point -#include "s_pointtemp.h" - - -/* - * General CI points. +/** + * Used to cull points with invalid coords */ -#define FLAGS (INDEX | LARGE) -#define NAME general_ci_point -#include "s_pointtemp.h" +#define CULL_INVALID(V) \ + do { \ + float tmp = (V)->attrib[FRAG_ATTRIB_WPOS][0] \ + + (V)->attrib[FRAG_ATTRIB_WPOS][1]; \ + if (IS_INF_OR_NAN(tmp)) \ + return; \ + } while(0) -/* - * Antialiased CI points. +/** + * Draw a point sprite */ -#define FLAGS (INDEX | SMOOTH) -#define NAME antialiased_ci_point -#include "s_pointtemp.h" +static void +sprite_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + SWspan span; + GLfloat size; + GLuint tCoords[MAX_TEXTURE_COORD_UNITS]; + GLuint numTcoords = 0; + GLfloat t0, dtdy; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point.Size; + } + /* clamp to non-AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + + /* span init */ + INIT_SPAN(span, GL_POINT); + 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; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { + const GLuint u = attr - FRAG_ATTRIB_TEX0; + /* a texcoord */ + if (ctx->Point.CoordReplace[u]) { + GLfloat s, r, dsdx; + + s = 0.0; + dsdx = 1.0 / size; + + if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { + t0 = 0.0; + dtdy = 1.0 / size; + } + else { + /* GL_UPPER_LEFT */ + t0 = 1.0; + dtdy = -1.0 / size; + } + tCoords[numTcoords++] = attr; + + if (ctx->Point.SpriteRMode == GL_ZERO) + r = 0.0F; + else if (ctx->Point.SpriteRMode == GL_S) + r = vert->attrib[attr][0]; + else /* GL_R */ + r = vert->attrib[attr][2]; + + span.attrStart[attr][0] = s; + span.attrStart[attr][1] = 0.0; /* overwritten below */ + span.attrStart[attr][2] = r; + span.attrStart[attr][3] = 1.0; + + span.attrStepX[attr][0] = dsdx; + span.attrStepX[attr][1] = 0.0; + span.attrStepX[attr][2] = 0.0; + span.attrStepX[attr][3] = 0.0; + + span.attrStepY[attr][0] = 0.0; + span.attrStepY[attr][1] = dtdy; + span.attrStepY[attr][2] = 0.0; + span.attrStepY[attr][3] = 0.0; + + continue; + } + } + /* use vertex's texcoord/attrib */ + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + GLint iSize = (GLint) (size + 0.5F); + GLint xmin, xmax, ymin, ymax, iy; + GLint iRadius; + GLfloat tcoord = t0; + + iSize = MAX2(1, iSize); + iRadius = iSize / 2; + + if (iSize & 1) { + /* odd size */ + xmin = (GLint) (x - iRadius); + xmax = (GLint) (x + iRadius); + ymin = (GLint) (y - iRadius); + ymax = (GLint) (y + iRadius); + } + else { + /* even size */ + xmin = (GLint) x - iRadius + 1; + xmax = xmin + iSize - 1; + ymin = (GLint) y - iRadius + 1; + ymax = ymin + iSize - 1; + } + /* render spans */ + for (iy = ymin; iy <= ymax; iy++) { + GLuint i; + /* setup texcoord T for this row */ + for (i = 0; i < numTcoords; i++) { + span.attrStart[tCoords[i]][1] = tcoord; + } -/* - * Distance attenuated, general CI points. - */ -#define FLAGS (INDEX | ATTENUATE) -#define NAME atten_general_ci_point -#include "s_pointtemp.h" + /* these might get changed by span clipping */ + span.x = xmin; + span.y = iy; + span.end = xmax - xmin + 1; + _swrast_write_rgba_span(ctx, &span); -/* - * RGBA points with size == 1.0 - */ -#define FLAGS (RGBA) -#define NAME size1_rgba_point -#include "s_pointtemp.h" + tcoord += dtdy; + } + } +} -/* - * General RGBA points. +/** + * Draw smooth/antialiased point. RGB or CI mode. */ -#define FLAGS (RGBA | LARGE) -#define NAME general_rgba_point -#include "s_pointtemp.h" - +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; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point.Size; + } + /* clamp to AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); -/* - * Antialiased RGBA points. - */ -#define FLAGS (RGBA | SMOOTH) -#define NAME antialiased_rgba_point -#include "s_pointtemp.h" + /* alpha attenuation / fade factor */ + if (ctx->Multisample.Enabled) { + if (vert->pointSize >= ctx->Point.Threshold) { + alphaAtten = 1.0F; + } + else { + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; + alphaAtten = dsize * dsize; + } + } + else { + alphaAtten = 1.0; + } + (void) alphaAtten; /* not used */ + + /* span init */ + INIT_SPAN(span, GL_POINT); + span.interpMask = SPAN_Z | SPAN_RGBA; + span.arrayMask = SPAN_COVERAGE | SPAN_MASK; + + 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; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + const GLfloat radius = 0.5F * size; + const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + const GLfloat rmax = radius + 0.7071F; + const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); + const GLfloat rmax2 = rmax * rmax; + const GLfloat cscale = 1.0F / (rmax2 - rmin2); + const GLint xmin = (GLint) (x - radius); + const GLint xmax = (GLint) (x + radius); + const GLint ymin = (GLint) (y - radius); + const GLint ymax = (GLint) (y + radius); + GLint ix, iy; + + for (iy = ymin; iy <= ymax; iy++) { + + /* these might get changed by span clipping */ + span.x = xmin; + span.y = iy; + span.end = xmax - xmin + 1; + + /* compute coverage for each pixel in span */ + for (ix = xmin; ix <= xmax; ix++) { + const GLfloat dx = ix - x + 0.5F; + const GLfloat dy = iy - y + 0.5F; + const GLfloat dist2 = dx * dx + dy * dy; + GLfloat coverage; + + if (dist2 < rmax2) { + if (dist2 >= rmin2) { + /* compute partial coverage */ + coverage = 1.0F - (dist2 - rmin2) * cscale; + if (ciMode) { + /* coverage in [0,15] */ + coverage *= 15.0; + } + } + else { + /* full coverage */ + coverage = 1.0F; + } + span.array->mask[ix - xmin] = 1; + } + else { + /* zero coverage - fragment outside the radius */ + coverage = 0.0; + span.array->mask[ix - xmin] = 0; + } + span.array->coverage[ix - xmin] = coverage; + } + /* render span */ + _swrast_write_rgba_span(ctx, &span); -/* - * Textured RGBA points. - */ -#define FLAGS (RGBA | LARGE | ATTRIBS | SPECULAR) -#define NAME textured_rgba_point -#include "s_pointtemp.h" + } + } +} -/* - * Antialiased points with texture mapping. +/** + * Draw large (size >= 1) non-AA point. RGB or CI mode. */ -#define FLAGS (RGBA | SMOOTH | ATTRIBS | SPECULAR) -#define NAME antialiased_tex_rgba_point -#include "s_pointtemp.h" +static void +large_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + const GLboolean ciMode = !ctx->Visual.rgbMode; + SWspan span; + GLfloat size; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point.Size; + } + /* clamp to non-AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + /* span init */ + INIT_SPAN(span, GL_POINT); + span.arrayMask = SPAN_XY; -/* - * Distance attenuated, general RGBA points. - */ -#define FLAGS (RGBA | ATTENUATE) -#define NAME atten_general_rgba_point -#include "s_pointtemp.h" + 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; + } + /* need these for fragment programs */ + span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + GLint iSize = (GLint) (size + 0.5F); + GLint xmin, xmax, ymin, ymax, ix, iy; + GLint iRadius; + + iSize = MAX2(1, iSize); + iRadius = iSize / 2; + + if (iSize & 1) { + /* odd size */ + xmin = (GLint) (x - iRadius); + xmax = (GLint) (x + iRadius); + ymin = (GLint) (y - iRadius); + ymax = (GLint) (y + iRadius); + } + else { + /* even size */ + xmin = (GLint) x - iRadius + 1; + xmax = xmin + iSize - 1; + ymin = (GLint) y - iRadius + 1; + ymax = ymin + iSize - 1; + } -/* - * Distance attenuated, textured RGBA points. - */ -#define FLAGS (RGBA | ATTENUATE | ATTRIBS | SPECULAR) -#define NAME atten_textured_rgba_point -#include "s_pointtemp.h" + /* generate fragments */ + span.end = 0; + for (iy = ymin; iy <= ymax; iy++) { + for (ix = xmin; ix <= xmax; ix++) { + span.array->x[span.end] = ix; + span.array->y[span.end] = iy; + span.end++; + } + } + assert(span.end <= MAX_WIDTH); + _swrast_write_rgba_span(ctx, &span); + } +} -/* - * Distance attenuated, antialiased points with or without texture mapping. +/** + * Draw size=1, single-pixel point */ -#define FLAGS (RGBA | ATTENUATE | ATTRIBS | SMOOTH) -#define NAME atten_antialiased_rgba_point -#include "s_pointtemp.h" +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 + * possible with a single _swrast_write_rgba_span() call. + */ + SWspan *span = &(swrast->PointSpan); + GLuint count; + + CULL_INVALID(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_LAMBDA;*/ + span->arrayAttribs = swrast->_ActiveAttribMask; /* we'll produce these vals */ + + /* need these for fragment programs */ + span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + /* check if we need to flush */ + if (span->end >= MAX_WIDTH || + (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { + if (ciMode) + _swrast_write_index_span(ctx, span); + else + _swrast_write_rgba_span(ctx, span); + span->end = 0; + } + count = span->end; -/* - * Sprite (textured point) - */ -#define FLAGS (RGBA | SPRITE | SPECULAR) -#define NAME sprite_point -#include "s_pointtemp.h" + /* 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]; + } + ATTRIB_LOOP_BEGIN + COPY_4V(span->array->attribs[attr][count], vert->attrib[attr]); + ATTRIB_LOOP_END + /* fragment position */ + span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; + span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; + span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); -#define FLAGS (RGBA | SPRITE | SPECULAR | ATTENUATE) -#define NAME atten_sprite_point -#include "s_pointtemp.h" + span->end = count + 1; + ASSERT(span->end <= MAX_WIDTH); +} +/** + * Add specular color to primary color, draw point, restore original + * primary color. + */ void _swrast_add_spec_terms_point(GLcontext *ctx, const SWvertex *v0) { - SWvertex *ncv0 = (SWvertex *) v0; + SWvertex *ncv0 = (SWvertex *) v0; /* cast away const */ GLfloat rSum, gSum, bSum; GLchan cSave[4]; /* save */ - COPY_CHAN4( cSave, ncv0->color ); + COPY_CHAN4(cSave, ncv0->color); /* sum */ rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0]; gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1]; @@ -176,115 +535,35 @@ _swrast_add_spec_terms_point(GLcontext *ctx, const SWvertex *v0) } - -/* record the current point function name */ -#ifdef DEBUG - -static const char *pntFuncName = NULL; - -#define USE(pntFunc) \ -do { \ - pntFuncName = #pntFunc; \ - /*printf("%s\n", pntFuncName);*/ \ - swrast->Point = pntFunc; \ -} while (0) - -#else - -#define USE(pntFunc) swrast->Point = pntFunc - -#endif - - -/* - * Examine the current context to determine which point drawing function - * should be used. +/** + * Examine current state to determine which point drawing function to use. */ void -_swrast_choose_point( GLcontext *ctx ) +_swrast_choose_point(GLcontext *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLboolean rgbMode = ctx->Visual.rgbMode; - GLboolean specular = (ctx->Fog.ColorSumEnabled || - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); - if (ctx->RenderMode==GL_RENDER) { + if (ctx->RenderMode == GL_RENDER) { if (ctx->Point.PointSprite) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - /* XXX this might not be good enough */ - if (ctx->Point._Attenuated) - USE(atten_sprite_point); - else - USE(sprite_point); + swrast->Point = sprite_point; } else if (ctx->Point.SmoothFlag) { - /* Smooth points */ - if (rgbMode) { - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - USE(atten_antialiased_rgba_point); - } - else if (ctx->Texture._EnabledCoordUnits) { - USE(antialiased_tex_rgba_point); - } - else { - USE(antialiased_rgba_point); - } - } - else { - USE(antialiased_ci_point); - } + swrast->Point = smooth_point; } - else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - if (rgbMode) { - if (ctx->Texture._EnabledCoordUnits) { - if (ctx->Point.SmoothFlag) { - USE(atten_antialiased_rgba_point); - } - else { - USE(atten_textured_rgba_point); - } - } - else { - USE(atten_general_rgba_point); - } - } - else { - /* ci, atten */ - USE(atten_general_ci_point); - } - } - else if ((ctx->Texture._EnabledCoordUnits - || specular - || swrast->_FogEnabled) && rgbMode) { - /* textured, fogged */ - USE(textured_rgba_point); - } - else if (ctx->Point._Size != 1.0) { - /* large points */ - if (rgbMode) { - USE(general_rgba_point); - } - else { - USE(general_ci_point); - } + else if (ctx->Point.Size > 1.0 || + ctx->Point._Attenuated || + ctx->VertexProgram.PointSizeEnabled) { + swrast->Point = large_point; } else { - /* single pixel points */ - if (rgbMode) { - assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0); - USE(size1_rgba_point); - } - else { - USE(size1_ci_point); - } + swrast->Point = pixel_point; } } - else if (ctx->RenderMode==GL_FEEDBACK) { - USE(_swrast_feedback_point); + else if (ctx->RenderMode == GL_FEEDBACK) { + swrast->Point = _swrast_feedback_point; } else { /* GL_SELECT mode */ - USE(_swrast_select_point); + swrast->Point = _swrast_select_point; } } diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h deleted file mode 100644 index 206085b5b87..00000000000 --- a/src/mesa/swrast/s_pointtemp.h +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Regarding GL_NV_point_sprite: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - - -/* - * Point rendering template code. - * - * Set FLAGS = bitwise-OR of the following tokens: - * - * RGBA = do rgba instead of color index - * SMOOTH = do antialiasing - * ATTRIBS = general attributes (texcoords, etc) - * LARGE = do points with diameter > 1 pixel - * ATTENUATE = compute point size attenuation - * SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite - * - * Notes: LARGE and ATTENUATE are exclusive of each other. - * ATTRIBS requires RGBA - */ - - -/* - * NOTES on antialiased point rasterization: - * - * Let d = distance of fragment center from vertex. - * if d < rmin2 then - * fragment has 100% coverage - * else if d > rmax2 then - * fragment has 0% coverage - * else - * fragment has % coverage = (d - rmin2) / (rmax2 - rmin2) - */ - - -static void -NAME ( GLcontext *ctx, const SWvertex *vert ) -{ -#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE) - GLfloat size; -#endif -#if FLAGS & RGBA -#if (FLAGS & ATTENUATE) && (FLAGS & SMOOTH) - GLfloat alphaAtten; -#endif - const GLchan red = vert->color[0]; - const GLchan green = vert->color[1]; - const GLchan blue = vert->color[2]; - const GLchan alpha = vert->color[3]; -#endif -#if FLAGS & INDEX - const GLuint colorIndex = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0]; /* XXX round? */ -#endif -#if FLAGS & ATTRIBS - GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */ -#endif - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan *span = &(swrast->PointSpan); - - /* - printf("%s %g %g %g %g\n", __FUNCTION__, - vert->attrib[FRAG_ATTRIB_COL1][0], - vert->attrib[FRAG_ATTRIB_COL1][1], - vert->attrib[FRAG_ATTRIB_COL1][2], - vert->attrib[FRAG_ATTRIB_COL1][3]); - if ( vert->attrib[FRAG_ATTRIB_COL1][0] == 0.0 && - vert->attrib[FRAG_ATTRIB_COL1][1] == 1.0 && - vert->attrib[FRAG_ATTRIB_COL1][2] == 0.0) - foo(); - */ - - /* Cull primitives with malformed coordinates. - */ - { - float tmp = vert->attrib[FRAG_ATTRIB_WPOS][0] + vert->attrib[FRAG_ATTRIB_WPOS][1]; - if (IS_INF_OR_NAN(tmp)) - return; - } - - /* - * Span init - */ - span->interpMask = 0; - span->arrayMask = SPAN_XY | SPAN_Z; -#if FLAGS & RGBA - span->arrayMask |= SPAN_RGBA; -#endif -#if FLAGS & INDEX - span->arrayMask |= SPAN_INDEX; -#endif -#if FLAGS & ATTRIBS - span->arrayMask |= SPAN_LAMBDA; - - /* we're filling in the attrib arrays: */ - span->arrayAttribs = swrast->_ActiveAttribMask; - - ATTRIB_LOOP_BEGIN - COPY_4V(attrib[attr], vert->attrib[attr]); - ATTRIB_LOOP_END - - /* need these for fragment programs */ - span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; -#else - assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0); -#endif - -#if FLAGS & SMOOTH - span->arrayMask |= SPAN_COVERAGE; -#endif -#if FLAGS & SPRITE - span->arrayMask |= SPAN_LAMBDA; -#endif - - /* Compute point size if not known to be one */ -#if FLAGS & ATTENUATE - /* first, clamp attenuated size to the user-specifed range */ - size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); -#if (FLAGS & RGBA) && (FLAGS & SMOOTH) - /* only if multisampling, compute the fade factor */ - if (ctx->Multisample.Enabled) { - if (vert->pointSize >= ctx->Point.Threshold) { - alphaAtten = 1.0F; - } - else { - GLfloat dsize = vert->pointSize / ctx->Point.Threshold; - alphaAtten = dsize * dsize; - } - } - else { - alphaAtten = 1.0; - } -#endif -#elif FLAGS & (LARGE | SMOOTH | SPRITE) - /* constant, non-attenuated size */ - size = ctx->Point._Size; /* this is already clamped */ -#endif - - -#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE) - /*** - *** Multi-pixel points - ***/ - - /* do final clamping now */ - if (ctx->Point.SmoothFlag) { - size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); - } - else { - size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); - } - - {{ - GLint x, y; - const GLfloat radius = 0.5F * size; - const GLuint z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - GLuint count; -#if FLAGS & SMOOTH - const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - const GLfloat rmax = radius + 0.7071F; - const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); - const GLfloat rmax2 = rmax * rmax; - const GLfloat cscale = 1.0F / (rmax2 - rmin2); - const GLint xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - radius); - const GLint xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + radius); - const GLint ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - radius); - const GLint ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + radius); -#else - /* non-smooth */ - GLint xmin, xmax, ymin, ymax; - GLint iSize = (GLint) (size + 0.5F); - GLint iRadius; - iSize = MAX2(1, iSize); - iRadius = iSize / 2; - if (iSize & 1) { - /* odd size */ - xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius); - xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + iRadius); - ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius); - ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + iRadius); - } - else { - /* even size */ - xmin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius + 1; - xmax = xmin + iSize - 1; - ymin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius + 1; - ymax = ymin + iSize - 1; - } -#endif /*SMOOTH*/ - - /* check if we need to flush */ - if (span->end + (xmax-xmin+1) * (ymax-ymin+1) >= MAX_WIDTH || - (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { - if (span->end > 0) { -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - span->end = 0; - } - } - - /* - * OK, generate fragments - */ - count = span->end; - (void) radius; - for (y = ymin; y <= ymax; y++) { - /* check if we need to flush */ - if (count + (xmax-xmin+1) >= MAX_WIDTH) { - span->end = count; -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - count = span->end = 0; - } - for (x = xmin; x <= xmax; x++) { -#if FLAGS & SPRITE - GLuint u; -#endif - -#if FLAGS & RGBA - span->array->rgba[count][RCOMP] = red; - span->array->rgba[count][GCOMP] = green; - span->array->rgba[count][BCOMP] = blue; - span->array->rgba[count][ACOMP] = alpha; -#endif -#if FLAGS & INDEX - span->array->index[count] = colorIndex; -#endif -#if FLAGS & ATTRIBS - ATTRIB_LOOP_BEGIN - COPY_4V(span->array->attribs[attr][count], attrib[attr]); - /** - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - span->array->lambda[u][count] = 0.0; - } - **/ - ATTRIB_LOOP_END -#endif - -#if FLAGS & SMOOTH - /* compute coverage */ - { - const GLfloat dx = x - vert->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F; - const GLfloat dy = y - vert->attrib[FRAG_ATTRIB_WPOS][1] + 0.5F; - const GLfloat dist2 = dx * dx + dy * dy; - if (dist2 < rmax2) { - if (dist2 >= rmin2) { - /* compute partial coverage */ - span->array->coverage[count] = 1.0F - (dist2 - rmin2) * cscale; -#if FLAGS & INDEX - /* coverage in [0,15] */ - span->array->coverage[count] *= 15.0; -#endif - } - else { - /* full coverage */ - span->array->coverage[count] = 1.0F; - } - - span->array->x[count] = x; - span->array->y[count] = y; - span->array->z[count] = z; - -#if (FLAGS & ATTENUATE) && (FLAGS & RGBA) - span->array->rgba[count][ACOMP] = (GLchan) (alpha * alphaAtten); -#elif FLAGS & RGBA - span->array->rgba[count][ACOMP] = alpha; -#endif /*ATTENUATE*/ - count++; - } /*if*/ - } - -#else /*SMOOTH*/ - - /* not smooth (square points) */ - span->array->x[count] = x; - span->array->y[count] = y; - span->array->z[count] = z; - -#if FLAGS & SPRITE - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - GLuint attr = FRAG_ATTRIB_TEX0 + u; - if (ctx->Texture.Unit[u]._ReallyEnabled) { - if (ctx->Point.CoordReplace[u]) { - GLfloat s = 0.5F + (x + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][0]) / size; - GLfloat t, r; - if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) - t = 0.5F + (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size; - else /* GL_UPPER_LEFT */ - t = 0.5F - (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size; - if (ctx->Point.SpriteRMode == GL_ZERO) - r = 0.0F; - else if (ctx->Point.SpriteRMode == GL_S) - r = vert->attrib[attr][0]; - else /* GL_R */ - r = vert->attrib[attr][2]; - span->array->attribs[attr][count][0] = s; - span->array->attribs[attr][count][1] = t; - span->array->attribs[attr][count][2] = r; - span->array->attribs[attr][count][3] = 1.0F; - span->array->lambda[u][count] = 0.0; /* XXX fix? */ - } - else { - COPY_4V(span->array->attribs[attr][count], - vert->attrib[attr]); - } - } - } -#endif /*SPRITE*/ - - count++; /* square point */ - -#endif /*SMOOTH*/ - - } /*for x*/ - } /*for y*/ - span->end = count; - }} - -#else /* LARGE | ATTENUATE | SMOOTH | SPRITE */ - - /*** - *** Single-pixel points - ***/ - {{ - GLuint count; - - /* check if we need to flush */ - if (span->end >= MAX_WIDTH || - (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - span->end = 0; - } - - count = span->end; - -#if FLAGS & RGBA - span->array->rgba[count][RCOMP] = red; - span->array->rgba[count][GCOMP] = green; - span->array->rgba[count][BCOMP] = blue; - span->array->rgba[count][ACOMP] = alpha; -#endif -#if FLAGS & INDEX - span->array->index[count] = colorIndex; -#endif -#if FLAGS & ATTRIBS - ATTRIB_LOOP_BEGIN - COPY_4V(span->array->attribs[attr][count], attribs[attr]); - ATTRIB_LOOP_END -#endif - - span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; - span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; - span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - - span->end = count + 1; - }} - -#endif /* LARGE || ATTENUATE || SMOOTH */ - - ASSERT(span->end <= MAX_WIDTH); -} - - -#undef FLAGS -#undef NAME diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 90a3d5545f8..f23272c2bee 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -171,6 +171,12 @@ interpolate_active_attribs(GLcontext *ctx, SWspan *span, GLbitfield attrMask) { const SWcontext *swrast = SWRAST_CONTEXT(ctx); + /* + * Don't overwrite existing array values, such as colors that may have + * been produced by glDraw/CopyPixels. + */ + attrMask &= ~span->arrayAttribs; + ATTRIB_LOOP_BEGIN if (attrMask & (1 << attr)) { const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; @@ -196,6 +202,7 @@ interpolate_active_attribs(GLcontext *ctx, SWspan *span, GLbitfield attrMask) v3 += dv3dx; w += dwdx; } + ASSERT((span->arrayAttribs & (1 << attr)) == 0); span->arrayAttribs |= (1 << attr); } ATTRIB_LOOP_END @@ -1145,6 +1152,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) span->end, span->array->mask); span->array->ChanType = newType; + span->array->rgba = dst; } @@ -1169,10 +1177,15 @@ shade_texture_span(GLcontext *ctx, SWspan *span) if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) { /* programmable shading */ + if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { + convert_color_type(span, GL_FLOAT, 0); + } + if (span->primitive != GL_POINT) { + /* for points, we populated the arrays already */ + interpolate_active_attribs(ctx, span, ~0); + } span->array->ChanType = GL_FLOAT; - interpolate_active_attribs(ctx, span, ~0); - if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z (ctx, span); @@ -1227,7 +1240,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) const GLbitfield origInterpMask = span->interpMask; const GLbitfield origArrayMask = span->arrayMask; const GLbitfield origArrayAttribs = span->arrayAttribs; - const GLenum chanType = span->array->ChanType; + const GLenum origChanType = span->array->ChanType; + void * const origRgba = span->array->rgba; const GLboolean shader = (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled); const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledUnits; @@ -1449,7 +1463,8 @@ end: span->interpMask = origInterpMask; span->arrayMask = origArrayMask; span->arrayAttribs = origArrayAttribs; - span->array->ChanType = chanType; + span->array->ChanType = origChanType; + span->array->rgba = origRgba; } diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index 585cce91ee9..512134db0f8 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -159,15 +159,15 @@ typedef struct sw_span -#define INIT_SPAN(S, PRIMITIVE, END, INTERP_MASK, ARRAY_MASK) \ -do { \ - (S).primitive = (PRIMITIVE); \ - (S).interpMask = (INTERP_MASK); \ - (S).arrayMask = (ARRAY_MASK); \ - (S).arrayAttribs = 0x0; \ - (S).end = (END); \ - (S).facing = 0; \ - (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ +#define INIT_SPAN(S, PRIMITIVE) \ +do { \ + (S).primitive = (PRIMITIVE); \ + (S).interpMask = 0x0; \ + (S).arrayMask = 0x0; \ + (S).arrayAttribs = 0x0; \ + (S).end = 0; \ + (S).facing = 0; \ + (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ } while (0) diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index 89991fad02d..d0cbdd6917d 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -392,6 +392,23 @@ do_stencil_test( GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[], } +/** + * Compute the zpass/zfail masks by comparing the pre- and post-depth test + * masks. + */ +static INLINE void +compute_pass_fail_masks(GLuint n, const GLubyte origMask[], + const GLubyte newMask[], + GLubyte passMask[], GLubyte failMask[]) +{ + GLuint i; + for (i = 0; i < n; i++) { + ASSERT(newMask[i] == 0 || newMask[i] == 1); + passMask[i] = origMask[i] & newMask[i]; + failMask[i] = origMask[i] & (newMask[i] ^ 1); + } +} + /** * Apply stencil and depth testing to the span of pixels. @@ -460,39 +477,24 @@ stencil_and_ztest_span(GLcontext *ctx, SWspan *span, GLuint face) /* * Perform depth buffering, then apply zpass or zfail stencil function. */ - GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH]; - GLuint i; + GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; /* save the current mask bits */ - _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte)); + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); /* apply the depth test */ _swrast_depth_test_span(ctx, span); - /* Set the stencil pass/fail flags according to result of depth testing. - * if oldmask[i] == 0 then - * Don't touch the stencil value - * else if oldmask[i] and newmask[i] then - * Depth test passed - * else - * assert(oldmask[i] && !newmask[i]) - * Depth test failed - * endif - */ - for (i=0;i<n;i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - passmask[i] = oldmask[i] & mask[i]; - failmask[i] = oldmask[i] & (mask[i] ^ 1); - } + compute_pass_fail_masks(n, origMask, mask, passMask, failMask); /* apply the pass and fail operations */ if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) { apply_stencil_op( ctx, ctx->Stencil.ZFailFunc[face], face, - n, stencil, failmask ); + n, stencil, failMask ); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { apply_stencil_op( ctx, ctx->Stencil.ZPassFunc[face], face, - n, stencil, passmask ); + n, stencil, passMask ); } } @@ -902,6 +904,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n, static GLboolean stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) { + GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->_StencilBuffer; const GLuint n = span->end; @@ -916,13 +919,10 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) if (!rb->GetPointer(ctx, rb, 0, 0)) { /* No direct access */ GLstencil stencil[MAX_WIDTH]; - GLubyte origMask[MAX_WIDTH]; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte)); - _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); - (void) do_stencil_test(ctx, face, n, stencil, mask); if (ctx->Depth.Test == GL_FALSE) { @@ -930,27 +930,19 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) n, stencil, mask); } else { + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); + _swrast_depth_test_span(ctx, span); + compute_pass_fail_masks(n, origMask, mask, passMask, failMask); + if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) { - GLubyte failmask[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - failmask[i] = origMask[i] & (mask[i] ^ 1); - } apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face, - n, stencil, failmask); + n, stencil, failMask); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { - GLubyte passmask[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - passmask[i] = origMask[i] & mask[i]; - } apply_stencil_op(ctx, ctx->Stencil.ZPassFunc[face], face, - n, stencil, passmask); + n, stencil, passMask); } } @@ -972,28 +964,21 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) ctx->Stencil.ZPassFunc[face], face, mask); } else { - GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH]; - GLuint i; - - _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte)); + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); _swrast_depth_test_span(ctx, span); - for (i=0;i<n;i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - passmask[i] = oldmask[i] & mask[i]; - failmask[i] = oldmask[i] & (mask[i] ^ 1); - } + compute_pass_fail_masks(n, origMask, mask, passMask, failMask); if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) { apply_stencil_op_to_pixels(ctx, n, x, y, ctx->Stencil.ZFailFunc[face], - face, failmask); + face, failMask); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { apply_stencil_op_to_pixels(ctx, n, x, y, ctx->Stencil.ZPassFunc[face], - face, passmask); + face, passMask); } } diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index d4516f6faa8..c2a7512388e 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -3347,7 +3347,7 @@ texture_sample_func _swrast_choose_texture_sample_func( GLcontext *ctx, const struct gl_texture_object *t ) { - if (!t || !t->Complete) { + if (!t || !t->_Complete) { return &null_sample_func; } else { diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 2a90ffd85f8..cded4a6c1c4 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -144,7 +144,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, (void) swrast; - INIT_SPAN(span, GL_POLYGON, 0, 0, 0); + INIT_SPAN(span, GL_POLYGON); span.y = 0; /* silence warnings */ #ifdef INTERP_Z @@ -393,7 +393,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, span.greenStep = 0; span.blueStep = 0; # ifdef INTERP_ALPHA - span.attrStepX[FRAG_ATTRIB_COL0][3] = span.attrStepX[FRAG_ATTRIB_COL0][3] = 0.0F; + span.attrStepX[FRAG_ATTRIB_COL0][3] = span.attrStepY[FRAG_ATTRIB_COL0][3] = 0.0F; span.alphaStep = 0; # endif } diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 78fa137d3fd..9f1a4c6f0a7 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -148,26 +148,25 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, ASSERT((span->arrayMask & SPAN_XY) == 0); ASSERT(span->primitive == GL_BITMAP); - INIT_SPAN(zoomed, GL_BITMAP, 0, 0, 0); + INIT_SPAN(zoomed, GL_BITMAP); zoomed.x = x0; zoomed.end = zoomedWidth; zoomed.array = &zoomed_arrays; zoomed_arrays.ChanType = span->array->ChanType; - /* XXX temporary */ -#if CHAN_TYPE == GL_UNSIGNED_BYTE - zoomed_arrays.rgba = zoomed_arrays.rgba8; -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - zoomed_arrays.rgba = zoomed_arrays.rgba16; -#else - zoomed_arrays.rgba = zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; -#endif + if (zoomed_arrays.ChanType == GL_UNSIGNED_BYTE) + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba8; + else if (zoomed_arrays.ChanType == GL_UNSIGNED_SHORT) + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba16; + else + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; + COPY_4V(zoomed.attrStart[FRAG_ATTRIB_WPOS], span->attrStart[FRAG_ATTRIB_WPOS]); + COPY_4V(zoomed.attrStepX[FRAG_ATTRIB_WPOS], span->attrStepX[FRAG_ATTRIB_WPOS]); + COPY_4V(zoomed.attrStepY[FRAG_ATTRIB_WPOS], span->attrStepY[FRAG_ATTRIB_WPOS]); - /* copy fog interp info */ zoomed.attrStart[FRAG_ATTRIB_FOGC][0] = span->attrStart[FRAG_ATTRIB_FOGC][0]; zoomed.attrStepX[FRAG_ATTRIB_FOGC][0] = span->attrStepX[FRAG_ATTRIB_FOGC][0]; zoomed.attrStepY[FRAG_ATTRIB_FOGC][0] = span->attrStepY[FRAG_ATTRIB_FOGC][0]; - /* XXX copy texcoord info? */ if (format == GL_RGBA || format == GL_RGB) { /* copy Z info */ @@ -176,6 +175,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, /* we'll generate an array of colorss */ zoomed.interpMask = span->interpMask & ~SPAN_RGBA; zoomed.arrayMask |= SPAN_RGBA; + zoomed.arrayAttribs |= FRAG_BIT_COL0; /* we'll produce these values */ ASSERT(span->arrayMask & SPAN_RGBA); } else if (format == GL_COLOR_INDEX) { diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index d101a9e2ae2..85a27fd55bf 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -32,7 +32,7 @@ #ifndef SWRAST_H #define SWRAST_H -#include "mtypes.h" +#include "main/mtypes.h" /** * \struct SWvertex |