[Mesa-dev] [PATCH V3 16/28] glsl: add packing rules for tessellation stages to the packing code
Anuj Phogat
anuj.phogat at gmail.com
Thu Feb 4 19:05:03 UTC 2016
On Thu, Jan 28, 2016 at 9:22 PM, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> 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.
>
> Cc: Anuj Phogat <anuj.phogat at gmail.com>
> ---
> src/compiler/glsl/lower_packed_varyings.cpp | 63 ++++++++++++++++-------------
> 1 file changed, 35 insertions(+), 28 deletions(-)
>
> diff --git a/src/compiler/glsl/lower_packed_varyings.cpp b/src/compiler/glsl/lower_packed_varyings.cpp
> index 2899846..4723c2b 100644
> --- a/src/compiler/glsl/lower_packed_varyings.cpp
> +++ b/src/compiler/glsl/lower_packed_varyings.cpp
> @@ -737,40 +737,47 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
> ir_variable_mode mode, unsigned gs_input_vertices,
> gl_shader *shader, bool disable_varying_packing)
> {
> - 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);
> - 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);
> + 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.0
>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the mesa-dev
mailing list