[Mesa-dev] [PATCH 09/27] glsl: add packing rules for tessellation stages to the packing code

Timothy Arceri timothy.arceri at collabora.com
Thu Mar 31 10:57:44 UTC 2016


Following patches will allow packing of varyings with explicit locations
via the component layout qualifier. Adding the rules here will enable
us to call an alternate path for packing tessellation stages with
explicit locations.

V3: Don't remove rules from the varying linking code as we need to
disable packing in the producer if the consumer is a TCS.

V2: move the tessellation packing rules, allow TES output to be packed.

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/compiler/glsl/lower_packed_varyings.cpp | 65 ++++++++++++++++-------------
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/src/compiler/glsl/lower_packed_varyings.cpp b/src/compiler/glsl/lower_packed_varyings.cpp
index 42164e0..29ca779 100644
--- a/src/compiler/glsl/lower_packed_varyings.cpp
+++ b/src/compiler/glsl/lower_packed_varyings.cpp
@@ -750,41 +750,48 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
                       gl_shader *shader, bool disable_varying_packing,
                       bool xfb_enabled)
 {
-   exec_list *instructions = shader->ir;
    ir_function *main_func = shader->symbols->get_function("main");
    exec_list void_parameters;
    ir_function_signature *main_func_sig
       = main_func->matching_signature(NULL, &void_parameters, false);
-   exec_list new_instructions, new_variables;
-   lower_packed_varyings_visitor visitor(mem_ctx, locations_used, mode,
-                                         gs_input_vertices,
-                                         &new_instructions,
-                                         &new_variables,
-                                         disable_varying_packing,
-                                         xfb_enabled);
-   visitor.run(shader);
-   if (mode == ir_var_shader_out) {
-      if (shader->Stage == MESA_SHADER_GEOMETRY) {
-         /* For geometry shaders, outputs need to be lowered before each call
-          * to EmitVertex()
-          */
-         lower_packed_varyings_gs_splicer splicer(mem_ctx, &new_instructions);
-
-         /* Add all the variables in first. */
-         main_func_sig->body.head->insert_before(&new_variables);
 
-         /* Now update all the EmitVertex instances */
-         splicer.run(instructions);
+   if (!(shader->Stage == MESA_SHADER_TESS_CTRL ||
+         (shader->Stage == MESA_SHADER_TESS_EVAL &&
+          mode == ir_var_shader_in))) {
+      exec_list *instructions = shader->ir;
+      exec_list new_instructions, new_variables;
+
+      lower_packed_varyings_visitor visitor(mem_ctx, locations_used, mode,
+                                            gs_input_vertices,
+                                            &new_instructions,
+                                            &new_variables,
+                                            disable_varying_packing,
+                                            xfb_enabled);
+      visitor.run(shader);
+      if (mode == ir_var_shader_out) {
+         if (shader->Stage == MESA_SHADER_GEOMETRY) {
+            /* For geometry shaders, outputs need to be lowered before each
+             * call to EmitVertex()
+             */
+            lower_packed_varyings_gs_splicer splicer(mem_ctx,
+                                                     &new_instructions);
+
+            /* Add all the variables in first. */
+            main_func_sig->body.head->insert_before(&new_variables);
+
+            /* Now update all the EmitVertex instances */
+            splicer.run(instructions);
+         } else {
+            /* For other shader types, outputs need to be lowered at the end
+             * of main()
+             */
+            main_func_sig->body.append_list(&new_variables);
+            main_func_sig->body.append_list(&new_instructions);
+         }
       } else {
-         /* For other shader types, outputs need to be lowered at the end of
-          * main()
-          */
-         main_func_sig->body.append_list(&new_variables);
-         main_func_sig->body.append_list(&new_instructions);
+         /* Shader inputs need to be lowered at the beginning of main() */
+         main_func_sig->body.head->insert_before(&new_instructions);
+         main_func_sig->body.head->insert_before(&new_variables);
       }
-   } else {
-      /* Shader inputs need to be lowered at the beginning of main() */
-      main_func_sig->body.head->insert_before(&new_instructions);
-      main_func_sig->body.head->insert_before(&new_variables);
    }
 }
-- 
2.5.5



More information about the mesa-dev mailing list