Revert "i965/fs: Change fs_visitor::emit_lrp to use MAC for gen<6"
[mesa.git] / src / glsl / lower_named_interface_blocks.cpp
index d0d491d3db170d66ca3938f0de0245954255c4fb..04e0d36e675b2cca038867e77df6c2450f6db455 100644 (file)
@@ -65,6 +65,8 @@
 #include "ir_rvalue_visitor.h"
 #include "program/hash_table.h"
 
+namespace {
+
 class flatten_named_interface_blocks_declarations : public ir_rvalue_visitor
 {
 public:
@@ -83,6 +85,8 @@ public:
    virtual void handle_rvalue(ir_rvalue **rvalue);
 };
 
+} /* anonymous namespace */
+
 void
 flatten_named_interface_blocks_declarations::run(exec_list *instructions)
 {
@@ -104,7 +108,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
        * but, this will require changes to the other uniform block
        * support code.
        */
-      if (var->mode == ir_var_uniform)
+      if (var->data.mode == ir_var_uniform)
          continue;
 
       const glsl_type * iface_t = var->type;
@@ -121,37 +125,41 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
       for (unsigned i = 0; i < iface_t->length; i++) {
          const char * field_name = iface_t->fields.structure[i].name;
          char *iface_field_name =
-            ralloc_asprintf(mem_ctx, "%s.%s",
-                            iface_t->name, field_name);
+            ralloc_asprintf(mem_ctx, "%s.%s.%s",
+                            iface_t->name, var->name, field_name);
 
          ir_variable *found_var =
             (ir_variable *) hash_table_find(interface_namespace,
                                             iface_field_name);
          if (!found_var) {
             ir_variable *new_var;
+            char *var_name =
+               ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name);
             if (array_t == NULL) {
-               char *var_name =
-                  ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name);
                new_var =
                   new(mem_ctx) ir_variable(iface_t->fields.structure[i].type,
                                            var_name,
-                                           (ir_variable_mode) var->mode);
+                                           (ir_variable_mode) var->data.mode);
+               new_var->data.from_named_ifc_block_nonarray = 1;
             } else {
                const glsl_type *new_array_type =
                   glsl_type::get_array_instance(
                      iface_t->fields.structure[i].type,
                      array_t->length);
-               char *var_name =
-                  ralloc_asprintf(mem_ctx, "%s[%d]",
-                                  iface_t->fields.structure[i].name,
-                                  array_t->length);
                new_var =
                   new(mem_ctx) ir_variable(new_array_type,
                                            var_name,
-                                           (ir_variable_mode) var->mode);
+                                           (ir_variable_mode) var->data.mode);
+               new_var->data.from_named_ifc_block_array = 1;
             }
-
-            new_var->interface_type = iface_t;
+            new_var->data.location = iface_t->fields.structure[i].location;
+            new_var->data.explicit_location = (new_var->data.location >= 0);
+            new_var->data.interpolation =
+               iface_t->fields.structure[i].interpolation;
+            new_var->data.centroid = iface_t->fields.structure[i].centroid;
+            new_var->data.sample = iface_t->fields.structure[i].sample;
+
+            new_var->init_interface_type(iface_t);
             hash_table_insert(interface_namespace, new_var,
                               iface_field_name);
             insert_pos->insert_after(new_var);
@@ -204,13 +212,13 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
     * but, this will require changes to the other uniform block
     * support code.
     */
-   if (var->mode == ir_var_uniform)
+   if (var->data.mode == ir_var_uniform)
       return;
 
-   if (var->interface_type != NULL) {
+   if (var->get_interface_type() != NULL) {
       char *iface_field_name =
-         ralloc_asprintf(mem_ctx, "%s.%s", var->interface_type->name,
-                         ir->field);
+         ralloc_asprintf(mem_ctx, "%s.%s.%s", var->get_interface_type()->name,
+                         var->name, ir->field);
       /* Find the variable in the set of flattened interface blocks */
       ir_variable *found_var =
          (ir_variable *) hash_table_find(interface_namespace,