draw: implement pipeline statistics in the draw module
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_vsplit.c
index a6875253094a7731635860c6c0598cd75393bedb..c2d2a8fd555a8ad2f8f5acf9b5bd8f462cfe7f8c 100644 (file)
@@ -85,7 +85,12 @@ vsplit_flush_cache(struct vsplit_frontend *vsplit, unsigned flags)
 static INLINE void
 vsplit_add_cache(struct vsplit_frontend *vsplit, unsigned fetch)
 {
-   unsigned hash = fetch % MAP_SIZE;
+   struct draw_context *draw = vsplit->draw;
+   unsigned hash;
+
+   fetch = MIN2(fetch, draw->pt.max_index);
+
+   hash = fetch % MAP_SIZE;
 
    if (vsplit->cache.fetches[hash] != fetch) {
       /* update cache */
@@ -173,11 +178,14 @@ static void vsplit_prepare(struct draw_pt_front_end *frontend,
 }
 
 
-static void vsplit_finish(struct draw_pt_front_end *frontend)
+static void vsplit_flush(struct draw_pt_front_end *frontend, unsigned flags)
 {
    struct vsplit_frontend *vsplit = (struct vsplit_frontend *) frontend;
-   vsplit->middle->finish(vsplit->middle);
-   vsplit->middle = NULL;
+
+   if (flags & DRAW_FLUSH_STATE_CHANGE) {
+      vsplit->middle->finish(vsplit->middle);
+      vsplit->middle = NULL;
+   }
 }
 
 
@@ -197,7 +205,7 @@ struct draw_pt_front_end *draw_pt_vsplit(struct draw_context *draw)
 
    vsplit->base.prepare = vsplit_prepare;
    vsplit->base.run     = NULL;
-   vsplit->base.finish  = vsplit_finish;
+   vsplit->base.flush   = vsplit_flush;
    vsplit->base.destroy = vsplit_destroy;
    vsplit->draw = draw;