[Mesa-dev] [PATCH 24/28] glsl: make needs_lowering() a shared packing helper function

Anuj Phogat anuj.phogat at gmail.com
Thu Jan 14 12:23:58 PST 2016


On Mon, Dec 28, 2015 at 9:00 PM, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> ---
>  src/glsl/lower_packed_varyings.cpp | 58 +++++++++++++++++++-------------------
>  1 file changed, 29 insertions(+), 29 deletions(-)
>
> diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
> index 1c67b3a..08d6447 100644
> --- a/src/glsl/lower_packed_varyings.cpp
> +++ b/src/glsl/lower_packed_varyings.cpp
> @@ -152,6 +152,34 @@
>
>  using namespace ir_builder;
>
> +static bool
> +needs_lowering(ir_variable *var, bool has_enhanced_layouts,
> +               bool disable_varying_packing)
> +{
> +   /* Don't lower varying with explicit location unless ARB_enhanced_layouts
> +    * is enabled, also don't try to pack structs with explicit location as
> +    * they don't support the component layout qualifier anyway.
> +    */
> +   if (var->data.explicit_location && (!has_enhanced_layouts ||
> +       var->type->without_array()->is_record())) {
> +      return false;
> +   }
> +
> +   /* Don't disable packing for explicit locations when ARB_enhanced_layouts
> +    * is supported.
> +    */
> +   if (disable_varying_packing && !var->data.explicit_location)
> +      return false;
> +
> +   /* Things composed of vec4's and doubles don't need lowering everything
> +    * else does.
> +    */
> +   const glsl_type *type = var->type->without_array();
> +   if (type->vector_elements == 4 && !type->is_double())
> +      return false;
> +   return true;
> +}
> +
>  namespace {
>
>  /**
> @@ -191,7 +219,6 @@ private:
>                                              ir_variable *unpacked_var,
>                                              const char *name,
>                                              unsigned vertex_index);
> -   bool needs_lowering(ir_variable *var);
>
>     /**
>      * Memory context used to allocate new instructions for the shader.
> @@ -275,7 +302,7 @@ lower_packed_varyings_visitor::run(struct gl_shader *shader)
>
>        if (var->data.mode != this->mode ||
>            var->data.location < (int) this->base_location ||
> -          !this->needs_lowering(var))
> +          !needs_lowering(var, has_enhanced_layouts, disable_varying_packing))
>           continue;
>
>        /* This lowering pass is only capable of packing floats and ints
> @@ -677,33 +704,6 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
>     return deref;
>  }
>
> -bool
> -lower_packed_varyings_visitor::needs_lowering(ir_variable *var)
> -{
> -   /* Don't lower varying with explicit location unless ARB_enhanced_layouts
> -    * is enabled, also don't try to pack structs with explicit location as
> -    * they don't support the component layout qualifier anyway.
> -    */
> -   if (var->data.explicit_location && (!has_enhanced_layouts ||
> -       var->type->without_array()->is_record())) {
> -      return false;
> -   }
> -
> -   /* Don't disable packing for explicit locations when ARB_enhanced_layouts
> -    * is supported.
> -    */
> -   if (disable_varying_packing && !var->data.explicit_location)
> -      return false;
> -
> -   /* Things composed of vec4's and doubles don't need lowering everything
> -    * else does.
> -    */
> -   const glsl_type *type = var->type->without_array();
> -   if (type->vector_elements == 4 && !type->is_double())
> -      return false;
> -   return true;
> -}
> -
>
>  /**
>   * Visitor that splices varying packing code before every use of EmitVertex()
> --
> 2.4.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list