summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-09-07 16:23:22 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-09-07 16:23:22 +0000
commit1456a0fff6a68dac046aaa57585eadf65ad66892 (patch)
tree0e00c34aa2d3ae1c644e2057a9c92b792c10aba2
parent133f14168009393c5f396d218521625cb79b653f (diff)
Use lower alignments where possible. Also pad out allocated blocks to
a multiple of alignment to avoid accumulating unusable free blocks.
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_pool.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/bufmgr.h3
-rw-r--r--src/mesa/drivers/dri/i965/bufmgr_fake.c19
-rw-r--r--src/mesa/drivers/dri/i965/intel_batchbuffer.c2
-rw-r--r--src/mesa/drivers/dri/i965/intel_buffer_objects.c2
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.c2
7 files changed, 20 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_state_pool.c b/src/mesa/drivers/dri/i965/brw_state_pool.c
index 60565bf83c..2b469638cf 100644
--- a/src/mesa/drivers/dri/i965/brw_state_pool.c
+++ b/src/mesa/drivers/dri/i965/brw_state_pool.c
@@ -95,7 +95,7 @@ static void brw_init_pool( struct brw_context *brw,
pool->size = size;
pool->brw = brw;
- bmGenBuffers(&brw->intel, "pool", 1, &pool->buffer);
+ bmGenBuffers(&brw->intel, "pool", 1, &pool->buffer, 0);
/* Also want to say not to wait on fences when data is presented
*/
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index accf1243ec..4707a709e7 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -79,7 +79,7 @@ static void upload_wm_unit(struct brw_context *brw )
*/
if (!brw->wm.scratch_buffer) {
- bmGenBuffers(intel, "wm scratch", 1, &brw->wm.scratch_buffer);
+ bmGenBuffers(intel, "wm scratch", 1, &brw->wm.scratch_buffer, 12);
bmBufferSetInvalidateCB(intel,
brw->wm.scratch_buffer,
invalidate_scratch_cb,
diff --git a/src/mesa/drivers/dri/i965/bufmgr.h b/src/mesa/drivers/dri/i965/bufmgr.h
index 50fbcda50b..63e1011a76 100644
--- a/src/mesa/drivers/dri/i965/bufmgr.h
+++ b/src/mesa/drivers/dri/i965/bufmgr.h
@@ -84,7 +84,8 @@ int bmInitPool( struct intel_context *,
* understood, and drivers can just pass the calls through without too
* much thunking.
*/
-void bmGenBuffers(struct intel_context *, const char *, unsigned n, struct buffer **buffers);
+void bmGenBuffers(struct intel_context *, const char *, unsigned n, struct buffer **buffers,
+ int align );
void bmDeleteBuffers(struct intel_context *, unsigned n, struct buffer **buffers);
diff --git a/src/mesa/drivers/dri/i965/bufmgr_fake.c b/src/mesa/drivers/dri/i965/bufmgr_fake.c
index b9f1553c74..1cb3f67b34 100644
--- a/src/mesa/drivers/dri/i965/bufmgr_fake.c
+++ b/src/mesa/drivers/dri/i965/bufmgr_fake.c
@@ -163,10 +163,16 @@ static GLboolean alloc_from_pool( struct intel_context *intel,
struct bufmgr *bm = intel->bm;
struct pool *pool = &bm->pool[pool_nr];
struct block *block = (struct block *)calloc(sizeof *block, 1);
+ GLuint sz, align = (1<<buf->alignment);
+
if (!block)
return GL_FALSE;
- block->mem = mmAllocMem(pool->heap, buf->size, buf->alignment, 0);
+ sz = (buf->size + align-1) & ~(align-1);
+
+ block->mem = mmAllocMem(pool->heap,
+ sz,
+ buf->alignment, 0);
if (!block->mem) {
free(block);
return GL_FALSE;
@@ -621,14 +627,14 @@ int bmInitPool( struct intel_context *intel,
return retval;
}
-static struct buffer *do_GenBuffer(struct intel_context *intel, const char *name)
+static struct buffer *do_GenBuffer(struct intel_context *intel, const char *name, int align)
{
struct bufmgr *bm = intel->bm;
struct buffer *buf = calloc(sizeof(*buf), 1);
buf->id = ++bm->buf_nr;
buf->name = name;
- buf->alignment = 12; /* page-alignment to fit in with AGP swapping */
+ buf->alignment = align ? align : 6;
buf->flags = BM_MEM_AGP|BM_MEM_VRAM|BM_MEM_LOCAL;
return buf;
@@ -638,7 +644,8 @@ static struct buffer *do_GenBuffer(struct intel_context *intel, const char *name
void bmGenBuffers(struct intel_context *intel,
const char *name, unsigned n,
- struct buffer **buffers)
+ struct buffer **buffers,
+ int align )
{
struct bufmgr *bm = intel->bm;
LOCK(bm);
@@ -646,7 +653,7 @@ void bmGenBuffers(struct intel_context *intel,
int i;
for (i = 0; i < n; i++)
- buffers[i] = do_GenBuffer(intel, name);
+ buffers[i] = do_GenBuffer(intel, name, align);
}
UNLOCK(bm);
}
@@ -694,7 +701,7 @@ struct buffer *bmGenBufferStatic(struct intel_context *intel,
if (bm->pool[pool].static_buffer)
buf = bm->pool[pool].static_buffer;
else {
- buf = do_GenBuffer(intel, "static");
+ buf = do_GenBuffer(intel, "static", 12);
bm->pool[pool].static_buffer = buf;
assert(!buf->block);
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 441412a7c2..7510ac5b92 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -92,7 +92,7 @@ struct intel_batchbuffer *intel_batchbuffer_alloc( struct intel_context *intel )
batch->intel = intel;
- bmGenBuffers(intel, "batch", 1, &batch->buffer);
+ bmGenBuffers(intel, "batch", 1, &batch->buffer, 12);
bmBufferSetInvalidateCB(intel, batch->buffer,
intel_batchbuffer_reset_cb,
diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
index 0f88583635..015e433fd7 100644
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
@@ -52,7 +52,7 @@ static struct gl_buffer_object *intel_bufferobj_alloc( GLcontext *ctx,
/* XXX: We generate our own handle, which is different to 'name' above.
*/
- bmGenBuffers(intel, "bufferobj", 1, &obj->buffer);
+ bmGenBuffers(intel, "bufferobj", 1, &obj->buffer, 6);
assert(obj->buffer);
return &obj->Base;
diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c
index e2cb427304..51495448ca 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/src/mesa/drivers/dri/i965/intel_regions.c
@@ -82,7 +82,7 @@ struct intel_region *intel_region_alloc( struct intel_context *intel,
region->height = height; /* needed? */
region->refcount = 1;
- bmGenBuffers(intel, "tex", 1, &region->buffer);
+ bmGenBuffers(intel, "tex", 1, &region->buffer, 6);
bmBufferData(intel, region->buffer, pitch * cpp * height, NULL, 0);
return region;