mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
glsl: switch ir_variable_refcount to linear_ctx
Compiling my shader-db with the gallium noop driver is 6.8% faster now. Theoretical stat-based results are below, which don't always reflect real results. When compiling Heaven shaders with the gallium noop driver, 134610 calloc calls are removed. 134610 / ralloc count = 6%, so it's roughly the equivalent of 6% of the cost of all ralloc calls that's removed. The shift from calloc to linear_alloc increases ralloc calls by 0.4%, so the approximate reduction is 6% -> 0.4% overhead change. Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36539>
This commit is contained in:
parent
dfe45d1b67
commit
8462b1dc71
3 changed files with 9 additions and 23 deletions
|
|
@ -37,31 +37,15 @@
|
|||
|
||||
ir_variable_refcount_visitor::ir_variable_refcount_visitor()
|
||||
{
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->linalloc = linear_context(ralloc_context(NULL));
|
||||
this->ht = _mesa_pointer_hash_table_create(NULL);
|
||||
this->global = true;
|
||||
}
|
||||
|
||||
static void
|
||||
free_entry(struct hash_entry *entry)
|
||||
{
|
||||
ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *) entry->data;
|
||||
|
||||
/* Free assignment list */
|
||||
ir_exec_node *n;
|
||||
while ((n = ivre->assign_list.pop_head()) != NULL) {
|
||||
struct assignment_entry *assignment_entry =
|
||||
ir_exec_node_data(struct assignment_entry, n, link);
|
||||
free(assignment_entry);
|
||||
}
|
||||
|
||||
delete ivre;
|
||||
}
|
||||
|
||||
ir_variable_refcount_visitor::~ir_variable_refcount_visitor()
|
||||
{
|
||||
ralloc_free(this->mem_ctx);
|
||||
_mesa_hash_table_destroy(this->ht, free_entry);
|
||||
ralloc_free(ralloc_parent_of_linear_context(this->linalloc));
|
||||
_mesa_hash_table_destroy(this->ht, NULL);
|
||||
}
|
||||
|
||||
// constructor
|
||||
|
|
@ -83,7 +67,7 @@ ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
|
|||
if (e)
|
||||
return (ir_variable_refcount_entry *)e->data;
|
||||
|
||||
ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
|
||||
ir_variable_refcount_entry *entry = new(linalloc) ir_variable_refcount_entry(var);
|
||||
assert(entry->referenced_count == 0);
|
||||
_mesa_hash_table_insert(this->ht, var, entry);
|
||||
|
||||
|
|
@ -149,7 +133,8 @@ ir_variable_refcount_visitor::visit_leave(ir_assignment *ir)
|
|||
assert(entry->referenced_count >= entry->assigned_count);
|
||||
if (entry->referenced_count == entry->assigned_count) {
|
||||
struct assignment_entry *assignment_entry =
|
||||
(struct assignment_entry *)calloc(1, sizeof(*assignment_entry));
|
||||
(struct assignment_entry *)linear_zalloc(this->linalloc,
|
||||
struct assignment_entry);
|
||||
assignment_entry->assign = ir;
|
||||
entry->assign_list.push_head(&assignment_entry->link);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ struct assignment_entry {
|
|||
class ir_variable_refcount_entry
|
||||
{
|
||||
public:
|
||||
DECLARE_LINEAR_ALLOC_CXX_OPERATORS(ir_variable_refcount_entry,,)
|
||||
|
||||
ir_variable_refcount_entry(ir_variable *var);
|
||||
|
||||
ir_variable *var; /* The key: the variable's pointer. */
|
||||
|
|
@ -90,7 +92,7 @@ public:
|
|||
*/
|
||||
struct hash_table *ht;
|
||||
|
||||
void *mem_ctx;
|
||||
linear_ctx *linalloc;
|
||||
|
||||
bool global;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ do_dead_code(ir_exec_list *instructions)
|
|||
}
|
||||
|
||||
assignment_entry->link.remove();
|
||||
free(assignment_entry);
|
||||
}
|
||||
progress = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue