util: Add a way to set the min_buffer_size in linear_alloc

The default value remains 2048, which is also used for rounding up
any user provided size.

The option is useful in cases where there's a better idea of the
amount of data that's going to be used.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25279>
This commit is contained in:
Caio Oliveira
2023-10-02 22:35:04 -07:00
committed by Marge Bot
parent 39c8cca34f
commit 89afcc94ea
3 changed files with 47 additions and 7 deletions
+6
View File
@@ -579,6 +579,10 @@ typedef struct linear_ctx linear_ctx;
*/
void *linear_alloc_child(linear_ctx *ctx, unsigned size);
typedef struct {
unsigned min_buffer_size;
} linear_opts;
/**
* Allocate a linear context that will internally hold linear buffers.
* Use it for all child node allocations.
@@ -587,6 +591,8 @@ void *linear_alloc_child(linear_ctx *ctx, unsigned size);
*/
linear_ctx *linear_context(void *ralloc_ctx);
linear_ctx *linear_context_with_opts(void *ralloc_ctx, const linear_opts *opts);
/**
* Same as linear_alloc_child, but also clears memory.
*/