mesa: make sure the gotten value isn't greater than the
authorXiang, Haihao <haihao.xiang@intel.com>
Thu, 27 Sep 2007 07:52:01 +0000 (15:52 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 27 Sep 2007 07:52:01 +0000 (15:52 +0800)
max depth buffer value on 64bit system. fix bug #12095

src/mesa/swrast/s_span.c

index bbde0025f45d3a8da88c9f27521bd667cbd7d04e..f1e58bd3d81bbfff2d361fcfb35f28a4093e60c3 100644 (file)
@@ -64,8 +64,11 @@ _swrast_span_default_attribs(GLcontext *ctx, SWspan *span)
       const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
       if (ctx->DrawBuffer->Visual.depthBits <= 16)
          span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
-      else
-         span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F);
+      else {
+         GLfloat tmpf = ctx->Current.RasterPos[2] * depthMax; 
+         tmpf = MIN2(tmpf, depthMax);
+         span->z = (GLint)tmpf;
+      }
       span->zStep = 0;
       span->interpMask |= SPAN_Z;
    }