a multiple of alignment to avoid accumulating unusable free blocks.
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
*/
*/
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,
* 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);
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;
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;
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);
int i;
for (i = 0; i < n; i++)
- buffers[i] = do_GenBuffer(intel, name);
+ buffers[i] = do_GenBuffer(intel, name, align);
}
UNLOCK(bm);
}
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);
batch->intel = intel;
- bmGenBuffers(intel, "batch", 1, &batch->buffer);
+ bmGenBuffers(intel, "batch", 1, &batch->buffer, 12);
bmBufferSetInvalidateCB(intel, batch->buffer,
intel_batchbuffer_reset_cb,
/* 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;
region->height = height; /* needed? */
region->refcount = 1;
- bmGenBuffers(intel, "tex", 1, ®ion->buffer);
+ bmGenBuffers(intel, "tex", 1, ®ion->buffer, 6);
bmBufferData(intel, region->buffer, pitch * cpp * height, NULL, 0);
return region;