Make flushing more lazy in the draw module.
[mesa.git] / src / mesa / pipe / draw / draw_private.h
index fb0aaff40d77e648b29dd76218ae3dcdfaa00e67..ebef5347ab951660ae32d5880e009b2766e0b4e9 100644 (file)
@@ -54,7 +54,8 @@
 struct vertex_header {
    unsigned clipmask:12;
    unsigned edgeflag:1;
-   unsigned pad:19;
+   unsigned pad:3;
+   unsigned vertex_id:16;
 
    float clip[4];
 
@@ -62,7 +63,7 @@ struct vertex_header {
 };
 
 /* XXX This is too large */
-#define MAX_VERTEX_SIZE ((2 + TGSI_ATTRIB_MAX) * 4 * sizeof(float))
+#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
 
 
 
@@ -125,6 +126,8 @@ struct draw_context
    struct {
       struct draw_stage *first;  /**< one of the following */
 
+      struct draw_stage *validate; 
+
       /* stages (in logical order) */
       struct draw_stage *feedback;
       struct draw_stage *flatshade;
@@ -133,7 +136,7 @@ struct draw_context
       struct draw_stage *twoside;
       struct draw_stage *offset;
       struct draw_stage *unfilled;
-      struct draw_stage *setup;  /* aka render/rasterize */
+      struct draw_stage *rasterize;
    } pipeline;
 
    /* pipe state that we need: */
@@ -170,13 +173,10 @@ struct draw_context
    uint attrib_front0, attrib_back0;
    uint attrib_front1, attrib_back1;
 
-   unsigned nr_vertices;
-
+   unsigned drawing;
    unsigned prim;   /**< current prim type: PIPE_PRIM_x */
    unsigned reduced_prim;
 
-   struct vertex_header *(*get_vertex)( struct draw_context *draw,
-                                       unsigned i );
 
    /* Post-tnl vertex cache:
     */
@@ -185,6 +185,9 @@ struct draw_context
       unsigned idx[VCACHE_SIZE + VCACHE_OVERFLOW];
       struct vertex_header *vertex[VCACHE_SIZE + VCACHE_OVERFLOW];
       unsigned overflow;
+
+      struct vertex_header *(*get_vertex)( struct draw_context *draw,
+                                           unsigned i );
    } vcache;
 
    /* Vertex shader queue:
@@ -218,6 +221,7 @@ extern struct draw_stage *draw_offset_stage( struct draw_context *context );
 extern struct draw_stage *draw_clip_stage( struct draw_context *context );
 extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
 extern struct draw_stage *draw_cull_stage( struct draw_context *context );
+extern struct draw_stage *draw_validate_stage( struct draw_context *context );
 
 
 extern void draw_free_tmps( struct draw_stage *stage );
@@ -227,9 +231,10 @@ extern void draw_alloc_tmps( struct draw_stage *stage, unsigned nr );
 extern int draw_vertex_cache_check_space( struct draw_context *draw, 
                                          unsigned nr_verts );
 
-extern void draw_vertex_cache_validate( struct draw_context *draw );
 extern void draw_vertex_cache_invalidate( struct draw_context *draw );
 extern void draw_vertex_cache_unreference( struct draw_context *draw );
+extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw );
+
 
 extern void draw_vertex_shader_queue_flush( struct draw_context *draw );
 
@@ -241,6 +246,17 @@ extern void draw_vertex_fetch( struct draw_context *draw,
                               unsigned count );
 
 
+#define DRAW_FLUSH_PRIM_QUEUE                0x1
+#define DRAW_FLUSH_VERTEX_CACHE_INVALIDATE   0x2
+#define DRAW_FLUSH_DRAW                      0x4
+
+
+void draw_do_flush( struct draw_context *draw,
+                    unsigned flags );
+
+
+
+
 /**
  * Get a writeable copy of a vertex.
  * \param stage  drawing stage info
@@ -255,6 +271,7 @@ dup_vert( struct draw_stage *stage,
 {   
    struct vertex_header *tmp = stage->tmp[idx];
    memcpy(tmp, vert, stage->draw->vertex_info.size * sizeof(float) );
+   tmp->vertex_id = ~0;
    return tmp;
 }