summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Bornecrantz <wallbraker@gmail.com>2009-09-08 20:40:37 +0100
committerJakob Bornecrantz <jakob@vmware.com>2009-09-09 00:43:35 +0100
commitd585616f5bb950b3ed0b1142498e06f4dca98559 (patch)
tree0c96b7f261e44ceb0f6913bc3b35a6c86d87b9cb
parent6e61d062093a71e267aed02870607fc5a0d7d8f4 (diff)
i915g: Keep vertex buffers in a fifo
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index 508f4560e4..f10f10a72a 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -44,6 +44,7 @@
#include "pipe/p_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_fifo.h"
#include "i915_context.h"
#include "i915_reg.h"
@@ -78,6 +79,11 @@ struct i915_vbuf_render {
void *vbo_ptr;
size_t vbo_alloc_size;
size_t vbo_max_used;
+
+ /* stuff for the pool */
+ struct util_fifo *pool_fifo;
+ unsigned pool_used;
+ boolean pool_not_used;
};
@@ -120,9 +126,14 @@ i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) {
} else {
+ if (i915->vbo_flushed)
+ i915_render->pool_used = 0;
i915->vbo_flushed = 0;
if (i915_render->vbo) {
- iws->buffer_destroy(iws, i915_render->vbo);
+ if (i915_render->pool_not_used)
+ iws->buffer_destroy(iws, i915_render->vbo);
+ else
+ u_fifo_add(i915_render->pool_fifo, i915_render->vbo);
i915_render->vbo = NULL;
}
}
@@ -130,9 +141,21 @@ i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
if (!i915_render->vbo) {
i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
i915_render->vbo_offset = 0;
- i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
- INTEL_NEW_VERTEX);
+ if (i915_render->vbo_size != i915_render->vbo_alloc_size) {
+ i915_render->pool_not_used = TRUE;
+ i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
+ INTEL_NEW_VERTEX);
+ } else {
+ i915_render->pool_not_used = FALSE;
+
+ if (i915_render->pool_used >= 2) {
+ FLUSH_BATCH(NULL);
+ i915->vbo_flushed = 0;
+ i915_render->pool_used = 0;
+ }
+ u_fifo_pop(i915_render->pool_fifo, (void**)&i915_render->vbo);
+ }
}
i915_render->vertex_size = vertex_size;
@@ -504,6 +527,7 @@ i915_vbuf_render_create(struct i915_context *i915)
{
struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
struct intel_winsys *iws = i915->iws;
+ int i;
i915_render->i915 = i915;
@@ -527,8 +551,15 @@ i915_vbuf_render_create(struct i915_context *i915)
i915_render->vbo_alloc_size = 128 * 4096;
i915_render->vbo_size = i915_render->vbo_alloc_size;
i915_render->vbo_offset = 0;
- i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
- INTEL_NEW_VERTEX);
+
+ i915_render->pool_fifo = u_fifo_create(6);
+ for (i = 0; i < 6; i++)
+ u_fifo_add(i915_render->pool_fifo,
+ iws->buffer_create(iws, i915_render->vbo_size, 64,
+ INTEL_NEW_VERTEX));
+ u_fifo_pop(i915_render->pool_fifo, (void**)&i915_render->vbo);
+ i915_render->pool_used = 1;
+
/* TODO JB: is this realy needed? */
i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE);
iws->buffer_unmap(iws, i915_render->vbo);