Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / glsl / ir.cpp
index 460d43b02e1361f2532ea3db63ebdb794d0d54b4..fc356ba52752dac3a6ee9e8e74b0362c1c3fd904 100644 (file)
@@ -472,6 +472,22 @@ const char *ir_expression::operator_string()
    return operator_string(this->operation);
 }
 
+const char*
+depth_layout_string(ir_depth_layout layout)
+{
+   switch(layout) {
+   case ir_depth_layout_none:      return "";
+   case ir_depth_layout_any:       return "depth_any";
+   case ir_depth_layout_greater:   return "depth_greater";
+   case ir_depth_layout_less:      return "depth_less";
+   case ir_depth_layout_unchanged: return "depth_unchanged";
+
+   default:
+      assert(0);
+      return "";
+   }
+}
+
 ir_expression_operation
 ir_expression::get_operator(const char *str)
 {
@@ -562,7 +578,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
          || type->is_record() || type->is_array());
 
    if (type->is_array()) {
-      this->array_elements = talloc_array(this, ir_constant *, type->length);
+      this->array_elements = ralloc_array(this, ir_constant *, type->length);
       unsigned i = 0;
       foreach_list(node, value_list) {
         ir_constant *value = (ir_constant *) node;
@@ -1020,7 +1036,7 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value,
 ir_dereference_array::ir_dereference_array(ir_variable *var,
                                           ir_rvalue *array_index)
 {
-   void *ctx = talloc_parent(var);
+   void *ctx = ralloc_parent(var);
 
    this->ir_type = ir_type_dereference_array;
    this->array_index = array_index;
@@ -1053,7 +1069,7 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
 {
    this->ir_type = ir_type_dereference_record;
    this->record = value;
-   this->field = talloc_strdup(this, field);
+   this->field = ralloc_strdup(this, field);
    this->type = (this->record != NULL)
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }
@@ -1062,11 +1078,11 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
 ir_dereference_record::ir_dereference_record(ir_variable *var,
                                             const char *field)
 {
-   void *ctx = talloc_parent(var);
+   void *ctx = ralloc_parent(var);
 
    this->ir_type = ir_type_dereference_record;
    this->record = new(ctx) ir_dereference_variable(var);
-   this->field = talloc_strdup(this, field);
+   this->field = ralloc_strdup(this, field);
    this->type = (this->record != NULL)
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }
@@ -1229,7 +1245,7 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
 ir_swizzle *
 ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
 {
-   void *ctx = talloc_parent(val);
+   void *ctx = ralloc_parent(val);
 
    /* For each possible swizzle character, this table encodes the value in
     * \c idx_map that represents the 0th element of the vector.  For invalid
@@ -1318,13 +1334,14 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
 {
    this->ir_type = ir_type_variable;
    this->type = type;
-   this->name = talloc_strdup(this, name);
+   this->name = ralloc_strdup(this, name);
    this->explicit_location = false;
    this->location = -1;
    this->warn_extension = NULL;
    this->constant_value = NULL;
    this->origin_upper_left = false;
    this->pixel_center_integer = false;
+   this->depth_layout = ir_depth_layout_none;
    this->used = false;
 
    if (type && type->base_type == GLSL_TYPE_SAMPLER)
@@ -1362,6 +1379,21 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type)
 }
 
 
+static bool
+modes_match(unsigned a, unsigned b)
+{
+   if (a == b)
+      return true;
+
+   /* Accept "in" vs. "const in" */
+   if ((a == ir_var_const_in && b == ir_var_in) ||
+       (b == ir_var_const_in && a == ir_var_in))
+      return true;
+
+   return false;
+}
+
+
 const char *
 ir_function_signature::qualifiers_match(exec_list *params)
 {
@@ -1374,7 +1406,7 @@ ir_function_signature::qualifiers_match(exec_list *params)
       ir_variable *b = (ir_variable *)iter_b.get();
 
       if (a->read_only != b->read_only ||
-         a->mode != b->mode ||
+         !modes_match(a->mode, b->mode) ||
          a->interpolation != b->interpolation ||
          a->centroid != b->centroid) {
 
@@ -1409,7 +1441,7 @@ ir_function_signature::replace_parameters(exec_list *new_params)
 ir_function::ir_function(const char *name)
 {
    this->ir_type = ir_type_function;
-   this->name = talloc_strdup(this, name);
+   this->name = ralloc_strdup(this, name);
 }
 
 
@@ -1475,7 +1507,7 @@ steal_memory(ir_instruction *ir, void *new_ctx)
       }
    }
 
-   talloc_steal(new_ctx, ir);
+   ralloc_steal(new_ctx, ir);
 }