X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_aatritemp.h;h=1de627208a1580dfabc2528401fb516c319fd41a;hb=30f4ccff5bd7304a623d2909aaf8de35727ce03d;hp=5c1c6d9044b1f3e33722a75ea23747faefd58c88;hpb=87b9f5a7251b96bd315a72ae6fd972aa94e226e0;p=mesa.git diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 5c1c6d9044b..1de627208a1 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -17,9 +16,10 @@ * 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. + * THE AUTHORS OR COPYRIGHT HOLDERS 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. */ @@ -36,12 +36,12 @@ * DO_ATTRIBS - if defined, compute texcoords, varying, etc. */ -/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ +/*void triangle( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ { const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLfloat *p0 = v0->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *p1 = v1->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *p2 = v2->attrib[FRAG_ATTRIB_WPOS]; + const GLfloat *p0 = v0->attrib[VARYING_SLOT_POS]; + const GLfloat *p1 = v1->attrib[VARYING_SLOT_POS]; + const GLfloat *p2 = v2->attrib[VARYING_SLOT_POS]; const SWvertex *vMin, *vMid, *vMax; GLint iyMin, iyMax; GLfloat yMin, yMax; @@ -55,7 +55,7 @@ #endif GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; #if defined(DO_ATTRIBS) - GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; + GLfloat attrPlane[VARYING_SLOT_MAX][4][4]; GLfloat wPlane[4]; /* win[3] */ #endif GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceCullSign; @@ -67,9 +67,9 @@ /* determine bottom to top order of vertices */ { - GLfloat y0 = v0->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat y1 = v1->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat y2 = v2->attrib[FRAG_ATTRIB_WPOS][1]; + GLfloat y0 = v0->attrib[VARYING_SLOT_POS][1]; + GLfloat y1 = v1->attrib[VARYING_SLOT_POS][1]; + GLfloat y2 = v2->attrib[VARYING_SLOT_POS][1]; if (y0 <= y1) { if (y1 <= y2) { vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ @@ -94,16 +94,16 @@ } } - majDx = vMax->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0]; - majDy = vMax->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1]; + majDx = vMax->attrib[VARYING_SLOT_POS][0] - vMin->attrib[VARYING_SLOT_POS][0]; + majDy = vMax->attrib[VARYING_SLOT_POS][1] - vMin->attrib[VARYING_SLOT_POS][1]; /* front/back-face determination and cullling */ { - const GLfloat botDx = vMid->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0]; - const GLfloat botDy = vMid->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1]; + const GLfloat botDx = vMid->attrib[VARYING_SLOT_POS][0] - vMin->attrib[VARYING_SLOT_POS][0]; + const GLfloat botDy = vMid->attrib[VARYING_SLOT_POS][1] - vMin->attrib[VARYING_SLOT_POS][1]; const GLfloat area = majDx * botDy - botDx * majDy; /* Do backface culling */ - if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) + if (area * bf < 0 || area == 0 || util_is_inf_or_nan(area)) return; ltor = (GLboolean) (area < 0.0F); @@ -134,12 +134,12 @@ span.arrayMask |= SPAN_RGBA; #if defined(DO_ATTRIBS) { - const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invW2 = v2->attrib[FRAG_ATTRIB_WPOS][3]; + const GLfloat invW0 = v0->attrib[VARYING_SLOT_POS][3]; + const GLfloat invW1 = v1->attrib[VARYING_SLOT_POS][3]; + const GLfloat invW2 = v2->attrib[VARYING_SLOT_POS][3]; compute_plane(p0, p1, p2, invW0, invW1, invW2, wPlane); - span.attrStepX[FRAG_ATTRIB_WPOS][3] = plane_dx(wPlane); - span.attrStepY[FRAG_ATTRIB_WPOS][3] = plane_dy(wPlane); + span.attrStepX[VARYING_SLOT_POS][3] = plane_dx(wPlane); + span.attrStepY[VARYING_SLOT_POS][3] = plane_dy(wPlane); ATTRIB_LOOP_BEGIN GLuint c; if (swrast->_InterpMode[attr] == GL_FLAT) { @@ -169,27 +169,34 @@ * edges, stopping when we find that coverage = 0. If the long edge * is on the left we scan left-to-right. Else, we scan right-to-left. */ - yMin = vMin->attrib[FRAG_ATTRIB_WPOS][1]; - yMax = vMax->attrib[FRAG_ATTRIB_WPOS][1]; + yMin = vMin->attrib[VARYING_SLOT_POS][1]; + yMax = vMax->attrib[VARYING_SLOT_POS][1]; iyMin = (GLint) yMin; iyMax = (GLint) yMax + 1; if (ltor) { /* scan left to right */ - const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS]; + const GLfloat *pMin = vMin->attrib[VARYING_SLOT_POS]; + const GLfloat *pMid = vMid->attrib[VARYING_SLOT_POS]; + const GLfloat *pMax = vMax->attrib[VARYING_SLOT_POS]; const GLfloat dxdy = majDx / majDy; const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F; - GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; GLint iy; - for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { +#ifdef _OPENMP +#pragma omp parallel for schedule(dynamic) private(iy) firstprivate(span) +#endif + for (iy = iyMin; iy < iyMax; iy++) { + GLfloat x = pMin[0] - (yMin - iy) * dxdy; GLint ix, startX = (GLint) (x - xAdj); GLuint count; GLfloat coverage = 0.0F; +#ifdef _OPENMP + /* each thread needs to use a different (global) SpanArrays variable */ + span.array = SWRAST_CONTEXT(ctx)->SpanArrays + omp_get_thread_num(); +#endif /* skip over fragments with zero coverage */ - while (startX < MAX_WIDTH) { + while (startX < SWRAST_MAX_WIDTH) { coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); if (coverage > 0.0F) break; @@ -201,7 +208,7 @@ #if defined(DO_ATTRIBS) /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 0.5F, iy + 0.5F, wPlane); + span.attrStart[VARYING_SLOT_POS][3] = solve_plane(ix + 0.5F, iy + 0.5F, wPlane); ATTRIB_LOOP_BEGIN GLuint c; for (c = 0; c < 4; c++) { @@ -228,29 +235,35 @@ coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); } - if (ix <= startX) - continue; - - span.x = startX; - span.y = iy; - span.end = (GLuint) ix - (GLuint) startX; - _swrast_write_rgba_span(ctx, &span); + if (ix > startX) { + span.x = startX; + span.y = iy; + span.end = (GLuint) ix - (GLuint) startX; + _swrast_write_rgba_span(ctx, &span); + } } } else { /* scan right to left */ - const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS]; + const GLfloat *pMin = vMin->attrib[VARYING_SLOT_POS]; + const GLfloat *pMid = vMid->attrib[VARYING_SLOT_POS]; + const GLfloat *pMax = vMax->attrib[VARYING_SLOT_POS]; const GLfloat dxdy = majDx / majDy; const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; - GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; GLint iy; - for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { +#ifdef _OPENMP +#pragma omp parallel for schedule(dynamic) private(iy) firstprivate(span) +#endif + for (iy = iyMin; iy < iyMax; iy++) { + GLfloat x = pMin[0] - (yMin - iy) * dxdy; GLint ix, left, startX = (GLint) (x + xAdj); GLuint count, n; GLfloat coverage = 0.0F; +#ifdef _OPENMP + /* each thread needs to use a different (global) SpanArrays variable */ + span.array = SWRAST_CONTEXT(ctx)->SpanArrays + omp_get_thread_num(); +#endif /* make sure we're not past the window edge */ if (startX >= ctx->DrawBuffer->_Xmax) { startX = ctx->DrawBuffer->_Xmax - 1; @@ -271,7 +284,7 @@ /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; - ASSERT(ix >= 0); + assert(ix >= 0); array->coverage[ix] = coverage; #ifdef DO_Z array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); @@ -287,7 +300,7 @@ #if defined(DO_ATTRIBS) /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5F, iy + 0.5F, wPlane); + span.attrStart[VARYING_SLOT_POS][3] = solve_plane(ix + 1.5F, iy + 0.5F, wPlane); ATTRIB_LOOP_BEGIN GLuint c; for (c = 0; c < 4; c++) { @@ -296,31 +309,30 @@ ATTRIB_LOOP_END #endif - if (startX <= ix) - continue; - - n = (GLuint) startX - (GLuint) ix; + if (startX > ix) { + n = (GLuint) startX - (GLuint) ix; - left = ix + 1; + left = ix + 1; - /* shift all values to the left */ - /* XXX this is temporary */ - { - SWspanarrays *array = span.array; - GLint j; - for (j = 0; j < (GLint) n; j++) { - array->coverage[j] = array->coverage[j + left]; - COPY_CHAN4(array->rgba[j], array->rgba[j + left]); + /* shift all values to the left */ + /* XXX this is temporary */ + { + SWspanarrays *array = span.array; + GLint j; + for (j = 0; j < (GLint) n; j++) { + array->coverage[j] = array->coverage[j + left]; + COPY_CHAN4(array->rgba[j], array->rgba[j + left]); #ifdef DO_Z - array->z[j] = array->z[j + left]; + array->z[j] = array->z[j + left]; #endif + } } - } - span.x = left; - span.y = iy; - span.end = n; - _swrast_write_rgba_span(ctx, &span); + span.x = left; + span.y = iy; + span.end = n; + _swrast_write_rgba_span(ctx, &span); + } } } }