r300: Further reduced the radeon_span.c diff.
[mesa.git] / src / mesa / swrast / s_linetemp.h
index 1cb330dbdf50c0c272c3f801e0bc364592dd737e..b6e8f287f4582090473fc8418f40442c62f6410e 100644 (file)
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.5.3
  *
- * Copyright (C) 1999-2002  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"),
@@ -36,8 +35,7 @@
  *    INTERP_RGBA     - if defined, interpolate RGBA values
  *    INTERP_SPEC     - if defined, interpolate specular RGB values
  *    INTERP_INDEX    - if defined, interpolate color index values
- *    INTERP_TEX      - if defined, interpolate unit 0 texcoords
- *    INTERP_MULTITEX - if defined, interpolate multi-texcoords
+ *    INTERP_ATTRIBS  - if defined, interpolate attribs (texcoords, varying, etc)
  *
  * When one can directly address pixels in the color buffer the following
  * macros can be defined and used to directly compute pixel addresses during
@@ -71,7 +69,8 @@
 static void
 NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 {
-   struct sw_span span;
+   const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   SWspan span;
    GLuint interpFlags = 0;
    GLint x0 = (GLint) vert0->win[0];
    GLint x1 = (GLint) vert1->win[0];
@@ -81,13 +80,15 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    GLint numPixels;
    GLint xstep, ystep;
 #if defined(DEPTH_TYPE)
-   const GLint depthBits = ctx->Visual.depthBits;
+   const GLint depthBits = ctx->DrawBuffer->Visual.depthBits;
    const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+   struct gl_renderbuffer *zrb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
 #define FixedToDepth(F)  ((F) >> fixedToDepthShift)
    GLint zPtrXstep, zPtrYstep;
    DEPTH_TYPE *zPtr;
 #elif defined(INTERP_Z)
-   const GLint depthBits = ctx->Visual.depthBits;
+   const GLint depthBits = ctx->DrawBuffer->Visual.depthBits;
+/*ctx->Visual.depthBits;*/
 #endif
 #ifdef PIXEL_ADDRESS
    PIXEL_TYPE *pixelPtr;
@@ -98,6 +99,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    SETUP_CODE
 #endif
 
+   (void) swrast;
+
    /* Cull primitives with malformed coordinates.
     */
    {
@@ -152,7 +155,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
       return;
 
 #ifdef DEPTH_TYPE
-   zPtr = (DEPTH_TYPE *) _swrast_zbuffer_address(ctx, x0, y0);
+   zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0);
 #endif
 #ifdef PIXEL_ADDRESS
    pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0);
@@ -251,11 +254,11 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 #ifdef INTERP_INDEX
    interpFlags |= SPAN_INDEX;
    if (ctx->Light.ShadeModel == GL_SMOOTH) {
-      span.index = IntToFixed(vert0->index);
-      span.indexStep = IntToFixed(vert1->index - vert0->index) / numPixels;
+      span.index = FloatToFixed(vert0->index);
+      span.indexStep = FloatToFixed(vert1->index - vert0->index) / numPixels;
    }
    else {
-      span.index = IntToFixed(vert1->index);
+      span.index = FloatToFixed(vert1->index);
       span.indexStep = 0;
    }
 #endif
@@ -268,74 +271,52 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
       }
       else {
          /* don't use fixed point */
-         span.z = (GLint) vert0->win[2];
+         span.z = (GLuint) vert0->win[2];
          span.zStep = (GLint) ((vert1->win[2] - vert0->win[2]) / numPixels);
       }
    }
 #endif
 #ifdef INTERP_FOG
    interpFlags |= SPAN_FOG;
-   span.fog = vert0->fog;
-   span.fogStep = (vert1->fog - vert0->fog) / numPixels;
+   span.attrStart[FRAG_ATTRIB_FOGC][0] = vert0->attrib[FRAG_ATTRIB_FOGC][0];
+   span.attrStepX[FRAG_ATTRIB_FOGC][0] = (vert1->attrib[FRAG_ATTRIB_FOGC][0]
+                                          - vert0->attrib[FRAG_ATTRIB_FOGC][0]) / numPixels;
 #endif
