fragment program execution
[mesa.git] / src / mesa / tnl / t_eval_api.c
index 37d8f69118bbfe179b9fd4542ed6e271243e7636..feddf2619a18c0c2a88f593b7296150163e61916 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: t_eval_api.c,v 1.8 2001/12/03 17:39:12 keithw Exp $ */
+/* $Id: t_eval_api.c,v 1.12 2002/10/24 23:57:25 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  4.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2002  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"),
  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Keith Whitwell - original code
+ *    Brian Paul - vertex program updates
  */
 
 
@@ -29,7 +33,7 @@
 #include "colormac.h"
 #include "context.h"
 #include "macros.h"
-#include "mem.h"
+#include "imports.h"
 #include "mmath.h"
 #include "mtypes.h"
 #include "math/m_eval.h"
@@ -40,9 +44,6 @@
 #include "t_imm_exec.h"
 
 
-
-
-
 /* KW: If are compiling, we don't know whether eval will produce a
  *     vertex when it is run in the future.  If this is pure immediate
  *     mode, eval is a noop if neither vertex map is enabled.
@@ -61,7 +62,8 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
    GLenum prim;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-/*     fprintf(stderr, "%s\n", __FUNCTION__); */
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glEvalMesh1()");
 
    switch (mode) {
       case GL_POINT:
@@ -77,7 +79,8 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
 
    /* No effect if vertex maps disabled.
     */
-   if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
+   if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3 &&
+       (!ctx->VertexProgram.Enabled || !ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
       return;
 
    du = ctx->Eval.MapGrid1du;
@@ -100,7 +103,12 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
     */
    {
       GLboolean compiling = ctx->CompileFlag;
+      TNLcontext *tnl = TNL_CONTEXT(ctx);
       struct immediate *im = TNL_CURRENT_IM(ctx);
+      GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
+
+      NotifyBegin = tnl->Driver.NotifyBegin;
+      tnl->Driver.NotifyBegin = 0;
 
       if (compiling) {
         struct immediate *tmp = _tnl_alloc_immediate( ctx );
@@ -110,7 +118,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
         ctx->CompileFlag = GL_FALSE;
       }
 
-      _tnl_hard_begin( ctx, prim );
+      _tnl_Begin( prim );
       for (i=i1;i<=i2;i++,u+=du) {
         _tnl_eval_coord1f( ctx, u );
       }
@@ -119,11 +127,12 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
       /* Need this for replay *and* compile:
        */
       FLUSH_VERTICES( ctx, 0 );
+      tnl->Driver.NotifyBegin = NotifyBegin;
 
       if (compiling) {
         TNL_CURRENT_IM(ctx)->ref_count--;
         ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 );
-        _tnl_free_immediate( TNL_CURRENT_IM(ctx) );
+        _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) );
         SET_IMMEDIATE( ctx, im );
         ctx->CompileFlag = GL_TRUE;
       }
@@ -140,14 +149,15 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
    GLfloat u, du, v, dv, v1, u1;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-/*     fprintf(stderr, "%s\n", __FUNCTION__); */
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glEvalMesh2()");
 
    /* No effect if vertex maps disabled.
     */
-   if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
+   if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3 &&
+       (!ctx->VertexProgram.Enabled || !ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
       return;
 
-
    du = ctx->Eval.MapGrid2du;
    dv = ctx->Eval.MapGrid2dv;
    v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
@@ -160,6 +170,11 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
    {
       GLboolean compiling = ctx->CompileFlag;
       struct immediate *im = TNL_CURRENT_IM(ctx);
+      TNLcontext *tnl = TNL_CONTEXT(ctx);
+      GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
+
+      NotifyBegin = tnl->Driver.NotifyBegin;
+      tnl->Driver.NotifyBegin = 0;
 
       if (compiling) {
         struct immediate *tmp = _tnl_alloc_immediate( ctx );
@@ -171,7 +186,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
 
       switch (mode) {
       case GL_POINT:
-        _tnl_hard_begin( ctx, GL_POINTS );
+        _tnl_Begin( GL_POINTS );
         for (v=v1,j=j1;j<=j2;j++,v+=dv) {
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
               _tnl_eval_coord2f( ctx, u, v );
@@ -181,14 +196,14 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
         break;
       case GL_LINE:
         for (v=v1,j=j1;j<=j2;j++,v+=dv) {
-           _tnl_hard_begin( ctx, GL_LINE_STRIP );
+           _tnl_Begin( GL_LINE_STRIP );
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
               _tnl_eval_coord2f( ctx, u, v );
            }
            _tnl_end(ctx);
         }
         for (u=u1,i=i1;i<=i2;i++,u+=du) {
-           _tnl_hard_begin( ctx, GL_LINE_STRIP );
+           _tnl_Begin( GL_LINE_STRIP );
            for (v=v1,j=j1;j<=j2;j++,v+=dv) {
               _tnl_eval_coord2f( ctx, u, v );
            }
@@ -197,7 +212,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
         break;
       case GL_FILL:
         for (v=v1,j=j1;j<j2;j++,v+=dv) {
-           _tnl_hard_begin( ctx, GL_TRIANGLE_STRIP );
+           _tnl_Begin( GL_TRIANGLE_STRIP );
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
               _tnl_eval_coord2f( ctx, u, v );
               _tnl_eval_coord2f( ctx, u, v+dv );
@@ -213,10 +228,11 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
       /* Need this for replay *and* compile:
        */
       FLUSH_VERTICES( ctx, 0 );
+      tnl->Driver.NotifyBegin = NotifyBegin;
         
       if (compiling) {
         TNL_CURRENT_IM(ctx)->ref_count--;
-        _tnl_free_immediate( TNL_CURRENT_IM( ctx ) );
+        _tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) );
         SET_IMMEDIATE( ctx, im );
         ctx->CompileFlag = GL_TRUE;
       }
@@ -224,7 +240,6 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
 }
 
 
-
 void _tnl_eval_init( GLcontext *ctx )
 {
    GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt);