struct pipe_context *pipe;
unsigned size; /* Size of the whole buffer, in bytes. */
- unsigned alignment; /* Alignment of each sub-allocation. */
unsigned bind; /* Bitmask of PIPE_BIND_* flags. */
enum pipe_resource_usage usage;
boolean zero_buffer_memory; /* If the buffer contents should be zeroed. */
* cleared to 0 after the allocation.
*/
struct u_suballocator *
-u_suballocator_create(struct pipe_context *pipe, unsigned size,
- unsigned alignment, unsigned bind,
+u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind,
enum pipe_resource_usage usage,
boolean zero_buffer_memory)
{
return NULL;
allocator->pipe = pipe;
- allocator->size = align(size, alignment);
- allocator->alignment = alignment;
+ allocator->size = size;
allocator->bind = bind;
allocator->usage = usage;
allocator->zero_buffer_memory = zero_buffer_memory;
void
u_suballocator_alloc(struct u_suballocator *allocator, unsigned size,
- unsigned *out_offset, struct pipe_resource **outbuf)
+ unsigned alignment, unsigned *out_offset,
+ struct pipe_resource **outbuf)
{
- unsigned alloc_size = align(size, allocator->alignment);
+ allocator->offset = align(allocator->offset, alignment);
/* Don't allow allocations larger than the buffer size. */
- if (alloc_size > allocator->size)
+ if (size > allocator->size)
goto fail;
/* Make sure we have enough space in the buffer. */
if (!allocator->buffer ||
- allocator->offset + alloc_size > allocator->size) {
+ allocator->offset + size > allocator->size) {
/* Allocate a new buffer. */
pipe_resource_reference(&allocator->buffer, NULL);
allocator->offset = 0;
}
}
- assert(allocator->offset % allocator->alignment == 0);
+ assert(allocator->offset % alignment == 0);
assert(allocator->offset < allocator->buffer->width0);
- assert(allocator->offset + alloc_size <= allocator->buffer->width0);
+ assert(allocator->offset + size <= allocator->buffer->width0);
/* Return the buffer. */
*out_offset = allocator->offset;
pipe_resource_reference(outbuf, allocator->buffer);
- allocator->offset += alloc_size;
+ allocator->offset += size;
return;
fail:
struct u_suballocator;
struct u_suballocator *
-u_suballocator_create(struct pipe_context *pipe, unsigned size,
- unsigned alignment, unsigned bind,
+u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind,
enum pipe_resource_usage usage,
boolean zero_buffer_memory);
void
u_suballocator_alloc(struct u_suballocator *allocator, unsigned size,
- unsigned *out_offset, struct pipe_resource **outbuf);
+ unsigned alignment, unsigned *out_offset,
+ struct pipe_resource **outbuf);
#endif