-#ifdef INTERP_TEX
-   interpFlags |= SPAN_TEXTURE;
+#if defined(INTERP_ATTRIBS)
+   interpFlags |= (SPAN_TEXTURE | SPAN_VARYING);
    {
+      const GLfloat invLen = 1.0F / numPixels;
       const GLfloat invw0 = vert0->win[3];
       const GLfloat invw1 = vert1->win[3];
-      const GLfloat invLen = 1.0F / numPixels;
-      GLfloat ds, dt, dr, dq;
-      span.tex[0][0] = invw0 * vert0->texcoord[0][0];
-      span.tex[0][1] = invw0 * vert0->texcoord[0][1];
-      span.tex[0][2] = invw0 * vert0->texcoord[0][2];
-      span.tex[0][3] = invw0 * vert0->texcoord[0][3];
-      ds = (invw1 * vert1->texcoord[0][0]) - span.tex[0][0];
-      dt = (invw1 * vert1->texcoord[0][1]) - span.tex[0][1];
-      dr = (invw1 * vert1->texcoord[0][2]) - span.tex[0][2];
-      dq = (invw1 * vert1->texcoord[0][3]) - span.tex[0][3];
-      span.texStepX[0][0] = ds * invLen;
-      span.texStepX[0][1] = dt * invLen;
-      span.texStepX[0][2] = dr * invLen;
-      span.texStepX[0][3] = dq * invLen;
-      span.texStepY[0][0] = 0.0F;
-      span.texStepY[0][1] = 0.0F;
-      span.texStepY[0][2] = 0.0F;
-      span.texStepY[0][3] = 0.0F;
-   }
-#endif
-#ifdef INTERP_MULTITEX
-   interpFlags |= SPAN_TEXTURE;
-   {
-      const GLfloat invLen = 1.0F / numPixels;
-      GLuint u;
-      for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-         if (ctx->Texture.Unit[u]._ReallyEnabled) {
-            const GLfloat invw0 = vert0->win[3];
-            const GLfloat invw1 = vert1->win[3];
-            GLfloat ds, dt, dr, dq;
-            span.tex[u][0] = invw0 * vert0->texcoord[u][0];
-            span.tex[u][1] = invw0 * vert0->texcoord[u][1];
-            span.tex[u][2] = invw0 * vert0->texcoord[u][2];
-            span.tex[u][3] = invw0 * vert0->texcoord[u][3];
-            ds = (invw1 * vert1->texcoord[u][0]) - span.tex[u][0];
-            dt = (invw1 * vert1->texcoord[u][1]) - span.tex[u][1];
-            dr = (invw1 * vert1->texcoord[u][2]) - span.tex[u][2];
-            dq = (invw1 * vert1->texcoord[u][3]) - span.tex[u][3];
-            span.texStepX[u][0] = ds * invLen;
-            span.texStepX[u][1] = dt * invLen;
-            span.texStepX[u][2] = dr * invLen;
-            span.texStepX[u][3] = dq * invLen;
-            span.texStepY[u][0] = 0.0F;
-            span.texStepY[u][1] = 0.0F;
-            span.texStepY[u][2] = 0.0F;
-            span.texStepY[u][3] = 0.0F;
-        }
-      }
+      ATTRIB_LOOP_BEGIN
+         GLfloat ds, dt, dr, dq;
+         span.attrStart[attr][0] = invw0 * vert0->attrib[attr][0];
+         span.attrStart[attr][1] = invw0 * vert0->attrib[attr][1];
+         span.attrStart[attr][2] = invw0 * vert0->attrib[attr][2];
+         span.attrStart[attr][3] = invw0 * vert0->attrib[attr][3];
+         ds = (invw1 * vert1->attrib[attr][0]) - span.attrStart[attr][0];
+         dt = (invw1 * vert1->attrib[attr][1]) - span.attrStart[attr][1];
+         dr = (invw1 * vert1->attrib[attr][2]) - span.attrStart[attr][2];
+         dq = (invw1 * vert1->attrib[attr][3]) - span.attrStart[attr][3];
+         span.attrStepX[attr][0] = ds * invLen;
+         span.attrStepX[attr][1] = dt * invLen;
+         span.attrStepX[attr][2] = dr * invLen;
+         span.attrStepX[attr][3] = dq * invLen;
+         span.attrStepY[attr][0] = 0.0F;
+         span.attrStepY[attr][1] = 0.0F;
+         span.attrStepY[attr][2] = 0.0F;
+         span.attrStepY[attr][3] = 0.0F;
+      ATTRIB_LOOP_END
    }
 #endif
 
    INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
 
+   /* Need these for fragment prog texcoord interpolation */
+   span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F;
+   span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
+   span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
+
    /*
     * Draw
     */
@@ -349,7 +330,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 
       for (i = 0; i < dx; i++) {
 #ifdef DEPTH_TYPE
-         GLdepth Z = FixedToDepth(span.z);
+         GLuint Z = FixedToDepth(span.z);
 #endif
 #ifdef PLOT
          PLOT( x0, y0 );
@@ -389,7 +370,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 
       for (i=0;i<dy;i++) {
 #ifdef DEPTH_TYPE
-         GLdepth Z = FixedToDepth(span.z);
+         GLuint Z = FixedToDepth(span.z);
 #endif
 #ifdef PLOT
          PLOT( x0, y0 );
@@ -425,6 +406,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    RENDER_SPAN( span );
 #endif
 
+   (void)span;
+
 }
 
 
@@ -433,8 +416,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 #undef INTERP_FOG
 #undef INTERP_RGBA
 #undef INTERP_SPEC
-#undef INTERP_TEX
-#undef INTERP_MULTITEX
+#undef INTERP_ATTRIBS
 #undef INTERP_INDEX
 #undef PIXEL_ADDRESS
 #undef PIXEL_TYPE