Can't bail in sisDDLogicOpCode when logicop is off, because it's called with
[mesa.git] / src / mesa / drivers / dri / i830 / i830_render.c
index f66acd3b56452f96d37abd7e098f91464b8d28fd..498384bdb297ae3c26691a1d2fdff8b03951f254 100644 (file)
@@ -48,7 +48,6 @@
 #include "i830_context.h"
 #include "i830_tris.h"
 #include "i830_state.h"
-#include "i830_vb.h"
 #include "i830_ioctl.h"
 
 /*
@@ -110,21 +109,6 @@ static const int scale_prim[GL_POLYGON+1] = {
    3
 };
 
-/* Fallback to normal rendering.  Should now never be called.
- */
-static void VERT_FALLBACK( GLcontext *ctx,
-                          GLuint start,
-                          GLuint count,
-                          GLuint flags )
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
-   tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
-   tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, 
-                                                         count, flags );
-   I830_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
-}
-
 
 #define LOCAL_VARS i830ContextPtr imesa = I830_CONTEXT(ctx)
 #define INIT( prim ) do {                                              \
@@ -132,15 +116,17 @@ static void VERT_FALLBACK( GLcontext *ctx,
    i830RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] );      \
 } while (0)
 
-#define NEW_PRIMITIVE()  I830_STATECHANGE( imesa, 0 )
-#define NEW_BUFFER()  I830_FIREVERTICES( imesa )
+#define FLUSH()  I830_FIREVERTICES( imesa )
 #define GET_CURRENT_VB_MAX_VERTS() \
   (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
   (I830_DMA_BUF_SZ-8) / (imesa->vertex_size * 4)
   
-#define EMIT_VERTS( ctx, j, nr ) \
-  i830_emit_contiguous_verts(ctx, j, (j)+(nr))  
+
+#define ALLOC_VERTS( nr ) \
+  i830AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+  _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
   
 #define TAG(x) i830_##x
 #include "tnl_dd/t_dd_dmatmp.h"
@@ -165,7 +151,6 @@ static GLboolean choose_render( struct vertex_buffer *VB, int bufsz )
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
       GLuint prim = VB->Primitive[i].mode;
-      GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
       if (!length)
@@ -200,16 +185,15 @@ static GLboolean i830_run_render( GLcontext *ctx,
    i830ContextPtr imesa = I830_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   GLuint i, length, flags = 0;
+   GLuint i;
    /* Don't handle clipping or indexed vertices.
     */
-   if (VB->ClipOrMask || imesa->RenderIndex != 0 || VB->Elts || 
-       !choose_render( VB, GET_SUBSEQUENT_VB_MAX_VERTS() )) {
+   if (imesa->RenderIndex != 0 || 
+       !i830_validate_render( ctx, VB ) ||
+       !choose_render( VB, 200 )) { /* 200 is estimate of nr verts/buf */
       return GL_TRUE;
    }
 
-   imesa->SetupNewInputs = VERT_BIT_POS;
-
    tnl->Driver.Render.Start( ctx );
    
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
@@ -234,22 +218,7 @@ static GLboolean i830_run_render( GLcontext *ctx,
 static void i830_check_render( GLcontext *ctx, 
                               struct tnl_pipeline_stage *stage )
 {
-   GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
-   if (ctx->RenderMode == GL_RENDER) {
-      if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
-        inputs |= VERT_BIT_COLOR1;
-
-      if (ctx->Texture.Unit[0]._ReallyEnabled)
-        inputs |= VERT_BIT_TEX0;
-
-      if (ctx->Texture.Unit[1]._ReallyEnabled)
-        inputs |= VERT_BIT_TEX1;
-
-      if (ctx->Fog.Enabled)
-        inputs |= VERT_BIT_FOG;
-   }
-
-   stage->inputs = inputs;
+   stage->inputs = TNL_CONTEXT(ctx)->render_inputs;
 }
 
 static void dtr( struct tnl_pipeline_stage *stage )