i915g: Improve the flush heuristic by using the previous frame's number of vertices.
authorStéphane Marchesin <marcheu@chromium.org>
Wed, 24 Aug 2011 01:44:36 +0000 (18:44 -0700)
committerStéphane Marchesin <marcheu@chromium.org>
Fri, 26 Aug 2011 05:57:48 +0000 (22:57 -0700)
src/gallium/drivers/i915/i915_batch.h
src/gallium/drivers/i915/i915_clear.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_flush.c

index a1f8bcae802e712981adb5bb76a9242818fbb720..56d331f3e7af3ec8f173165d5d170135edff29fa 100644 (file)
@@ -64,11 +64,16 @@ static INLINE void i915_flush_heuristically(struct i915_context* i915,
                                             int num_vertex)
 {
    struct i915_winsys *iws = i915->iws;
-   i915->vertices_since_last_flush += num_vertex;
-   if ( i915->vertices_since_last_flush > 4096
-      || ( i915->vertices_since_last_flush > 256 &&
-           !iws->buffer_is_busy(iws, i915->current.cbuf_bo)) )
+
+   i915->queued_vertices += num_vertex;
+
+   /* fire if we have more than 1/20th of the last frame's vertices */
+   if (i915->queued_vertices > i915->last_fired_vertices / 20) {
       FLUSH_BATCH(NULL);
+      i915->fired_vertices += i915->queued_vertices;
+      i915->queued_vertices = 0;
+      return;
+   }
 }
 
 
index e1d6a749cdc8cf6038029070b94f22e20f48f93c..4f9aa2c312036053abb2c3e9740fdd6aecabce3b 100644 (file)
@@ -125,6 +125,9 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
     * This is not required, just a heuristic
     */
    FLUSH_BATCH(NULL);
+
+   i915->last_fired_vertices = i915->fired_vertices;
+   i915->fired_vertices = 0;
 }
 
 /**
index 84862351ffeedbab8e04d51fcc036bbe7e832bd3..fca8688a52607a3da4a9a8cd87de589ff34192aa 100644 (file)
@@ -264,7 +264,10 @@ struct i915_context {
    struct util_slab_mempool transfer_pool;
    struct util_slab_mempool texture_transfer_pool;
 
-   int vertices_since_last_flush;
+   /* state for tracking flushes */
+   int last_fired_vertices;
+   int fired_vertices;
+   int queued_vertices;
 
    /** blitter/hw-clear */
    struct blitter_context* blitter;
index 6d76afa9dbc668e9760ff8e585f64d428e6fc9e2..5d8e3c8274f5a7e10b66bdf6462cf70bc58ef09c 100644 (file)
@@ -77,5 +77,6 @@ void i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence)
    i915->static_dirty = ~0;
    /* kernel emits flushes in between batchbuffers */
    i915->flush_dirty = 0;
-   i915->vertices_since_last_flush = 0;
+   i915->fired_vertices += i915->queued_vertices;
+   i915->queued_vertices = 0;
 }