fragment program execution
[mesa.git] / src / mesa / tnl / t_imm_api.c
index 9f9d4ab5d119f634c1a5114fde3474501a52b711..462d8dbaf6e38f44b284c5d06ef7bacc7d05a51c 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: t_imm_api.c,v 1.33 2002/10/09 19:38:32 brianp Exp $ */
+/* $Id: t_imm_api.c,v 1.39 2003/01/14 04:55:47 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  5.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"),
@@ -24,7 +24,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Keith Whitwell <keithw@valinux.com>
+ *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
 
@@ -34,7 +34,7 @@
 #include "dlist.h"
 #include "enums.h"
 #include "light.h"
-#include "mem.h"
+#include "imports.h"
 #include "state.h"
 #include "colormac.h"
 #include "macros.h"
@@ -127,6 +127,11 @@ _tnl_save_Begin( GLenum mode )
    }
 #endif
 
+   if (IM->Count > IMM_MAXDATA-8) {
+      _tnl_flush_immediate( ctx, IM );
+      IM = TNL_CURRENT_IM(ctx);
+   }
+
    /* Check for and flush buffered vertices from internal operations.
     */
    if (IM->SavedBeginState) {
@@ -194,6 +199,15 @@ _tnl_Begin( GLenum mode )
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
+   {
+      struct immediate *IM = TNL_CURRENT_IM(ctx);
+      if (IM->Count > IMM_MAXDATA-8) {
+        _tnl_flush_immediate( ctx, IM );
+        IM = TNL_CURRENT_IM(ctx);
+      }
+   }
+
+
    {
       struct immediate *IM = TNL_CURRENT_IM(ctx);
       GLuint count = IM->Count;
@@ -205,8 +219,8 @@ _tnl_Begin( GLenum mode )
         return;
       }
 
-      assert( IM->SavedBeginState == 0 );
-      assert( IM->BeginState == 0 );
+      assert( (IM->SavedBeginState & (VERT_BEGIN_0|VERT_BEGIN_1)) == 0 );
+      assert( (IM->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1)) == 0 );
 
       /* Not quite right.  Need to use the fallback '_aa_ArrayElement'
        * when not known to be inside begin/end and arrays are
@@ -332,7 +346,10 @@ _tnl_end( GLcontext *ctx )
    GLuint state = IM->BeginState;
    GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1);
 
-   assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES );
+   /* Not the case if vertices emitted without calling glBegin first:
+    */
+/*   assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES ); */
+
 
    state |= inflags << 2;      /* errors */
 
@@ -870,7 +887,7 @@ _tnl_Vertex4fv( const GLfloat *v )
  * don't crash.  We no-op on invalid targets.
  */
 
-#define MAX_TARGET (GL_TEXTURE0_ARB + MAX_TEXTURE_UNITS)
+#define MAX_TARGET (GL_TEXTURE0_ARB + MAX_TEXTURE_COORD_UNITS)
 
 #define MULTI_TEXCOORD1(target, s)                     \
 {                                                      \