nir/vtn: Use return type rather than image type for tex ops
[mesa.git] / src / compiler / glsl / ir_array_refcount.cpp
index 1a46b2185d4b875ad083ac9ec1cd8a0c53cfbdf3..0c18c7e0ecf143c3e24e30506f779751b8208e16 100644 (file)
@@ -37,8 +37,7 @@ ir_array_refcount_visitor::ir_array_refcount_visitor()
    : last_array_deref(0), derefs(0), num_derefs(0), derefs_size(0)
 {
    this->mem_ctx = ralloc_context(NULL);
-   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+   this->ht = _mesa_pointer_hash_table_create(NULL);
 }
 
 static void
@@ -76,54 +75,6 @@ ir_array_refcount_entry::~ir_array_refcount_entry()
    delete [] bits;
 }
 
-
-void
-ir_array_refcount_entry::mark_array_elements_referenced(const array_deref_range *dr,
-                                                        unsigned count)
-{
-   if (count != array_depth)
-      return;
-
-   mark_array_elements_referenced(dr, count, 1, 0);
-}
-
-void
-ir_array_refcount_entry::mark_array_elements_referenced(const array_deref_range *dr,
-                                                        unsigned count,
-                                                        unsigned scale,
-                                                        unsigned linearized_index)
-{
-   /* Walk through the list of array dereferences in least- to
-    * most-significant order.  Along the way, accumulate the current
-    * linearized offset and the scale factor for each array-of-.
-    */
-   for (unsigned i = 0; i < count; i++) {
-      if (dr[i].index < dr[i].size) {
-         linearized_index += dr[i].index * scale;
-         scale *= dr[i].size;
-      } else {
-         /* For each element in the current array, update the count and
-          * offset, then recurse to process the remaining arrays.
-          *
-          * There is some inefficency here if the last element in the
-          * array_deref_range list specifies the entire array.  In that case,
-          * the loop will make recursive calls with count == 0.  In the call,
-          * all that will happen is the bit will be set.
-          */
-         for (unsigned j = 0; j < dr[i].size; j++) {
-            mark_array_elements_referenced(&dr[i + 1],
-                                           count - (i + 1),
-                                           scale * dr[i].size,
-                                           linearized_index + (j * scale));
-         }
-
-         return;
-      }
-   }
-
-   BITSET_SET(bits, linearized_index);
-}
-
 ir_array_refcount_entry *
 ir_array_refcount_visitor::get_variable_entry(ir_variable *var)
 {
@@ -225,7 +176,9 @@ ir_array_refcount_visitor::visit_enter(ir_dereference_array *ir)
    if (entry == NULL)
       return visit_stop;
 
-   entry->mark_array_elements_referenced(derefs, num_derefs);
+   link_util_mark_array_elements_referenced(derefs, num_derefs,
+                                            entry->array_depth,
+                                            entry->bits);
 
    return visit_continue;
 }