glcpp_lex_init_extra (parser, &parser->scanner);
parser->defines = _mesa_hash_table_create(NULL, _mesa_hash_string,
_mesa_key_string_equal);
- parser->linalloc = linear_alloc_parent(parser, 0);
+ parser->linalloc = linear_alloc_parent(parser);
parser->active = NULL;
parser->lexing_directive = 0;
parser->lexing_version_directive = 0;
this->translation_unit.make_empty();
this->symbols = new(mem_ctx) glsl_symbol_table;
- this->linalloc = linear_alloc_parent(this, 0);
+ this->linalloc = linear_alloc_parent(this);
this->info_log = ralloc_strdup(mem_ctx, "");
this->error = false;
this->separate_function_namespace = false;
this->table = _mesa_symbol_table_ctor();
this->mem_ctx = ralloc_context(NULL);
- this->linalloc = linear_alloc_parent(this->mem_ctx, 0);
+ this->linalloc = linear_alloc_parent(this->mem_ctx);
}
glsl_symbol_table::~glsl_symbol_table()
bool progress = false;
void *ctx = ralloc_context(NULL);
- void *lin_ctx = linear_alloc_parent(ctx, 0);
+ void *lin_ctx = linear_alloc_parent(ctx);
/* Safe looping, since process_assignment */
for (ir = first, ir_next = (ir_instruction *)first->next;;
simple_mtx_lock(&glsl_type_cache_mutex);
if (glsl_type_cache.users == 0) {
glsl_type_cache.mem_ctx = ralloc_context(NULL);
- glsl_type_cache.lin_ctx = linear_zalloc_parent(glsl_type_cache.mem_ctx, 0);
+ glsl_type_cache.lin_ctx = linear_alloc_parent(glsl_type_cache.mem_ctx);
}
glsl_type_cache.users++;
simple_mtx_unlock(&glsl_type_cache_mutex);
void *mem_ctx = ralloc_context(NULL);
struct combine_stores_state state = {
.modes = modes,
- .lin_ctx = linear_zalloc_parent(mem_ctx, 0),
+ .lin_ctx = linear_alloc_parent(mem_ctx),
};
list_inithead(&state.pending);
struct copy_prop_var_state state = {
.impl = impl,
.mem_ctx = mem_ctx,
- .lin_ctx = linear_zalloc_parent(mem_ctx, 0),
+ .lin_ctx = linear_alloc_parent(mem_ctx),
.vars_written_map = _mesa_pointer_hash_table_create(mem_ctx),
};
nir_vars_test::nir_vars_test()
: nir_test::nir_test("nir_vars_test")
{
- lin_ctx = linear_alloc_parent(b->shader, 0);
+ lin_ctx = linear_alloc_parent(b->shader);
}
nir_vars_test::~nir_vars_test()
typedef struct linear_header linear_header;
typedef struct linear_size_chunk linear_size_chunk;
-#define LINEAR_PARENT_TO_HEADER(parent) \
- (linear_header*) \
- ((char*)(parent) - sizeof(linear_size_chunk) - sizeof(linear_header))
-
/* Allocate the linear buffer with its header. */
static linear_header *
create_linear_node(void *ralloc_ctx, unsigned min_size)
void *
linear_alloc_child(void *parent, unsigned size)
{
- linear_header *first = LINEAR_PARENT_TO_HEADER(parent);
+ linear_header *first = parent;
linear_header *latest = first->latest;
linear_header *new_node;
linear_size_chunk *ptr;
}
void *
-linear_alloc_parent(void *ralloc_ctx, unsigned size)
+linear_alloc_parent(void *ralloc_ctx)
{
linear_header *node;
if (unlikely(!ralloc_ctx))
return NULL;
- size = ALIGN_POT(size, SUBALLOC_ALIGNMENT);
-
- node = create_linear_node(ralloc_ctx, size);
+ node = create_linear_node(ralloc_ctx, 0);
if (unlikely(!node))
return NULL;
- return linear_alloc_child((char*)node +
- sizeof(linear_header) +
- sizeof(linear_size_chunk), size);
+ return node;
}
void *
return ptr;
}
-void *
-linear_zalloc_parent(void *parent, unsigned size)
-{
- void *ptr = linear_alloc_parent(parent, size);
-
- if (likely(ptr))
- memset(ptr, 0, size);
- return ptr;
-}
-
void
linear_free_parent(void *ptr)
{
if (unlikely(!ptr))
return;
- linear_header *first = LINEAR_PARENT_TO_HEADER(ptr);
+ linear_header *first = ptr;
assert(first->magic == LMAGIC);
/* Other nodes are ralloc children of the first node. */
if (unlikely(!ptr))
return;
- linear_header *first = LINEAR_PARENT_TO_HEADER(ptr);
+ linear_header *first = ptr;
assert(first->magic == LMAGIC);
/* Other nodes are ralloc children of the first node. */
void *
ralloc_parent_of_linear_parent(void *ptr)
{
- linear_header *node = LINEAR_PARENT_TO_HEADER(ptr);
+ linear_header *node = ptr;
assert(node->magic == LMAGIC);
return PTR_FROM_HEADER(get_header(node)->parent);
}
#define DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(type) \
DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, linear_zalloc_child)
-
/**
* Do a fast allocation from the linear buffer, also known as the child node
* from the allocator's point of view. It can't be freed directly. You have
void *linear_alloc_child(void *parent, unsigned size) MALLOCLIKE;
/**
- * Allocate a parent node that will hold linear buffers. The returned
- * allocation is actually the first child node, but it's also the handle
- * of the parent node. Use it for all child node allocations.
+ * Allocate a parent node that will hold linear buffers.
+ * Use it for all child node allocations.
*
* \param ralloc_ctx ralloc context, must not be NULL
- * \param size size to allocate (max 32 bits)
*/
-void *linear_alloc_parent(void *ralloc_ctx, unsigned size) MALLOCLIKE;
+void *linear_alloc_parent(void *ralloc_ctx);
/**
* Same as linear_alloc_child, but also clears memory.
void *linear_zalloc_child(void *parent, unsigned size) MALLOCLIKE;
/**
- * Same as linear_alloc_parent, but also clears memory.
- */
-void *linear_zalloc_parent(void *ralloc_ctx, unsigned size) MALLOCLIKE;
-
-/**
* Free the linear parent node. This will free all child nodes too.
* Freeing the ralloc parent will also free this.
*/