Fixes from https://bugs.freedesktop.org/attachment.cgi?id=3077
[mesa.git] / src / mesa / drivers / dri / unichrome / via_render.c
index 8e4efd220f90eed96e97d3e0568e6a5367718c1e..387473ef5229f1f9bfede21b410f6234cde52407 100644 (file)
@@ -38,7 +38,6 @@
 #include "via_context.h"
 #include "via_tris.h"
 #include "via_state.h"
-#include "via_vb.h"
 #include "via_ioctl.h"
 
 /*
@@ -52,7 +51,7 @@
 #define HAVE_LINE_LOOP   1
 #define HAVE_TRIANGLES   1
 #define HAVE_TRI_STRIPS  1
-#define HAVE_TRI_STRIP_1 0      /* has it, template can't use it yet */
+#define HAVE_TRI_STRIP_1 0  
 #define HAVE_TRI_FANS    1
 #define HAVE_POLYGONS    1
 #define HAVE_QUADS       0
@@ -60,7 +59,7 @@
 
 #define HAVE_ELTS        0
 
-#define LOCAL_VARS viaContextPtr vmesa = VIA_CONTEXT(ctx)
+#define LOCAL_VARS struct via_context *vmesa = VIA_CONTEXT(ctx)
 #define INIT(prim) do {                                        \
    viaRasterPrimitive(ctx, prim, prim);        \
 } while (0)
@@ -73,7 +72,7 @@
     viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
 
 #define EMIT_VERTS(ctx, j, nr, buf) \
-    via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
+    _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )  
     
 #define FLUSH() VIA_FINISH_PRIM( vmesa )
 
 static GLboolean via_run_fastrender(GLcontext *ctx,
                                     struct tnl_pipeline_stage *stage)
 {
-    viaContextPtr vmesa = VIA_CONTEXT(ctx);
+    struct via_context *vmesa = VIA_CONTEXT(ctx);
     TNLcontext *tnl = TNL_CONTEXT(ctx);
     struct vertex_buffer *VB = &tnl->vb;
     GLuint i;
     
-    /* Don't handle clipping or indexed vertices.
-     */
+
+    tnl->Driver.Render.Start(ctx);
+    
     if (VB->ClipOrMask || 
        vmesa->renderIndex != 0 || 
        !via_fastvalidate_render( ctx, VB )) {
-       if (VIA_DEBUG) { 
-           fprintf(stderr, "slow path\n");    
-           fprintf(stderr, "ClipOrMask = %08x\n", VB->ClipOrMask);
-           fprintf(stderr, "renderIndex = %08x\n", vmesa->renderIndex);        
-           fprintf(stderr, "Elts = %08x\n", (GLuint)VB->Elts); 
-       }           
+       tnl->Driver.Render.Finish(ctx);
         return GL_TRUE;
     }
-    if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);    
-    vmesa->setupNewInputs = VERT_BIT_CLIP;
 
-    tnl->Driver.Render.Start(ctx);
-    
+    tnl->clipspace.new_inputs |= VERT_BIT_POS;
+
     for (i = 0; i < VB->PrimitiveCount; ++i) {
         GLuint mode = VB->Primitive[i].mode;
         GLuint start = VB->Primitive[i].start;
@@ -121,53 +114,17 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
     }
 
     tnl->Driver.Render.Finish(ctx);
-    
-    if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);    
-    return GL_FALSE;            /* finished the pipe */
-}
 
-
-static void via_check_fastrender(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
-    GLuint inputs = VERT_BIT_CLIP | 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;
-}
-
-
-static void fastdtr(struct tnl_pipeline_stage *stage)
-{
-    (void)stage;
+    return GL_FALSE;            /* finished the pipe */
 }
 
-
 const struct tnl_pipeline_stage _via_fastrender_stage =
 {
     "via fast render",
-    (_DD_NEW_SEPARATE_SPECULAR |
-     _NEW_TEXTURE|
-     _NEW_FOG|
-     _NEW_RENDERMODE),           /* re-check (new inputs) */
-    0,                           /* re-run (always runs) */
-    GL_TRUE,                     /* active */
-    0, 0,                        /* inputs (set in check_render), outputs */
-    0, 0,                        /* changed_inputs, private */
-    fastdtr,                     /* destructor */
-    via_check_fastrender,        /* check - initially set to alloc data */
+    NULL,
+    NULL,
+    NULL,
+    NULL,
     via_run_fastrender           /* run */
 };