Mesa (master): i915g: Improve the flush heuristic by using the previous frame' s number of vertices.
Stephane Marchesin
marcheu at kemper.freedesktop.org
Fri Aug 26 05:57:11 UTC 2011
Module: Mesa
Branch: master
Commit: b97889f543085f516fc1c821c621790399d57fa5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b97889f543085f516fc1c821c621790399d57fa5
Author: Stéphane Marchesin <marcheu at chromium.org>
Date: Tue Aug 23 18:44:36 2011 -0700
i915g: Improve the flush heuristic by using the previous frame's number of vertices.
---
src/gallium/drivers/i915/i915_batch.h | 13 +++++++++----
src/gallium/drivers/i915/i915_clear.c | 3 +++
src/gallium/drivers/i915/i915_context.h | 5 ++++-
src/gallium/drivers/i915/i915_flush.c | 3 ++-
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/i915/i915_batch.h b/src/gallium/drivers/i915/i915_batch.h
index a1f8bca..56d331f 100644
--- a/src/gallium/drivers/i915/i915_batch.h
+++ b/src/gallium/drivers/i915/i915_batch.h
@@ -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;
+ }
}
diff --git a/src/gallium/drivers/i915/i915_clear.c b/src/gallium/drivers/i915/i915_clear.c
index e1d6a74..4f9aa2c 100644
--- a/src/gallium/drivers/i915/i915_clear.c
+++ b/src/gallium/drivers/i915/i915_clear.c
@@ -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;
}
/**
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 8486235..fca8688 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -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;
diff --git a/src/gallium/drivers/i915/i915_flush.c b/src/gallium/drivers/i915/i915_flush.c
index 6d76afa..5d8e3c8 100644
--- a/src/gallium/drivers/i915/i915_flush.c
+++ b/src/gallium/drivers/i915/i915_flush.c
@@ -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;
}
More information about the mesa-commit
mailing list