Update Visual Studio Project file for src tree updates.
[mesa.git] / src / mesa / tnl / t_vb_vertex.c
index aa414bc5b1881d19a82bea55d5ecb1b46c8a4be8..3951439fff3882c7b3dd5b0cab21b89bcdbb0228 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: t_vb_vertex.c,v 1.16 2002/10/29 20:29:04 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  6.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
@@ -33,7 +31,6 @@
 #include "context.h"
 #include "macros.h"
 #include "imports.h"
-#include "mmath.h"
 #include "mtypes.h"
 
 #include "math/m_xform.h"
@@ -131,12 +128,14 @@ static void (*(usercliptab[5]))( GLcontext *,
 
 
 static GLboolean run_vertex_stage( GLcontext *ctx,
-                                  struct gl_pipeline_stage *stage )
+                                  struct tnl_pipeline_stage *stage )
 {
    struct vertex_stage_data *store = (struct vertex_stage_data *)stage->privatePtr;
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
 
+   ASSERT(!ctx->VertexProgram._Enabled);
+
    if (stage->changed_inputs) {
 
       if (ctx->_NeedEyeCoords) {
@@ -149,37 +148,51 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
            VB->EyePtr = TransformRaw( &store->eye,
                                        ctx->ModelviewMatrixStack.Top,
                                       VB->ObjPtr);
-
-        if (ctx->ProjectionMatrixStack.Top->type == MATRIX_IDENTITY)
-           VB->ClipPtr = VB->EyePtr;
-        else
-           VB->ClipPtr = TransformRaw( &store->clip,
-                                        &ctx->_ModelProjectMatrix,
-                                       VB->ObjPtr );
-      }
-      else {
-        /* Combined modelviewproject transform:
-         */
-        if (ctx->_ModelProjectMatrix.type == MATRIX_IDENTITY)
-           VB->ClipPtr = VB->ObjPtr;
-        else
-           VB->ClipPtr = TransformRaw( &store->clip,
-                                        &ctx->_ModelProjectMatrix,
-                                       VB->ObjPtr );
+#if 0
+         /* examine some eye coordinates */
+         {
+            GLuint i;
+            GLfloat *v = VB->EyePtr->start;
+            for (i = 0; i < 4; i++) {
+               _mesa_printf("eye[%d] = %g, %g, %g, %g\n",
+                            i, v[0], v[1], v[2], v[3]);
+               v += 4;
+            }
+         }
+#endif
       }
 
+      VB->ClipPtr = TransformRaw( &store->clip,
+                                 &ctx->_ModelProjectMatrix,
+                                 VB->ObjPtr );
+
       /* Drivers expect this to be clean to element 4...
        */
-      if (VB->ClipPtr->size < 4) {
-        if (VB->ClipPtr->flags & VEC_NOT_WRITEABLE) {
-           ASSERT(VB->ClipPtr == VB->ObjPtr);
-           VB->import_data( ctx, VERT_BIT_POS, VEC_NOT_WRITEABLE );
-           VB->ClipPtr = VB->ObjPtr;
-        }
-        if (VB->ClipPtr->size == 2)
-           _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 );
+      switch (VB->ClipPtr->size) {
+      case 1:                  
+        /* impossible */
+      case 2:
+        _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 );
+         /* fall-through */
+      case 3:
         _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 );
+         /* fall-through */
+      case 4:
+        break;
+      }
+
+#if 0
+      /* examine some clip coordinates */
+      {
+         GLuint i;
+         GLfloat *v = VB->ClipPtr->start;
+         for (i = 0; i < 4; i++) {
+            _mesa_printf("clip[%d] = %g, %g, %g, %g\n",
+                         i, v[0], v[1], v[2], v[3]);
+            v += 4;
+         }
       }
+#endif
 
       /* Cliptest and perspective divide.  Clip functions must clear
        * the clipmask.
@@ -194,7 +207,6 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
                                                store->clipmask,
                                                &store->ormask,
                                                &store->andmask );
-
       }
       else {
         VB->NdcPtr = 0;
@@ -223,12 +235,10 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
            return GL_FALSE;
       }
 
+      VB->ClipAndMask = store->andmask;
       VB->ClipOrMask = store->ormask;
       VB->ClipMask = store->clipmask;
 
-      if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_BIT_POS))
-        VB->importable_data |= VERT_BIT_CLIP;
-
       store->save_eyeptr = VB->EyePtr;
       store->save_clipptr = VB->ClipPtr;
       store->save_ndcptr = VB->NdcPtr;
@@ -240,9 +250,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
       VB->ClipPtr = store->save_clipptr;
       VB->NdcPtr = store->save_ndcptr;
       VB->ClipMask = store->clipmask;
+      VB->ClipAndMask = store->andmask;
       VB->ClipOrMask = store->ormask;
-      if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_BIT_POS))
-        VB->importable_data |= VERT_BIT_CLIP;
       if (store->andmask)
         return GL_FALSE;
    }
@@ -251,13 +260,13 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
 }
 
 
-static void check_vertex( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_vertex( GLcontext *ctx, struct tnl_pipeline_stage *stage )
 {
-   stage->active = !ctx->VertexProgram.Enabled;
+   stage->active = !ctx->VertexProgram._Enabled;
 }
 
 static GLboolean init_vertex_stage( GLcontext *ctx,
-                                   struct gl_pipeline_stage *stage )
+                                   struct tnl_pipeline_stage *stage )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
    struct vertex_stage_data *store;
@@ -286,7 +295,7 @@ static GLboolean init_vertex_stage( GLcontext *ctx,
    return stage->run( ctx, stage );
 }
 
-static void dtr( struct gl_pipeline_stage *stage )
+static void dtr( struct tnl_pipeline_stage *stage )
 {
    struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage);
 
@@ -302,17 +311,18 @@ static void dtr( struct gl_pipeline_stage *stage )
 }
 
 
-const struct gl_pipeline_stage _tnl_vertex_transform_stage =
+const struct tnl_pipeline_stage _tnl_vertex_transform_stage =
 {
    "modelview/project/cliptest/divide",
-   0,                          /* re-check -- always on */
-   _MESA_NEW_NEED_EYE_COORDS |
+   _NEW_PROGRAM,                /* check_state: only care about vertex prog */
+   _MESA_NEW_NEED_EYE_COORDS |  /* run_state: when to invalidate / re-run */
    _NEW_MODELVIEW|
    _NEW_PROJECTION|
-   _NEW_TRANSFORM,             /* re-run */
+   _NEW_PROGRAM|
+   _NEW_TRANSFORM,
    GL_TRUE,                    /* active */
-   VERT_BIT_POS,               /* inputs */
-   VERT_BIT_EYE|VERT_BIT_CLIP,         /* outputs */
+   _TNL_BIT_POS,               /* inputs */
+   _TNL_BIT_POS,               /* outputs */
    0,                          /* changed_inputs */
    NULL,                       /* private data */
    dtr,                                /* destructor */