[Mesa-dev] [PATCH 3/8] glsl: Change ir_const_expr to use util/hash_table

Thomas Helland thomashelland90 at gmail.com
Sat Feb 28 04:53:49 PST 2015


This is faster than program_hash_table,
and we don't need the extra capabilities.

Results from oprofile on a shader-db run:
mesa_hash_data	        3.09 ---> 3.05
hash_table_insert       2.57 ---> 2.58
hash_table_search       2.67 ---> 2.72
runtime	                170  ---> 162
---
 src/glsl/ir_constant_expression.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 07dd439..94c6fe0 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -37,7 +37,7 @@
 #include "main/core.h" /* for MAX2, MIN2, CLAMP */
 #include "ir.h"
 #include "glsl_types.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
 
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
 static int isnormal(double x)
@@ -480,7 +480,8 @@ constant_referenced(const ir_dereference *deref,
       const ir_dereference_variable *const dv =
          (const ir_dereference_variable *) deref;
 
-      store = (ir_constant *) hash_table_find(variable_context, dv->var);
+      store = (ir_constant *) _mesa_hash_table_search(
+            variable_context, dv->var);
       break;
    }
 
@@ -1863,7 +1864,8 @@ ir_dereference_variable::constant_expression_value(struct hash_table *variable_c
 
    /* Give priority to the context hashtable, if it exists */
    if (variable_context) {
-      ir_constant *value = (ir_constant *)hash_table_find(variable_context, var);
+      ir_constant *value = (ir_constant *)_mesa_hash_table_search(
+            variable_context, var);
       if(value)
 	 return value;
    }
@@ -1983,7 +1985,7 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s
 	 /* (declare () type symbol) */
       case ir_type_variable: {
 	 ir_variable *var = inst->as_variable();
-	 hash_table_insert(variable_context, ir_constant::zero(this, var->type), var);
+	 _mesa_hash_table_insert(variable_context, ir_constant::zero(this, var->type), var);
 	 break;
       }
 
@@ -2107,8 +2109,8 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s
     * We expect the correctness of the number of parameters to have
     * been checked earlier.
     */
-   hash_table *deref_hash = hash_table_ctor(8, hash_table_pointer_hash,
-					    hash_table_pointer_compare);
+   hash_table *deref_hash = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+         _mesa_key_pointer_equal);
 
    /* If "origin" is non-NULL, then the function body is there.  So we
     * have to use the variable objects from the object with the body,
@@ -2119,13 +2121,13 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s
    foreach_in_list(ir_rvalue, n, actual_parameters) {
       ir_constant *constant = n->constant_expression_value(variable_context);
       if (constant == NULL) {
-         hash_table_dtor(deref_hash);
+         _mesa_hash_table_destroy(deref_hash, NULL);
          return NULL;
       }
 
 
       ir_variable *var = (ir_variable *)parameter_info;
-      hash_table_insert(deref_hash, constant, var);
+      _mesa_hash_table_insert(deref_hash, constant, var);
 
       parameter_info = parameter_info->next;
    }
@@ -2138,7 +2140,7 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s
    if (constant_expression_evaluate_expression_list(origin ? origin->body : body, deref_hash, &result) && result)
       result = result->clone(ralloc_parent(this), NULL);
 
-   hash_table_dtor(deref_hash);
+   _mesa_hash_table_destroy(deref_hash, NULL);
 
    return result;
 }
-- 
2.2.1



More information about the mesa-dev mailing list