nir/st_glsl_to_nir: add param to disable splitting of inputs
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 19 Jan 2018 02:05:35 +0000 (13:05 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 30 Jan 2018 22:14:08 +0000 (09:14 +1100)
We need this because we will always copy fs outputs to temps and
split the arrays, but do not want to do either of these with fs
inputs as it is unnessisary and makes handling interpolateAt
builtins difficult.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_io_arrays_to_elements.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 4bb96c3c9529a3cd1d2fedd887913232482229e0..86d1c68fa72a283feb8302deb712d71fc8b6ba47 100644 (file)
@@ -2522,7 +2522,8 @@ bool nir_lower_load_const_to_scalar(nir_shader *shader);
 bool nir_lower_read_invocation_to_scalar(nir_shader *shader);
 bool nir_lower_phis_to_scalar(nir_shader *shader);
 void nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer);
-void nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader);
+void nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
+                                                  bool outputs_only);
 void nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask);
 void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask);
 
index cdf9a76a881edf6bb8e36495d9a89af0c7d1b794..9a5eec8f870c8726958a9162b64217a51ea6b7c4 100644 (file)
@@ -346,7 +346,8 @@ lower_io_arrays_to_elements(nir_shader *shader, nir_variable_mode mask,
 }
 
 void
-nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader)
+nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
+                                             bool outputs_only)
 {
    struct hash_table *split_inputs =
       _mesa_hash_table_create(NULL, _mesa_hash_pointer,
@@ -360,19 +361,22 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader)
    lower_io_arrays_to_elements(shader, nir_var_shader_out, indirects,
                                patch_indirects, split_outputs, true);
 
-   lower_io_arrays_to_elements(shader, nir_var_shader_in, indirects,
-                               patch_indirects, split_inputs, true);
+   if (!outputs_only) {
+      lower_io_arrays_to_elements(shader, nir_var_shader_in, indirects,
+                                  patch_indirects, split_inputs, true);
 
-   /* Remove old input from the shaders inputs list */
-   struct hash_entry *entry;
-   hash_table_foreach(split_inputs, entry) {
-      nir_variable *var = (nir_variable *) entry->key;
-      exec_node_remove(&var->node);
+      /* Remove old input from the shaders inputs list */
+      struct hash_entry *entry;
+      hash_table_foreach(split_inputs, entry) {
+         nir_variable *var = (nir_variable *) entry->key;
+         exec_node_remove(&var->node);
 
-      free(entry->data);
+         free(entry->data);
+      }
    }
 
    /* Remove old output from the shaders outputs list */
+   struct hash_entry *entry;
    hash_table_foreach(split_outputs, entry) {
       nir_variable *var = (nir_variable *) entry->key;
       exec_node_remove(&var->node);
index 6d3a7c78dcde5d234450022f1a8f47aca44cd8cb..a3d447c5a410f20c63b7707257f3b428f5529d63 100644 (file)
@@ -660,7 +660,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
    NIR_PASS_V(nir, nir_lower_var_copies);
    if (nir->info.stage != MESA_SHADER_TESS_CTRL &&
        nir->info.stage != MESA_SHADER_TESS_EVAL)
-      NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects);
+      NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
 
    if (nir->info.stage == MESA_SHADER_VERTEX) {
       /* Needs special handling so drvloc matches the vbo state: */