nir/lower_io: Make variable location assignment a manual operation
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 18 Mar 2015 22:04:15 +0000 (15:04 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 19 Mar 2015 20:18:39 +0000 (13:18 -0700)
Previously, we just assigned variable locations in nir_lower_io.  Now, we
force the user to assign variable locations for us.  This gives the backend
a bit more control over where variables are placed.

v2: Rename from _packed to _scalar

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/nir/nir.h
src/glsl/nir/nir_lower_io.c
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 6b42df953da7360ee37d249aaedfae91b816c472..a2a03b227074a3a8628f23b6d7de9e6ffef6b997 100644 (file)
@@ -1577,6 +1577,9 @@ void nir_lower_global_vars_to_local(nir_shader *shader);
 
 void nir_lower_locals_to_regs(nir_shader *shader);
 
+void nir_assign_var_locations_scalar(struct exec_list *var_list,
+                                     unsigned *size);
+
 void nir_lower_io(nir_shader *shader);
 
 void nir_lower_vars_to_ssa(nir_shader *shader);
index 37c357e893ba9fb2e2206b925d08287f92b7ab62..602b8c95b8e6240b92159183c7bfec441e4edfa1 100644 (file)
@@ -76,8 +76,8 @@ type_size(const struct glsl_type *type)
    return 0;
 }
 
-static void
-assign_var_locations(struct exec_list *var_list, unsigned *size)
+void
+nir_assign_var_locations_scalar(struct exec_list *var_list, unsigned *size)
 {
    unsigned location = 0;
 
@@ -96,14 +96,6 @@ assign_var_locations(struct exec_list *var_list, unsigned *size)
    *size = location;
 }
 
-static void
-assign_var_locations_shader(nir_shader *shader)
-{
-   assign_var_locations(&shader->inputs, &shader->num_inputs);
-   assign_var_locations(&shader->outputs, &shader->num_outputs);
-   assign_var_locations(&shader->uniforms, &shader->num_uniforms);
-}
-
 static bool
 deref_has_indirect(nir_deref_var *deref)
 {
@@ -304,8 +296,6 @@ nir_lower_io_impl(nir_function_impl *impl)
 void
 nir_lower_io(nir_shader *shader)
 {
-   assign_var_locations_shader(shader);
-
    nir_foreach_overload(shader, overload) {
       if (overload->impl)
          nir_lower_io_impl(overload->impl);
index 9431e5dd74e1c40c75c3204e2aee1037a154bd14..8ef57af2c4816e1d49e0d24075ce63579bd1a19f 100644 (file)
@@ -105,6 +105,10 @@ fs_visitor::emit_nir_code()
    /* Get rid of split copies */
    nir_optimize(nir);
 
+   nir_assign_var_locations_scalar(&nir->uniforms, &nir->num_uniforms);
+   nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs);
+   nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs);
+
    nir_lower_io(nir);
    nir_validate_shader(nir);