nir/lower_outputs_to_temporaries: Take a nir_function entrypoint
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 Dec 2015 01:31:19 +0000 (17:31 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 Dec 2015 01:45:43 +0000 (17:45 -0800)
src/glsl/nir/glsl_to_nir.cpp
src/glsl/nir/nir.h
src/glsl/nir/nir_lower_outputs_to_temporaries.c
src/glsl/nir/spirv/spirv_to_nir.c

index cadcea5034672578c3c00147a82dd10e4cc6a0c7..3cc42d229a0b1cf39eaf9ce5c4b623b1e83efe51 100644 (file)
@@ -145,7 +145,16 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    v2.run(sh->ir);
    visit_exec_list(sh->ir, &v1);
 
-   nir_lower_outputs_to_temporaries(shader);
+   nir_function *main = NULL;
+   nir_foreach_function(shader, func) {
+      if (strcmp(func->name, "main") == 0) {
+         main = func;
+         break;
+      }
+   }
+   assert(main);
+
+   nir_lower_outputs_to_temporaries(shader, main);
 
    shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
    if (shader_prog->Label)
index b413b38220e26486b91bd607689e20fd5abb86a9..a050be4d53bda8c27425948d0d683de30ed6ab9e 100644 (file)
@@ -2036,9 +2036,8 @@ bool nir_lower_global_vars_to_local(nir_shader *shader);
 
 bool nir_lower_locals_to_regs(nir_shader *shader);
 
-void nir_lower_outputs_to_temporaries(nir_shader *shader);
-
-void nir_lower_outputs_to_temporaries(nir_shader *shader);
+void nir_lower_outputs_to_temporaries(nir_shader *shader,
+                                      nir_function *entrypoint);
 
 void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint);
 
index 71b06b81fcceace1712108a45f1eb540ef44f47d..70d85138552cf81f74c584b22d7b4f584b23f90a 100644 (file)
@@ -74,7 +74,7 @@ emit_output_copies_block(nir_block *block, void *state)
 }
 
 void
-nir_lower_outputs_to_temporaries(nir_shader *shader)
+nir_lower_outputs_to_temporaries(nir_shader *shader, nir_function *entrypoint)
 {
    struct lower_outputs_state state;
 
@@ -114,7 +114,7 @@ nir_lower_outputs_to_temporaries(nir_shader *shader)
           * before each EmitVertex call.
           */
          nir_foreach_block(function->impl, emit_output_copies_block, &state);
-      } else if (strcmp(function->name, "main") == 0) {
+      } else if (function == entrypoint) {
          /* For all other shader types, we need to do the copies right before
           * the jumps to the end block.
           */
index 5b31f7e7e2a165623982c59db11741ad5d427965..c4b0c50c52ea00ca78631e2f6480978ab886f2f5 100644 (file)
@@ -3738,7 +3738,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
    /* Because we can still have output reads in NIR, we need to lower
     * outputs to temporaries before we are truely finished.
     */
-   nir_lower_outputs_to_temporaries(entry_point->shader);
+   nir_lower_outputs_to_temporaries(entry_point->shader, entry_point);
 
    return entry_point;
 }