<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 26, 2016 at 2:02 PM, Rob Clark <span dir="ltr"><<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
<br>
Since it will gain support to lower inputs, give it a more generic name.<br>
<br>
Signed-off-by: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
---<br>
 src/compiler/Makefile.sources                      |   2 +-<br>
 src/compiler/nir/nir.h                             |   2 +-<br>
 src/compiler/nir/nir_lower_io_to_temporaries.c     | 129 +++++++++++++++++++++<br>
 .../nir/nir_lower_outputs_to_temporaries.c         | 129 ---------------------<br>
 src/mesa/drivers/dri/i965/brw_nir.c                |   2 +-<br>
 5 files changed, 132 insertions(+), 132 deletions(-)<br>
 create mode 100644 src/compiler/nir/nir_lower_io_to_temporaries.c<br>
 delete mode 100644 src/compiler/nir/nir_lower_outputs_to_temporaries.c<br>
<br>
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources<br>
index 8f1ffdc..454e768 100644<br>
--- a/src/compiler/Makefile.sources<br>
+++ b/src/compiler/Makefile.sources<br>
@@ -196,8 +196,8 @@ NIR_FILES = \<br>
        nir/nir_lower_idiv.c \<br>
        nir/nir_lower_indirect_derefs.c \<br>
        nir/nir_lower_io.c \<br>
+       nir/nir_lower_io_to_temporaries.c \<br>
        nir/nir_lower_io_types.c \<br>
-       nir/nir_lower_outputs_to_temporaries.c \<br></blockquote><div><br></div><div>If you don't also update nir/Makefile.sources it will break scons.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        nir/nir_lower_passthrough_edgeflags.c \<br>
        nir/nir_lower_phis_to_scalar.c \<br>
        nir/nir_lower_returns.c \<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index 7f7c459..ab73068 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2160,7 +2160,7 @@ bool nir_lower_indirect_derefs(nir_shader *shader, uint32_t mode_mask);<br>
<br>
 bool nir_lower_locals_to_regs(nir_shader *shader);<br>
