Merge branch 'origin'
[mesa.git] / src / mesa / swrast / s_linetemp.h
index d0f8d6f5bdbd48e697a95c8073cd936c655b0773..8b3918511d1defc7b4a4bda578703b83de9db983 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: s_linetemp.h,v 1.16 2002/11/15 15:05:04 brianp Exp $ */
-
 /*
  * 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"),
@@ -72,7 +70,7 @@
 static void
 NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 {
-   struct sw_span span;
+   SWspan span;
    GLuint interpFlags = 0;
    GLint x0 = (GLint) vert0->win[0];
    GLint x1 = (GLint) vert1->win[0];
@@ -82,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;
@@ -153,7 +153,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
       return;
 
 #ifdef DEPTH_TYPE
-   zPtr = (DEPTH_TYPE *) _mesa_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);
@@ -252,11 +252,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,8 +268,9 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
          span.zStep = FloatToFixed(vert1->win[2] - vert0->win[2]) / numPixels;
       }
       else {
-         span.z = vert0->win[2];
-         span.zStep = (vert1->win[2] - vert0->win[2]) / numPixels;
+         /* don't use fixed point */
+         span.z = (GLuint) vert0->win[2];
+         span.zStep = (GLint) ((vert1->win[2] - vert0->win[2]) / numPixels);
       }
    }
 #endif
@@ -336,6 +337,11 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
 
    INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
 
+   /* Need these for fragment prog texcoord interpolation */
+   span.w = 1.0F;
+   span.dwdx = 0.0F;
+   span.dwdy = 0.0F;
+
    /*
     * Draw
     */
@@ -349,7 +355,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 +395,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 +431,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    RENDER_SPAN( span );
 #endif
 
+   (void)span;
+
 }