X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_points.c;h=1663ece82941de2f5111a82453fe24f6edb06b12;hb=3c90777fd7cce57486dc7d98e676ffe9dede55ae;hp=22639c58ff706c3bf93ed033ca5c3c5f007d8212;hpb=cc7dd4fc1b3c765ca1ecd943d189bb156dae529d;p=mesa.git diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 22639c58ff7..1663ece8294 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -27,7 +27,6 @@ #include "main/colormac.h" #include "main/context.h" #include "main/macros.h" -#include "texstate.h" #include "s_context.h" #include "s_feedback.h" #include "s_points.h" @@ -126,22 +125,23 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) GLfloat s, r, dsdx; /* texcoord / pointcoord interpolants */ - s = 0.0; - dsdx = 1.0 / size; + s = 0.0F; + dsdx = 1.0F / size; if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { - t0 = 0.0; - dtdy = 1.0 / size; + dtdy = 1.0F / size; + t0 = 0.5F * dtdy; } else { /* GL_UPPER_LEFT */ - t0 = 1.0; - dtdy = -1.0 / size; + dtdy = -1.0F / size; + t0 = 1.0F + 0.5F * dtdy; } ATTRIB_LOOP_BEGIN - if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { + if (attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) { + /* a texcoord attribute */ const GLuint u = attr - FRAG_ATTRIB_TEX0; - /* a texcoord */ + ASSERT(u < Elements(ctx->Point.CoordReplace)); if (ctx->Point.CoordReplace[u]) { tCoords[numTcoords++] = attr; @@ -170,15 +170,15 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) continue; } } - else if (attr == FRAG_ATTRIB_FOGC) { - /* GLSL gl_PointCoord is stored in fog.zw */ - span.attrStart[FRAG_ATTRIB_FOGC][2] = 0.0; - span.attrStart[FRAG_ATTRIB_FOGC][3] = 0.0; /* t0 set below */ - span.attrStepX[FRAG_ATTRIB_FOGC][2] = dsdx; - span.attrStepX[FRAG_ATTRIB_FOGC][3] = 0.0; - span.attrStepY[FRAG_ATTRIB_FOGC][2] = 0.0; - span.attrStepY[FRAG_ATTRIB_FOGC][3] = dtdy; - tCoords[numTcoords++] = FRAG_ATTRIB_FOGC; + else if (attr == FRAG_ATTRIB_PNTC) { + /* GLSL gl_PointCoord.xy (.zw undefined) */ + span.attrStart[FRAG_ATTRIB_PNTC][0] = 0.0; + span.attrStart[FRAG_ATTRIB_PNTC][1] = 0.0; /* t0 set below */ + span.attrStepX[FRAG_ATTRIB_PNTC][0] = dsdx; + span.attrStepX[FRAG_ATTRIB_PNTC][1] = 0.0; + span.attrStepY[FRAG_ATTRIB_PNTC][0] = 0.0; + span.attrStepY[FRAG_ATTRIB_PNTC][1] = dtdy; + tCoords[numTcoords++] = FRAG_ATTRIB_PNTC; continue; } /* use vertex's texcoord/attrib */ @@ -221,10 +221,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) GLuint i; /* setup texcoord T for this row */ for (i = 0; i < numTcoords; i++) { - if (tCoords[i] == FRAG_ATTRIB_FOGC) - span.attrStart[FRAG_ATTRIB_FOGC][3] = tcoord; - else - span.attrStart[tCoords[i]][1] = tcoord; + span.attrStart[tCoords[i]][1] = tcoord; } /* these might get changed by span clipping */ @@ -247,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; @@ -338,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 */ @@ -372,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; @@ -392,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; @@ -469,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 @@ -483,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 */ @@ -500,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; } } @@ -513,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 @@ -570,6 +543,9 @@ void _swrast_choose_point(GLcontext *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); + const GLfloat size = CLAMP(ctx->Point.Size, + ctx->Point.MinSize, + ctx->Point.MaxSize); if (ctx->RenderMode == GL_RENDER) { if (ctx->Point.PointSprite) { @@ -578,7 +554,7 @@ _swrast_choose_point(GLcontext *ctx) else if (ctx->Point.SmoothFlag) { swrast->Point = smooth_point; } - else if (ctx->Point.Size > 1.0 || + else if (size > 1.0 || ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { swrast->Point = large_point;