nir: Return correct size in nir_assign_io_var_locations()
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 17 May 2019 12:56:45 +0000 (14:56 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Mon, 8 Jul 2019 12:14:53 +0000 (14:14 +0200)
It was double-counting cases where multiple variables were assigned to
the same slot, and not handling the case where the last variable is a
compact variable.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/nir/nir_linking_helpers.c

index b85690983d5157db12bf9a2a17f30f1dccdfd413..28d2774cae205d7cf08c8f02b403c39a7d1423e3 100644 (file)
@@ -1064,7 +1064,6 @@ nir_assign_io_var_locations(struct exec_list *var_list, unsigned *size,
       if (processed) {
          unsigned driver_location = assigned_locations[var->data.location];
          var->data.driver_location = driver_location;
-         *size += glsl_count_attribute_slots(type, false);
 
          /* An array may be packed such that is crosses multiple other arrays
           * or variables, we need to make sure we have allocated the elements
@@ -1096,6 +1095,9 @@ nir_assign_io_var_locations(struct exec_list *var_list, unsigned *size,
       location += var_size;
    }
 
-   *size += location;
+   if (last_partial)
+      location++;
+
+   *size = location;
 }