linker: Move global instructions from the linked shader first
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 19 Jul 2010 19:33:54 +0000 (12:33 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 19 Jul 2010 19:36:32 +0000 (12:36 -0700)
For the shader containing 'main', use the linked shader (i.e., the
clone of the original shader that contained main) as the source for
global instructions to move into main.

src/glsl/linker.cpp

index c71c07d6e97fef3912f62757e2ebc6a9bbdc4f0a..d46744eeda5c7b8223411203535da2e6e1232f1b 100644 (file)
@@ -687,12 +687,16 @@ link_intrastage_shaders(struct gl_shader_program *prog,
    /* Move any instructions other than variable declarations or function
     * declarations into main.
     */
-   exec_node *insertion_point = (exec_node *) &main_sig->body;
+   exec_node *insertion_point =
+      move_non_declarations(linked->ir, (exec_node *) &main_sig->body, false,
+                           linked);
+
    for (unsigned i = 0; i < num_shaders; i++) {
+      if (shader_list[i] == main)
+        continue;
+
       insertion_point = move_non_declarations(shader_list[i]->ir,
-                                             insertion_point,
-                                             (shader_list[i] != main),
-                                             linked);
+                                             insertion_point, true, linked);
    }
 
    /* Resolve initializers for global variables in the linked shader.