Merge branch 'master' into opengl-es-v2
[mesa.git] / src / mesa / tnl / t_vb_vertex.c
index b3defaad05ebaa9d19b26a16b9a9b012e4f22157..bc7e0951ec8c93c47bf011d586ceda5c6816df62 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  6.5
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  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"),
  */
 
 
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "math/m_xform.h"
 
@@ -118,6 +118,22 @@ static void (*(usercliptab[5]))( GLcontext *,
 };
 
 
+void
+tnl_clip_prepare(GLcontext *ctx)
+{
+   /* Neither the x86 nor sparc asm cliptest functions have been updated
+    * for ARB_depth_clamp, so force the C paths.
+    */
+   if (ctx->Transform.DepthClamp) {
+      static GLboolean c_funcs_installed = GL_FALSE;
+      if (!c_funcs_installed) {
+         init_c_cliptest();
+         c_funcs_installed = GL_TRUE;
+      }
+   }
+}
+
+
 
 static GLboolean run_vertex_stage( GLcontext *ctx,
                                   struct tnl_pipeline_stage *stage )
@@ -126,24 +142,26 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
 
-   if (ctx->VertexProgram._Enabled
+   if (ctx->VertexProgram._Current
       return GL_TRUE;
 
+   tnl_clip_prepare(ctx);
+
    if (ctx->_NeedEyeCoords) {
       /* Separate modelview transformation:
        * Use combined ModelProject to avoid some depth artifacts
        */
       if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
-        VB->EyePtr = VB->ObjPtr;
+        VB->EyePtr = VB->AttribPtr[_TNL_ATTRIB_POS];
       else
         VB->EyePtr = TransformRaw( &store->eye,
                                    ctx->ModelviewMatrixStack.Top,
-                                   VB->ObjPtr);
+                                   VB->AttribPtr[_TNL_ATTRIB_POS]);
    }
 
    VB->ClipPtr = TransformRaw( &store->clip,
                               &ctx->_ModelProjectMatrix,
-                              VB->ObjPtr );
+                              VB->AttribPtr[_TNL_ATTRIB_POS] );
 
    /* Drivers expect this to be clean to element 4...
     */
@@ -165,7 +183,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
     * the clipmask.
     */
    store->ormask = 0;
-   store->andmask = CLIP_ALL_BITS;
+   store->andmask = CLIP_FRUSTUM_BITS;
 
    if (tnl->NeedNdcCoords) {
       VB->NdcPtr =
@@ -173,7 +191,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
                                            &store->proj,
                                            store->clipmask,
                                            &store->ormask,
-                                           &store->andmask );
+                                           &store->andmask,
+                                           !ctx->Transform.DepthClamp );
    }
    else {
       VB->NdcPtr = NULL;
@@ -181,7 +200,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
                                            NULL,
                                            store->clipmask,
                                            &store->ormask,
-                                           &store->andmask );
+                                           &store->andmask,
+                                           !ctx->Transform.DepthClamp );
    }
 
    if (store->andmask)