<br>
-void nir_lower_outputs_to_temporaries(nir_shader *shader);<br>
+void nir_lower_io_to_temporaries(nir_shader *shader);<br>
<br>
 void nir_assign_var_locations(struct exec_list *var_list,<br>
                               unsigned *size,<br>
diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c<br>
new file mode 100644<br>
index 0000000..0db436b<br>
--- /dev/null<br>
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c<br>
@@ -0,0 +1,129 @@<br>
+/*<br>
+ * Copyright © 2015 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * Implements a pass that lowers output variables to a temporary plus an<br>
+ * output variable with a single copy at each exit point of the shader.<br>
+ * This way the output variable is only ever written.<br>
+ */<br>
+<br>
+#include "nir.h"<br>
+<br>
+struct lower_io_state {<br>
+   nir_shader *shader;<br>
+   struct exec_list old_outputs;<br>
+};<br>
+<br>
+static void<br>
+emit_output_copies(nir_cursor cursor, struct lower_io_state *state)<br>
+{<br>
+   assert(exec_list_length(&state->shader->outputs) ==<br>
+          exec_list_length(&state->old_outputs));<br>
+<br>
+   foreach_two_lists(out_node, &state->shader->outputs,<br>
+                     temp_node, &state->old_outputs) {<br>
+      nir_variable *output = exec_node_data(nir_variable, out_node, node);<br>
+      nir_variable *temp = exec_node_data(nir_variable, temp_node, node);<br>
+<br>
+      nir_intrinsic_instr *copy =<br>
+         nir_intrinsic_instr_create(state->shader, nir_intrinsic_copy_var);<br>
+      copy->variables[0] = nir_deref_var_create(copy, output);<br>
+      copy->variables[1] = nir_deref_var_create(copy, temp);<br>
+<br>
+      nir_instr_insert(cursor, &copy->instr);<br>
+   }<br>
+}<br>
+<br>
+static bool<br>
+emit_output_copies_block(nir_block *block, void *state)<br>
+{<br>
+   nir_foreach_instr(block, instr) {<br>
+      if (instr->type != nir_instr_type_intrinsic)<br>
+         continue;<br>
+<br>
+      nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
+      if (intrin->intrinsic == nir_intrinsic_emit_vertex)<br>
+         emit_output_copies(nir_before_instr(&intrin->instr), state);<br>
+   }<br>
+<br>
+   return true;<br>
+}<br>
+<br>
+void<br>
+nir_lower_io_to_temporaries(nir_shader *shader)<br>
+{<br>
+   struct lower_io_state state;<br>
+<br>
+   if (shader->stage == MESA_SHADER_TESS_CTRL)<br>
+      return;<br>
+<br>
+   state.shader = shader;<br>
+   exec_list_move_nodes_to(&shader->outputs, &state.old_outputs);<br>
+<br>
+   /* Walk over all of the outputs turn each output into a temporary and<br>
+    * make a new variable for the actual output.<br>
+    */<br>
+   nir_foreach_variable(var, &state.old_outputs) {<br>
+      nir_variable *output = ralloc(shader, nir_variable);<br>
+      memcpy(output, var, sizeof *output);<br>
+<br>
+      /* The orignal is now the temporary */<br>
+      nir_variable *temp = var;<br>
+<br>
+      /* Reparent the name to the new variable */<br>
+      ralloc_steal(output, output->name);<br>
+<br>
+      /* Give the output a new name with @out-temp appended */<br>
+      temp->name = ralloc_asprintf(var, "%s@out-temp", output->name);<br>
+      temp->data.mode = nir_var_global;<br>
+      temp->constant_initializer = NULL;<br>
+<br>
+      exec_list_push_tail(&shader->outputs, &output->node);<br>
+   }<br>
+<br>
+   nir_foreach_function(shader, function) {<br>
+      if (function->impl == NULL)<br>
+         continue;<br>
+<br>
+      if (shader->stage == MESA_SHADER_GEOMETRY) {<br>
+         /* For geometry shaders, we have to emit the output copies right<br>
+          * before each EmitVertex call.<br>
+          */<br>
+         nir_foreach_block(function->impl, emit_output_copies_block, &state);<br>
+      } else if (strcmp(function->name, "main") == 0) {<br>
+         /* For all other shader types, we need to do the copies right before<br>
+          * the jumps to the end block.<br>
+          */<br>
+         struct set_entry *block_entry;<br>
+         set_foreach(function->impl->end_block->predecessors, block_entry) {<br>
+            struct nir_block *block = (void *)block_entry->key;<br>
+            emit_output_copies(nir_after_block_before_jump(block), &state);<br>
+         }<br>
+      }<br>
+<br>
+      nir_metadata_preserve(function->impl, nir_metadata_block_index |<br>
+                                            nir_metadata_dominance);<br>
+   }<br>
+<br>
+   exec_list_append(&shader->globals, &state.old_outputs);<br>
+}<br>
diff --git a/src/compiler/nir/nir_lower_outputs_to_temporaries.c b/src/compiler/nir/nir_lower_outputs_to_temporaries.c<br>
deleted file mode 100644<br>
index 0e518cd..0000000<br>
--- a/src/compiler/nir/nir_lower_outputs_to_temporaries.c<br>
+++ /dev/null<br>
@@ -1,129 +0,0 @@<br>
-/*<br>
- * Copyright © 2015 Intel Corporation<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice (including the next<br>
- * paragraph) shall be included in all copies or substantial portions of the<br>
- * Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
- * IN THE SOFTWARE.<br>
- */<br>
-<br>
-/*<br>
- * Implements a pass that lowers output variables to a temporary plus an<br>
- * output variable with a single copy at each exit point of the shader.<br>
- * This way the output variable is only ever written.<br>
- */<br>
-<br>
-#include "nir.h"<br>
-<br>
-struct lower_outputs_state {<br>
-   nir_shader *shader;<br>
-   struct exec_list old_outputs;<br>
-};<br>
-<br>
-static void<br>
-emit_output_copies(nir_cursor cursor, struct lower_outputs_state *state)<br>
-{<br>
-   assert(exec_list_length(&state->shader->outputs) ==<br>
-          exec_list_length(&state->old_outputs));<br>
-<br>
-   foreach_two_lists(out_node, &state->shader->outputs,<br>
-                     temp_node, &state->old_outputs) {<br>
-      nir_variable *output = exec_node_data(nir_variable, out_node, node);<br>
-      nir_variable *temp = exec_node_data(nir_variable, temp_node, node);<br>
-<br>
-      nir_intrinsic_instr *copy =<br>
-         nir_intrinsic_instr_create(state->shader, nir_intrinsic_copy_var);<br>
-      copy->variables[0] = nir_deref_var_create(copy, output);<br>
-      copy->variables[1] = nir_deref_var_create(copy, temp);<br>
-<br>
-      nir_instr_insert(cursor, &copy->instr);<br>
-   }<br>
-}<br>
-<br>
-static bool<br>
-emit_output_copies_block(nir_block *block, void *state)<br>
-{<br>
-   nir_foreach_instr(block, instr) {<br>
-      if (instr->type != nir_instr_type_intrinsic)<br>
-         continue;<br>
-<br>
-      nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
-      if (intrin->intrinsic == nir_intrinsic_emit_vertex)<br>
-         emit_output_copies(nir_before_instr(&intrin->instr), state);<br>
-   }<br>
-<br>
-   return true;<br>
-}<br>
-<br>
-void<br>
-nir_lower_outputs_to_temporaries(nir_shader *shader)<br>
-{<br>
-   struct lower_outputs_state state;<br>
-<br>
-   if (shader->stage == MESA_SHADER_TESS_CTRL)<br>
-      return;<br>
-<br>
-   state.shader = shader;<br>
-   exec_list_move_nodes_to(&shader->outputs, &state.old_outputs);<br>
-<br>
-   /* Walk over all of the outputs turn each output into a temporary and<br>
-    * make a new variable for the actual output.<br>
-    */<br>
-   nir_foreach_variable(var, &state.old_outputs) {<br>
-      nir_variable *output = ralloc(shader, nir_variable);<br>
-      memcpy(output, var, sizeof *output);<br>
-<br>
-      /* The orignal is now the temporary */<br>
-      nir_variable *temp = var;<br>
-<br>
-      /* Reparent the name to the new variable */<br>
-      ralloc_steal(output, output->name);<br>
-<br>
-      /* Give the output a new name with @out-temp appended */<br>
-      temp->name = ralloc_asprintf(var, "%s@out-temp", output->name);<br>
-      temp->data.mode = nir_var_global;<br>
-      temp->constant_initializer = NULL;<br>
-<br>
-      exec_list_push_tail(&shader->outputs, &output->node);<br>
-   }<br>
-<br>
-   nir_foreach_function(shader, function) {<br>
-      if (function->impl == NULL)<br>
-         continue;<br>
-<br>
-      if (shader->stage == MESA_SHADER_GEOMETRY) {<br>
-         /* For geometry shaders, we have to emit the output copies right<br>
-          * before each EmitVertex call.<br>
-          */<br>
-         nir_foreach_block(function->impl, emit_output_copies_block, &state);<br>
-      } else if (strcmp(function->name, "main") == 0) {<br>
-         /* For all other shader types, we need to do the copies right before<br>
-          * the jumps to the end block.<br>
-          */<br>
-         struct set_entry *block_entry;<br>
-         set_foreach(function->impl->end_block->predecessors, block_entry) {<br>
-            struct nir_block *block = (void *)block_entry->key;<br>
-            emit_output_copies(nir_after_block_before_jump(block), &state);<br>
-         }<br>
-      }<br>
-<br>
-      nir_metadata_preserve(function->impl, nir_metadata_block_index |<br>
-                                            nir_metadata_dominance);<br>
-   }<br>
-<br>
-   exec_list_append(&shader->globals, &state.old_outputs);<br>
-}<br>
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c<br>
index e0c9465..10f4ae1 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_nir.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_nir.c<br>
@@ -560,7 +560,7 @@ brw_create_nir(struct brw_context *brw,<br>
    /* First, lower the GLSL IR or Mesa IR to NIR */<br>
    if (shader_prog) {<br>
       nir = glsl_to_nir(shader_prog, stage, options);<br>
-      nir_lower_outputs_to_temporaries(nir);<br>
+      nir_lower_io_to_temporaries(nir);<br>
    } else {<br>
       nir = prog_to_nir(prog, options);<br>
       OPT_V(nir_convert_to_ssa); /* turn registers into SSA */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>